babylon.module.d.ts 6.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Offline (baking) quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  828. /** High quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  830. /** Medium quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  832. /** Low quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  834. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  835. static readonly SCALEMODE_FLOOR: number;
  836. /** Defines that texture rescaling will look for the nearest power of 2 size */
  837. static readonly SCALEMODE_NEAREST: number;
  838. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  839. static readonly SCALEMODE_CEILING: number;
  840. /**
  841. * The dirty texture flag value
  842. */
  843. static readonly MATERIAL_TextureDirtyFlag: number;
  844. /**
  845. * The dirty light flag value
  846. */
  847. static readonly MATERIAL_LightDirtyFlag: number;
  848. /**
  849. * The dirty fresnel flag value
  850. */
  851. static readonly MATERIAL_FresnelDirtyFlag: number;
  852. /**
  853. * The dirty attribute flag value
  854. */
  855. static readonly MATERIAL_AttributesDirtyFlag: number;
  856. /**
  857. * The dirty misc flag value
  858. */
  859. static readonly MATERIAL_MiscDirtyFlag: number;
  860. /**
  861. * The all dirty flag value
  862. */
  863. static readonly MATERIAL_AllDirtyFlag: number;
  864. /**
  865. * Returns the triangle fill mode
  866. */
  867. static readonly MATERIAL_TriangleFillMode: number;
  868. /**
  869. * Returns the wireframe mode
  870. */
  871. static readonly MATERIAL_WireFrameFillMode: number;
  872. /**
  873. * Returns the point fill mode
  874. */
  875. static readonly MATERIAL_PointFillMode: number;
  876. /**
  877. * Returns the point list draw mode
  878. */
  879. static readonly MATERIAL_PointListDrawMode: number;
  880. /**
  881. * Returns the line list draw mode
  882. */
  883. static readonly MATERIAL_LineListDrawMode: number;
  884. /**
  885. * Returns the line loop draw mode
  886. */
  887. static readonly MATERIAL_LineLoopDrawMode: number;
  888. /**
  889. * Returns the line strip draw mode
  890. */
  891. static readonly MATERIAL_LineStripDrawMode: number;
  892. /**
  893. * Returns the triangle strip draw mode
  894. */
  895. static readonly MATERIAL_TriangleStripDrawMode: number;
  896. /**
  897. * Returns the triangle fan draw mode
  898. */
  899. static readonly MATERIAL_TriangleFanDrawMode: number;
  900. /**
  901. * Stores the clock-wise side orientation
  902. */
  903. static readonly MATERIAL_ClockWiseSideOrientation: number;
  904. /**
  905. * Stores the counter clock-wise side orientation
  906. */
  907. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  908. /**
  909. * Nothing
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_NothingTrigger: number;
  913. /**
  914. * On pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickTrigger: number;
  918. /**
  919. * On left pick
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnLeftPickTrigger: number;
  923. /**
  924. * On right pick
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnRightPickTrigger: number;
  928. /**
  929. * On center pick
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnCenterPickTrigger: number;
  933. /**
  934. * On pick down
  935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnPickDownTrigger: number;
  938. /**
  939. * On double pick
  940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnDoublePickTrigger: number;
  943. /**
  944. * On pick up
  945. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickUpTrigger: number;
  948. /**
  949. * On pick out.
  950. * This trigger will only be raised if you also declared a OnPickDown
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickOutTrigger: number;
  954. /**
  955. * On long press
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnLongPressTrigger: number;
  959. /**
  960. * On pointer over
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPointerOverTrigger: number;
  964. /**
  965. * On pointer out
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnPointerOutTrigger: number;
  969. /**
  970. * On every frame
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnEveryFrameTrigger: number;
  974. /**
  975. * On intersection enter
  976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnIntersectionEnterTrigger: number;
  979. /**
  980. * On intersection exit
  981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnIntersectionExitTrigger: number;
  984. /**
  985. * On key down
  986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnKeyDownTrigger: number;
  989. /**
  990. * On key up
  991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnKeyUpTrigger: number;
  994. /**
  995. * Billboard mode will only apply to Y axis
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  998. /**
  999. * Billboard mode will apply to all axes
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1002. /**
  1003. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1004. */
  1005. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1006. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1007. * Test order :
  1008. * Is the bounding sphere outside the frustum ?
  1009. * If not, are the bounding box vertices outside the frustum ?
  1010. * It not, then the cullable object is in the frustum.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1013. /** Culling strategy : Bounding Sphere Only.
  1014. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1015. * It's also less accurate than the standard because some not visible objects can still be selected.
  1016. * Test : is the bounding sphere outside the frustum ?
  1017. * If not, then the cullable object is in the frustum.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1020. /** Culling strategy : Optimistic Inclusion.
  1021. * This in an inclusion test first, then the standard exclusion test.
  1022. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1023. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1024. * Anyway, it's as accurate as the standard strategy.
  1025. * Test :
  1026. * Is the cullable object bounding sphere center in the frustum ?
  1027. * If not, apply the default culling strategy.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1030. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1031. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1032. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1033. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1034. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1040. /**
  1041. * No logging while loading
  1042. */
  1043. static readonly SCENELOADER_NO_LOGGING: number;
  1044. /**
  1045. * Minimal logging while loading
  1046. */
  1047. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1048. /**
  1049. * Summary logging while loading
  1050. */
  1051. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1052. /**
  1053. * Detailled logging while loading
  1054. */
  1055. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1056. }
  1057. }
  1058. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1059. import { Nullable } from "babylonjs/types";
  1060. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1061. /**
  1062. * This represents the required contract to create a new type of texture loader.
  1063. */
  1064. export interface IInternalTextureLoader {
  1065. /**
  1066. * Defines wether the loader supports cascade loading the different faces.
  1067. */
  1068. supportCascades: boolean;
  1069. /**
  1070. * This returns if the loader support the current file information.
  1071. * @param extension defines the file extension of the file being loaded
  1072. * @returns true if the loader can load the specified file
  1073. */
  1074. canLoad(extension: string): boolean;
  1075. /**
  1076. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1077. * @param data contains the texture data
  1078. * @param texture defines the BabylonJS internal texture
  1079. * @param createPolynomials will be true if polynomials have been requested
  1080. * @param onLoad defines the callback to trigger once the texture is ready
  1081. * @param onError defines the callback to trigger in case of error
  1082. */
  1083. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1084. /**
  1085. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1086. * @param data contains the texture data
  1087. * @param texture defines the BabylonJS internal texture
  1088. * @param callback defines the method to call once ready to upload
  1089. */
  1090. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1091. }
  1092. }
  1093. declare module "babylonjs/Engines/IPipelineContext" {
  1094. /**
  1095. * Class used to store and describe the pipeline context associated with an effect
  1096. */
  1097. export interface IPipelineContext {
  1098. /**
  1099. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1100. */
  1101. isAsync: boolean;
  1102. /**
  1103. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1104. */
  1105. isReady: boolean;
  1106. /** @hidden */
  1107. _getVertexShaderCode(): string | null;
  1108. /** @hidden */
  1109. _getFragmentShaderCode(): string | null;
  1110. /** @hidden */
  1111. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1112. }
  1113. }
  1114. declare module "babylonjs/Meshes/dataBuffer" {
  1115. /**
  1116. * Class used to store gfx data (like WebGLBuffer)
  1117. */
  1118. export class DataBuffer {
  1119. /**
  1120. * Gets or sets the number of objects referencing this buffer
  1121. */
  1122. references: number;
  1123. /** Gets or sets the size of the underlying buffer */
  1124. capacity: number;
  1125. /**
  1126. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1127. */
  1128. is32Bits: boolean;
  1129. /**
  1130. * Gets the underlying buffer
  1131. */
  1132. get underlyingResource(): any;
  1133. }
  1134. }
  1135. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1136. /** @hidden */
  1137. export interface IShaderProcessor {
  1138. attributeProcessor?: (attribute: string) => string;
  1139. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1140. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1141. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1142. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1143. lineProcessor?: (line: string, isFragment: boolean) => string;
  1144. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1146. }
  1147. }
  1148. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1149. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1150. /** @hidden */
  1151. export interface ProcessingOptions {
  1152. defines: string[];
  1153. indexParameters: any;
  1154. isFragment: boolean;
  1155. shouldUseHighPrecisionShader: boolean;
  1156. supportsUniformBuffers: boolean;
  1157. shadersRepository: string;
  1158. includesShadersStore: {
  1159. [key: string]: string;
  1160. };
  1161. processor?: IShaderProcessor;
  1162. version: string;
  1163. platformName: string;
  1164. lookForClosingBracketForUniformBuffer?: boolean;
  1165. }
  1166. }
  1167. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1168. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1169. /** @hidden */
  1170. export class ShaderCodeNode {
  1171. line: string;
  1172. children: ShaderCodeNode[];
  1173. additionalDefineKey?: string;
  1174. additionalDefineValue?: string;
  1175. isValid(preprocessors: {
  1176. [key: string]: string;
  1177. }): boolean;
  1178. process(preprocessors: {
  1179. [key: string]: string;
  1180. }, options: ProcessingOptions): string;
  1181. }
  1182. }
  1183. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1184. /** @hidden */
  1185. export class ShaderCodeCursor {
  1186. private _lines;
  1187. lineIndex: number;
  1188. get currentLine(): string;
  1189. get canRead(): boolean;
  1190. set lines(value: string[]);
  1191. }
  1192. }
  1193. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1194. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1195. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1196. /** @hidden */
  1197. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1198. process(preprocessors: {
  1199. [key: string]: string;
  1200. }, options: ProcessingOptions): string;
  1201. }
  1202. }
  1203. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1204. /** @hidden */
  1205. export class ShaderDefineExpression {
  1206. isTrue(preprocessors: {
  1207. [key: string]: string;
  1208. }): boolean;
  1209. private static _OperatorPriority;
  1210. private static _Stack;
  1211. static postfixToInfix(postfix: string[]): string;
  1212. static infixToPostfix(infix: string): string[];
  1213. }
  1214. }
  1215. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1216. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1217. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1218. /** @hidden */
  1219. export class ShaderCodeTestNode extends ShaderCodeNode {
  1220. testExpression: ShaderDefineExpression;
  1221. isValid(preprocessors: {
  1222. [key: string]: string;
  1223. }): boolean;
  1224. }
  1225. }
  1226. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1227. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1228. /** @hidden */
  1229. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1230. define: string;
  1231. not: boolean;
  1232. constructor(define: string, not?: boolean);
  1233. isTrue(preprocessors: {
  1234. [key: string]: string;
  1235. }): boolean;
  1236. }
  1237. }
  1238. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1239. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1240. /** @hidden */
  1241. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1242. leftOperand: ShaderDefineExpression;
  1243. rightOperand: ShaderDefineExpression;
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. }
  1248. }
  1249. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1250. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1251. /** @hidden */
  1252. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1253. leftOperand: ShaderDefineExpression;
  1254. rightOperand: ShaderDefineExpression;
  1255. isTrue(preprocessors: {
  1256. [key: string]: string;
  1257. }): boolean;
  1258. }
  1259. }
  1260. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1261. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1262. /** @hidden */
  1263. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1264. define: string;
  1265. operand: string;
  1266. testValue: string;
  1267. constructor(define: string, operand: string, testValue: string);
  1268. isTrue(preprocessors: {
  1269. [key: string]: string;
  1270. }): boolean;
  1271. }
  1272. }
  1273. declare module "babylonjs/Offline/IOfflineProvider" {
  1274. /**
  1275. * Class used to enable access to offline support
  1276. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1277. */
  1278. export interface IOfflineProvider {
  1279. /**
  1280. * Gets a boolean indicating if scene must be saved in the database
  1281. */
  1282. enableSceneOffline: boolean;
  1283. /**
  1284. * Gets a boolean indicating if textures must be saved in the database
  1285. */
  1286. enableTexturesOffline: boolean;
  1287. /**
  1288. * Open the offline support and make it available
  1289. * @param successCallback defines the callback to call on success
  1290. * @param errorCallback defines the callback to call on error
  1291. */
  1292. open(successCallback: () => void, errorCallback: () => void): void;
  1293. /**
  1294. * Loads an image from the offline support
  1295. * @param url defines the url to load from
  1296. * @param image defines the target DOM image
  1297. */
  1298. loadImage(url: string, image: HTMLImageElement): void;
  1299. /**
  1300. * Loads a file from offline support
  1301. * @param url defines the URL to load from
  1302. * @param sceneLoaded defines a callback to call on success
  1303. * @param progressCallBack defines a callback to call when progress changed
  1304. * @param errorCallback defines a callback to call on error
  1305. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1306. */
  1307. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1308. }
  1309. }
  1310. declare module "babylonjs/Misc/filesInputStore" {
  1311. /**
  1312. * Class used to help managing file picking and drag'n'drop
  1313. * File Storage
  1314. */
  1315. export class FilesInputStore {
  1316. /**
  1317. * List of files ready to be loaded
  1318. */
  1319. static FilesToLoad: {
  1320. [key: string]: File;
  1321. };
  1322. }
  1323. }
  1324. declare module "babylonjs/Misc/retryStrategy" {
  1325. import { WebRequest } from "babylonjs/Misc/webRequest";
  1326. /**
  1327. * Class used to define a retry strategy when error happens while loading assets
  1328. */
  1329. export class RetryStrategy {
  1330. /**
  1331. * Function used to defines an exponential back off strategy
  1332. * @param maxRetries defines the maximum number of retries (3 by default)
  1333. * @param baseInterval defines the interval between retries
  1334. * @returns the strategy function to use
  1335. */
  1336. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1337. }
  1338. }
  1339. declare module "babylonjs/Misc/baseError" {
  1340. /**
  1341. * @ignore
  1342. * Application error to support additional information when loading a file
  1343. */
  1344. export abstract class BaseError extends Error {
  1345. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1346. }
  1347. }
  1348. declare module "babylonjs/Misc/fileTools" {
  1349. import { WebRequest } from "babylonjs/Misc/webRequest";
  1350. import { Nullable } from "babylonjs/types";
  1351. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1352. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1353. import { BaseError } from "babylonjs/Misc/baseError";
  1354. /** @ignore */
  1355. export class LoadFileError extends BaseError {
  1356. request?: WebRequest;
  1357. file?: File;
  1358. /**
  1359. * Creates a new LoadFileError
  1360. * @param message defines the message of the error
  1361. * @param request defines the optional web request
  1362. * @param file defines the optional file
  1363. */
  1364. constructor(message: string, object?: WebRequest | File);
  1365. }
  1366. /** @ignore */
  1367. export class RequestFileError extends BaseError {
  1368. request: WebRequest;
  1369. /**
  1370. * Creates a new LoadFileError
  1371. * @param message defines the message of the error
  1372. * @param request defines the optional web request
  1373. */
  1374. constructor(message: string, request: WebRequest);
  1375. }
  1376. /** @ignore */
  1377. export class ReadFileError extends BaseError {
  1378. file: File;
  1379. /**
  1380. * Creates a new ReadFileError
  1381. * @param message defines the message of the error
  1382. * @param file defines the optional file
  1383. */
  1384. constructor(message: string, file: File);
  1385. }
  1386. /**
  1387. * @hidden
  1388. */
  1389. export class FileTools {
  1390. /**
  1391. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1392. */
  1393. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1394. /**
  1395. * Gets or sets the base URL to use to load assets
  1396. */
  1397. static BaseUrl: string;
  1398. /**
  1399. * Default behaviour for cors in the application.
  1400. * It can be a string if the expected behavior is identical in the entire app.
  1401. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1402. */
  1403. static CorsBehavior: string | ((url: string | string[]) => string);
  1404. /**
  1405. * Gets or sets a function used to pre-process url before using them to load assets
  1406. */
  1407. static PreprocessUrl: (url: string) => string;
  1408. /**
  1409. * Removes unwanted characters from an url
  1410. * @param url defines the url to clean
  1411. * @returns the cleaned url
  1412. */
  1413. private static _CleanUrl;
  1414. /**
  1415. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1416. * @param url define the url we are trying
  1417. * @param element define the dom element where to configure the cors policy
  1418. */
  1419. static SetCorsBehavior(url: string | string[], element: {
  1420. crossOrigin: string | null;
  1421. }): void;
  1422. /**
  1423. * Loads an image as an HTMLImageElement.
  1424. * @param input url string, ArrayBuffer, or Blob to load
  1425. * @param onLoad callback called when the image successfully loads
  1426. * @param onError callback called when the image fails to load
  1427. * @param offlineProvider offline provider for caching
  1428. * @param mimeType optional mime type
  1429. * @returns the HTMLImageElement of the loaded image
  1430. */
  1431. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1432. /**
  1433. * Reads a file from a File object
  1434. * @param file defines the file to load
  1435. * @param onSuccess defines the callback to call when data is loaded
  1436. * @param onProgress defines the callback to call during loading process
  1437. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1438. * @param onError defines the callback to call when an error occurs
  1439. * @returns a file request object
  1440. */
  1441. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1442. /**
  1443. * Loads a file from a url
  1444. * @param url url to load
  1445. * @param onSuccess callback called when the file successfully loads
  1446. * @param onProgress callback called while file is loading (if the server supports this mode)
  1447. * @param offlineProvider defines the offline provider for caching
  1448. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1449. * @param onError callback called when the file fails to load
  1450. * @returns a file request object
  1451. */
  1452. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1453. /**
  1454. * Loads a file
  1455. * @param url url to load
  1456. * @param onSuccess callback called when the file successfully loads
  1457. * @param onProgress callback called while file is loading (if the server supports this mode)
  1458. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1459. * @param onError callback called when the file fails to load
  1460. * @param onOpened callback called when the web request is opened
  1461. * @returns a file request object
  1462. */
  1463. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1464. /**
  1465. * Checks if the loaded document was accessed via `file:`-Protocol.
  1466. * @returns boolean
  1467. */
  1468. static IsFileURL(): boolean;
  1469. }
  1470. }
  1471. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1472. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1473. import { WebRequest } from "babylonjs/Misc/webRequest";
  1474. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1475. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1476. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1477. /** @hidden */
  1478. export class ShaderProcessor {
  1479. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1480. private static _ProcessPrecision;
  1481. private static _ExtractOperation;
  1482. private static _BuildSubExpression;
  1483. private static _BuildExpression;
  1484. private static _MoveCursorWithinIf;
  1485. private static _MoveCursor;
  1486. private static _EvaluatePreProcessors;
  1487. private static _PreparePreProcessors;
  1488. private static _ProcessShaderConversion;
  1489. private static _ProcessIncludes;
  1490. /**
  1491. * Loads a file from a url
  1492. * @param url url to load
  1493. * @param onSuccess callback called when the file successfully loads
  1494. * @param onProgress callback called while file is loading (if the server supports this mode)
  1495. * @param offlineProvider defines the offline provider for caching
  1496. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1497. * @param onError callback called when the file fails to load
  1498. * @returns a file request object
  1499. * @hidden
  1500. */
  1501. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1502. }
  1503. }
  1504. declare module "babylonjs/Maths/math.like" {
  1505. import { float, int, DeepImmutable } from "babylonjs/types";
  1506. /**
  1507. * @hidden
  1508. */
  1509. export interface IColor4Like {
  1510. r: float;
  1511. g: float;
  1512. b: float;
  1513. a: float;
  1514. }
  1515. /**
  1516. * @hidden
  1517. */
  1518. export interface IColor3Like {
  1519. r: float;
  1520. g: float;
  1521. b: float;
  1522. }
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IVector4Like {
  1527. x: float;
  1528. y: float;
  1529. z: float;
  1530. w: float;
  1531. }
  1532. /**
  1533. * @hidden
  1534. */
  1535. export interface IVector3Like {
  1536. x: float;
  1537. y: float;
  1538. z: float;
  1539. }
  1540. /**
  1541. * @hidden
  1542. */
  1543. export interface IVector2Like {
  1544. x: float;
  1545. y: float;
  1546. }
  1547. /**
  1548. * @hidden
  1549. */
  1550. export interface IMatrixLike {
  1551. toArray(): DeepImmutable<Float32Array>;
  1552. updateFlag: int;
  1553. }
  1554. /**
  1555. * @hidden
  1556. */
  1557. export interface IViewportLike {
  1558. x: float;
  1559. y: float;
  1560. width: float;
  1561. height: float;
  1562. }
  1563. /**
  1564. * @hidden
  1565. */
  1566. export interface IPlaneLike {
  1567. normal: IVector3Like;
  1568. d: float;
  1569. normalize(): void;
  1570. }
  1571. }
  1572. declare module "babylonjs/Materials/iEffectFallbacks" {
  1573. import { Effect } from "babylonjs/Materials/effect";
  1574. /**
  1575. * Interface used to define common properties for effect fallbacks
  1576. */
  1577. export interface IEffectFallbacks {
  1578. /**
  1579. * Removes the defines that should be removed when falling back.
  1580. * @param currentDefines defines the current define statements for the shader.
  1581. * @param effect defines the current effect we try to compile
  1582. * @returns The resulting defines with defines of the current rank removed.
  1583. */
  1584. reduce(currentDefines: string, effect: Effect): string;
  1585. /**
  1586. * Removes the fallback from the bound mesh.
  1587. */
  1588. unBindMesh(): void;
  1589. /**
  1590. * Checks to see if more fallbacks are still availible.
  1591. */
  1592. hasMoreFallbacks: boolean;
  1593. }
  1594. }
  1595. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1596. /**
  1597. * Class used to evalaute queries containing `and` and `or` operators
  1598. */
  1599. export class AndOrNotEvaluator {
  1600. /**
  1601. * Evaluate a query
  1602. * @param query defines the query to evaluate
  1603. * @param evaluateCallback defines the callback used to filter result
  1604. * @returns true if the query matches
  1605. */
  1606. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1607. private static _HandleParenthesisContent;
  1608. private static _SimplifyNegation;
  1609. }
  1610. }
  1611. declare module "babylonjs/Misc/tags" {
  1612. /**
  1613. * Class used to store custom tags
  1614. */
  1615. export class Tags {
  1616. /**
  1617. * Adds support for tags on the given object
  1618. * @param obj defines the object to use
  1619. */
  1620. static EnableFor(obj: any): void;
  1621. /**
  1622. * Removes tags support
  1623. * @param obj defines the object to use
  1624. */
  1625. static DisableFor(obj: any): void;
  1626. /**
  1627. * Gets a boolean indicating if the given object has tags
  1628. * @param obj defines the object to use
  1629. * @returns a boolean
  1630. */
  1631. static HasTags(obj: any): boolean;
  1632. /**
  1633. * Gets the tags available on a given object
  1634. * @param obj defines the object to use
  1635. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1636. * @returns the tags
  1637. */
  1638. static GetTags(obj: any, asString?: boolean): any;
  1639. /**
  1640. * Adds tags to an object
  1641. * @param obj defines the object to use
  1642. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1643. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1644. */
  1645. static AddTagsTo(obj: any, tagsString: string): void;
  1646. /**
  1647. * @hidden
  1648. */
  1649. static _AddTagTo(obj: any, tag: string): void;
  1650. /**
  1651. * Removes specific tags from a specific object
  1652. * @param obj defines the object to use
  1653. * @param tagsString defines the tags to remove
  1654. */
  1655. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1656. /**
  1657. * @hidden
  1658. */
  1659. static _RemoveTagFrom(obj: any, tag: string): void;
  1660. /**
  1661. * Defines if tags hosted on an object match a given query
  1662. * @param obj defines the object to use
  1663. * @param tagsQuery defines the tag query
  1664. * @returns a boolean
  1665. */
  1666. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1667. }
  1668. }
  1669. declare module "babylonjs/Maths/math.scalar" {
  1670. /**
  1671. * Scalar computation library
  1672. */
  1673. export class Scalar {
  1674. /**
  1675. * Two pi constants convenient for computation.
  1676. */
  1677. static TwoPi: number;
  1678. /**
  1679. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1680. * @param a number
  1681. * @param b number
  1682. * @param epsilon (default = 1.401298E-45)
  1683. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1684. */
  1685. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1686. /**
  1687. * Returns a string : the upper case translation of the number i to hexadecimal.
  1688. * @param i number
  1689. * @returns the upper case translation of the number i to hexadecimal.
  1690. */
  1691. static ToHex(i: number): string;
  1692. /**
  1693. * Returns -1 if value is negative and +1 is value is positive.
  1694. * @param value the value
  1695. * @returns the value itself if it's equal to zero.
  1696. */
  1697. static Sign(value: number): number;
  1698. /**
  1699. * Returns the value itself if it's between min and max.
  1700. * Returns min if the value is lower than min.
  1701. * Returns max if the value is greater than max.
  1702. * @param value the value to clmap
  1703. * @param min the min value to clamp to (default: 0)
  1704. * @param max the max value to clamp to (default: 1)
  1705. * @returns the clamped value
  1706. */
  1707. static Clamp(value: number, min?: number, max?: number): number;
  1708. /**
  1709. * the log2 of value.
  1710. * @param value the value to compute log2 of
  1711. * @returns the log2 of value.
  1712. */
  1713. static Log2(value: number): number;
  1714. /**
  1715. * Loops the value, so that it is never larger than length and never smaller than 0.
  1716. *
  1717. * This is similar to the modulo operator but it works with floating point numbers.
  1718. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1719. * With t = 5 and length = 2.5, the result would be 0.0.
  1720. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1721. * @param value the value
  1722. * @param length the length
  1723. * @returns the looped value
  1724. */
  1725. static Repeat(value: number, length: number): number;
  1726. /**
  1727. * Normalize the value between 0.0 and 1.0 using min and max values
  1728. * @param value value to normalize
  1729. * @param min max to normalize between
  1730. * @param max min to normalize between
  1731. * @returns the normalized value
  1732. */
  1733. static Normalize(value: number, min: number, max: number): number;
  1734. /**
  1735. * Denormalize the value from 0.0 and 1.0 using min and max values
  1736. * @param normalized value to denormalize
  1737. * @param min max to denormalize between
  1738. * @param max min to denormalize between
  1739. * @returns the denormalized value
  1740. */
  1741. static Denormalize(normalized: number, min: number, max: number): number;
  1742. /**
  1743. * Calculates the shortest difference between two given angles given in degrees.
  1744. * @param current current angle in degrees
  1745. * @param target target angle in degrees
  1746. * @returns the delta
  1747. */
  1748. static DeltaAngle(current: number, target: number): number;
  1749. /**
  1750. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1751. * @param tx value
  1752. * @param length length
  1753. * @returns The returned value will move back and forth between 0 and length
  1754. */
  1755. static PingPong(tx: number, length: number): number;
  1756. /**
  1757. * Interpolates between min and max with smoothing at the limits.
  1758. *
  1759. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1760. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1761. * @param from from
  1762. * @param to to
  1763. * @param tx value
  1764. * @returns the smooth stepped value
  1765. */
  1766. static SmoothStep(from: number, to: number, tx: number): number;
  1767. /**
  1768. * Moves a value current towards target.
  1769. *
  1770. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1771. * Negative values of maxDelta pushes the value away from target.
  1772. * @param current current value
  1773. * @param target target value
  1774. * @param maxDelta max distance to move
  1775. * @returns resulting value
  1776. */
  1777. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1778. /**
  1779. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1780. *
  1781. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1782. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1783. * @param current current value
  1784. * @param target target value
  1785. * @param maxDelta max distance to move
  1786. * @returns resulting angle
  1787. */
  1788. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1789. /**
  1790. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1791. * @param start start value
  1792. * @param end target value
  1793. * @param amount amount to lerp between
  1794. * @returns the lerped value
  1795. */
  1796. static Lerp(start: number, end: number, amount: number): number;
  1797. /**
  1798. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1799. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1800. * @param start start value
  1801. * @param end target value
  1802. * @param amount amount to lerp between
  1803. * @returns the lerped value
  1804. */
  1805. static LerpAngle(start: number, end: number, amount: number): number;
  1806. /**
  1807. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1808. * @param a start value
  1809. * @param b target value
  1810. * @param value value between a and b
  1811. * @returns the inverseLerp value
  1812. */
  1813. static InverseLerp(a: number, b: number, value: number): number;
  1814. /**
  1815. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1816. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1817. * @param value1 spline value
  1818. * @param tangent1 spline value
  1819. * @param value2 spline value
  1820. * @param tangent2 spline value
  1821. * @param amount input value
  1822. * @returns hermite result
  1823. */
  1824. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1825. /**
  1826. * Returns a random float number between and min and max values
  1827. * @param min min value of random
  1828. * @param max max value of random
  1829. * @returns random value
  1830. */
  1831. static RandomRange(min: number, max: number): number;
  1832. /**
  1833. * This function returns percentage of a number in a given range.
  1834. *
  1835. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1836. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1837. * @param number to convert to percentage
  1838. * @param min min range
  1839. * @param max max range
  1840. * @returns the percentage
  1841. */
  1842. static RangeToPercent(number: number, min: number, max: number): number;
  1843. /**
  1844. * This function returns number that corresponds to the percentage in a given range.
  1845. *
  1846. * PercentToRange(0.34,0,100) will return 34.
  1847. * @param percent to convert to number
  1848. * @param min min range
  1849. * @param max max range
  1850. * @returns the number
  1851. */
  1852. static PercentToRange(percent: number, min: number, max: number): number;
  1853. /**
  1854. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1855. * @param angle The angle to normalize in radian.
  1856. * @return The converted angle.
  1857. */
  1858. static NormalizeRadians(angle: number): number;
  1859. }
  1860. }
  1861. declare module "babylonjs/Maths/math.constants" {
  1862. /**
  1863. * Constant used to convert a value to gamma space
  1864. * @ignorenaming
  1865. */
  1866. export const ToGammaSpace: number;
  1867. /**
  1868. * Constant used to convert a value to linear space
  1869. * @ignorenaming
  1870. */
  1871. export const ToLinearSpace = 2.2;
  1872. /**
  1873. * Constant used to define the minimal number value in Babylon.js
  1874. * @ignorenaming
  1875. */
  1876. let Epsilon: number;
  1877. export { Epsilon };
  1878. }
  1879. declare module "babylonjs/Maths/math.viewport" {
  1880. /**
  1881. * Class used to represent a viewport on screen
  1882. */
  1883. export class Viewport {
  1884. /** viewport left coordinate */
  1885. x: number;
  1886. /** viewport top coordinate */
  1887. y: number;
  1888. /**viewport width */
  1889. width: number;
  1890. /** viewport height */
  1891. height: number;
  1892. /**
  1893. * Creates a Viewport object located at (x, y) and sized (width, height)
  1894. * @param x defines viewport left coordinate
  1895. * @param y defines viewport top coordinate
  1896. * @param width defines the viewport width
  1897. * @param height defines the viewport height
  1898. */
  1899. constructor(
  1900. /** viewport left coordinate */
  1901. x: number,
  1902. /** viewport top coordinate */
  1903. y: number,
  1904. /**viewport width */
  1905. width: number,
  1906. /** viewport height */
  1907. height: number);
  1908. /**
  1909. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1910. * @param renderWidth defines the rendering width
  1911. * @param renderHeight defines the rendering height
  1912. * @returns a new Viewport
  1913. */
  1914. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1915. /**
  1916. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1917. * @param renderWidth defines the rendering width
  1918. * @param renderHeight defines the rendering height
  1919. * @param ref defines the target viewport
  1920. * @returns the current viewport
  1921. */
  1922. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1923. /**
  1924. * Returns a new Viewport copied from the current one
  1925. * @returns a new Viewport
  1926. */
  1927. clone(): Viewport;
  1928. }
  1929. }
  1930. declare module "babylonjs/Misc/arrayTools" {
  1931. /**
  1932. * Class containing a set of static utilities functions for arrays.
  1933. */
  1934. export class ArrayTools {
  1935. /**
  1936. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1937. * @param size the number of element to construct and put in the array
  1938. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1939. * @returns a new array filled with new objects
  1940. */
  1941. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1942. }
  1943. }
  1944. declare module "babylonjs/Maths/math.plane" {
  1945. import { DeepImmutable } from "babylonjs/types";
  1946. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1947. /**
  1948. * Represens a plane by the equation ax + by + cz + d = 0
  1949. */
  1950. export class Plane {
  1951. private static _TmpMatrix;
  1952. /**
  1953. * Normal of the plane (a,b,c)
  1954. */
  1955. normal: Vector3;
  1956. /**
  1957. * d component of the plane
  1958. */
  1959. d: number;
  1960. /**
  1961. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1962. * @param a a component of the plane
  1963. * @param b b component of the plane
  1964. * @param c c component of the plane
  1965. * @param d d component of the plane
  1966. */
  1967. constructor(a: number, b: number, c: number, d: number);
  1968. /**
  1969. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * @returns a new plane copied from the current Plane.
  1974. */
  1975. clone(): Plane;
  1976. /**
  1977. * @returns the string "Plane".
  1978. */
  1979. getClassName(): string;
  1980. /**
  1981. * @returns the Plane hash code.
  1982. */
  1983. getHashCode(): number;
  1984. /**
  1985. * Normalize the current Plane in place.
  1986. * @returns the updated Plane.
  1987. */
  1988. normalize(): Plane;
  1989. /**
  1990. * Applies a transformation the plane and returns the result
  1991. * @param transformation the transformation matrix to be applied to the plane
  1992. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1993. */
  1994. transform(transformation: DeepImmutable<Matrix>): Plane;
  1995. /**
  1996. * Compute the dot product between the point and the plane normal
  1997. * @param point point to calculate the dot product with
  1998. * @returns the dot product (float) of the point coordinates and the plane normal.
  1999. */
  2000. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2001. /**
  2002. * Updates the current Plane from the plane defined by the three given points.
  2003. * @param point1 one of the points used to contruct the plane
  2004. * @param point2 one of the points used to contruct the plane
  2005. * @param point3 one of the points used to contruct the plane
  2006. * @returns the updated Plane.
  2007. */
  2008. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2009. /**
  2010. * Checks if the plane is facing a given direction
  2011. * @param direction the direction to check if the plane is facing
  2012. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2013. * @returns True is the vector "direction" is the same side than the plane normal.
  2014. */
  2015. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2016. /**
  2017. * Calculates the distance to a point
  2018. * @param point point to calculate distance to
  2019. * @returns the signed distance (float) from the given point to the Plane.
  2020. */
  2021. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2022. /**
  2023. * Creates a plane from an array
  2024. * @param array the array to create a plane from
  2025. * @returns a new Plane from the given array.
  2026. */
  2027. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2028. /**
  2029. * Creates a plane from three points
  2030. * @param point1 point used to create the plane
  2031. * @param point2 point used to create the plane
  2032. * @param point3 point used to create the plane
  2033. * @returns a new Plane defined by the three given points.
  2034. */
  2035. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2036. /**
  2037. * Creates a plane from an origin point and a normal
  2038. * @param origin origin of the plane to be constructed
  2039. * @param normal normal of the plane to be constructed
  2040. * @returns a new Plane the normal vector to this plane at the given origin point.
  2041. * Note : the vector "normal" is updated because normalized.
  2042. */
  2043. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  2044. /**
  2045. * Calculates the distance from a plane and a point
  2046. * @param origin origin of the plane to be constructed
  2047. * @param normal normal of the plane to be constructed
  2048. * @param point point to calculate distance to
  2049. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2050. */
  2051. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2052. }
  2053. }
  2054. declare module "babylonjs/Maths/math.vector" {
  2055. import { Viewport } from "babylonjs/Maths/math.viewport";
  2056. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2057. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2058. import { Plane } from "babylonjs/Maths/math.plane";
  2059. /**
  2060. * Class representing a vector containing 2 coordinates
  2061. */
  2062. export class Vector2 {
  2063. /** defines the first coordinate */
  2064. x: number;
  2065. /** defines the second coordinate */
  2066. y: number;
  2067. /**
  2068. * Creates a new Vector2 from the given x and y coordinates
  2069. * @param x defines the first coordinate
  2070. * @param y defines the second coordinate
  2071. */
  2072. constructor(
  2073. /** defines the first coordinate */
  2074. x?: number,
  2075. /** defines the second coordinate */
  2076. y?: number);
  2077. /**
  2078. * Gets a string with the Vector2 coordinates
  2079. * @returns a string with the Vector2 coordinates
  2080. */
  2081. toString(): string;
  2082. /**
  2083. * Gets class name
  2084. * @returns the string "Vector2"
  2085. */
  2086. getClassName(): string;
  2087. /**
  2088. * Gets current vector hash code
  2089. * @returns the Vector2 hash code as a number
  2090. */
  2091. getHashCode(): number;
  2092. /**
  2093. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2094. * @param array defines the source array
  2095. * @param index defines the offset in source array
  2096. * @returns the current Vector2
  2097. */
  2098. toArray(array: FloatArray, index?: number): Vector2;
  2099. /**
  2100. * Copy the current vector to an array
  2101. * @returns a new array with 2 elements: the Vector2 coordinates.
  2102. */
  2103. asArray(): number[];
  2104. /**
  2105. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2106. * @param source defines the source Vector2
  2107. * @returns the current updated Vector2
  2108. */
  2109. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2110. /**
  2111. * Sets the Vector2 coordinates with the given floats
  2112. * @param x defines the first coordinate
  2113. * @param y defines the second coordinate
  2114. * @returns the current updated Vector2
  2115. */
  2116. copyFromFloats(x: number, y: number): Vector2;
  2117. /**
  2118. * Sets the Vector2 coordinates with the given floats
  2119. * @param x defines the first coordinate
  2120. * @param y defines the second coordinate
  2121. * @returns the current updated Vector2
  2122. */
  2123. set(x: number, y: number): Vector2;
  2124. /**
  2125. * Add another vector with the current one
  2126. * @param otherVector defines the other vector
  2127. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2128. */
  2129. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2130. /**
  2131. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2132. * @param otherVector defines the other vector
  2133. * @param result defines the target vector
  2134. * @returns the unmodified current Vector2
  2135. */
  2136. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2137. /**
  2138. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2139. * @param otherVector defines the other vector
  2140. * @returns the current updated Vector2
  2141. */
  2142. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2143. /**
  2144. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2145. * @param otherVector defines the other vector
  2146. * @returns a new Vector2
  2147. */
  2148. addVector3(otherVector: Vector3): Vector2;
  2149. /**
  2150. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2151. * @param otherVector defines the other vector
  2152. * @returns a new Vector2
  2153. */
  2154. subtract(otherVector: Vector2): Vector2;
  2155. /**
  2156. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2157. * @param otherVector defines the other vector
  2158. * @param result defines the target vector
  2159. * @returns the unmodified current Vector2
  2160. */
  2161. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2162. /**
  2163. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2164. * @param otherVector defines the other vector
  2165. * @returns the current updated Vector2
  2166. */
  2167. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2168. /**
  2169. * Multiplies in place the current Vector2 coordinates by the given ones
  2170. * @param otherVector defines the other vector
  2171. * @returns the current updated Vector2
  2172. */
  2173. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2174. /**
  2175. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2176. * @param otherVector defines the other vector
  2177. * @returns a new Vector2
  2178. */
  2179. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2180. /**
  2181. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2182. * @param otherVector defines the other vector
  2183. * @param result defines the target vector
  2184. * @returns the unmodified current Vector2
  2185. */
  2186. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2187. /**
  2188. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2189. * @param x defines the first coordinate
  2190. * @param y defines the second coordinate
  2191. * @returns a new Vector2
  2192. */
  2193. multiplyByFloats(x: number, y: number): Vector2;
  2194. /**
  2195. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2196. * @param otherVector defines the other vector
  2197. * @returns a new Vector2
  2198. */
  2199. divide(otherVector: Vector2): Vector2;
  2200. /**
  2201. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2202. * @param otherVector defines the other vector
  2203. * @param result defines the target vector
  2204. * @returns the unmodified current Vector2
  2205. */
  2206. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2207. /**
  2208. * Divides the current Vector2 coordinates by the given ones
  2209. * @param otherVector defines the other vector
  2210. * @returns the current updated Vector2
  2211. */
  2212. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2213. /**
  2214. * Gets a new Vector2 with current Vector2 negated coordinates
  2215. * @returns a new Vector2
  2216. */
  2217. negate(): Vector2;
  2218. /**
  2219. * Negate this vector in place
  2220. * @returns this
  2221. */
  2222. negateInPlace(): Vector2;
  2223. /**
  2224. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2225. * @param result defines the Vector3 object where to store the result
  2226. * @returns the current Vector2
  2227. */
  2228. negateToRef(result: Vector2): Vector2;
  2229. /**
  2230. * Multiply the Vector2 coordinates by scale
  2231. * @param scale defines the scaling factor
  2232. * @returns the current updated Vector2
  2233. */
  2234. scaleInPlace(scale: number): Vector2;
  2235. /**
  2236. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2237. * @param scale defines the scaling factor
  2238. * @returns a new Vector2
  2239. */
  2240. scale(scale: number): Vector2;
  2241. /**
  2242. * Scale the current Vector2 values by a factor to a given Vector2
  2243. * @param scale defines the scale factor
  2244. * @param result defines the Vector2 object where to store the result
  2245. * @returns the unmodified current Vector2
  2246. */
  2247. scaleToRef(scale: number, result: Vector2): Vector2;
  2248. /**
  2249. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2250. * @param scale defines the scale factor
  2251. * @param result defines the Vector2 object where to store the result
  2252. * @returns the unmodified current Vector2
  2253. */
  2254. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2255. /**
  2256. * Gets a boolean if two vectors are equals
  2257. * @param otherVector defines the other vector
  2258. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2259. */
  2260. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2261. /**
  2262. * Gets a boolean if two vectors are equals (using an epsilon value)
  2263. * @param otherVector defines the other vector
  2264. * @param epsilon defines the minimal distance to consider equality
  2265. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2266. */
  2267. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2268. /**
  2269. * Gets a new Vector2 from current Vector2 floored values
  2270. * @returns a new Vector2
  2271. */
  2272. floor(): Vector2;
  2273. /**
  2274. * Gets a new Vector2 from current Vector2 floored values
  2275. * @returns a new Vector2
  2276. */
  2277. fract(): Vector2;
  2278. /**
  2279. * Gets the length of the vector
  2280. * @returns the vector length (float)
  2281. */
  2282. length(): number;
  2283. /**
  2284. * Gets the vector squared length
  2285. * @returns the vector squared length (float)
  2286. */
  2287. lengthSquared(): number;
  2288. /**
  2289. * Normalize the vector
  2290. * @returns the current updated Vector2
  2291. */
  2292. normalize(): Vector2;
  2293. /**
  2294. * Gets a new Vector2 copied from the Vector2
  2295. * @returns a new Vector2
  2296. */
  2297. clone(): Vector2;
  2298. /**
  2299. * Gets a new Vector2(0, 0)
  2300. * @returns a new Vector2
  2301. */
  2302. static Zero(): Vector2;
  2303. /**
  2304. * Gets a new Vector2(1, 1)
  2305. * @returns a new Vector2
  2306. */
  2307. static One(): Vector2;
  2308. /**
  2309. * Gets a new Vector2 set from the given index element of the given array
  2310. * @param array defines the data source
  2311. * @param offset defines the offset in the data source
  2312. * @returns a new Vector2
  2313. */
  2314. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2315. /**
  2316. * Sets "result" from the given index element of the given array
  2317. * @param array defines the data source
  2318. * @param offset defines the offset in the data source
  2319. * @param result defines the target vector
  2320. */
  2321. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2322. /**
  2323. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2324. * @param value1 defines 1st point of control
  2325. * @param value2 defines 2nd point of control
  2326. * @param value3 defines 3rd point of control
  2327. * @param value4 defines 4th point of control
  2328. * @param amount defines the interpolation factor
  2329. * @returns a new Vector2
  2330. */
  2331. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2332. /**
  2333. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2334. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2335. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2336. * @param value defines the value to clamp
  2337. * @param min defines the lower limit
  2338. * @param max defines the upper limit
  2339. * @returns a new Vector2
  2340. */
  2341. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2342. /**
  2343. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2344. * @param value1 defines the 1st control point
  2345. * @param tangent1 defines the outgoing tangent
  2346. * @param value2 defines the 2nd control point
  2347. * @param tangent2 defines the incoming tangent
  2348. * @param amount defines the interpolation factor
  2349. * @returns a new Vector2
  2350. */
  2351. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2352. /**
  2353. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2354. * @param start defines the start vector
  2355. * @param end defines the end vector
  2356. * @param amount defines the interpolation factor
  2357. * @returns a new Vector2
  2358. */
  2359. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2360. /**
  2361. * Gets the dot product of the vector "left" and the vector "right"
  2362. * @param left defines first vector
  2363. * @param right defines second vector
  2364. * @returns the dot product (float)
  2365. */
  2366. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2367. /**
  2368. * Returns a new Vector2 equal to the normalized given vector
  2369. * @param vector defines the vector to normalize
  2370. * @returns a new Vector2
  2371. */
  2372. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2373. /**
  2374. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2375. * @param left defines 1st vector
  2376. * @param right defines 2nd vector
  2377. * @returns a new Vector2
  2378. */
  2379. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2380. /**
  2381. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2382. * @param left defines 1st vector
  2383. * @param right defines 2nd vector
  2384. * @returns a new Vector2
  2385. */
  2386. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2387. /**
  2388. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2389. * @param vector defines the vector to transform
  2390. * @param transformation defines the matrix to apply
  2391. * @returns a new Vector2
  2392. */
  2393. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2394. /**
  2395. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2396. * @param vector defines the vector to transform
  2397. * @param transformation defines the matrix to apply
  2398. * @param result defines the target vector
  2399. */
  2400. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2401. /**
  2402. * Determines if a given vector is included in a triangle
  2403. * @param p defines the vector to test
  2404. * @param p0 defines 1st triangle point
  2405. * @param p1 defines 2nd triangle point
  2406. * @param p2 defines 3rd triangle point
  2407. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2408. */
  2409. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2410. /**
  2411. * Gets the distance between the vectors "value1" and "value2"
  2412. * @param value1 defines first vector
  2413. * @param value2 defines second vector
  2414. * @returns the distance between vectors
  2415. */
  2416. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2417. /**
  2418. * Returns the squared distance between the vectors "value1" and "value2"
  2419. * @param value1 defines first vector
  2420. * @param value2 defines second vector
  2421. * @returns the squared distance between vectors
  2422. */
  2423. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2424. /**
  2425. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2426. * @param value1 defines first vector
  2427. * @param value2 defines second vector
  2428. * @returns a new Vector2
  2429. */
  2430. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2431. /**
  2432. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2433. * @param p defines the middle point
  2434. * @param segA defines one point of the segment
  2435. * @param segB defines the other point of the segment
  2436. * @returns the shortest distance
  2437. */
  2438. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2439. }
  2440. /**
  2441. * Class used to store (x,y,z) vector representation
  2442. * A Vector3 is the main object used in 3D geometry
  2443. * It can represent etiher the coordinates of a point the space, either a direction
  2444. * Reminder: js uses a left handed forward facing system
  2445. */
  2446. export class Vector3 {
  2447. /**
  2448. * Defines the first coordinates (on X axis)
  2449. */
  2450. x: number;
  2451. /**
  2452. * Defines the second coordinates (on Y axis)
  2453. */
  2454. y: number;
  2455. /**
  2456. * Defines the third coordinates (on Z axis)
  2457. */
  2458. z: number;
  2459. private static _UpReadOnly;
  2460. private static _ZeroReadOnly;
  2461. /**
  2462. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2463. * @param x defines the first coordinates (on X axis)
  2464. * @param y defines the second coordinates (on Y axis)
  2465. * @param z defines the third coordinates (on Z axis)
  2466. */
  2467. constructor(
  2468. /**
  2469. * Defines the first coordinates (on X axis)
  2470. */
  2471. x?: number,
  2472. /**
  2473. * Defines the second coordinates (on Y axis)
  2474. */
  2475. y?: number,
  2476. /**
  2477. * Defines the third coordinates (on Z axis)
  2478. */
  2479. z?: number);
  2480. /**
  2481. * Creates a string representation of the Vector3
  2482. * @returns a string with the Vector3 coordinates.
  2483. */
  2484. toString(): string;
  2485. /**
  2486. * Gets the class name
  2487. * @returns the string "Vector3"
  2488. */
  2489. getClassName(): string;
  2490. /**
  2491. * Creates the Vector3 hash code
  2492. * @returns a number which tends to be unique between Vector3 instances
  2493. */
  2494. getHashCode(): number;
  2495. /**
  2496. * Creates an array containing three elements : the coordinates of the Vector3
  2497. * @returns a new array of numbers
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2502. * @param array defines the destination array
  2503. * @param index defines the offset in the destination array
  2504. * @returns the current Vector3
  2505. */
  2506. toArray(array: FloatArray, index?: number): Vector3;
  2507. /**
  2508. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2509. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2510. */
  2511. toQuaternion(): Quaternion;
  2512. /**
  2513. * Adds the given vector to the current Vector3
  2514. * @param otherVector defines the second operand
  2515. * @returns the current updated Vector3
  2516. */
  2517. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2518. /**
  2519. * Adds the given coordinates to the current Vector3
  2520. * @param x defines the x coordinate of the operand
  2521. * @param y defines the y coordinate of the operand
  2522. * @param z defines the z coordinate of the operand
  2523. * @returns the current updated Vector3
  2524. */
  2525. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2526. /**
  2527. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2528. * @param otherVector defines the second operand
  2529. * @returns the resulting Vector3
  2530. */
  2531. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2532. /**
  2533. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2534. * @param otherVector defines the second operand
  2535. * @param result defines the Vector3 object where to store the result
  2536. * @returns the current Vector3
  2537. */
  2538. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2539. /**
  2540. * Subtract the given vector from the current Vector3
  2541. * @param otherVector defines the second operand
  2542. * @returns the current updated Vector3
  2543. */
  2544. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2545. /**
  2546. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2547. * @param otherVector defines the second operand
  2548. * @returns the resulting Vector3
  2549. */
  2550. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2551. /**
  2552. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2553. * @param otherVector defines the second operand
  2554. * @param result defines the Vector3 object where to store the result
  2555. * @returns the current Vector3
  2556. */
  2557. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2558. /**
  2559. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2560. * @param x defines the x coordinate of the operand
  2561. * @param y defines the y coordinate of the operand
  2562. * @param z defines the z coordinate of the operand
  2563. * @returns the resulting Vector3
  2564. */
  2565. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2566. /**
  2567. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2568. * @param x defines the x coordinate of the operand
  2569. * @param y defines the y coordinate of the operand
  2570. * @param z defines the z coordinate of the operand
  2571. * @param result defines the Vector3 object where to store the result
  2572. * @returns the current Vector3
  2573. */
  2574. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2575. /**
  2576. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2577. * @returns a new Vector3
  2578. */
  2579. negate(): Vector3;
  2580. /**
  2581. * Negate this vector in place
  2582. * @returns this
  2583. */
  2584. negateInPlace(): Vector3;
  2585. /**
  2586. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2587. * @param result defines the Vector3 object where to store the result
  2588. * @returns the current Vector3
  2589. */
  2590. negateToRef(result: Vector3): Vector3;
  2591. /**
  2592. * Multiplies the Vector3 coordinates by the float "scale"
  2593. * @param scale defines the multiplier factor
  2594. * @returns the current updated Vector3
  2595. */
  2596. scaleInPlace(scale: number): Vector3;
  2597. /**
  2598. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2599. * @param scale defines the multiplier factor
  2600. * @returns a new Vector3
  2601. */
  2602. scale(scale: number): Vector3;
  2603. /**
  2604. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2605. * @param scale defines the multiplier factor
  2606. * @param result defines the Vector3 object where to store the result
  2607. * @returns the current Vector3
  2608. */
  2609. scaleToRef(scale: number, result: Vector3): Vector3;
  2610. /**
  2611. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2612. * @param scale defines the scale factor
  2613. * @param result defines the Vector3 object where to store the result
  2614. * @returns the unmodified current Vector3
  2615. */
  2616. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2617. /**
  2618. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2619. * @param origin defines the origin of the projection ray
  2620. * @param plane defines the plane to project to
  2621. * @returns the projected vector3
  2622. */
  2623. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2624. /**
  2625. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2626. * @param origin defines the origin of the projection ray
  2627. * @param plane defines the plane to project to
  2628. * @param result defines the Vector3 where to store the result
  2629. */
  2630. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2631. /**
  2632. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2633. * @param otherVector defines the second operand
  2634. * @returns true if both vectors are equals
  2635. */
  2636. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2637. /**
  2638. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2639. * @param otherVector defines the second operand
  2640. * @param epsilon defines the minimal distance to define values as equals
  2641. * @returns true if both vectors are distant less than epsilon
  2642. */
  2643. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2644. /**
  2645. * Returns true if the current Vector3 coordinates equals the given floats
  2646. * @param x defines the x coordinate of the operand
  2647. * @param y defines the y coordinate of the operand
  2648. * @param z defines the z coordinate of the operand
  2649. * @returns true if both vectors are equals
  2650. */
  2651. equalsToFloats(x: number, y: number, z: number): boolean;
  2652. /**
  2653. * Multiplies the current Vector3 coordinates by the given ones
  2654. * @param otherVector defines the second operand
  2655. * @returns the current updated Vector3
  2656. */
  2657. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2658. /**
  2659. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2660. * @param otherVector defines the second operand
  2661. * @returns the new Vector3
  2662. */
  2663. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2664. /**
  2665. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2666. * @param otherVector defines the second operand
  2667. * @param result defines the Vector3 object where to store the result
  2668. * @returns the current Vector3
  2669. */
  2670. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2671. /**
  2672. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2673. * @param x defines the x coordinate of the operand
  2674. * @param y defines the y coordinate of the operand
  2675. * @param z defines the z coordinate of the operand
  2676. * @returns the new Vector3
  2677. */
  2678. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2679. /**
  2680. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2681. * @param otherVector defines the second operand
  2682. * @returns the new Vector3
  2683. */
  2684. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2685. /**
  2686. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2687. * @param otherVector defines the second operand
  2688. * @param result defines the Vector3 object where to store the result
  2689. * @returns the current Vector3
  2690. */
  2691. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2692. /**
  2693. * Divides the current Vector3 coordinates by the given ones.
  2694. * @param otherVector defines the second operand
  2695. * @returns the current updated Vector3
  2696. */
  2697. divideInPlace(otherVector: Vector3): Vector3;
  2698. /**
  2699. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2700. * @param other defines the second operand
  2701. * @returns the current updated Vector3
  2702. */
  2703. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2704. /**
  2705. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2706. * @param other defines the second operand
  2707. * @returns the current updated Vector3
  2708. */
  2709. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2710. /**
  2711. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2712. * @param x defines the x coordinate of the operand
  2713. * @param y defines the y coordinate of the operand
  2714. * @param z defines the z coordinate of the operand
  2715. * @returns the current updated Vector3
  2716. */
  2717. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2718. /**
  2719. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2720. * @param x defines the x coordinate of the operand
  2721. * @param y defines the y coordinate of the operand
  2722. * @param z defines the z coordinate of the operand
  2723. * @returns the current updated Vector3
  2724. */
  2725. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2726. /**
  2727. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2728. * Check if is non uniform within a certain amount of decimal places to account for this
  2729. * @param epsilon the amount the values can differ
  2730. * @returns if the the vector is non uniform to a certain number of decimal places
  2731. */
  2732. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2733. /**
  2734. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2735. */
  2736. get isNonUniform(): boolean;
  2737. /**
  2738. * Gets a new Vector3 from current Vector3 floored values
  2739. * @returns a new Vector3
  2740. */
  2741. floor(): Vector3;
  2742. /**
  2743. * Gets a new Vector3 from current Vector3 floored values
  2744. * @returns a new Vector3
  2745. */
  2746. fract(): Vector3;
  2747. /**
  2748. * Gets the length of the Vector3
  2749. * @returns the length of the Vector3
  2750. */
  2751. length(): number;
  2752. /**
  2753. * Gets the squared length of the Vector3
  2754. * @returns squared length of the Vector3
  2755. */
  2756. lengthSquared(): number;
  2757. /**
  2758. * Normalize the current Vector3.
  2759. * Please note that this is an in place operation.
  2760. * @returns the current updated Vector3
  2761. */
  2762. normalize(): Vector3;
  2763. /**
  2764. * Reorders the x y z properties of the vector in place
  2765. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2766. * @returns the current updated vector
  2767. */
  2768. reorderInPlace(order: string): this;
  2769. /**
  2770. * Rotates the vector around 0,0,0 by a quaternion
  2771. * @param quaternion the rotation quaternion
  2772. * @param result vector to store the result
  2773. * @returns the resulting vector
  2774. */
  2775. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2776. /**
  2777. * Rotates a vector around a given point
  2778. * @param quaternion the rotation quaternion
  2779. * @param point the point to rotate around
  2780. * @param result vector to store the result
  2781. * @returns the resulting vector
  2782. */
  2783. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2784. /**
  2785. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2786. * The cross product is then orthogonal to both current and "other"
  2787. * @param other defines the right operand
  2788. * @returns the cross product
  2789. */
  2790. cross(other: Vector3): Vector3;
  2791. /**
  2792. * Normalize the current Vector3 with the given input length.
  2793. * Please note that this is an in place operation.
  2794. * @param len the length of the vector
  2795. * @returns the current updated Vector3
  2796. */
  2797. normalizeFromLength(len: number): Vector3;
  2798. /**
  2799. * Normalize the current Vector3 to a new vector
  2800. * @returns the new Vector3
  2801. */
  2802. normalizeToNew(): Vector3;
  2803. /**
  2804. * Normalize the current Vector3 to the reference
  2805. * @param reference define the Vector3 to update
  2806. * @returns the updated Vector3
  2807. */
  2808. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2809. /**
  2810. * Creates a new Vector3 copied from the current Vector3
  2811. * @returns the new Vector3
  2812. */
  2813. clone(): Vector3;
  2814. /**
  2815. * Copies the given vector coordinates to the current Vector3 ones
  2816. * @param source defines the source Vector3
  2817. * @returns the current updated Vector3
  2818. */
  2819. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2820. /**
  2821. * Copies the given floats to the current Vector3 coordinates
  2822. * @param x defines the x coordinate of the operand
  2823. * @param y defines the y coordinate of the operand
  2824. * @param z defines the z coordinate of the operand
  2825. * @returns the current updated Vector3
  2826. */
  2827. copyFromFloats(x: number, y: number, z: number): Vector3;
  2828. /**
  2829. * Copies the given floats to the current Vector3 coordinates
  2830. * @param x defines the x coordinate of the operand
  2831. * @param y defines the y coordinate of the operand
  2832. * @param z defines the z coordinate of the operand
  2833. * @returns the current updated Vector3
  2834. */
  2835. set(x: number, y: number, z: number): Vector3;
  2836. /**
  2837. * Copies the given float to the current Vector3 coordinates
  2838. * @param v defines the x, y and z coordinates of the operand
  2839. * @returns the current updated Vector3
  2840. */
  2841. setAll(v: number): Vector3;
  2842. /**
  2843. * Get the clip factor between two vectors
  2844. * @param vector0 defines the first operand
  2845. * @param vector1 defines the second operand
  2846. * @param axis defines the axis to use
  2847. * @param size defines the size along the axis
  2848. * @returns the clip factor
  2849. */
  2850. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2851. /**
  2852. * Get angle between two vectors
  2853. * @param vector0 angle between vector0 and vector1
  2854. * @param vector1 angle between vector0 and vector1
  2855. * @param normal direction of the normal
  2856. * @return the angle between vector0 and vector1
  2857. */
  2858. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2859. /**
  2860. * Returns a new Vector3 set from the index "offset" of the given array
  2861. * @param array defines the source array
  2862. * @param offset defines the offset in the source array
  2863. * @returns the new Vector3
  2864. */
  2865. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2866. /**
  2867. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2868. * @param array defines the source array
  2869. * @param offset defines the offset in the source array
  2870. * @returns the new Vector3
  2871. * @deprecated Please use FromArray instead.
  2872. */
  2873. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2874. /**
  2875. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2876. * @param array defines the source array
  2877. * @param offset defines the offset in the source array
  2878. * @param result defines the Vector3 where to store the result
  2879. */
  2880. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2881. /**
  2882. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2883. * @param array defines the source array
  2884. * @param offset defines the offset in the source array
  2885. * @param result defines the Vector3 where to store the result
  2886. * @deprecated Please use FromArrayToRef instead.
  2887. */
  2888. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2889. /**
  2890. * Sets the given vector "result" with the given floats.
  2891. * @param x defines the x coordinate of the source
  2892. * @param y defines the y coordinate of the source
  2893. * @param z defines the z coordinate of the source
  2894. * @param result defines the Vector3 where to store the result
  2895. */
  2896. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2897. /**
  2898. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2899. * @returns a new empty Vector3
  2900. */
  2901. static Zero(): Vector3;
  2902. /**
  2903. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2904. * @returns a new unit Vector3
  2905. */
  2906. static One(): Vector3;
  2907. /**
  2908. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2909. * @returns a new up Vector3
  2910. */
  2911. static Up(): Vector3;
  2912. /**
  2913. * Gets a up Vector3 that must not be updated
  2914. */
  2915. static get UpReadOnly(): DeepImmutable<Vector3>;
  2916. /**
  2917. * Gets a zero Vector3 that must not be updated
  2918. */
  2919. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2920. /**
  2921. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2922. * @returns a new down Vector3
  2923. */
  2924. static Down(): Vector3;
  2925. /**
  2926. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2927. * @param rightHandedSystem is the scene right-handed (negative z)
  2928. * @returns a new forward Vector3
  2929. */
  2930. static Forward(rightHandedSystem?: boolean): Vector3;
  2931. /**
  2932. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2933. * @param rightHandedSystem is the scene right-handed (negative-z)
  2934. * @returns a new forward Vector3
  2935. */
  2936. static Backward(rightHandedSystem?: boolean): Vector3;
  2937. /**
  2938. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2939. * @returns a new right Vector3
  2940. */
  2941. static Right(): Vector3;
  2942. /**
  2943. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2944. * @returns a new left Vector3
  2945. */
  2946. static Left(): Vector3;
  2947. /**
  2948. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2949. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2950. * @param vector defines the Vector3 to transform
  2951. * @param transformation defines the transformation matrix
  2952. * @returns the transformed Vector3
  2953. */
  2954. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2955. /**
  2956. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2957. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2958. * @param vector defines the Vector3 to transform
  2959. * @param transformation defines the transformation matrix
  2960. * @param result defines the Vector3 where to store the result
  2961. */
  2962. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2963. /**
  2964. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2965. * This method computes tranformed coordinates only, not transformed direction vectors
  2966. * @param x define the x coordinate of the source vector
  2967. * @param y define the y coordinate of the source vector
  2968. * @param z define the z coordinate of the source vector
  2969. * @param transformation defines the transformation matrix
  2970. * @param result defines the Vector3 where to store the result
  2971. */
  2972. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2973. /**
  2974. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2975. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2976. * @param vector defines the Vector3 to transform
  2977. * @param transformation defines the transformation matrix
  2978. * @returns the new Vector3
  2979. */
  2980. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2981. /**
  2982. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2983. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2984. * @param vector defines the Vector3 to transform
  2985. * @param transformation defines the transformation matrix
  2986. * @param result defines the Vector3 where to store the result
  2987. */
  2988. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2989. /**
  2990. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2991. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2992. * @param x define the x coordinate of the source vector
  2993. * @param y define the y coordinate of the source vector
  2994. * @param z define the z coordinate of the source vector
  2995. * @param transformation defines the transformation matrix
  2996. * @param result defines the Vector3 where to store the result
  2997. */
  2998. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2999. /**
  3000. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3001. * @param value1 defines the first control point
  3002. * @param value2 defines the second control point
  3003. * @param value3 defines the third control point
  3004. * @param value4 defines the fourth control point
  3005. * @param amount defines the amount on the spline to use
  3006. * @returns the new Vector3
  3007. */
  3008. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3009. /**
  3010. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3011. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3012. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3013. * @param value defines the current value
  3014. * @param min defines the lower range value
  3015. * @param max defines the upper range value
  3016. * @returns the new Vector3
  3017. */
  3018. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3019. /**
  3020. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3021. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3022. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3023. * @param value defines the current value
  3024. * @param min defines the lower range value
  3025. * @param max defines the upper range value
  3026. * @param result defines the Vector3 where to store the result
  3027. */
  3028. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3029. /**
  3030. * Checks if a given vector is inside a specific range
  3031. * @param v defines the vector to test
  3032. * @param min defines the minimum range
  3033. * @param max defines the maximum range
  3034. */
  3035. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3036. /**
  3037. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3038. * @param value1 defines the first control point
  3039. * @param tangent1 defines the first tangent vector
  3040. * @param value2 defines the second control point
  3041. * @param tangent2 defines the second tangent vector
  3042. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3043. * @returns the new Vector3
  3044. */
  3045. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3046. /**
  3047. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3048. * @param start defines the start value
  3049. * @param end defines the end value
  3050. * @param amount max defines amount between both (between 0 and 1)
  3051. * @returns the new Vector3
  3052. */
  3053. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3054. /**
  3055. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3056. * @param start defines the start value
  3057. * @param end defines the end value
  3058. * @param amount max defines amount between both (between 0 and 1)
  3059. * @param result defines the Vector3 where to store the result
  3060. */
  3061. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3062. /**
  3063. * Returns the dot product (float) between the vectors "left" and "right"
  3064. * @param left defines the left operand
  3065. * @param right defines the right operand
  3066. * @returns the dot product
  3067. */
  3068. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3069. /**
  3070. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3071. * The cross product is then orthogonal to both "left" and "right"
  3072. * @param left defines the left operand
  3073. * @param right defines the right operand
  3074. * @returns the cross product
  3075. */
  3076. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3077. /**
  3078. * Sets the given vector "result" with the cross product of "left" and "right"
  3079. * The cross product is then orthogonal to both "left" and "right"
  3080. * @param left defines the left operand
  3081. * @param right defines the right operand
  3082. * @param result defines the Vector3 where to store the result
  3083. */
  3084. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  3085. /**
  3086. * Returns a new Vector3 as the normalization of the given vector
  3087. * @param vector defines the Vector3 to normalize
  3088. * @returns the new Vector3
  3089. */
  3090. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3091. /**
  3092. * Sets the given vector "result" with the normalization of the given first vector
  3093. * @param vector defines the Vector3 to normalize
  3094. * @param result defines the Vector3 where to store the result
  3095. */
  3096. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3097. /**
  3098. * Project a Vector3 onto screen space
  3099. * @param vector defines the Vector3 to project
  3100. * @param world defines the world matrix to use
  3101. * @param transform defines the transform (view x projection) matrix to use
  3102. * @param viewport defines the screen viewport to use
  3103. * @returns the new Vector3
  3104. */
  3105. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3106. /** @hidden */
  3107. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3108. /**
  3109. * Unproject from screen space to object space
  3110. * @param source defines the screen space Vector3 to use
  3111. * @param viewportWidth defines the current width of the viewport
  3112. * @param viewportHeight defines the current height of the viewport
  3113. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3114. * @param transform defines the transform (view x projection) matrix to use
  3115. * @returns the new Vector3
  3116. */
  3117. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3118. /**
  3119. * Unproject from screen space to object space
  3120. * @param source defines the screen space Vector3 to use
  3121. * @param viewportWidth defines the current width of the viewport
  3122. * @param viewportHeight defines the current height of the viewport
  3123. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3124. * @param view defines the view matrix to use
  3125. * @param projection defines the projection matrix to use
  3126. * @returns the new Vector3
  3127. */
  3128. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3129. /**
  3130. * Unproject from screen space to object space
  3131. * @param source defines the screen space Vector3 to use
  3132. * @param viewportWidth defines the current width of the viewport
  3133. * @param viewportHeight defines the current height of the viewport
  3134. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3135. * @param view defines the view matrix to use
  3136. * @param projection defines the projection matrix to use
  3137. * @param result defines the Vector3 where to store the result
  3138. */
  3139. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3140. /**
  3141. * Unproject from screen space to object space
  3142. * @param sourceX defines the screen space x coordinate to use
  3143. * @param sourceY defines the screen space y coordinate to use
  3144. * @param sourceZ defines the screen space z coordinate to use
  3145. * @param viewportWidth defines the current width of the viewport
  3146. * @param viewportHeight defines the current height of the viewport
  3147. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3148. * @param view defines the view matrix to use
  3149. * @param projection defines the projection matrix to use
  3150. * @param result defines the Vector3 where to store the result
  3151. */
  3152. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3153. /**
  3154. * Gets the minimal coordinate values between two Vector3
  3155. * @param left defines the first operand
  3156. * @param right defines the second operand
  3157. * @returns the new Vector3
  3158. */
  3159. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3160. /**
  3161. * Gets the maximal coordinate values between two Vector3
  3162. * @param left defines the first operand
  3163. * @param right defines the second operand
  3164. * @returns the new Vector3
  3165. */
  3166. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3167. /**
  3168. * Returns the distance between the vectors "value1" and "value2"
  3169. * @param value1 defines the first operand
  3170. * @param value2 defines the second operand
  3171. * @returns the distance
  3172. */
  3173. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3174. /**
  3175. * Returns the squared distance between the vectors "value1" and "value2"
  3176. * @param value1 defines the first operand
  3177. * @param value2 defines the second operand
  3178. * @returns the squared distance
  3179. */
  3180. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3181. /**
  3182. * Returns a new Vector3 located at the center between "value1" and "value2"
  3183. * @param value1 defines the first operand
  3184. * @param value2 defines the second operand
  3185. * @returns the new Vector3
  3186. */
  3187. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3188. /**
  3189. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3190. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3191. * to something in order to rotate it from its local system to the given target system
  3192. * Note: axis1, axis2 and axis3 are normalized during this operation
  3193. * @param axis1 defines the first axis
  3194. * @param axis2 defines the second axis
  3195. * @param axis3 defines the third axis
  3196. * @returns a new Vector3
  3197. */
  3198. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3199. /**
  3200. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3201. * @param axis1 defines the first axis
  3202. * @param axis2 defines the second axis
  3203. * @param axis3 defines the third axis
  3204. * @param ref defines the Vector3 where to store the result
  3205. */
  3206. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3207. }
  3208. /**
  3209. * Vector4 class created for EulerAngle class conversion to Quaternion
  3210. */
  3211. export class Vector4 {
  3212. /** x value of the vector */
  3213. x: number;
  3214. /** y value of the vector */
  3215. y: number;
  3216. /** z value of the vector */
  3217. z: number;
  3218. /** w value of the vector */
  3219. w: number;
  3220. /**
  3221. * Creates a Vector4 object from the given floats.
  3222. * @param x x value of the vector
  3223. * @param y y value of the vector
  3224. * @param z z value of the vector
  3225. * @param w w value of the vector
  3226. */
  3227. constructor(
  3228. /** x value of the vector */
  3229. x: number,
  3230. /** y value of the vector */
  3231. y: number,
  3232. /** z value of the vector */
  3233. z: number,
  3234. /** w value of the vector */
  3235. w: number);
  3236. /**
  3237. * Returns the string with the Vector4 coordinates.
  3238. * @returns a string containing all the vector values
  3239. */
  3240. toString(): string;
  3241. /**
  3242. * Returns the string "Vector4".
  3243. * @returns "Vector4"
  3244. */
  3245. getClassName(): string;
  3246. /**
  3247. * Returns the Vector4 hash code.
  3248. * @returns a unique hash code
  3249. */
  3250. getHashCode(): number;
  3251. /**
  3252. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3253. * @returns the resulting array
  3254. */
  3255. asArray(): number[];
  3256. /**
  3257. * Populates the given array from the given index with the Vector4 coordinates.
  3258. * @param array array to populate
  3259. * @param index index of the array to start at (default: 0)
  3260. * @returns the Vector4.
  3261. */
  3262. toArray(array: FloatArray, index?: number): Vector4;
  3263. /**
  3264. * Adds the given vector to the current Vector4.
  3265. * @param otherVector the vector to add
  3266. * @returns the updated Vector4.
  3267. */
  3268. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3269. /**
  3270. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3271. * @param otherVector the vector to add
  3272. * @returns the resulting vector
  3273. */
  3274. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3275. /**
  3276. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3277. * @param otherVector the vector to add
  3278. * @param result the vector to store the result
  3279. * @returns the current Vector4.
  3280. */
  3281. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3282. /**
  3283. * Subtract in place the given vector from the current Vector4.
  3284. * @param otherVector the vector to subtract
  3285. * @returns the updated Vector4.
  3286. */
  3287. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3288. /**
  3289. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3290. * @param otherVector the vector to add
  3291. * @returns the new vector with the result
  3292. */
  3293. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3294. /**
  3295. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3296. * @param otherVector the vector to subtract
  3297. * @param result the vector to store the result
  3298. * @returns the current Vector4.
  3299. */
  3300. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3301. /**
  3302. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3303. */
  3304. /**
  3305. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3306. * @param x value to subtract
  3307. * @param y value to subtract
  3308. * @param z value to subtract
  3309. * @param w value to subtract
  3310. * @returns new vector containing the result
  3311. */
  3312. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3313. /**
  3314. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3315. * @param x value to subtract
  3316. * @param y value to subtract
  3317. * @param z value to subtract
  3318. * @param w value to subtract
  3319. * @param result the vector to store the result in
  3320. * @returns the current Vector4.
  3321. */
  3322. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3323. /**
  3324. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3325. * @returns a new vector with the negated values
  3326. */
  3327. negate(): Vector4;
  3328. /**
  3329. * Negate this vector in place
  3330. * @returns this
  3331. */
  3332. negateInPlace(): Vector4;
  3333. /**
  3334. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3335. * @param result defines the Vector3 object where to store the result
  3336. * @returns the current Vector4
  3337. */
  3338. negateToRef(result: Vector4): Vector4;
  3339. /**
  3340. * Multiplies the current Vector4 coordinates by scale (float).
  3341. * @param scale the number to scale with
  3342. * @returns the updated Vector4.
  3343. */
  3344. scaleInPlace(scale: number): Vector4;
  3345. /**
  3346. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3347. * @param scale the number to scale with
  3348. * @returns a new vector with the result
  3349. */
  3350. scale(scale: number): Vector4;
  3351. /**
  3352. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3353. * @param scale the number to scale with
  3354. * @param result a vector to store the result in
  3355. * @returns the current Vector4.
  3356. */
  3357. scaleToRef(scale: number, result: Vector4): Vector4;
  3358. /**
  3359. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3360. * @param scale defines the scale factor
  3361. * @param result defines the Vector4 object where to store the result
  3362. * @returns the unmodified current Vector4
  3363. */
  3364. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3365. /**
  3366. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3367. * @param otherVector the vector to compare against
  3368. * @returns true if they are equal
  3369. */
  3370. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3371. /**
  3372. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3373. * @param otherVector vector to compare against
  3374. * @param epsilon (Default: very small number)
  3375. * @returns true if they are equal
  3376. */
  3377. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3378. /**
  3379. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3380. * @param x x value to compare against
  3381. * @param y y value to compare against
  3382. * @param z z value to compare against
  3383. * @param w w value to compare against
  3384. * @returns true if equal
  3385. */
  3386. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3387. /**
  3388. * Multiplies in place the current Vector4 by the given one.
  3389. * @param otherVector vector to multiple with
  3390. * @returns the updated Vector4.
  3391. */
  3392. multiplyInPlace(otherVector: Vector4): Vector4;
  3393. /**
  3394. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3395. * @param otherVector vector to multiple with
  3396. * @returns resulting new vector
  3397. */
  3398. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3399. /**
  3400. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3401. * @param otherVector vector to multiple with
  3402. * @param result vector to store the result
  3403. * @returns the current Vector4.
  3404. */
  3405. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3406. /**
  3407. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3408. * @param x x value multiply with
  3409. * @param y y value multiply with
  3410. * @param z z value multiply with
  3411. * @param w w value multiply with
  3412. * @returns resulting new vector
  3413. */
  3414. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3415. /**
  3416. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3417. * @param otherVector vector to devide with
  3418. * @returns resulting new vector
  3419. */
  3420. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3421. /**
  3422. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3423. * @param otherVector vector to devide with
  3424. * @param result vector to store the result
  3425. * @returns the current Vector4.
  3426. */
  3427. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3428. /**
  3429. * Divides the current Vector3 coordinates by the given ones.
  3430. * @param otherVector vector to devide with
  3431. * @returns the updated Vector3.
  3432. */
  3433. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3434. /**
  3435. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3436. * @param other defines the second operand
  3437. * @returns the current updated Vector4
  3438. */
  3439. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3440. /**
  3441. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3442. * @param other defines the second operand
  3443. * @returns the current updated Vector4
  3444. */
  3445. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3446. /**
  3447. * Gets a new Vector4 from current Vector4 floored values
  3448. * @returns a new Vector4
  3449. */
  3450. floor(): Vector4;
  3451. /**
  3452. * Gets a new Vector4 from current Vector3 floored values
  3453. * @returns a new Vector4
  3454. */
  3455. fract(): Vector4;
  3456. /**
  3457. * Returns the Vector4 length (float).
  3458. * @returns the length
  3459. */
  3460. length(): number;
  3461. /**
  3462. * Returns the Vector4 squared length (float).
  3463. * @returns the length squared
  3464. */
  3465. lengthSquared(): number;
  3466. /**
  3467. * Normalizes in place the Vector4.
  3468. * @returns the updated Vector4.
  3469. */
  3470. normalize(): Vector4;
  3471. /**
  3472. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3473. * @returns this converted to a new vector3
  3474. */
  3475. toVector3(): Vector3;
  3476. /**
  3477. * Returns a new Vector4 copied from the current one.
  3478. * @returns the new cloned vector
  3479. */
  3480. clone(): Vector4;
  3481. /**
  3482. * Updates the current Vector4 with the given one coordinates.
  3483. * @param source the source vector to copy from
  3484. * @returns the updated Vector4.
  3485. */
  3486. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3487. /**
  3488. * Updates the current Vector4 coordinates with the given floats.
  3489. * @param x float to copy from
  3490. * @param y float to copy from
  3491. * @param z float to copy from
  3492. * @param w float to copy from
  3493. * @returns the updated Vector4.
  3494. */
  3495. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3496. /**
  3497. * Updates the current Vector4 coordinates with the given floats.
  3498. * @param x float to set from
  3499. * @param y float to set from
  3500. * @param z float to set from
  3501. * @param w float to set from
  3502. * @returns the updated Vector4.
  3503. */
  3504. set(x: number, y: number, z: number, w: number): Vector4;
  3505. /**
  3506. * Copies the given float to the current Vector3 coordinates
  3507. * @param v defines the x, y, z and w coordinates of the operand
  3508. * @returns the current updated Vector3
  3509. */
  3510. setAll(v: number): Vector4;
  3511. /**
  3512. * Returns a new Vector4 set from the starting index of the given array.
  3513. * @param array the array to pull values from
  3514. * @param offset the offset into the array to start at
  3515. * @returns the new vector
  3516. */
  3517. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3518. /**
  3519. * Updates the given vector "result" from the starting index of the given array.
  3520. * @param array the array to pull values from
  3521. * @param offset the offset into the array to start at
  3522. * @param result the vector to store the result in
  3523. */
  3524. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3525. /**
  3526. * Updates the given vector "result" from the starting index of the given Float32Array.
  3527. * @param array the array to pull values from
  3528. * @param offset the offset into the array to start at
  3529. * @param result the vector to store the result in
  3530. */
  3531. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3532. /**
  3533. * Updates the given vector "result" coordinates from the given floats.
  3534. * @param x float to set from
  3535. * @param y float to set from
  3536. * @param z float to set from
  3537. * @param w float to set from
  3538. * @param result the vector to the floats in
  3539. */
  3540. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3541. /**
  3542. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3543. * @returns the new vector
  3544. */
  3545. static Zero(): Vector4;
  3546. /**
  3547. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3548. * @returns the new vector
  3549. */
  3550. static One(): Vector4;
  3551. /**
  3552. * Returns a new normalized Vector4 from the given one.
  3553. * @param vector the vector to normalize
  3554. * @returns the vector
  3555. */
  3556. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3557. /**
  3558. * Updates the given vector "result" from the normalization of the given one.
  3559. * @param vector the vector to normalize
  3560. * @param result the vector to store the result in
  3561. */
  3562. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3563. /**
  3564. * Returns a vector with the minimum values from the left and right vectors
  3565. * @param left left vector to minimize
  3566. * @param right right vector to minimize
  3567. * @returns a new vector with the minimum of the left and right vector values
  3568. */
  3569. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3570. /**
  3571. * Returns a vector with the maximum values from the left and right vectors
  3572. * @param left left vector to maximize
  3573. * @param right right vector to maximize
  3574. * @returns a new vector with the maximum of the left and right vector values
  3575. */
  3576. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3577. /**
  3578. * Returns the distance (float) between the vectors "value1" and "value2".
  3579. * @param value1 value to calulate the distance between
  3580. * @param value2 value to calulate the distance between
  3581. * @return the distance between the two vectors
  3582. */
  3583. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3584. /**
  3585. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3586. * @param value1 value to calulate the distance between
  3587. * @param value2 value to calulate the distance between
  3588. * @return the distance between the two vectors squared
  3589. */
  3590. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3591. /**
  3592. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3593. * @param value1 value to calulate the center between
  3594. * @param value2 value to calulate the center between
  3595. * @return the center between the two vectors
  3596. */
  3597. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3598. /**
  3599. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3600. * This methods computes transformed normalized direction vectors only.
  3601. * @param vector the vector to transform
  3602. * @param transformation the transformation matrix to apply
  3603. * @returns the new vector
  3604. */
  3605. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3606. /**
  3607. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3608. * This methods computes transformed normalized direction vectors only.
  3609. * @param vector the vector to transform
  3610. * @param transformation the transformation matrix to apply
  3611. * @param result the vector to store the result in
  3612. */
  3613. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3614. /**
  3615. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3616. * This methods computes transformed normalized direction vectors only.
  3617. * @param x value to transform
  3618. * @param y value to transform
  3619. * @param z value to transform
  3620. * @param w value to transform
  3621. * @param transformation the transformation matrix to apply
  3622. * @param result the vector to store the results in
  3623. */
  3624. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3625. /**
  3626. * Creates a new Vector4 from a Vector3
  3627. * @param source defines the source data
  3628. * @param w defines the 4th component (default is 0)
  3629. * @returns a new Vector4
  3630. */
  3631. static FromVector3(source: Vector3, w?: number): Vector4;
  3632. }
  3633. /**
  3634. * Class used to store quaternion data
  3635. * @see https://en.wikipedia.org/wiki/Quaternion
  3636. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3637. */
  3638. export class Quaternion {
  3639. /** defines the first component (0 by default) */
  3640. x: number;
  3641. /** defines the second component (0 by default) */
  3642. y: number;
  3643. /** defines the third component (0 by default) */
  3644. z: number;
  3645. /** defines the fourth component (1.0 by default) */
  3646. w: number;
  3647. /**
  3648. * Creates a new Quaternion from the given floats
  3649. * @param x defines the first component (0 by default)
  3650. * @param y defines the second component (0 by default)
  3651. * @param z defines the third component (0 by default)
  3652. * @param w defines the fourth component (1.0 by default)
  3653. */
  3654. constructor(
  3655. /** defines the first component (0 by default) */
  3656. x?: number,
  3657. /** defines the second component (0 by default) */
  3658. y?: number,
  3659. /** defines the third component (0 by default) */
  3660. z?: number,
  3661. /** defines the fourth component (1.0 by default) */
  3662. w?: number);
  3663. /**
  3664. * Gets a string representation for the current quaternion
  3665. * @returns a string with the Quaternion coordinates
  3666. */
  3667. toString(): string;
  3668. /**
  3669. * Gets the class name of the quaternion
  3670. * @returns the string "Quaternion"
  3671. */
  3672. getClassName(): string;
  3673. /**
  3674. * Gets a hash code for this quaternion
  3675. * @returns the quaternion hash code
  3676. */
  3677. getHashCode(): number;
  3678. /**
  3679. * Copy the quaternion to an array
  3680. * @returns a new array populated with 4 elements from the quaternion coordinates
  3681. */
  3682. asArray(): number[];
  3683. /**
  3684. * Check if two quaternions are equals
  3685. * @param otherQuaternion defines the second operand
  3686. * @return true if the current quaternion and the given one coordinates are strictly equals
  3687. */
  3688. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3689. /**
  3690. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3691. * @param otherQuaternion defines the other quaternion
  3692. * @param epsilon defines the minimal distance to consider equality
  3693. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3694. */
  3695. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3696. /**
  3697. * Clone the current quaternion
  3698. * @returns a new quaternion copied from the current one
  3699. */
  3700. clone(): Quaternion;
  3701. /**
  3702. * Copy a quaternion to the current one
  3703. * @param other defines the other quaternion
  3704. * @returns the updated current quaternion
  3705. */
  3706. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3707. /**
  3708. * Updates the current quaternion with the given float coordinates
  3709. * @param x defines the x coordinate
  3710. * @param y defines the y coordinate
  3711. * @param z defines the z coordinate
  3712. * @param w defines the w coordinate
  3713. * @returns the updated current quaternion
  3714. */
  3715. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3716. /**
  3717. * Updates the current quaternion from the given float coordinates
  3718. * @param x defines the x coordinate
  3719. * @param y defines the y coordinate
  3720. * @param z defines the z coordinate
  3721. * @param w defines the w coordinate
  3722. * @returns the updated current quaternion
  3723. */
  3724. set(x: number, y: number, z: number, w: number): Quaternion;
  3725. /**
  3726. * Adds two quaternions
  3727. * @param other defines the second operand
  3728. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3729. */
  3730. add(other: DeepImmutable<Quaternion>): Quaternion;
  3731. /**
  3732. * Add a quaternion to the current one
  3733. * @param other defines the quaternion to add
  3734. * @returns the current quaternion
  3735. */
  3736. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3737. /**
  3738. * Subtract two quaternions
  3739. * @param other defines the second operand
  3740. * @returns a new quaternion as the subtraction result of the given one from the current one
  3741. */
  3742. subtract(other: Quaternion): Quaternion;
  3743. /**
  3744. * Multiplies the current quaternion by a scale factor
  3745. * @param value defines the scale factor
  3746. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3747. */
  3748. scale(value: number): Quaternion;
  3749. /**
  3750. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3751. * @param scale defines the scale factor
  3752. * @param result defines the Quaternion object where to store the result
  3753. * @returns the unmodified current quaternion
  3754. */
  3755. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3756. /**
  3757. * Multiplies in place the current quaternion by a scale factor
  3758. * @param value defines the scale factor
  3759. * @returns the current modified quaternion
  3760. */
  3761. scaleInPlace(value: number): Quaternion;
  3762. /**
  3763. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3764. * @param scale defines the scale factor
  3765. * @param result defines the Quaternion object where to store the result
  3766. * @returns the unmodified current quaternion
  3767. */
  3768. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3769. /**
  3770. * Multiplies two quaternions
  3771. * @param q1 defines the second operand
  3772. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3773. */
  3774. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3775. /**
  3776. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3777. * @param q1 defines the second operand
  3778. * @param result defines the target quaternion
  3779. * @returns the current quaternion
  3780. */
  3781. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3782. /**
  3783. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3784. * @param q1 defines the second operand
  3785. * @returns the currentupdated quaternion
  3786. */
  3787. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3788. /**
  3789. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3790. * @param ref defines the target quaternion
  3791. * @returns the current quaternion
  3792. */
  3793. conjugateToRef(ref: Quaternion): Quaternion;
  3794. /**
  3795. * Conjugates in place (1-q) the current quaternion
  3796. * @returns the current updated quaternion
  3797. */
  3798. conjugateInPlace(): Quaternion;
  3799. /**
  3800. * Conjugates in place (1-q) the current quaternion
  3801. * @returns a new quaternion
  3802. */
  3803. conjugate(): Quaternion;
  3804. /**
  3805. * Gets length of current quaternion
  3806. * @returns the quaternion length (float)
  3807. */
  3808. length(): number;
  3809. /**
  3810. * Normalize in place the current quaternion
  3811. * @returns the current updated quaternion
  3812. */
  3813. normalize(): Quaternion;
  3814. /**
  3815. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3816. * @param order is a reserved parameter and is ignore for now
  3817. * @returns a new Vector3 containing the Euler angles
  3818. */
  3819. toEulerAngles(order?: string): Vector3;
  3820. /**
  3821. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3822. * @param result defines the vector which will be filled with the Euler angles
  3823. * @param order is a reserved parameter and is ignore for now
  3824. * @returns the current unchanged quaternion
  3825. */
  3826. toEulerAnglesToRef(result: Vector3): Quaternion;
  3827. /**
  3828. * Updates the given rotation matrix with the current quaternion values
  3829. * @param result defines the target matrix
  3830. * @returns the current unchanged quaternion
  3831. */
  3832. toRotationMatrix(result: Matrix): Quaternion;
  3833. /**
  3834. * Updates the current quaternion from the given rotation matrix values
  3835. * @param matrix defines the source matrix
  3836. * @returns the current updated quaternion
  3837. */
  3838. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3839. /**
  3840. * Creates a new quaternion from a rotation matrix
  3841. * @param matrix defines the source matrix
  3842. * @returns a new quaternion created from the given rotation matrix values
  3843. */
  3844. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3845. /**
  3846. * Updates the given quaternion with the given rotation matrix values
  3847. * @param matrix defines the source matrix
  3848. * @param result defines the target quaternion
  3849. */
  3850. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3851. /**
  3852. * Returns the dot product (float) between the quaternions "left" and "right"
  3853. * @param left defines the left operand
  3854. * @param right defines the right operand
  3855. * @returns the dot product
  3856. */
  3857. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3858. /**
  3859. * Checks if the two quaternions are close to each other
  3860. * @param quat0 defines the first quaternion to check
  3861. * @param quat1 defines the second quaternion to check
  3862. * @returns true if the two quaternions are close to each other
  3863. */
  3864. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3865. /**
  3866. * Creates an empty quaternion
  3867. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3868. */
  3869. static Zero(): Quaternion;
  3870. /**
  3871. * Inverse a given quaternion
  3872. * @param q defines the source quaternion
  3873. * @returns a new quaternion as the inverted current quaternion
  3874. */
  3875. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3876. /**
  3877. * Inverse a given quaternion
  3878. * @param q defines the source quaternion
  3879. * @param result the quaternion the result will be stored in
  3880. * @returns the result quaternion
  3881. */
  3882. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3883. /**
  3884. * Creates an identity quaternion
  3885. * @returns the identity quaternion
  3886. */
  3887. static Identity(): Quaternion;
  3888. /**
  3889. * Gets a boolean indicating if the given quaternion is identity
  3890. * @param quaternion defines the quaternion to check
  3891. * @returns true if the quaternion is identity
  3892. */
  3893. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3894. /**
  3895. * Creates a quaternion from a rotation around an axis
  3896. * @param axis defines the axis to use
  3897. * @param angle defines the angle to use
  3898. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3899. */
  3900. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3901. /**
  3902. * Creates a rotation around an axis and stores it into the given quaternion
  3903. * @param axis defines the axis to use
  3904. * @param angle defines the angle to use
  3905. * @param result defines the target quaternion
  3906. * @returns the target quaternion
  3907. */
  3908. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3909. /**
  3910. * Creates a new quaternion from data stored into an array
  3911. * @param array defines the data source
  3912. * @param offset defines the offset in the source array where the data starts
  3913. * @returns a new quaternion
  3914. */
  3915. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3916. /**
  3917. * Updates the given quaternion "result" from the starting index of the given array.
  3918. * @param array the array to pull values from
  3919. * @param offset the offset into the array to start at
  3920. * @param result the quaternion to store the result in
  3921. */
  3922. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3923. /**
  3924. * Create a quaternion from Euler rotation angles
  3925. * @param x Pitch
  3926. * @param y Yaw
  3927. * @param z Roll
  3928. * @returns the new Quaternion
  3929. */
  3930. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3931. /**
  3932. * Updates a quaternion from Euler rotation angles
  3933. * @param x Pitch
  3934. * @param y Yaw
  3935. * @param z Roll
  3936. * @param result the quaternion to store the result
  3937. * @returns the updated quaternion
  3938. */
  3939. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3940. /**
  3941. * Create a quaternion from Euler rotation vector
  3942. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3943. * @returns the new Quaternion
  3944. */
  3945. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3946. /**
  3947. * Updates a quaternion from Euler rotation vector
  3948. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3949. * @param result the quaternion to store the result
  3950. * @returns the updated quaternion
  3951. */
  3952. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3953. /**
  3954. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3955. * @param yaw defines the rotation around Y axis
  3956. * @param pitch defines the rotation around X axis
  3957. * @param roll defines the rotation around Z axis
  3958. * @returns the new quaternion
  3959. */
  3960. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3961. /**
  3962. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3963. * @param yaw defines the rotation around Y axis
  3964. * @param pitch defines the rotation around X axis
  3965. * @param roll defines the rotation around Z axis
  3966. * @param result defines the target quaternion
  3967. */
  3968. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3971. * @param alpha defines the rotation around first axis
  3972. * @param beta defines the rotation around second axis
  3973. * @param gamma defines the rotation around third axis
  3974. * @returns the new quaternion
  3975. */
  3976. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3977. /**
  3978. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3979. * @param alpha defines the rotation around first axis
  3980. * @param beta defines the rotation around second axis
  3981. * @param gamma defines the rotation around third axis
  3982. * @param result defines the target quaternion
  3983. */
  3984. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3985. /**
  3986. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3987. * @param axis1 defines the first axis
  3988. * @param axis2 defines the second axis
  3989. * @param axis3 defines the third axis
  3990. * @returns the new quaternion
  3991. */
  3992. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3993. /**
  3994. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3995. * @param axis1 defines the first axis
  3996. * @param axis2 defines the second axis
  3997. * @param axis3 defines the third axis
  3998. * @param ref defines the target quaternion
  3999. */
  4000. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4001. /**
  4002. * Interpolates between two quaternions
  4003. * @param left defines first quaternion
  4004. * @param right defines second quaternion
  4005. * @param amount defines the gradient to use
  4006. * @returns the new interpolated quaternion
  4007. */
  4008. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4009. /**
  4010. * Interpolates between two quaternions and stores it into a target quaternion
  4011. * @param left defines first quaternion
  4012. * @param right defines second quaternion
  4013. * @param amount defines the gradient to use
  4014. * @param result defines the target quaternion
  4015. */
  4016. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4017. /**
  4018. * Interpolate between two quaternions using Hermite interpolation
  4019. * @param value1 defines first quaternion
  4020. * @param tangent1 defines the incoming tangent
  4021. * @param value2 defines second quaternion
  4022. * @param tangent2 defines the outgoing tangent
  4023. * @param amount defines the target quaternion
  4024. * @returns the new interpolated quaternion
  4025. */
  4026. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4027. }
  4028. /**
  4029. * Class used to store matrix data (4x4)
  4030. */
  4031. export class Matrix {
  4032. private static _updateFlagSeed;
  4033. private static _identityReadOnly;
  4034. private _isIdentity;
  4035. private _isIdentityDirty;
  4036. private _isIdentity3x2;
  4037. private _isIdentity3x2Dirty;
  4038. /**
  4039. * Gets the update flag of the matrix which is an unique number for the matrix.
  4040. * It will be incremented every time the matrix data change.
  4041. * You can use it to speed the comparison between two versions of the same matrix.
  4042. */
  4043. updateFlag: number;
  4044. private readonly _m;
  4045. /**
  4046. * Gets the internal data of the matrix
  4047. */
  4048. get m(): DeepImmutable<Float32Array>;
  4049. /** @hidden */
  4050. _markAsUpdated(): void;
  4051. /** @hidden */
  4052. private _updateIdentityStatus;
  4053. /**
  4054. * Creates an empty matrix (filled with zeros)
  4055. */
  4056. constructor();
  4057. /**
  4058. * Check if the current matrix is identity
  4059. * @returns true is the matrix is the identity matrix
  4060. */
  4061. isIdentity(): boolean;
  4062. /**
  4063. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4064. * @returns true is the matrix is the identity matrix
  4065. */
  4066. isIdentityAs3x2(): boolean;
  4067. /**
  4068. * Gets the determinant of the matrix
  4069. * @returns the matrix determinant
  4070. */
  4071. determinant(): number;
  4072. /**
  4073. * Returns the matrix as a Float32Array
  4074. * @returns the matrix underlying array
  4075. */
  4076. toArray(): DeepImmutable<Float32Array>;
  4077. /**
  4078. * Returns the matrix as a Float32Array
  4079. * @returns the matrix underlying array.
  4080. */
  4081. asArray(): DeepImmutable<Float32Array>;
  4082. /**
  4083. * Inverts the current matrix in place
  4084. * @returns the current inverted matrix
  4085. */
  4086. invert(): Matrix;
  4087. /**
  4088. * Sets all the matrix elements to zero
  4089. * @returns the current matrix
  4090. */
  4091. reset(): Matrix;
  4092. /**
  4093. * Adds the current matrix with a second one
  4094. * @param other defines the matrix to add
  4095. * @returns a new matrix as the addition of the current matrix and the given one
  4096. */
  4097. add(other: DeepImmutable<Matrix>): Matrix;
  4098. /**
  4099. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4100. * @param other defines the matrix to add
  4101. * @param result defines the target matrix
  4102. * @returns the current matrix
  4103. */
  4104. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4105. /**
  4106. * Adds in place the given matrix to the current matrix
  4107. * @param other defines the second operand
  4108. * @returns the current updated matrix
  4109. */
  4110. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4111. /**
  4112. * Sets the given matrix to the current inverted Matrix
  4113. * @param other defines the target matrix
  4114. * @returns the unmodified current matrix
  4115. */
  4116. invertToRef(other: Matrix): Matrix;
  4117. /**
  4118. * add a value at the specified position in the current Matrix
  4119. * @param index the index of the value within the matrix. between 0 and 15.
  4120. * @param value the value to be added
  4121. * @returns the current updated matrix
  4122. */
  4123. addAtIndex(index: number, value: number): Matrix;
  4124. /**
  4125. * mutiply the specified position in the current Matrix by a value
  4126. * @param index the index of the value within the matrix. between 0 and 15.
  4127. * @param value the value to be added
  4128. * @returns the current updated matrix
  4129. */
  4130. multiplyAtIndex(index: number, value: number): Matrix;
  4131. /**
  4132. * Inserts the translation vector (using 3 floats) in the current matrix
  4133. * @param x defines the 1st component of the translation
  4134. * @param y defines the 2nd component of the translation
  4135. * @param z defines the 3rd component of the translation
  4136. * @returns the current updated matrix
  4137. */
  4138. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4139. /**
  4140. * Adds the translation vector (using 3 floats) in the current matrix
  4141. * @param x defines the 1st component of the translation
  4142. * @param y defines the 2nd component of the translation
  4143. * @param z defines the 3rd component of the translation
  4144. * @returns the current updated matrix
  4145. */
  4146. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4147. /**
  4148. * Inserts the translation vector in the current matrix
  4149. * @param vector3 defines the translation to insert
  4150. * @returns the current updated matrix
  4151. */
  4152. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4153. /**
  4154. * Gets the translation value of the current matrix
  4155. * @returns a new Vector3 as the extracted translation from the matrix
  4156. */
  4157. getTranslation(): Vector3;
  4158. /**
  4159. * Fill a Vector3 with the extracted translation from the matrix
  4160. * @param result defines the Vector3 where to store the translation
  4161. * @returns the current matrix
  4162. */
  4163. getTranslationToRef(result: Vector3): Matrix;
  4164. /**
  4165. * Remove rotation and scaling part from the matrix
  4166. * @returns the updated matrix
  4167. */
  4168. removeRotationAndScaling(): Matrix;
  4169. /**
  4170. * Multiply two matrices
  4171. * @param other defines the second operand
  4172. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4173. */
  4174. multiply(other: DeepImmutable<Matrix>): Matrix;
  4175. /**
  4176. * Copy the current matrix from the given one
  4177. * @param other defines the source matrix
  4178. * @returns the current updated matrix
  4179. */
  4180. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4181. /**
  4182. * Populates the given array from the starting index with the current matrix values
  4183. * @param array defines the target array
  4184. * @param offset defines the offset in the target array where to start storing values
  4185. * @returns the current matrix
  4186. */
  4187. copyToArray(array: Float32Array, offset?: number): Matrix;
  4188. /**
  4189. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4190. * @param other defines the second operand
  4191. * @param result defines the matrix where to store the multiplication
  4192. * @returns the current matrix
  4193. */
  4194. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4195. /**
  4196. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4197. * @param other defines the second operand
  4198. * @param result defines the array where to store the multiplication
  4199. * @param offset defines the offset in the target array where to start storing values
  4200. * @returns the current matrix
  4201. */
  4202. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4203. /**
  4204. * Check equality between this matrix and a second one
  4205. * @param value defines the second matrix to compare
  4206. * @returns true is the current matrix and the given one values are strictly equal
  4207. */
  4208. equals(value: DeepImmutable<Matrix>): boolean;
  4209. /**
  4210. * Clone the current matrix
  4211. * @returns a new matrix from the current matrix
  4212. */
  4213. clone(): Matrix;
  4214. /**
  4215. * Returns the name of the current matrix class
  4216. * @returns the string "Matrix"
  4217. */
  4218. getClassName(): string;
  4219. /**
  4220. * Gets the hash code of the current matrix
  4221. * @returns the hash code
  4222. */
  4223. getHashCode(): number;
  4224. /**
  4225. * Decomposes the current Matrix into a translation, rotation and scaling components
  4226. * @param scale defines the scale vector3 given as a reference to update
  4227. * @param rotation defines the rotation quaternion given as a reference to update
  4228. * @param translation defines the translation vector3 given as a reference to update
  4229. * @returns true if operation was successful
  4230. */
  4231. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4232. /**
  4233. * Gets specific row of the matrix
  4234. * @param index defines the number of the row to get
  4235. * @returns the index-th row of the current matrix as a new Vector4
  4236. */
  4237. getRow(index: number): Nullable<Vector4>;
  4238. /**
  4239. * Sets the index-th row of the current matrix to the vector4 values
  4240. * @param index defines the number of the row to set
  4241. * @param row defines the target vector4
  4242. * @returns the updated current matrix
  4243. */
  4244. setRow(index: number, row: Vector4): Matrix;
  4245. /**
  4246. * Compute the transpose of the matrix
  4247. * @returns the new transposed matrix
  4248. */
  4249. transpose(): Matrix;
  4250. /**
  4251. * Compute the transpose of the matrix and store it in a given matrix
  4252. * @param result defines the target matrix
  4253. * @returns the current matrix
  4254. */
  4255. transposeToRef(result: Matrix): Matrix;
  4256. /**
  4257. * Sets the index-th row of the current matrix with the given 4 x float values
  4258. * @param index defines the row index
  4259. * @param x defines the x component to set
  4260. * @param y defines the y component to set
  4261. * @param z defines the z component to set
  4262. * @param w defines the w component to set
  4263. * @returns the updated current matrix
  4264. */
  4265. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4266. /**
  4267. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4268. * @param scale defines the scale factor
  4269. * @returns a new matrix
  4270. */
  4271. scale(scale: number): Matrix;
  4272. /**
  4273. * Scale the current matrix values by a factor to a given result matrix
  4274. * @param scale defines the scale factor
  4275. * @param result defines the matrix to store the result
  4276. * @returns the current matrix
  4277. */
  4278. scaleToRef(scale: number, result: Matrix): Matrix;
  4279. /**
  4280. * Scale the current matrix values by a factor and add the result to a given matrix
  4281. * @param scale defines the scale factor
  4282. * @param result defines the Matrix to store the result
  4283. * @returns the current matrix
  4284. */
  4285. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4286. /**
  4287. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4288. * @param ref matrix to store the result
  4289. */
  4290. toNormalMatrix(ref: Matrix): void;
  4291. /**
  4292. * Gets only rotation part of the current matrix
  4293. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4294. */
  4295. getRotationMatrix(): Matrix;
  4296. /**
  4297. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4298. * @param result defines the target matrix to store data to
  4299. * @returns the current matrix
  4300. */
  4301. getRotationMatrixToRef(result: Matrix): Matrix;
  4302. /**
  4303. * Toggles model matrix from being right handed to left handed in place and vice versa
  4304. */
  4305. toggleModelMatrixHandInPlace(): void;
  4306. /**
  4307. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4308. */
  4309. toggleProjectionMatrixHandInPlace(): void;
  4310. /**
  4311. * Creates a matrix from an array
  4312. * @param array defines the source array
  4313. * @param offset defines an offset in the source array
  4314. * @returns a new Matrix set from the starting index of the given array
  4315. */
  4316. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4317. /**
  4318. * Copy the content of an array into a given matrix
  4319. * @param array defines the source array
  4320. * @param offset defines an offset in the source array
  4321. * @param result defines the target matrix
  4322. */
  4323. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4324. /**
  4325. * Stores an array into a matrix after having multiplied each component by a given factor
  4326. * @param array defines the source array
  4327. * @param offset defines the offset in the source array
  4328. * @param scale defines the scaling factor
  4329. * @param result defines the target matrix
  4330. */
  4331. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4332. /**
  4333. * Gets an identity matrix that must not be updated
  4334. */
  4335. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4336. /**
  4337. * Stores a list of values (16) inside a given matrix
  4338. * @param initialM11 defines 1st value of 1st row
  4339. * @param initialM12 defines 2nd value of 1st row
  4340. * @param initialM13 defines 3rd value of 1st row
  4341. * @param initialM14 defines 4th value of 1st row
  4342. * @param initialM21 defines 1st value of 2nd row
  4343. * @param initialM22 defines 2nd value of 2nd row
  4344. * @param initialM23 defines 3rd value of 2nd row
  4345. * @param initialM24 defines 4th value of 2nd row
  4346. * @param initialM31 defines 1st value of 3rd row
  4347. * @param initialM32 defines 2nd value of 3rd row
  4348. * @param initialM33 defines 3rd value of 3rd row
  4349. * @param initialM34 defines 4th value of 3rd row
  4350. * @param initialM41 defines 1st value of 4th row
  4351. * @param initialM42 defines 2nd value of 4th row
  4352. * @param initialM43 defines 3rd value of 4th row
  4353. * @param initialM44 defines 4th value of 4th row
  4354. * @param result defines the target matrix
  4355. */
  4356. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4357. /**
  4358. * Creates new matrix from a list of values (16)
  4359. * @param initialM11 defines 1st value of 1st row
  4360. * @param initialM12 defines 2nd value of 1st row
  4361. * @param initialM13 defines 3rd value of 1st row
  4362. * @param initialM14 defines 4th value of 1st row
  4363. * @param initialM21 defines 1st value of 2nd row
  4364. * @param initialM22 defines 2nd value of 2nd row
  4365. * @param initialM23 defines 3rd value of 2nd row
  4366. * @param initialM24 defines 4th value of 2nd row
  4367. * @param initialM31 defines 1st value of 3rd row
  4368. * @param initialM32 defines 2nd value of 3rd row
  4369. * @param initialM33 defines 3rd value of 3rd row
  4370. * @param initialM34 defines 4th value of 3rd row
  4371. * @param initialM41 defines 1st value of 4th row
  4372. * @param initialM42 defines 2nd value of 4th row
  4373. * @param initialM43 defines 3rd value of 4th row
  4374. * @param initialM44 defines 4th value of 4th row
  4375. * @returns the new matrix
  4376. */
  4377. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4378. /**
  4379. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4380. * @param scale defines the scale vector3
  4381. * @param rotation defines the rotation quaternion
  4382. * @param translation defines the translation vector3
  4383. * @returns a new matrix
  4384. */
  4385. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4386. /**
  4387. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4388. * @param scale defines the scale vector3
  4389. * @param rotation defines the rotation quaternion
  4390. * @param translation defines the translation vector3
  4391. * @param result defines the target matrix
  4392. */
  4393. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4394. /**
  4395. * Creates a new identity matrix
  4396. * @returns a new identity matrix
  4397. */
  4398. static Identity(): Matrix;
  4399. /**
  4400. * Creates a new identity matrix and stores the result in a given matrix
  4401. * @param result defines the target matrix
  4402. */
  4403. static IdentityToRef(result: Matrix): void;
  4404. /**
  4405. * Creates a new zero matrix
  4406. * @returns a new zero matrix
  4407. */
  4408. static Zero(): Matrix;
  4409. /**
  4410. * Creates a new rotation matrix for "angle" radians around the X axis
  4411. * @param angle defines the angle (in radians) to use
  4412. * @return the new matrix
  4413. */
  4414. static RotationX(angle: number): Matrix;
  4415. /**
  4416. * Creates a new matrix as the invert of a given matrix
  4417. * @param source defines the source matrix
  4418. * @returns the new matrix
  4419. */
  4420. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4421. /**
  4422. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4423. * @param angle defines the angle (in radians) to use
  4424. * @param result defines the target matrix
  4425. */
  4426. static RotationXToRef(angle: number, result: Matrix): void;
  4427. /**
  4428. * Creates a new rotation matrix for "angle" radians around the Y axis
  4429. * @param angle defines the angle (in radians) to use
  4430. * @return the new matrix
  4431. */
  4432. static RotationY(angle: number): Matrix;
  4433. /**
  4434. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4435. * @param angle defines the angle (in radians) to use
  4436. * @param result defines the target matrix
  4437. */
  4438. static RotationYToRef(angle: number, result: Matrix): void;
  4439. /**
  4440. * Creates a new rotation matrix for "angle" radians around the Z axis
  4441. * @param angle defines the angle (in radians) to use
  4442. * @return the new matrix
  4443. */
  4444. static RotationZ(angle: number): Matrix;
  4445. /**
  4446. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4447. * @param angle defines the angle (in radians) to use
  4448. * @param result defines the target matrix
  4449. */
  4450. static RotationZToRef(angle: number, result: Matrix): void;
  4451. /**
  4452. * Creates a new rotation matrix for "angle" radians around the given axis
  4453. * @param axis defines the axis to use
  4454. * @param angle defines the angle (in radians) to use
  4455. * @return the new matrix
  4456. */
  4457. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4458. /**
  4459. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4460. * @param axis defines the axis to use
  4461. * @param angle defines the angle (in radians) to use
  4462. * @param result defines the target matrix
  4463. */
  4464. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4465. /**
  4466. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4467. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4468. * @param from defines the vector to align
  4469. * @param to defines the vector to align to
  4470. * @param result defines the target matrix
  4471. */
  4472. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4473. /**
  4474. * Creates a rotation matrix
  4475. * @param yaw defines the yaw angle in radians (Y axis)
  4476. * @param pitch defines the pitch angle in radians (X axis)
  4477. * @param roll defines the roll angle in radians (X axis)
  4478. * @returns the new rotation matrix
  4479. */
  4480. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4481. /**
  4482. * Creates a rotation matrix and stores it in a given matrix
  4483. * @param yaw defines the yaw angle in radians (Y axis)
  4484. * @param pitch defines the pitch angle in radians (X axis)
  4485. * @param roll defines the roll angle in radians (X axis)
  4486. * @param result defines the target matrix
  4487. */
  4488. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4489. /**
  4490. * Creates a scaling matrix
  4491. * @param x defines the scale factor on X axis
  4492. * @param y defines the scale factor on Y axis
  4493. * @param z defines the scale factor on Z axis
  4494. * @returns the new matrix
  4495. */
  4496. static Scaling(x: number, y: number, z: number): Matrix;
  4497. /**
  4498. * Creates a scaling matrix and stores it in a given matrix
  4499. * @param x defines the scale factor on X axis
  4500. * @param y defines the scale factor on Y axis
  4501. * @param z defines the scale factor on Z axis
  4502. * @param result defines the target matrix
  4503. */
  4504. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4505. /**
  4506. * Creates a translation matrix
  4507. * @param x defines the translation on X axis
  4508. * @param y defines the translation on Y axis
  4509. * @param z defines the translationon Z axis
  4510. * @returns the new matrix
  4511. */
  4512. static Translation(x: number, y: number, z: number): Matrix;
  4513. /**
  4514. * Creates a translation matrix and stores it in a given matrix
  4515. * @param x defines the translation on X axis
  4516. * @param y defines the translation on Y axis
  4517. * @param z defines the translationon Z axis
  4518. * @param result defines the target matrix
  4519. */
  4520. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4521. /**
  4522. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4523. * @param startValue defines the start value
  4524. * @param endValue defines the end value
  4525. * @param gradient defines the gradient factor
  4526. * @returns the new matrix
  4527. */
  4528. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4529. /**
  4530. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4531. * @param startValue defines the start value
  4532. * @param endValue defines the end value
  4533. * @param gradient defines the gradient factor
  4534. * @param result defines the Matrix object where to store data
  4535. */
  4536. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4537. /**
  4538. * Builds a new matrix whose values are computed by:
  4539. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4540. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4541. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4542. * @param startValue defines the first matrix
  4543. * @param endValue defines the second matrix
  4544. * @param gradient defines the gradient between the two matrices
  4545. * @returns the new matrix
  4546. */
  4547. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4548. /**
  4549. * Update a matrix to values which are computed by:
  4550. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4551. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4552. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4553. * @param startValue defines the first matrix
  4554. * @param endValue defines the second matrix
  4555. * @param gradient defines the gradient between the two matrices
  4556. * @param result defines the target matrix
  4557. */
  4558. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4559. /**
  4560. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4561. * This function works in left handed mode
  4562. * @param eye defines the final position of the entity
  4563. * @param target defines where the entity should look at
  4564. * @param up defines the up vector for the entity
  4565. * @returns the new matrix
  4566. */
  4567. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4568. /**
  4569. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4570. * This function works in left handed mode
  4571. * @param eye defines the final position of the entity
  4572. * @param target defines where the entity should look at
  4573. * @param up defines the up vector for the entity
  4574. * @param result defines the target matrix
  4575. */
  4576. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4577. /**
  4578. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4579. * This function works in right handed mode
  4580. * @param eye defines the final position of the entity
  4581. * @param target defines where the entity should look at
  4582. * @param up defines the up vector for the entity
  4583. * @returns the new matrix
  4584. */
  4585. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4586. /**
  4587. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4588. * This function works in right handed mode
  4589. * @param eye defines the final position of the entity
  4590. * @param target defines where the entity should look at
  4591. * @param up defines the up vector for the entity
  4592. * @param result defines the target matrix
  4593. */
  4594. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4595. /**
  4596. * Create a left-handed orthographic projection matrix
  4597. * @param width defines the viewport width
  4598. * @param height defines the viewport height
  4599. * @param znear defines the near clip plane
  4600. * @param zfar defines the far clip plane
  4601. * @returns a new matrix as a left-handed orthographic projection matrix
  4602. */
  4603. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4604. /**
  4605. * Store a left-handed orthographic projection to a given matrix
  4606. * @param width defines the viewport width
  4607. * @param height defines the viewport height
  4608. * @param znear defines the near clip plane
  4609. * @param zfar defines the far clip plane
  4610. * @param result defines the target matrix
  4611. */
  4612. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4613. /**
  4614. * Create a left-handed orthographic projection matrix
  4615. * @param left defines the viewport left coordinate
  4616. * @param right defines the viewport right coordinate
  4617. * @param bottom defines the viewport bottom coordinate
  4618. * @param top defines the viewport top coordinate
  4619. * @param znear defines the near clip plane
  4620. * @param zfar defines the far clip plane
  4621. * @returns a new matrix as a left-handed orthographic projection matrix
  4622. */
  4623. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4624. /**
  4625. * Stores a left-handed orthographic projection into a given matrix
  4626. * @param left defines the viewport left coordinate
  4627. * @param right defines the viewport right coordinate
  4628. * @param bottom defines the viewport bottom coordinate
  4629. * @param top defines the viewport top coordinate
  4630. * @param znear defines the near clip plane
  4631. * @param zfar defines the far clip plane
  4632. * @param result defines the target matrix
  4633. */
  4634. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4635. /**
  4636. * Creates a right-handed orthographic projection matrix
  4637. * @param left defines the viewport left coordinate
  4638. * @param right defines the viewport right coordinate
  4639. * @param bottom defines the viewport bottom coordinate
  4640. * @param top defines the viewport top coordinate
  4641. * @param znear defines the near clip plane
  4642. * @param zfar defines the far clip plane
  4643. * @returns a new matrix as a right-handed orthographic projection matrix
  4644. */
  4645. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4646. /**
  4647. * Stores a right-handed orthographic projection into a given matrix
  4648. * @param left defines the viewport left coordinate
  4649. * @param right defines the viewport right coordinate
  4650. * @param bottom defines the viewport bottom coordinate
  4651. * @param top defines the viewport top coordinate
  4652. * @param znear defines the near clip plane
  4653. * @param zfar defines the far clip plane
  4654. * @param result defines the target matrix
  4655. */
  4656. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4657. /**
  4658. * Creates a left-handed perspective projection matrix
  4659. * @param width defines the viewport width
  4660. * @param height defines the viewport height
  4661. * @param znear defines the near clip plane
  4662. * @param zfar defines the far clip plane
  4663. * @returns a new matrix as a left-handed perspective projection matrix
  4664. */
  4665. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4666. /**
  4667. * Creates a left-handed perspective projection matrix
  4668. * @param fov defines the horizontal field of view
  4669. * @param aspect defines the aspect ratio
  4670. * @param znear defines the near clip plane
  4671. * @param zfar defines the far clip plane
  4672. * @returns a new matrix as a left-handed perspective projection matrix
  4673. */
  4674. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4675. /**
  4676. * Stores a left-handed perspective projection into a given matrix
  4677. * @param fov defines the horizontal field of view
  4678. * @param aspect defines the aspect ratio
  4679. * @param znear defines the near clip plane
  4680. * @param zfar defines the far clip plane
  4681. * @param result defines the target matrix
  4682. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4683. */
  4684. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4685. /**
  4686. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4687. * @param fov defines the horizontal field of view
  4688. * @param aspect defines the aspect ratio
  4689. * @param znear defines the near clip plane
  4690. * @param zfar not used as infinity is used as far clip
  4691. * @param result defines the target matrix
  4692. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4693. */
  4694. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4695. /**
  4696. * Creates a right-handed perspective projection matrix
  4697. * @param fov defines the horizontal field of view
  4698. * @param aspect defines the aspect ratio
  4699. * @param znear defines the near clip plane
  4700. * @param zfar defines the far clip plane
  4701. * @returns a new matrix as a right-handed perspective projection matrix
  4702. */
  4703. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4704. /**
  4705. * Stores a right-handed perspective projection into a given matrix
  4706. * @param fov defines the horizontal field of view
  4707. * @param aspect defines the aspect ratio
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @param result defines the target matrix
  4711. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4712. */
  4713. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4714. /**
  4715. * Stores a right-handed perspective projection into a given matrix
  4716. * @param fov defines the horizontal field of view
  4717. * @param aspect defines the aspect ratio
  4718. * @param znear defines the near clip plane
  4719. * @param zfar not used as infinity is used as far clip
  4720. * @param result defines the target matrix
  4721. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4722. */
  4723. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4724. /**
  4725. * Stores a perspective projection for WebVR info a given matrix
  4726. * @param fov defines the field of view
  4727. * @param znear defines the near clip plane
  4728. * @param zfar defines the far clip plane
  4729. * @param result defines the target matrix
  4730. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4731. */
  4732. static PerspectiveFovWebVRToRef(fov: {
  4733. upDegrees: number;
  4734. downDegrees: number;
  4735. leftDegrees: number;
  4736. rightDegrees: number;
  4737. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4738. /**
  4739. * Computes a complete transformation matrix
  4740. * @param viewport defines the viewport to use
  4741. * @param world defines the world matrix
  4742. * @param view defines the view matrix
  4743. * @param projection defines the projection matrix
  4744. * @param zmin defines the near clip plane
  4745. * @param zmax defines the far clip plane
  4746. * @returns the transformation matrix
  4747. */
  4748. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4749. /**
  4750. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4751. * @param matrix defines the matrix to use
  4752. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4753. */
  4754. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4755. /**
  4756. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4757. * @param matrix defines the matrix to use
  4758. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4759. */
  4760. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4761. /**
  4762. * Compute the transpose of a given matrix
  4763. * @param matrix defines the matrix to transpose
  4764. * @returns the new matrix
  4765. */
  4766. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4767. /**
  4768. * Compute the transpose of a matrix and store it in a target matrix
  4769. * @param matrix defines the matrix to transpose
  4770. * @param result defines the target matrix
  4771. */
  4772. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4773. /**
  4774. * Computes a reflection matrix from a plane
  4775. * @param plane defines the reflection plane
  4776. * @returns a new matrix
  4777. */
  4778. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4779. /**
  4780. * Computes a reflection matrix from a plane
  4781. * @param plane defines the reflection plane
  4782. * @param result defines the target matrix
  4783. */
  4784. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4785. /**
  4786. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4787. * @param xaxis defines the value of the 1st axis
  4788. * @param yaxis defines the value of the 2nd axis
  4789. * @param zaxis defines the value of the 3rd axis
  4790. * @param result defines the target matrix
  4791. */
  4792. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4793. /**
  4794. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4795. * @param quat defines the quaternion to use
  4796. * @param result defines the target matrix
  4797. */
  4798. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4799. }
  4800. /**
  4801. * @hidden
  4802. */
  4803. export class TmpVectors {
  4804. static Vector2: Vector2[];
  4805. static Vector3: Vector3[];
  4806. static Vector4: Vector4[];
  4807. static Quaternion: Quaternion[];
  4808. static Matrix: Matrix[];
  4809. }
  4810. }
  4811. declare module "babylonjs/Maths/math.path" {
  4812. import { DeepImmutable, Nullable } from "babylonjs/types";
  4813. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4814. /**
  4815. * Defines potential orientation for back face culling
  4816. */
  4817. export enum Orientation {
  4818. /**
  4819. * Clockwise
  4820. */
  4821. CW = 0,
  4822. /** Counter clockwise */
  4823. CCW = 1
  4824. }
  4825. /** Class used to represent a Bezier curve */
  4826. export class BezierCurve {
  4827. /**
  4828. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4829. * @param t defines the time
  4830. * @param x1 defines the left coordinate on X axis
  4831. * @param y1 defines the left coordinate on Y axis
  4832. * @param x2 defines the right coordinate on X axis
  4833. * @param y2 defines the right coordinate on Y axis
  4834. * @returns the interpolated value
  4835. */
  4836. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4837. }
  4838. /**
  4839. * Defines angle representation
  4840. */
  4841. export class Angle {
  4842. private _radians;
  4843. /**
  4844. * Creates an Angle object of "radians" radians (float).
  4845. * @param radians the angle in radians
  4846. */
  4847. constructor(radians: number);
  4848. /**
  4849. * Get value in degrees
  4850. * @returns the Angle value in degrees (float)
  4851. */
  4852. degrees(): number;
  4853. /**
  4854. * Get value in radians
  4855. * @returns the Angle value in radians (float)
  4856. */
  4857. radians(): number;
  4858. /**
  4859. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4860. * @param a defines first vector
  4861. * @param b defines second vector
  4862. * @returns a new Angle
  4863. */
  4864. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4865. /**
  4866. * Gets a new Angle object from the given float in radians
  4867. * @param radians defines the angle value in radians
  4868. * @returns a new Angle
  4869. */
  4870. static FromRadians(radians: number): Angle;
  4871. /**
  4872. * Gets a new Angle object from the given float in degrees
  4873. * @param degrees defines the angle value in degrees
  4874. * @returns a new Angle
  4875. */
  4876. static FromDegrees(degrees: number): Angle;
  4877. }
  4878. /**
  4879. * This represents an arc in a 2d space.
  4880. */
  4881. export class Arc2 {
  4882. /** Defines the start point of the arc */
  4883. startPoint: Vector2;
  4884. /** Defines the mid point of the arc */
  4885. midPoint: Vector2;
  4886. /** Defines the end point of the arc */
  4887. endPoint: Vector2;
  4888. /**
  4889. * Defines the center point of the arc.
  4890. */
  4891. centerPoint: Vector2;
  4892. /**
  4893. * Defines the radius of the arc.
  4894. */
  4895. radius: number;
  4896. /**
  4897. * Defines the angle of the arc (from mid point to end point).
  4898. */
  4899. angle: Angle;
  4900. /**
  4901. * Defines the start angle of the arc (from start point to middle point).
  4902. */
  4903. startAngle: Angle;
  4904. /**
  4905. * Defines the orientation of the arc (clock wise/counter clock wise).
  4906. */
  4907. orientation: Orientation;
  4908. /**
  4909. * Creates an Arc object from the three given points : start, middle and end.
  4910. * @param startPoint Defines the start point of the arc
  4911. * @param midPoint Defines the midlle point of the arc
  4912. * @param endPoint Defines the end point of the arc
  4913. */
  4914. constructor(
  4915. /** Defines the start point of the arc */
  4916. startPoint: Vector2,
  4917. /** Defines the mid point of the arc */
  4918. midPoint: Vector2,
  4919. /** Defines the end point of the arc */
  4920. endPoint: Vector2);
  4921. }
  4922. /**
  4923. * Represents a 2D path made up of multiple 2D points
  4924. */
  4925. export class Path2 {
  4926. private _points;
  4927. private _length;
  4928. /**
  4929. * If the path start and end point are the same
  4930. */
  4931. closed: boolean;
  4932. /**
  4933. * Creates a Path2 object from the starting 2D coordinates x and y.
  4934. * @param x the starting points x value
  4935. * @param y the starting points y value
  4936. */
  4937. constructor(x: number, y: number);
  4938. /**
  4939. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4940. * @param x the added points x value
  4941. * @param y the added points y value
  4942. * @returns the updated Path2.
  4943. */
  4944. addLineTo(x: number, y: number): Path2;
  4945. /**
  4946. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4947. * @param midX middle point x value
  4948. * @param midY middle point y value
  4949. * @param endX end point x value
  4950. * @param endY end point y value
  4951. * @param numberOfSegments (default: 36)
  4952. * @returns the updated Path2.
  4953. */
  4954. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4955. /**
  4956. * Closes the Path2.
  4957. * @returns the Path2.
  4958. */
  4959. close(): Path2;
  4960. /**
  4961. * Gets the sum of the distance between each sequential point in the path
  4962. * @returns the Path2 total length (float).
  4963. */
  4964. length(): number;
  4965. /**
  4966. * Gets the points which construct the path
  4967. * @returns the Path2 internal array of points.
  4968. */
  4969. getPoints(): Vector2[];
  4970. /**
  4971. * Retreives the point at the distance aways from the starting point
  4972. * @param normalizedLengthPosition the length along the path to retreive the point from
  4973. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4974. */
  4975. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4976. /**
  4977. * Creates a new path starting from an x and y position
  4978. * @param x starting x value
  4979. * @param y starting y value
  4980. * @returns a new Path2 starting at the coordinates (x, y).
  4981. */
  4982. static StartingAt(x: number, y: number): Path2;
  4983. }
  4984. /**
  4985. * Represents a 3D path made up of multiple 3D points
  4986. */
  4987. export class Path3D {
  4988. /**
  4989. * an array of Vector3, the curve axis of the Path3D
  4990. */
  4991. path: Vector3[];
  4992. private _curve;
  4993. private _distances;
  4994. private _tangents;
  4995. private _normals;
  4996. private _binormals;
  4997. private _raw;
  4998. private _alignTangentsWithPath;
  4999. private readonly _pointAtData;
  5000. /**
  5001. * new Path3D(path, normal, raw)
  5002. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5003. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5004. * @param path an array of Vector3, the curve axis of the Path3D
  5005. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5006. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5007. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5008. */
  5009. constructor(
  5010. /**
  5011. * an array of Vector3, the curve axis of the Path3D
  5012. */
  5013. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5014. /**
  5015. * Returns the Path3D array of successive Vector3 designing its curve.
  5016. * @returns the Path3D array of successive Vector3 designing its curve.
  5017. */
  5018. getCurve(): Vector3[];
  5019. /**
  5020. * Returns the Path3D array of successive Vector3 designing its curve.
  5021. * @returns the Path3D array of successive Vector3 designing its curve.
  5022. */
  5023. getPoints(): Vector3[];
  5024. /**
  5025. * @returns the computed length (float) of the path.
  5026. */
  5027. length(): number;
  5028. /**
  5029. * Returns an array populated with tangent vectors on each Path3D curve point.
  5030. * @returns an array populated with tangent vectors on each Path3D curve point.
  5031. */
  5032. getTangents(): Vector3[];
  5033. /**
  5034. * Returns an array populated with normal vectors on each Path3D curve point.
  5035. * @returns an array populated with normal vectors on each Path3D curve point.
  5036. */
  5037. getNormals(): Vector3[];
  5038. /**
  5039. * Returns an array populated with binormal vectors on each Path3D curve point.
  5040. * @returns an array populated with binormal vectors on each Path3D curve point.
  5041. */
  5042. getBinormals(): Vector3[];
  5043. /**
  5044. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5045. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5046. */
  5047. getDistances(): number[];
  5048. /**
  5049. * Returns an interpolated point along this path
  5050. * @param position the position of the point along this path, from 0.0 to 1.0
  5051. * @returns a new Vector3 as the point
  5052. */
  5053. getPointAt(position: number): Vector3;
  5054. /**
  5055. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5056. * @param position the position of the point along this path, from 0.0 to 1.0
  5057. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5058. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5059. */
  5060. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5061. /**
  5062. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5063. * @param position the position of the point along this path, from 0.0 to 1.0
  5064. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5065. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5066. */
  5067. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5068. /**
  5069. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5070. * @param position the position of the point along this path, from 0.0 to 1.0
  5071. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5072. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5073. */
  5074. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5075. /**
  5076. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5077. * @param position the position of the point along this path, from 0.0 to 1.0
  5078. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5079. */
  5080. getDistanceAt(position: number): number;
  5081. /**
  5082. * Returns the array index of the previous point of an interpolated point along this path
  5083. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5084. * @returns the array index
  5085. */
  5086. getPreviousPointIndexAt(position: number): number;
  5087. /**
  5088. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5089. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5090. * @returns the sub position
  5091. */
  5092. getSubPositionAt(position: number): number;
  5093. /**
  5094. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5095. * @param target the vector of which to get the closest position to
  5096. * @returns the position of the closest virtual point on this path to the target vector
  5097. */
  5098. getClosestPositionTo(target: Vector3): number;
  5099. /**
  5100. * Returns a sub path (slice) of this path
  5101. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5102. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5103. * @returns a sub path (slice) of this path
  5104. */
  5105. slice(start?: number, end?: number): Path3D;
  5106. /**
  5107. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5108. * @param path path which all values are copied into the curves points
  5109. * @param firstNormal which should be projected onto the curve
  5110. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5111. * @returns the same object updated.
  5112. */
  5113. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5114. private _compute;
  5115. private _getFirstNonNullVector;
  5116. private _getLastNonNullVector;
  5117. private _normalVector;
  5118. /**
  5119. * Updates the point at data for an interpolated point along this curve
  5120. * @param position the position of the point along this curve, from 0.0 to 1.0
  5121. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5122. * @returns the (updated) point at data
  5123. */
  5124. private _updatePointAtData;
  5125. /**
  5126. * Updates the point at data from the specified parameters
  5127. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5128. * @param point the interpolated point
  5129. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5130. */
  5131. private _setPointAtData;
  5132. /**
  5133. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5134. */
  5135. private _updateInterpolationMatrix;
  5136. }
  5137. /**
  5138. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5139. * A Curve3 is designed from a series of successive Vector3.
  5140. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5141. */
  5142. export class Curve3 {
  5143. private _points;
  5144. private _length;
  5145. /**
  5146. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5147. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5148. * @param v1 (Vector3) the control point
  5149. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5150. * @param nbPoints (integer) the wanted number of points in the curve
  5151. * @returns the created Curve3
  5152. */
  5153. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5154. /**
  5155. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5156. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5157. * @param v1 (Vector3) the first control point
  5158. * @param v2 (Vector3) the second control point
  5159. * @param v3 (Vector3) the end point of the Cubic Bezier
  5160. * @param nbPoints (integer) the wanted number of points in the curve
  5161. * @returns the created Curve3
  5162. */
  5163. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5164. /**
  5165. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5166. * @param p1 (Vector3) the origin point of the Hermite Spline
  5167. * @param t1 (Vector3) the tangent vector at the origin point
  5168. * @param p2 (Vector3) the end point of the Hermite Spline
  5169. * @param t2 (Vector3) the tangent vector at the end point
  5170. * @param nbPoints (integer) the wanted number of points in the curve
  5171. * @returns the created Curve3
  5172. */
  5173. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5174. /**
  5175. * Returns a Curve3 object along a CatmullRom Spline curve :
  5176. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5177. * @param nbPoints (integer) the wanted number of points between each curve control points
  5178. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5179. * @returns the created Curve3
  5180. */
  5181. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5182. /**
  5183. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5184. * A Curve3 is designed from a series of successive Vector3.
  5185. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5186. * @param points points which make up the curve
  5187. */
  5188. constructor(points: Vector3[]);
  5189. /**
  5190. * @returns the Curve3 stored array of successive Vector3
  5191. */
  5192. getPoints(): Vector3[];
  5193. /**
  5194. * @returns the computed length (float) of the curve.
  5195. */
  5196. length(): number;
  5197. /**
  5198. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5199. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5200. * curveA and curveB keep unchanged.
  5201. * @param curve the curve to continue from this curve
  5202. * @returns the newly constructed curve
  5203. */
  5204. continue(curve: DeepImmutable<Curve3>): Curve3;
  5205. private _computeLength;
  5206. }
  5207. }
  5208. declare module "babylonjs/Animations/easing" {
  5209. /**
  5210. * This represents the main contract an easing function should follow.
  5211. * Easing functions are used throughout the animation system.
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export interface IEasingFunction {
  5215. /**
  5216. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5217. * of the easing function.
  5218. * The link below provides some of the most common examples of easing functions.
  5219. * @see https://easings.net/
  5220. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5221. * @returns the corresponding value on the curve defined by the easing function
  5222. */
  5223. ease(gradient: number): number;
  5224. }
  5225. /**
  5226. * Base class used for every default easing function.
  5227. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5228. */
  5229. export class EasingFunction implements IEasingFunction {
  5230. /**
  5231. * Interpolation follows the mathematical formula associated with the easing function.
  5232. */
  5233. static readonly EASINGMODE_EASEIN: number;
  5234. /**
  5235. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5236. */
  5237. static readonly EASINGMODE_EASEOUT: number;
  5238. /**
  5239. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5240. */
  5241. static readonly EASINGMODE_EASEINOUT: number;
  5242. private _easingMode;
  5243. /**
  5244. * Sets the easing mode of the current function.
  5245. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5246. */
  5247. setEasingMode(easingMode: number): void;
  5248. /**
  5249. * Gets the current easing mode.
  5250. * @returns the easing mode
  5251. */
  5252. getEasingMode(): number;
  5253. /**
  5254. * @hidden
  5255. */
  5256. easeInCore(gradient: number): number;
  5257. /**
  5258. * Given an input gradient between 0 and 1, this returns the corresponding value
  5259. * of the easing function.
  5260. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5261. * @returns the corresponding value on the curve defined by the easing function
  5262. */
  5263. ease(gradient: number): number;
  5264. }
  5265. /**
  5266. * Easing function with a circle shape (see link below).
  5267. * @see https://easings.net/#easeInCirc
  5268. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5269. */
  5270. export class CircleEase extends EasingFunction implements IEasingFunction {
  5271. /** @hidden */
  5272. easeInCore(gradient: number): number;
  5273. }
  5274. /**
  5275. * Easing function with a ease back shape (see link below).
  5276. * @see https://easings.net/#easeInBack
  5277. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5278. */
  5279. export class BackEase extends EasingFunction implements IEasingFunction {
  5280. /** Defines the amplitude of the function */
  5281. amplitude: number;
  5282. /**
  5283. * Instantiates a back ease easing
  5284. * @see https://easings.net/#easeInBack
  5285. * @param amplitude Defines the amplitude of the function
  5286. */
  5287. constructor(
  5288. /** Defines the amplitude of the function */
  5289. amplitude?: number);
  5290. /** @hidden */
  5291. easeInCore(gradient: number): number;
  5292. }
  5293. /**
  5294. * Easing function with a bouncing shape (see link below).
  5295. * @see https://easings.net/#easeInBounce
  5296. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5297. */
  5298. export class BounceEase extends EasingFunction implements IEasingFunction {
  5299. /** Defines the number of bounces */
  5300. bounces: number;
  5301. /** Defines the amplitude of the bounce */
  5302. bounciness: number;
  5303. /**
  5304. * Instantiates a bounce easing
  5305. * @see https://easings.net/#easeInBounce
  5306. * @param bounces Defines the number of bounces
  5307. * @param bounciness Defines the amplitude of the bounce
  5308. */
  5309. constructor(
  5310. /** Defines the number of bounces */
  5311. bounces?: number,
  5312. /** Defines the amplitude of the bounce */
  5313. bounciness?: number);
  5314. /** @hidden */
  5315. easeInCore(gradient: number): number;
  5316. }
  5317. /**
  5318. * Easing function with a power of 3 shape (see link below).
  5319. * @see https://easings.net/#easeInCubic
  5320. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5321. */
  5322. export class CubicEase extends EasingFunction implements IEasingFunction {
  5323. /** @hidden */
  5324. easeInCore(gradient: number): number;
  5325. }
  5326. /**
  5327. * Easing function with an elastic shape (see link below).
  5328. * @see https://easings.net/#easeInElastic
  5329. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5330. */
  5331. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5332. /** Defines the number of oscillations*/
  5333. oscillations: number;
  5334. /** Defines the amplitude of the oscillations*/
  5335. springiness: number;
  5336. /**
  5337. * Instantiates an elastic easing function
  5338. * @see https://easings.net/#easeInElastic
  5339. * @param oscillations Defines the number of oscillations
  5340. * @param springiness Defines the amplitude of the oscillations
  5341. */
  5342. constructor(
  5343. /** Defines the number of oscillations*/
  5344. oscillations?: number,
  5345. /** Defines the amplitude of the oscillations*/
  5346. springiness?: number);
  5347. /** @hidden */
  5348. easeInCore(gradient: number): number;
  5349. }
  5350. /**
  5351. * Easing function with an exponential shape (see link below).
  5352. * @see https://easings.net/#easeInExpo
  5353. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5354. */
  5355. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5356. /** Defines the exponent of the function */
  5357. exponent: number;
  5358. /**
  5359. * Instantiates an exponential easing function
  5360. * @see https://easings.net/#easeInExpo
  5361. * @param exponent Defines the exponent of the function
  5362. */
  5363. constructor(
  5364. /** Defines the exponent of the function */
  5365. exponent?: number);
  5366. /** @hidden */
  5367. easeInCore(gradient: number): number;
  5368. }
  5369. /**
  5370. * Easing function with a power shape (see link below).
  5371. * @see https://easings.net/#easeInQuad
  5372. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5373. */
  5374. export class PowerEase extends EasingFunction implements IEasingFunction {
  5375. /** Defines the power of the function */
  5376. power: number;
  5377. /**
  5378. * Instantiates an power base easing function
  5379. * @see https://easings.net/#easeInQuad
  5380. * @param power Defines the power of the function
  5381. */
  5382. constructor(
  5383. /** Defines the power of the function */
  5384. power?: number);
  5385. /** @hidden */
  5386. easeInCore(gradient: number): number;
  5387. }
  5388. /**
  5389. * Easing function with a power of 2 shape (see link below).
  5390. * @see https://easings.net/#easeInQuad
  5391. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5392. */
  5393. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5394. /** @hidden */
  5395. easeInCore(gradient: number): number;
  5396. }
  5397. /**
  5398. * Easing function with a power of 4 shape (see link below).
  5399. * @see https://easings.net/#easeInQuart
  5400. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5401. */
  5402. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with a power of 5 shape (see link below).
  5408. * @see https://easings.net/#easeInQuint
  5409. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a sin shape (see link below).
  5417. * @see https://easings.net/#easeInSine
  5418. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class SineEase extends EasingFunction implements IEasingFunction {
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with a bezier shape (see link below).
  5426. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5427. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5430. /** Defines the x component of the start tangent in the bezier curve */
  5431. x1: number;
  5432. /** Defines the y component of the start tangent in the bezier curve */
  5433. y1: number;
  5434. /** Defines the x component of the end tangent in the bezier curve */
  5435. x2: number;
  5436. /** Defines the y component of the end tangent in the bezier curve */
  5437. y2: number;
  5438. /**
  5439. * Instantiates a bezier function
  5440. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5441. * @param x1 Defines the x component of the start tangent in the bezier curve
  5442. * @param y1 Defines the y component of the start tangent in the bezier curve
  5443. * @param x2 Defines the x component of the end tangent in the bezier curve
  5444. * @param y2 Defines the y component of the end tangent in the bezier curve
  5445. */
  5446. constructor(
  5447. /** Defines the x component of the start tangent in the bezier curve */
  5448. x1?: number,
  5449. /** Defines the y component of the start tangent in the bezier curve */
  5450. y1?: number,
  5451. /** Defines the x component of the end tangent in the bezier curve */
  5452. x2?: number,
  5453. /** Defines the y component of the end tangent in the bezier curve */
  5454. y2?: number);
  5455. /** @hidden */
  5456. easeInCore(gradient: number): number;
  5457. }
  5458. }
  5459. declare module "babylonjs/Maths/math.color" {
  5460. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5461. /**
  5462. * Class used to hold a RBG color
  5463. */
  5464. export class Color3 {
  5465. /**
  5466. * Defines the red component (between 0 and 1, default is 0)
  5467. */
  5468. r: number;
  5469. /**
  5470. * Defines the green component (between 0 and 1, default is 0)
  5471. */
  5472. g: number;
  5473. /**
  5474. * Defines the blue component (between 0 and 1, default is 0)
  5475. */
  5476. b: number;
  5477. /**
  5478. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5479. * @param r defines the red component (between 0 and 1, default is 0)
  5480. * @param g defines the green component (between 0 and 1, default is 0)
  5481. * @param b defines the blue component (between 0 and 1, default is 0)
  5482. */
  5483. constructor(
  5484. /**
  5485. * Defines the red component (between 0 and 1, default is 0)
  5486. */
  5487. r?: number,
  5488. /**
  5489. * Defines the green component (between 0 and 1, default is 0)
  5490. */
  5491. g?: number,
  5492. /**
  5493. * Defines the blue component (between 0 and 1, default is 0)
  5494. */
  5495. b?: number);
  5496. /**
  5497. * Creates a string with the Color3 current values
  5498. * @returns the string representation of the Color3 object
  5499. */
  5500. toString(): string;
  5501. /**
  5502. * Returns the string "Color3"
  5503. * @returns "Color3"
  5504. */
  5505. getClassName(): string;
  5506. /**
  5507. * Compute the Color3 hash code
  5508. * @returns an unique number that can be used to hash Color3 objects
  5509. */
  5510. getHashCode(): number;
  5511. /**
  5512. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5513. * @param array defines the array where to store the r,g,b components
  5514. * @param index defines an optional index in the target array to define where to start storing values
  5515. * @returns the current Color3 object
  5516. */
  5517. toArray(array: FloatArray, index?: number): Color3;
  5518. /**
  5519. * Returns a new Color4 object from the current Color3 and the given alpha
  5520. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5521. * @returns a new Color4 object
  5522. */
  5523. toColor4(alpha?: number): Color4;
  5524. /**
  5525. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5526. * @returns the new array
  5527. */
  5528. asArray(): number[];
  5529. /**
  5530. * Returns the luminance value
  5531. * @returns a float value
  5532. */
  5533. toLuminance(): number;
  5534. /**
  5535. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5536. * @param otherColor defines the second operand
  5537. * @returns the new Color3 object
  5538. */
  5539. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5540. /**
  5541. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5542. * @param otherColor defines the second operand
  5543. * @param result defines the Color3 object where to store the result
  5544. * @returns the current Color3
  5545. */
  5546. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5547. /**
  5548. * Determines equality between Color3 objects
  5549. * @param otherColor defines the second operand
  5550. * @returns true if the rgb values are equal to the given ones
  5551. */
  5552. equals(otherColor: DeepImmutable<Color3>): boolean;
  5553. /**
  5554. * Determines equality between the current Color3 object and a set of r,b,g values
  5555. * @param r defines the red component to check
  5556. * @param g defines the green component to check
  5557. * @param b defines the blue component to check
  5558. * @returns true if the rgb values are equal to the given ones
  5559. */
  5560. equalsFloats(r: number, g: number, b: number): boolean;
  5561. /**
  5562. * Multiplies in place each rgb value by scale
  5563. * @param scale defines the scaling factor
  5564. * @returns the updated Color3
  5565. */
  5566. scale(scale: number): Color3;
  5567. /**
  5568. * Multiplies the rgb values by scale and stores the result into "result"
  5569. * @param scale defines the scaling factor
  5570. * @param result defines the Color3 object where to store the result
  5571. * @returns the unmodified current Color3
  5572. */
  5573. scaleToRef(scale: number, result: Color3): Color3;
  5574. /**
  5575. * Scale the current Color3 values by a factor and add the result to a given Color3
  5576. * @param scale defines the scale factor
  5577. * @param result defines color to store the result into
  5578. * @returns the unmodified current Color3
  5579. */
  5580. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5581. /**
  5582. * Clamps the rgb values by the min and max values and stores the result into "result"
  5583. * @param min defines minimum clamping value (default is 0)
  5584. * @param max defines maximum clamping value (default is 1)
  5585. * @param result defines color to store the result into
  5586. * @returns the original Color3
  5587. */
  5588. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5589. /**
  5590. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5591. * @param otherColor defines the second operand
  5592. * @returns the new Color3
  5593. */
  5594. add(otherColor: DeepImmutable<Color3>): Color3;
  5595. /**
  5596. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5597. * @param otherColor defines the second operand
  5598. * @param result defines Color3 object to store the result into
  5599. * @returns the unmodified current Color3
  5600. */
  5601. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5602. /**
  5603. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5604. * @param otherColor defines the second operand
  5605. * @returns the new Color3
  5606. */
  5607. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5608. /**
  5609. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5610. * @param otherColor defines the second operand
  5611. * @param result defines Color3 object to store the result into
  5612. * @returns the unmodified current Color3
  5613. */
  5614. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5615. /**
  5616. * Copy the current object
  5617. * @returns a new Color3 copied the current one
  5618. */
  5619. clone(): Color3;
  5620. /**
  5621. * Copies the rgb values from the source in the current Color3
  5622. * @param source defines the source Color3 object
  5623. * @returns the updated Color3 object
  5624. */
  5625. copyFrom(source: DeepImmutable<Color3>): Color3;
  5626. /**
  5627. * Updates the Color3 rgb values from the given floats
  5628. * @param r defines the red component to read from
  5629. * @param g defines the green component to read from
  5630. * @param b defines the blue component to read from
  5631. * @returns the current Color3 object
  5632. */
  5633. copyFromFloats(r: number, g: number, b: number): Color3;
  5634. /**
  5635. * Updates the Color3 rgb values from the given floats
  5636. * @param r defines the red component to read from
  5637. * @param g defines the green component to read from
  5638. * @param b defines the blue component to read from
  5639. * @returns the current Color3 object
  5640. */
  5641. set(r: number, g: number, b: number): Color3;
  5642. /**
  5643. * Compute the Color3 hexadecimal code as a string
  5644. * @returns a string containing the hexadecimal representation of the Color3 object
  5645. */
  5646. toHexString(): string;
  5647. /**
  5648. * Computes a new Color3 converted from the current one to linear space
  5649. * @returns a new Color3 object
  5650. */
  5651. toLinearSpace(): Color3;
  5652. /**
  5653. * Converts current color in rgb space to HSV values
  5654. * @returns a new color3 representing the HSV values
  5655. */
  5656. toHSV(): Color3;
  5657. /**
  5658. * Converts current color in rgb space to HSV values
  5659. * @param result defines the Color3 where to store the HSV values
  5660. */
  5661. toHSVToRef(result: Color3): void;
  5662. /**
  5663. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5664. * @param convertedColor defines the Color3 object where to store the linear space version
  5665. * @returns the unmodified Color3
  5666. */
  5667. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5668. /**
  5669. * Computes a new Color3 converted from the current one to gamma space
  5670. * @returns a new Color3 object
  5671. */
  5672. toGammaSpace(): Color3;
  5673. /**
  5674. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5675. * @param convertedColor defines the Color3 object where to store the gamma space version
  5676. * @returns the unmodified Color3
  5677. */
  5678. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5679. private static _BlackReadOnly;
  5680. /**
  5681. * Convert Hue, saturation and value to a Color3 (RGB)
  5682. * @param hue defines the hue
  5683. * @param saturation defines the saturation
  5684. * @param value defines the value
  5685. * @param result defines the Color3 where to store the RGB values
  5686. */
  5687. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5688. /**
  5689. * Creates a new Color3 from the string containing valid hexadecimal values
  5690. * @param hex defines a string containing valid hexadecimal values
  5691. * @returns a new Color3 object
  5692. */
  5693. static FromHexString(hex: string): Color3;
  5694. /**
  5695. * Creates a new Color3 from the starting index of the given array
  5696. * @param array defines the source array
  5697. * @param offset defines an offset in the source array
  5698. * @returns a new Color3 object
  5699. */
  5700. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5701. /**
  5702. * Creates a new Color3 from integer values (< 256)
  5703. * @param r defines the red component to read from (value between 0 and 255)
  5704. * @param g defines the green component to read from (value between 0 and 255)
  5705. * @param b defines the blue component to read from (value between 0 and 255)
  5706. * @returns a new Color3 object
  5707. */
  5708. static FromInts(r: number, g: number, b: number): Color3;
  5709. /**
  5710. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5711. * @param start defines the start Color3 value
  5712. * @param end defines the end Color3 value
  5713. * @param amount defines the gradient value between start and end
  5714. * @returns a new Color3 object
  5715. */
  5716. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5717. /**
  5718. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5719. * @param left defines the start value
  5720. * @param right defines the end value
  5721. * @param amount defines the gradient factor
  5722. * @param result defines the Color3 object where to store the result
  5723. */
  5724. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5725. /**
  5726. * Returns a Color3 value containing a red color
  5727. * @returns a new Color3 object
  5728. */
  5729. static Red(): Color3;
  5730. /**
  5731. * Returns a Color3 value containing a green color
  5732. * @returns a new Color3 object
  5733. */
  5734. static Green(): Color3;
  5735. /**
  5736. * Returns a Color3 value containing a blue color
  5737. * @returns a new Color3 object
  5738. */
  5739. static Blue(): Color3;
  5740. /**
  5741. * Returns a Color3 value containing a black color
  5742. * @returns a new Color3 object
  5743. */
  5744. static Black(): Color3;
  5745. /**
  5746. * Gets a Color3 value containing a black color that must not be updated
  5747. */
  5748. static get BlackReadOnly(): DeepImmutable<Color3>;
  5749. /**
  5750. * Returns a Color3 value containing a white color
  5751. * @returns a new Color3 object
  5752. */
  5753. static White(): Color3;
  5754. /**
  5755. * Returns a Color3 value containing a purple color
  5756. * @returns a new Color3 object
  5757. */
  5758. static Purple(): Color3;
  5759. /**
  5760. * Returns a Color3 value containing a magenta color
  5761. * @returns a new Color3 object
  5762. */
  5763. static Magenta(): Color3;
  5764. /**
  5765. * Returns a Color3 value containing a yellow color
  5766. * @returns a new Color3 object
  5767. */
  5768. static Yellow(): Color3;
  5769. /**
  5770. * Returns a Color3 value containing a gray color
  5771. * @returns a new Color3 object
  5772. */
  5773. static Gray(): Color3;
  5774. /**
  5775. * Returns a Color3 value containing a teal color
  5776. * @returns a new Color3 object
  5777. */
  5778. static Teal(): Color3;
  5779. /**
  5780. * Returns a Color3 value containing a random color
  5781. * @returns a new Color3 object
  5782. */
  5783. static Random(): Color3;
  5784. }
  5785. /**
  5786. * Class used to hold a RBGA color
  5787. */
  5788. export class Color4 {
  5789. /**
  5790. * Defines the red component (between 0 and 1, default is 0)
  5791. */
  5792. r: number;
  5793. /**
  5794. * Defines the green component (between 0 and 1, default is 0)
  5795. */
  5796. g: number;
  5797. /**
  5798. * Defines the blue component (between 0 and 1, default is 0)
  5799. */
  5800. b: number;
  5801. /**
  5802. * Defines the alpha component (between 0 and 1, default is 1)
  5803. */
  5804. a: number;
  5805. /**
  5806. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5807. * @param r defines the red component (between 0 and 1, default is 0)
  5808. * @param g defines the green component (between 0 and 1, default is 0)
  5809. * @param b defines the blue component (between 0 and 1, default is 0)
  5810. * @param a defines the alpha component (between 0 and 1, default is 1)
  5811. */
  5812. constructor(
  5813. /**
  5814. * Defines the red component (between 0 and 1, default is 0)
  5815. */
  5816. r?: number,
  5817. /**
  5818. * Defines the green component (between 0 and 1, default is 0)
  5819. */
  5820. g?: number,
  5821. /**
  5822. * Defines the blue component (between 0 and 1, default is 0)
  5823. */
  5824. b?: number,
  5825. /**
  5826. * Defines the alpha component (between 0 and 1, default is 1)
  5827. */
  5828. a?: number);
  5829. /**
  5830. * Adds in place the given Color4 values to the current Color4 object
  5831. * @param right defines the second operand
  5832. * @returns the current updated Color4 object
  5833. */
  5834. addInPlace(right: DeepImmutable<Color4>): Color4;
  5835. /**
  5836. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5837. * @returns the new array
  5838. */
  5839. asArray(): number[];
  5840. /**
  5841. * Stores from the starting index in the given array the Color4 successive values
  5842. * @param array defines the array where to store the r,g,b components
  5843. * @param index defines an optional index in the target array to define where to start storing values
  5844. * @returns the current Color4 object
  5845. */
  5846. toArray(array: number[], index?: number): Color4;
  5847. /**
  5848. * Determines equality between Color4 objects
  5849. * @param otherColor defines the second operand
  5850. * @returns true if the rgba values are equal to the given ones
  5851. */
  5852. equals(otherColor: DeepImmutable<Color4>): boolean;
  5853. /**
  5854. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5855. * @param right defines the second operand
  5856. * @returns a new Color4 object
  5857. */
  5858. add(right: DeepImmutable<Color4>): Color4;
  5859. /**
  5860. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5861. * @param right defines the second operand
  5862. * @returns a new Color4 object
  5863. */
  5864. subtract(right: DeepImmutable<Color4>): Color4;
  5865. /**
  5866. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5867. * @param right defines the second operand
  5868. * @param result defines the Color4 object where to store the result
  5869. * @returns the current Color4 object
  5870. */
  5871. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5872. /**
  5873. * Creates a new Color4 with the current Color4 values multiplied by scale
  5874. * @param scale defines the scaling factor to apply
  5875. * @returns a new Color4 object
  5876. */
  5877. scale(scale: number): Color4;
  5878. /**
  5879. * Multiplies the current Color4 values by scale and stores the result in "result"
  5880. * @param scale defines the scaling factor to apply
  5881. * @param result defines the Color4 object where to store the result
  5882. * @returns the current unmodified Color4
  5883. */
  5884. scaleToRef(scale: number, result: Color4): Color4;
  5885. /**
  5886. * Scale the current Color4 values by a factor and add the result to a given Color4
  5887. * @param scale defines the scale factor
  5888. * @param result defines the Color4 object where to store the result
  5889. * @returns the unmodified current Color4
  5890. */
  5891. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5892. /**
  5893. * Clamps the rgb values by the min and max values and stores the result into "result"
  5894. * @param min defines minimum clamping value (default is 0)
  5895. * @param max defines maximum clamping value (default is 1)
  5896. * @param result defines color to store the result into.
  5897. * @returns the cuurent Color4
  5898. */
  5899. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5900. /**
  5901. * Multipy an Color4 value by another and return a new Color4 object
  5902. * @param color defines the Color4 value to multiply by
  5903. * @returns a new Color4 object
  5904. */
  5905. multiply(color: Color4): Color4;
  5906. /**
  5907. * Multipy a Color4 value by another and push the result in a reference value
  5908. * @param color defines the Color4 value to multiply by
  5909. * @param result defines the Color4 to fill the result in
  5910. * @returns the result Color4
  5911. */
  5912. multiplyToRef(color: Color4, result: Color4): Color4;
  5913. /**
  5914. * Creates a string with the Color4 current values
  5915. * @returns the string representation of the Color4 object
  5916. */
  5917. toString(): string;
  5918. /**
  5919. * Returns the string "Color4"
  5920. * @returns "Color4"
  5921. */
  5922. getClassName(): string;
  5923. /**
  5924. * Compute the Color4 hash code
  5925. * @returns an unique number that can be used to hash Color4 objects
  5926. */
  5927. getHashCode(): number;
  5928. /**
  5929. * Creates a new Color4 copied from the current one
  5930. * @returns a new Color4 object
  5931. */
  5932. clone(): Color4;
  5933. /**
  5934. * Copies the given Color4 values into the current one
  5935. * @param source defines the source Color4 object
  5936. * @returns the current updated Color4 object
  5937. */
  5938. copyFrom(source: Color4): Color4;
  5939. /**
  5940. * Copies the given float values into the current one
  5941. * @param r defines the red component to read from
  5942. * @param g defines the green component to read from
  5943. * @param b defines the blue component to read from
  5944. * @param a defines the alpha component to read from
  5945. * @returns the current updated Color4 object
  5946. */
  5947. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5948. /**
  5949. * Copies the given float values into the current one
  5950. * @param r defines the red component to read from
  5951. * @param g defines the green component to read from
  5952. * @param b defines the blue component to read from
  5953. * @param a defines the alpha component to read from
  5954. * @returns the current updated Color4 object
  5955. */
  5956. set(r: number, g: number, b: number, a: number): Color4;
  5957. /**
  5958. * Compute the Color4 hexadecimal code as a string
  5959. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5960. * @returns a string containing the hexadecimal representation of the Color4 object
  5961. */
  5962. toHexString(returnAsColor3?: boolean): string;
  5963. /**
  5964. * Computes a new Color4 converted from the current one to linear space
  5965. * @returns a new Color4 object
  5966. */
  5967. toLinearSpace(): Color4;
  5968. /**
  5969. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5970. * @param convertedColor defines the Color4 object where to store the linear space version
  5971. * @returns the unmodified Color4
  5972. */
  5973. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5974. /**
  5975. * Computes a new Color4 converted from the current one to gamma space
  5976. * @returns a new Color4 object
  5977. */
  5978. toGammaSpace(): Color4;
  5979. /**
  5980. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5981. * @param convertedColor defines the Color4 object where to store the gamma space version
  5982. * @returns the unmodified Color4
  5983. */
  5984. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5985. /**
  5986. * Creates a new Color4 from the string containing valid hexadecimal values
  5987. * @param hex defines a string containing valid hexadecimal values
  5988. * @returns a new Color4 object
  5989. */
  5990. static FromHexString(hex: string): Color4;
  5991. /**
  5992. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5993. * @param left defines the start value
  5994. * @param right defines the end value
  5995. * @param amount defines the gradient factor
  5996. * @returns a new Color4 object
  5997. */
  5998. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5999. /**
  6000. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6001. * @param left defines the start value
  6002. * @param right defines the end value
  6003. * @param amount defines the gradient factor
  6004. * @param result defines the Color4 object where to store data
  6005. */
  6006. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6007. /**
  6008. * Creates a new Color4 from a Color3 and an alpha value
  6009. * @param color3 defines the source Color3 to read from
  6010. * @param alpha defines the alpha component (1.0 by default)
  6011. * @returns a new Color4 object
  6012. */
  6013. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6014. /**
  6015. * Creates a new Color4 from the starting index element of the given array
  6016. * @param array defines the source array to read from
  6017. * @param offset defines the offset in the source array
  6018. * @returns a new Color4 object
  6019. */
  6020. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6021. /**
  6022. * Creates a new Color3 from integer values (< 256)
  6023. * @param r defines the red component to read from (value between 0 and 255)
  6024. * @param g defines the green component to read from (value between 0 and 255)
  6025. * @param b defines the blue component to read from (value between 0 and 255)
  6026. * @param a defines the alpha component to read from (value between 0 and 255)
  6027. * @returns a new Color3 object
  6028. */
  6029. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6030. /**
  6031. * Check the content of a given array and convert it to an array containing RGBA data
  6032. * If the original array was already containing count * 4 values then it is returned directly
  6033. * @param colors defines the array to check
  6034. * @param count defines the number of RGBA data to expect
  6035. * @returns an array containing count * 4 values (RGBA)
  6036. */
  6037. static CheckColors4(colors: number[], count: number): number[];
  6038. }
  6039. /**
  6040. * @hidden
  6041. */
  6042. export class TmpColors {
  6043. static Color3: Color3[];
  6044. static Color4: Color4[];
  6045. }
  6046. }
  6047. declare module "babylonjs/Animations/animationKey" {
  6048. /**
  6049. * Defines an interface which represents an animation key frame
  6050. */
  6051. export interface IAnimationKey {
  6052. /**
  6053. * Frame of the key frame
  6054. */
  6055. frame: number;
  6056. /**
  6057. * Value at the specifies key frame
  6058. */
  6059. value: any;
  6060. /**
  6061. * The input tangent for the cubic hermite spline
  6062. */
  6063. inTangent?: any;
  6064. /**
  6065. * The output tangent for the cubic hermite spline
  6066. */
  6067. outTangent?: any;
  6068. /**
  6069. * The animation interpolation type
  6070. */
  6071. interpolation?: AnimationKeyInterpolation;
  6072. }
  6073. /**
  6074. * Enum for the animation key frame interpolation type
  6075. */
  6076. export enum AnimationKeyInterpolation {
  6077. /**
  6078. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6079. */
  6080. STEP = 1
  6081. }
  6082. }
  6083. declare module "babylonjs/Animations/animationRange" {
  6084. /**
  6085. * Represents the range of an animation
  6086. */
  6087. export class AnimationRange {
  6088. /**The name of the animation range**/
  6089. name: string;
  6090. /**The starting frame of the animation */
  6091. from: number;
  6092. /**The ending frame of the animation*/
  6093. to: number;
  6094. /**
  6095. * Initializes the range of an animation
  6096. * @param name The name of the animation range
  6097. * @param from The starting frame of the animation
  6098. * @param to The ending frame of the animation
  6099. */
  6100. constructor(
  6101. /**The name of the animation range**/
  6102. name: string,
  6103. /**The starting frame of the animation */
  6104. from: number,
  6105. /**The ending frame of the animation*/
  6106. to: number);
  6107. /**
  6108. * Makes a copy of the animation range
  6109. * @returns A copy of the animation range
  6110. */
  6111. clone(): AnimationRange;
  6112. }
  6113. }
  6114. declare module "babylonjs/Animations/animationEvent" {
  6115. /**
  6116. * Composed of a frame, and an action function
  6117. */
  6118. export class AnimationEvent {
  6119. /** The frame for which the event is triggered **/
  6120. frame: number;
  6121. /** The event to perform when triggered **/
  6122. action: (currentFrame: number) => void;
  6123. /** Specifies if the event should be triggered only once**/
  6124. onlyOnce?: boolean | undefined;
  6125. /**
  6126. * Specifies if the animation event is done
  6127. */
  6128. isDone: boolean;
  6129. /**
  6130. * Initializes the animation event
  6131. * @param frame The frame for which the event is triggered
  6132. * @param action The event to perform when triggered
  6133. * @param onlyOnce Specifies if the event should be triggered only once
  6134. */
  6135. constructor(
  6136. /** The frame for which the event is triggered **/
  6137. frame: number,
  6138. /** The event to perform when triggered **/
  6139. action: (currentFrame: number) => void,
  6140. /** Specifies if the event should be triggered only once**/
  6141. onlyOnce?: boolean | undefined);
  6142. /** @hidden */
  6143. _clone(): AnimationEvent;
  6144. }
  6145. }
  6146. declare module "babylonjs/Behaviors/behavior" {
  6147. import { Nullable } from "babylonjs/types";
  6148. /**
  6149. * Interface used to define a behavior
  6150. */
  6151. export interface Behavior<T> {
  6152. /** gets or sets behavior's name */
  6153. name: string;
  6154. /**
  6155. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6156. */
  6157. init(): void;
  6158. /**
  6159. * Called when the behavior is attached to a target
  6160. * @param target defines the target where the behavior is attached to
  6161. */
  6162. attach(target: T): void;
  6163. /**
  6164. * Called when the behavior is detached from its target
  6165. */
  6166. detach(): void;
  6167. }
  6168. /**
  6169. * Interface implemented by classes supporting behaviors
  6170. */
  6171. export interface IBehaviorAware<T> {
  6172. /**
  6173. * Attach a behavior
  6174. * @param behavior defines the behavior to attach
  6175. * @returns the current host
  6176. */
  6177. addBehavior(behavior: Behavior<T>): T;
  6178. /**
  6179. * Remove a behavior from the current object
  6180. * @param behavior defines the behavior to detach
  6181. * @returns the current host
  6182. */
  6183. removeBehavior(behavior: Behavior<T>): T;
  6184. /**
  6185. * Gets a behavior using its name to search
  6186. * @param name defines the name to search
  6187. * @returns the behavior or null if not found
  6188. */
  6189. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6190. }
  6191. }
  6192. declare module "babylonjs/Misc/smartArray" {
  6193. /**
  6194. * Defines an array and its length.
  6195. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6196. */
  6197. export interface ISmartArrayLike<T> {
  6198. /**
  6199. * The data of the array.
  6200. */
  6201. data: Array<T>;
  6202. /**
  6203. * The active length of the array.
  6204. */
  6205. length: number;
  6206. }
  6207. /**
  6208. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6209. */
  6210. export class SmartArray<T> implements ISmartArrayLike<T> {
  6211. /**
  6212. * The full set of data from the array.
  6213. */
  6214. data: Array<T>;
  6215. /**
  6216. * The active length of the array.
  6217. */
  6218. length: number;
  6219. protected _id: number;
  6220. /**
  6221. * Instantiates a Smart Array.
  6222. * @param capacity defines the default capacity of the array.
  6223. */
  6224. constructor(capacity: number);
  6225. /**
  6226. * Pushes a value at the end of the active data.
  6227. * @param value defines the object to push in the array.
  6228. */
  6229. push(value: T): void;
  6230. /**
  6231. * Iterates over the active data and apply the lambda to them.
  6232. * @param func defines the action to apply on each value.
  6233. */
  6234. forEach(func: (content: T) => void): void;
  6235. /**
  6236. * Sorts the full sets of data.
  6237. * @param compareFn defines the comparison function to apply.
  6238. */
  6239. sort(compareFn: (a: T, b: T) => number): void;
  6240. /**
  6241. * Resets the active data to an empty array.
  6242. */
  6243. reset(): void;
  6244. /**
  6245. * Releases all the data from the array as well as the array.
  6246. */
  6247. dispose(): void;
  6248. /**
  6249. * Concats the active data with a given array.
  6250. * @param array defines the data to concatenate with.
  6251. */
  6252. concat(array: any): void;
  6253. /**
  6254. * Returns the position of a value in the active data.
  6255. * @param value defines the value to find the index for
  6256. * @returns the index if found in the active data otherwise -1
  6257. */
  6258. indexOf(value: T): number;
  6259. /**
  6260. * Returns whether an element is part of the active data.
  6261. * @param value defines the value to look for
  6262. * @returns true if found in the active data otherwise false
  6263. */
  6264. contains(value: T): boolean;
  6265. private static _GlobalId;
  6266. }
  6267. /**
  6268. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6269. * The data in this array can only be present once
  6270. */
  6271. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6272. private _duplicateId;
  6273. /**
  6274. * Pushes a value at the end of the active data.
  6275. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6276. * @param value defines the object to push in the array.
  6277. */
  6278. push(value: T): void;
  6279. /**
  6280. * Pushes a value at the end of the active data.
  6281. * If the data is already present, it won t be added again
  6282. * @param value defines the object to push in the array.
  6283. * @returns true if added false if it was already present
  6284. */
  6285. pushNoDuplicate(value: T): boolean;
  6286. /**
  6287. * Resets the active data to an empty array.
  6288. */
  6289. reset(): void;
  6290. /**
  6291. * Concats the active data with a given array.
  6292. * This ensures no dupplicate will be present in the result.
  6293. * @param array defines the data to concatenate with.
  6294. */
  6295. concatWithNoDuplicate(array: any): void;
  6296. }
  6297. }
  6298. declare module "babylonjs/Cameras/cameraInputsManager" {
  6299. import { Nullable } from "babylonjs/types";
  6300. import { Camera } from "babylonjs/Cameras/camera";
  6301. /**
  6302. * @ignore
  6303. * This is a list of all the different input types that are available in the application.
  6304. * Fo instance: ArcRotateCameraGamepadInput...
  6305. */
  6306. export var CameraInputTypes: {};
  6307. /**
  6308. * This is the contract to implement in order to create a new input class.
  6309. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6310. */
  6311. export interface ICameraInput<TCamera extends Camera> {
  6312. /**
  6313. * Defines the camera the input is attached to.
  6314. */
  6315. camera: Nullable<TCamera>;
  6316. /**
  6317. * Gets the class name of the current intput.
  6318. * @returns the class name
  6319. */
  6320. getClassName(): string;
  6321. /**
  6322. * Get the friendly name associated with the input class.
  6323. * @returns the input friendly name
  6324. */
  6325. getSimpleName(): string;
  6326. /**
  6327. * Attach the input controls to a specific dom element to get the input from.
  6328. * @param element Defines the element the controls should be listened from
  6329. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6330. */
  6331. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6332. /**
  6333. * Detach the current controls from the specified dom element.
  6334. * @param element Defines the element to stop listening the inputs from
  6335. */
  6336. detachControl(element: Nullable<HTMLElement>): void;
  6337. /**
  6338. * Update the current camera state depending on the inputs that have been used this frame.
  6339. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6340. */
  6341. checkInputs?: () => void;
  6342. }
  6343. /**
  6344. * Represents a map of input types to input instance or input index to input instance.
  6345. */
  6346. export interface CameraInputsMap<TCamera extends Camera> {
  6347. /**
  6348. * Accessor to the input by input type.
  6349. */
  6350. [name: string]: ICameraInput<TCamera>;
  6351. /**
  6352. * Accessor to the input by input index.
  6353. */
  6354. [idx: number]: ICameraInput<TCamera>;
  6355. }
  6356. /**
  6357. * This represents the input manager used within a camera.
  6358. * It helps dealing with all the different kind of input attached to a camera.
  6359. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6360. */
  6361. export class CameraInputsManager<TCamera extends Camera> {
  6362. /**
  6363. * Defines the list of inputs attahed to the camera.
  6364. */
  6365. attached: CameraInputsMap<TCamera>;
  6366. /**
  6367. * Defines the dom element the camera is collecting inputs from.
  6368. * This is null if the controls have not been attached.
  6369. */
  6370. attachedElement: Nullable<HTMLElement>;
  6371. /**
  6372. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6373. */
  6374. noPreventDefault: boolean;
  6375. /**
  6376. * Defined the camera the input manager belongs to.
  6377. */
  6378. camera: TCamera;
  6379. /**
  6380. * Update the current camera state depending on the inputs that have been used this frame.
  6381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6382. */
  6383. checkInputs: () => void;
  6384. /**
  6385. * Instantiate a new Camera Input Manager.
  6386. * @param camera Defines the camera the input manager blongs to
  6387. */
  6388. constructor(camera: TCamera);
  6389. /**
  6390. * Add an input method to a camera
  6391. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6392. * @param input camera input method
  6393. */
  6394. add(input: ICameraInput<TCamera>): void;
  6395. /**
  6396. * Remove a specific input method from a camera
  6397. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6398. * @param inputToRemove camera input method
  6399. */
  6400. remove(inputToRemove: ICameraInput<TCamera>): void;
  6401. /**
  6402. * Remove a specific input type from a camera
  6403. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6404. * @param inputType the type of the input to remove
  6405. */
  6406. removeByType(inputType: string): void;
  6407. private _addCheckInputs;
  6408. /**
  6409. * Attach the input controls to the currently attached dom element to listen the events from.
  6410. * @param input Defines the input to attach
  6411. */
  6412. attachInput(input: ICameraInput<TCamera>): void;
  6413. /**
  6414. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6415. * @param element Defines the dom element to collect the events from
  6416. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6417. */
  6418. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6419. /**
  6420. * Detach the current manager inputs controls from a specific dom element.
  6421. * @param element Defines the dom element to collect the events from
  6422. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6423. */
  6424. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6425. /**
  6426. * Rebuild the dynamic inputCheck function from the current list of
  6427. * defined inputs in the manager.
  6428. */
  6429. rebuildInputCheck(): void;
  6430. /**
  6431. * Remove all attached input methods from a camera
  6432. */
  6433. clear(): void;
  6434. /**
  6435. * Serialize the current input manager attached to a camera.
  6436. * This ensures than once parsed,
  6437. * the input associated to the camera will be identical to the current ones
  6438. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6439. */
  6440. serialize(serializedCamera: any): void;
  6441. /**
  6442. * Parses an input manager serialized JSON to restore the previous list of inputs
  6443. * and states associated to a camera.
  6444. * @param parsedCamera Defines the JSON to parse
  6445. */
  6446. parse(parsedCamera: any): void;
  6447. }
  6448. }
  6449. declare module "babylonjs/Meshes/buffer" {
  6450. import { Nullable, DataArray } from "babylonjs/types";
  6451. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6452. /**
  6453. * Class used to store data that will be store in GPU memory
  6454. */
  6455. export class Buffer {
  6456. private _engine;
  6457. private _buffer;
  6458. /** @hidden */
  6459. _data: Nullable<DataArray>;
  6460. private _updatable;
  6461. private _instanced;
  6462. private _divisor;
  6463. /**
  6464. * Gets the byte stride.
  6465. */
  6466. readonly byteStride: number;
  6467. /**
  6468. * Constructor
  6469. * @param engine the engine
  6470. * @param data the data to use for this buffer
  6471. * @param updatable whether the data is updatable
  6472. * @param stride the stride (optional)
  6473. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6474. * @param instanced whether the buffer is instanced (optional)
  6475. * @param useBytes set to true if the stride in in bytes (optional)
  6476. * @param divisor sets an optional divisor for instances (1 by default)
  6477. */
  6478. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6479. /**
  6480. * Create a new VertexBuffer based on the current buffer
  6481. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6482. * @param offset defines offset in the buffer (0 by default)
  6483. * @param size defines the size in floats of attributes (position is 3 for instance)
  6484. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6485. * @param instanced defines if the vertex buffer contains indexed data
  6486. * @param useBytes defines if the offset and stride are in bytes *
  6487. * @param divisor sets an optional divisor for instances (1 by default)
  6488. * @returns the new vertex buffer
  6489. */
  6490. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6491. /**
  6492. * Gets a boolean indicating if the Buffer is updatable?
  6493. * @returns true if the buffer is updatable
  6494. */
  6495. isUpdatable(): boolean;
  6496. /**
  6497. * Gets current buffer's data
  6498. * @returns a DataArray or null
  6499. */
  6500. getData(): Nullable<DataArray>;
  6501. /**
  6502. * Gets underlying native buffer
  6503. * @returns underlying native buffer
  6504. */
  6505. getBuffer(): Nullable<DataBuffer>;
  6506. /**
  6507. * Gets the stride in float32 units (i.e. byte stride / 4).
  6508. * May not be an integer if the byte stride is not divisible by 4.
  6509. * @returns the stride in float32 units
  6510. * @deprecated Please use byteStride instead.
  6511. */
  6512. getStrideSize(): number;
  6513. /**
  6514. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6515. * @param data defines the data to store
  6516. */
  6517. create(data?: Nullable<DataArray>): void;
  6518. /** @hidden */
  6519. _rebuild(): void;
  6520. /**
  6521. * Update current buffer data
  6522. * @param data defines the data to store
  6523. */
  6524. update(data: DataArray): void;
  6525. /**
  6526. * Updates the data directly.
  6527. * @param data the new data
  6528. * @param offset the new offset
  6529. * @param vertexCount the vertex count (optional)
  6530. * @param useBytes set to true if the offset is in bytes
  6531. */
  6532. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6533. /**
  6534. * Release all resources
  6535. */
  6536. dispose(): void;
  6537. }
  6538. /**
  6539. * Specialized buffer used to store vertex data
  6540. */
  6541. export class VertexBuffer {
  6542. /** @hidden */
  6543. _buffer: Buffer;
  6544. private _kind;
  6545. private _size;
  6546. private _ownsBuffer;
  6547. private _instanced;
  6548. private _instanceDivisor;
  6549. /**
  6550. * The byte type.
  6551. */
  6552. static readonly BYTE: number;
  6553. /**
  6554. * The unsigned byte type.
  6555. */
  6556. static readonly UNSIGNED_BYTE: number;
  6557. /**
  6558. * The short type.
  6559. */
  6560. static readonly SHORT: number;
  6561. /**
  6562. * The unsigned short type.
  6563. */
  6564. static readonly UNSIGNED_SHORT: number;
  6565. /**
  6566. * The integer type.
  6567. */
  6568. static readonly INT: number;
  6569. /**
  6570. * The unsigned integer type.
  6571. */
  6572. static readonly UNSIGNED_INT: number;
  6573. /**
  6574. * The float type.
  6575. */
  6576. static readonly FLOAT: number;
  6577. /**
  6578. * Gets or sets the instance divisor when in instanced mode
  6579. */
  6580. get instanceDivisor(): number;
  6581. set instanceDivisor(value: number);
  6582. /**
  6583. * Gets the byte stride.
  6584. */
  6585. readonly byteStride: number;
  6586. /**
  6587. * Gets the byte offset.
  6588. */
  6589. readonly byteOffset: number;
  6590. /**
  6591. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6592. */
  6593. readonly normalized: boolean;
  6594. /**
  6595. * Gets the data type of each component in the array.
  6596. */
  6597. readonly type: number;
  6598. /**
  6599. * Constructor
  6600. * @param engine the engine
  6601. * @param data the data to use for this vertex buffer
  6602. * @param kind the vertex buffer kind
  6603. * @param updatable whether the data is updatable
  6604. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6605. * @param stride the stride (optional)
  6606. * @param instanced whether the buffer is instanced (optional)
  6607. * @param offset the offset of the data (optional)
  6608. * @param size the number of components (optional)
  6609. * @param type the type of the component (optional)
  6610. * @param normalized whether the data contains normalized data (optional)
  6611. * @param useBytes set to true if stride and offset are in bytes (optional)
  6612. * @param divisor defines the instance divisor to use (1 by default)
  6613. */
  6614. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6615. /** @hidden */
  6616. _rebuild(): void;
  6617. /**
  6618. * Returns the kind of the VertexBuffer (string)
  6619. * @returns a string
  6620. */
  6621. getKind(): string;
  6622. /**
  6623. * Gets a boolean indicating if the VertexBuffer is updatable?
  6624. * @returns true if the buffer is updatable
  6625. */
  6626. isUpdatable(): boolean;
  6627. /**
  6628. * Gets current buffer's data
  6629. * @returns a DataArray or null
  6630. */
  6631. getData(): Nullable<DataArray>;
  6632. /**
  6633. * Gets underlying native buffer
  6634. * @returns underlying native buffer
  6635. */
  6636. getBuffer(): Nullable<DataBuffer>;
  6637. /**
  6638. * Gets the stride in float32 units (i.e. byte stride / 4).
  6639. * May not be an integer if the byte stride is not divisible by 4.
  6640. * @returns the stride in float32 units
  6641. * @deprecated Please use byteStride instead.
  6642. */
  6643. getStrideSize(): number;
  6644. /**
  6645. * Returns the offset as a multiple of the type byte length.
  6646. * @returns the offset in bytes
  6647. * @deprecated Please use byteOffset instead.
  6648. */
  6649. getOffset(): number;
  6650. /**
  6651. * Returns the number of components per vertex attribute (integer)
  6652. * @returns the size in float
  6653. */
  6654. getSize(): number;
  6655. /**
  6656. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6657. * @returns true if this buffer is instanced
  6658. */
  6659. getIsInstanced(): boolean;
  6660. /**
  6661. * Returns the instancing divisor, zero for non-instanced (integer).
  6662. * @returns a number
  6663. */
  6664. getInstanceDivisor(): number;
  6665. /**
  6666. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6667. * @param data defines the data to store
  6668. */
  6669. create(data?: DataArray): void;
  6670. /**
  6671. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6672. * This function will create a new buffer if the current one is not updatable
  6673. * @param data defines the data to store
  6674. */
  6675. update(data: DataArray): void;
  6676. /**
  6677. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6678. * Returns the directly updated WebGLBuffer.
  6679. * @param data the new data
  6680. * @param offset the new offset
  6681. * @param useBytes set to true if the offset is in bytes
  6682. */
  6683. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6684. /**
  6685. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6686. */
  6687. dispose(): void;
  6688. /**
  6689. * Enumerates each value of this vertex buffer as numbers.
  6690. * @param count the number of values to enumerate
  6691. * @param callback the callback function called for each value
  6692. */
  6693. forEach(count: number, callback: (value: number, index: number) => void): void;
  6694. /**
  6695. * Positions
  6696. */
  6697. static readonly PositionKind: string;
  6698. /**
  6699. * Normals
  6700. */
  6701. static readonly NormalKind: string;
  6702. /**
  6703. * Tangents
  6704. */
  6705. static readonly TangentKind: string;
  6706. /**
  6707. * Texture coordinates
  6708. */
  6709. static readonly UVKind: string;
  6710. /**
  6711. * Texture coordinates 2
  6712. */
  6713. static readonly UV2Kind: string;
  6714. /**
  6715. * Texture coordinates 3
  6716. */
  6717. static readonly UV3Kind: string;
  6718. /**
  6719. * Texture coordinates 4
  6720. */
  6721. static readonly UV4Kind: string;
  6722. /**
  6723. * Texture coordinates 5
  6724. */
  6725. static readonly UV5Kind: string;
  6726. /**
  6727. * Texture coordinates 6
  6728. */
  6729. static readonly UV6Kind: string;
  6730. /**
  6731. * Colors
  6732. */
  6733. static readonly ColorKind: string;
  6734. /**
  6735. * Matrix indices (for bones)
  6736. */
  6737. static readonly MatricesIndicesKind: string;
  6738. /**
  6739. * Matrix weights (for bones)
  6740. */
  6741. static readonly MatricesWeightsKind: string;
  6742. /**
  6743. * Additional matrix indices (for bones)
  6744. */
  6745. static readonly MatricesIndicesExtraKind: string;
  6746. /**
  6747. * Additional matrix weights (for bones)
  6748. */
  6749. static readonly MatricesWeightsExtraKind: string;
  6750. /**
  6751. * Deduces the stride given a kind.
  6752. * @param kind The kind string to deduce
  6753. * @returns The deduced stride
  6754. */
  6755. static DeduceStride(kind: string): number;
  6756. /**
  6757. * Gets the byte length of the given type.
  6758. * @param type the type
  6759. * @returns the number of bytes
  6760. */
  6761. static GetTypeByteLength(type: number): number;
  6762. /**
  6763. * Enumerates each value of the given parameters as numbers.
  6764. * @param data the data to enumerate
  6765. * @param byteOffset the byte offset of the data
  6766. * @param byteStride the byte stride of the data
  6767. * @param componentCount the number of components per element
  6768. * @param componentType the type of the component
  6769. * @param count the number of values to enumerate
  6770. * @param normalized whether the data is normalized
  6771. * @param callback the callback function called for each value
  6772. */
  6773. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6774. private static _GetFloatValue;
  6775. }
  6776. }
  6777. declare module "babylonjs/Collisions/intersectionInfo" {
  6778. import { Nullable } from "babylonjs/types";
  6779. /**
  6780. * @hidden
  6781. */
  6782. export class IntersectionInfo {
  6783. bu: Nullable<number>;
  6784. bv: Nullable<number>;
  6785. distance: number;
  6786. faceId: number;
  6787. subMeshId: number;
  6788. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6789. }
  6790. }
  6791. declare module "babylonjs/Culling/boundingSphere" {
  6792. import { DeepImmutable } from "babylonjs/types";
  6793. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6794. import { Plane } from "babylonjs/Maths/math.plane";
  6795. /**
  6796. * Class used to store bounding sphere information
  6797. */
  6798. export class BoundingSphere {
  6799. /**
  6800. * Gets the center of the bounding sphere in local space
  6801. */
  6802. readonly center: Vector3;
  6803. /**
  6804. * Radius of the bounding sphere in local space
  6805. */
  6806. radius: number;
  6807. /**
  6808. * Gets the center of the bounding sphere in world space
  6809. */
  6810. readonly centerWorld: Vector3;
  6811. /**
  6812. * Radius of the bounding sphere in world space
  6813. */
  6814. radiusWorld: number;
  6815. /**
  6816. * Gets the minimum vector in local space
  6817. */
  6818. readonly minimum: Vector3;
  6819. /**
  6820. * Gets the maximum vector in local space
  6821. */
  6822. readonly maximum: Vector3;
  6823. private _worldMatrix;
  6824. private static readonly TmpVector3;
  6825. /**
  6826. * Creates a new bounding sphere
  6827. * @param min defines the minimum vector (in local space)
  6828. * @param max defines the maximum vector (in local space)
  6829. * @param worldMatrix defines the new world matrix
  6830. */
  6831. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6832. /**
  6833. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6834. * @param min defines the new minimum vector (in local space)
  6835. * @param max defines the new maximum vector (in local space)
  6836. * @param worldMatrix defines the new world matrix
  6837. */
  6838. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6839. /**
  6840. * Scale the current bounding sphere by applying a scale factor
  6841. * @param factor defines the scale factor to apply
  6842. * @returns the current bounding box
  6843. */
  6844. scale(factor: number): BoundingSphere;
  6845. /**
  6846. * Gets the world matrix of the bounding box
  6847. * @returns a matrix
  6848. */
  6849. getWorldMatrix(): DeepImmutable<Matrix>;
  6850. /** @hidden */
  6851. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6852. /**
  6853. * Tests if the bounding sphere is intersecting the frustum planes
  6854. * @param frustumPlanes defines the frustum planes to test
  6855. * @returns true if there is an intersection
  6856. */
  6857. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6858. /**
  6859. * Tests if the bounding sphere center is in between the frustum planes.
  6860. * Used for optimistic fast inclusion.
  6861. * @param frustumPlanes defines the frustum planes to test
  6862. * @returns true if the sphere center is in between the frustum planes
  6863. */
  6864. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6865. /**
  6866. * Tests if a point is inside the bounding sphere
  6867. * @param point defines the point to test
  6868. * @returns true if the point is inside the bounding sphere
  6869. */
  6870. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6871. /**
  6872. * Checks if two sphere intersct
  6873. * @param sphere0 sphere 0
  6874. * @param sphere1 sphere 1
  6875. * @returns true if the speres intersect
  6876. */
  6877. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6878. }
  6879. }
  6880. declare module "babylonjs/Culling/boundingBox" {
  6881. import { DeepImmutable } from "babylonjs/types";
  6882. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6883. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6884. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6885. import { Plane } from "babylonjs/Maths/math.plane";
  6886. /**
  6887. * Class used to store bounding box information
  6888. */
  6889. export class BoundingBox implements ICullable {
  6890. /**
  6891. * Gets the 8 vectors representing the bounding box in local space
  6892. */
  6893. readonly vectors: Vector3[];
  6894. /**
  6895. * Gets the center of the bounding box in local space
  6896. */
  6897. readonly center: Vector3;
  6898. /**
  6899. * Gets the center of the bounding box in world space
  6900. */
  6901. readonly centerWorld: Vector3;
  6902. /**
  6903. * Gets the extend size in local space
  6904. */
  6905. readonly extendSize: Vector3;
  6906. /**
  6907. * Gets the extend size in world space
  6908. */
  6909. readonly extendSizeWorld: Vector3;
  6910. /**
  6911. * Gets the OBB (object bounding box) directions
  6912. */
  6913. readonly directions: Vector3[];
  6914. /**
  6915. * Gets the 8 vectors representing the bounding box in world space
  6916. */
  6917. readonly vectorsWorld: Vector3[];
  6918. /**
  6919. * Gets the minimum vector in world space
  6920. */
  6921. readonly minimumWorld: Vector3;
  6922. /**
  6923. * Gets the maximum vector in world space
  6924. */
  6925. readonly maximumWorld: Vector3;
  6926. /**
  6927. * Gets the minimum vector in local space
  6928. */
  6929. readonly minimum: Vector3;
  6930. /**
  6931. * Gets the maximum vector in local space
  6932. */
  6933. readonly maximum: Vector3;
  6934. private _worldMatrix;
  6935. private static readonly TmpVector3;
  6936. /**
  6937. * @hidden
  6938. */
  6939. _tag: number;
  6940. /**
  6941. * Creates a new bounding box
  6942. * @param min defines the minimum vector (in local space)
  6943. * @param max defines the maximum vector (in local space)
  6944. * @param worldMatrix defines the new world matrix
  6945. */
  6946. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6947. /**
  6948. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6949. * @param min defines the new minimum vector (in local space)
  6950. * @param max defines the new maximum vector (in local space)
  6951. * @param worldMatrix defines the new world matrix
  6952. */
  6953. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6954. /**
  6955. * Scale the current bounding box by applying a scale factor
  6956. * @param factor defines the scale factor to apply
  6957. * @returns the current bounding box
  6958. */
  6959. scale(factor: number): BoundingBox;
  6960. /**
  6961. * Gets the world matrix of the bounding box
  6962. * @returns a matrix
  6963. */
  6964. getWorldMatrix(): DeepImmutable<Matrix>;
  6965. /** @hidden */
  6966. _update(world: DeepImmutable<Matrix>): void;
  6967. /**
  6968. * Tests if the bounding box is intersecting the frustum planes
  6969. * @param frustumPlanes defines the frustum planes to test
  6970. * @returns true if there is an intersection
  6971. */
  6972. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6973. /**
  6974. * Tests if the bounding box is entirely inside the frustum planes
  6975. * @param frustumPlanes defines the frustum planes to test
  6976. * @returns true if there is an inclusion
  6977. */
  6978. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6979. /**
  6980. * Tests if a point is inside the bounding box
  6981. * @param point defines the point to test
  6982. * @returns true if the point is inside the bounding box
  6983. */
  6984. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6985. /**
  6986. * Tests if the bounding box intersects with a bounding sphere
  6987. * @param sphere defines the sphere to test
  6988. * @returns true if there is an intersection
  6989. */
  6990. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6991. /**
  6992. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6993. * @param min defines the min vector to use
  6994. * @param max defines the max vector to use
  6995. * @returns true if there is an intersection
  6996. */
  6997. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6998. /**
  6999. * Tests if two bounding boxes are intersections
  7000. * @param box0 defines the first box to test
  7001. * @param box1 defines the second box to test
  7002. * @returns true if there is an intersection
  7003. */
  7004. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7005. /**
  7006. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7007. * @param minPoint defines the minimum vector of the bounding box
  7008. * @param maxPoint defines the maximum vector of the bounding box
  7009. * @param sphereCenter defines the sphere center
  7010. * @param sphereRadius defines the sphere radius
  7011. * @returns true if there is an intersection
  7012. */
  7013. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7014. /**
  7015. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7016. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7017. * @param frustumPlanes defines the frustum planes to test
  7018. * @return true if there is an inclusion
  7019. */
  7020. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7021. /**
  7022. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7023. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7024. * @param frustumPlanes defines the frustum planes to test
  7025. * @return true if there is an intersection
  7026. */
  7027. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7028. }
  7029. }
  7030. declare module "babylonjs/Collisions/collider" {
  7031. import { Nullable, IndicesArray } from "babylonjs/types";
  7032. import { Vector3 } from "babylonjs/Maths/math.vector";
  7033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7034. import { Plane } from "babylonjs/Maths/math.plane";
  7035. /** @hidden */
  7036. export class Collider {
  7037. /** Define if a collision was found */
  7038. collisionFound: boolean;
  7039. /**
  7040. * Define last intersection point in local space
  7041. */
  7042. intersectionPoint: Vector3;
  7043. /**
  7044. * Define last collided mesh
  7045. */
  7046. collidedMesh: Nullable<AbstractMesh>;
  7047. private _collisionPoint;
  7048. private _planeIntersectionPoint;
  7049. private _tempVector;
  7050. private _tempVector2;
  7051. private _tempVector3;
  7052. private _tempVector4;
  7053. private _edge;
  7054. private _baseToVertex;
  7055. private _destinationPoint;
  7056. private _slidePlaneNormal;
  7057. private _displacementVector;
  7058. /** @hidden */
  7059. _radius: Vector3;
  7060. /** @hidden */
  7061. _retry: number;
  7062. private _velocity;
  7063. private _basePoint;
  7064. private _epsilon;
  7065. /** @hidden */
  7066. _velocityWorldLength: number;
  7067. /** @hidden */
  7068. _basePointWorld: Vector3;
  7069. private _velocityWorld;
  7070. private _normalizedVelocity;
  7071. /** @hidden */
  7072. _initialVelocity: Vector3;
  7073. /** @hidden */
  7074. _initialPosition: Vector3;
  7075. private _nearestDistance;
  7076. private _collisionMask;
  7077. get collisionMask(): number;
  7078. set collisionMask(mask: number);
  7079. /**
  7080. * Gets the plane normal used to compute the sliding response (in local space)
  7081. */
  7082. get slidePlaneNormal(): Vector3;
  7083. /** @hidden */
  7084. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7085. /** @hidden */
  7086. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7087. /** @hidden */
  7088. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7089. /** @hidden */
  7090. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7091. /** @hidden */
  7092. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7093. /** @hidden */
  7094. _getResponse(pos: Vector3, vel: Vector3): void;
  7095. }
  7096. }
  7097. declare module "babylonjs/Culling/boundingInfo" {
  7098. import { DeepImmutable } from "babylonjs/types";
  7099. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7100. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7101. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7102. import { Plane } from "babylonjs/Maths/math.plane";
  7103. import { Collider } from "babylonjs/Collisions/collider";
  7104. /**
  7105. * Interface for cullable objects
  7106. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7107. */
  7108. export interface ICullable {
  7109. /**
  7110. * Checks if the object or part of the object is in the frustum
  7111. * @param frustumPlanes Camera near/planes
  7112. * @returns true if the object is in frustum otherwise false
  7113. */
  7114. isInFrustum(frustumPlanes: Plane[]): boolean;
  7115. /**
  7116. * Checks if a cullable object (mesh...) is in the camera frustum
  7117. * Unlike isInFrustum this cheks the full bounding box
  7118. * @param frustumPlanes Camera near/planes
  7119. * @returns true if the object is in frustum otherwise false
  7120. */
  7121. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7122. }
  7123. /**
  7124. * Info for a bounding data of a mesh
  7125. */
  7126. export class BoundingInfo implements ICullable {
  7127. /**
  7128. * Bounding box for the mesh
  7129. */
  7130. readonly boundingBox: BoundingBox;
  7131. /**
  7132. * Bounding sphere for the mesh
  7133. */
  7134. readonly boundingSphere: BoundingSphere;
  7135. private _isLocked;
  7136. private static readonly TmpVector3;
  7137. /**
  7138. * Constructs bounding info
  7139. * @param minimum min vector of the bounding box/sphere
  7140. * @param maximum max vector of the bounding box/sphere
  7141. * @param worldMatrix defines the new world matrix
  7142. */
  7143. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7144. /**
  7145. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7146. * @param min defines the new minimum vector (in local space)
  7147. * @param max defines the new maximum vector (in local space)
  7148. * @param worldMatrix defines the new world matrix
  7149. */
  7150. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7151. /**
  7152. * min vector of the bounding box/sphere
  7153. */
  7154. get minimum(): Vector3;
  7155. /**
  7156. * max vector of the bounding box/sphere
  7157. */
  7158. get maximum(): Vector3;
  7159. /**
  7160. * If the info is locked and won't be updated to avoid perf overhead
  7161. */
  7162. get isLocked(): boolean;
  7163. set isLocked(value: boolean);
  7164. /**
  7165. * Updates the bounding sphere and box
  7166. * @param world world matrix to be used to update
  7167. */
  7168. update(world: DeepImmutable<Matrix>): void;
  7169. /**
  7170. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7171. * @param center New center of the bounding info
  7172. * @param extend New extend of the bounding info
  7173. * @returns the current bounding info
  7174. */
  7175. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7176. /**
  7177. * Scale the current bounding info by applying a scale factor
  7178. * @param factor defines the scale factor to apply
  7179. * @returns the current bounding info
  7180. */
  7181. scale(factor: number): BoundingInfo;
  7182. /**
  7183. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7184. * @param frustumPlanes defines the frustum to test
  7185. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7186. * @returns true if the bounding info is in the frustum planes
  7187. */
  7188. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7189. /**
  7190. * Gets the world distance between the min and max points of the bounding box
  7191. */
  7192. get diagonalLength(): number;
  7193. /**
  7194. * Checks if a cullable object (mesh...) is in the camera frustum
  7195. * Unlike isInFrustum this cheks the full bounding box
  7196. * @param frustumPlanes Camera near/planes
  7197. * @returns true if the object is in frustum otherwise false
  7198. */
  7199. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7200. /** @hidden */
  7201. _checkCollision(collider: Collider): boolean;
  7202. /**
  7203. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7204. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7205. * @param point the point to check intersection with
  7206. * @returns if the point intersects
  7207. */
  7208. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7209. /**
  7210. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7211. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7212. * @param boundingInfo the bounding info to check intersection with
  7213. * @param precise if the intersection should be done using OBB
  7214. * @returns if the bounding info intersects
  7215. */
  7216. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7217. }
  7218. }
  7219. declare module "babylonjs/Maths/math.functions" {
  7220. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7221. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7222. /**
  7223. * Extracts minimum and maximum values from a list of indexed positions
  7224. * @param positions defines the positions to use
  7225. * @param indices defines the indices to the positions
  7226. * @param indexStart defines the start index
  7227. * @param indexCount defines the end index
  7228. * @param bias defines bias value to add to the result
  7229. * @return minimum and maximum values
  7230. */
  7231. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7232. minimum: Vector3;
  7233. maximum: Vector3;
  7234. };
  7235. /**
  7236. * Extracts minimum and maximum values from a list of positions
  7237. * @param positions defines the positions to use
  7238. * @param start defines the start index in the positions array
  7239. * @param count defines the number of positions to handle
  7240. * @param bias defines bias value to add to the result
  7241. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7242. * @return minimum and maximum values
  7243. */
  7244. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7245. minimum: Vector3;
  7246. maximum: Vector3;
  7247. };
  7248. }
  7249. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7250. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7251. /** @hidden */
  7252. export class WebGLDataBuffer extends DataBuffer {
  7253. private _buffer;
  7254. constructor(resource: WebGLBuffer);
  7255. get underlyingResource(): any;
  7256. }
  7257. }
  7258. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7259. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7260. import { Nullable } from "babylonjs/types";
  7261. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7262. /** @hidden */
  7263. export class WebGLPipelineContext implements IPipelineContext {
  7264. engine: ThinEngine;
  7265. program: Nullable<WebGLProgram>;
  7266. context?: WebGLRenderingContext;
  7267. vertexShader?: WebGLShader;
  7268. fragmentShader?: WebGLShader;
  7269. isParallelCompiled: boolean;
  7270. onCompiled?: () => void;
  7271. transformFeedback?: WebGLTransformFeedback | null;
  7272. vertexCompilationError: Nullable<string>;
  7273. fragmentCompilationError: Nullable<string>;
  7274. programLinkError: Nullable<string>;
  7275. programValidationError: Nullable<string>;
  7276. get isAsync(): boolean;
  7277. get isReady(): boolean;
  7278. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7279. _getVertexShaderCode(): string | null;
  7280. _getFragmentShaderCode(): string | null;
  7281. }
  7282. }
  7283. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7284. import { FloatArray, Nullable } from "babylonjs/types";
  7285. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7286. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7287. module "babylonjs/Engines/thinEngine" {
  7288. interface ThinEngine {
  7289. /**
  7290. * Create an uniform buffer
  7291. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7292. * @param elements defines the content of the uniform buffer
  7293. * @returns the webGL uniform buffer
  7294. */
  7295. createUniformBuffer(elements: FloatArray): DataBuffer;
  7296. /**
  7297. * Create a dynamic uniform buffer
  7298. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7299. * @param elements defines the content of the uniform buffer
  7300. * @returns the webGL uniform buffer
  7301. */
  7302. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7303. /**
  7304. * Update an existing uniform buffer
  7305. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7306. * @param uniformBuffer defines the target uniform buffer
  7307. * @param elements defines the content to update
  7308. * @param offset defines the offset in the uniform buffer where update should start
  7309. * @param count defines the size of the data to update
  7310. */
  7311. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7312. /**
  7313. * Bind an uniform buffer to the current webGL context
  7314. * @param buffer defines the buffer to bind
  7315. */
  7316. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7317. /**
  7318. * Bind a buffer to the current webGL context at a given location
  7319. * @param buffer defines the buffer to bind
  7320. * @param location defines the index where to bind the buffer
  7321. */
  7322. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7323. /**
  7324. * Bind a specific block at a given index in a specific shader program
  7325. * @param pipelineContext defines the pipeline context to use
  7326. * @param blockName defines the block name
  7327. * @param index defines the index where to bind the block
  7328. */
  7329. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7330. }
  7331. }
  7332. }
  7333. declare module "babylonjs/Materials/uniformBuffer" {
  7334. import { Nullable, FloatArray } from "babylonjs/types";
  7335. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7336. import { Engine } from "babylonjs/Engines/engine";
  7337. import { Effect } from "babylonjs/Materials/effect";
  7338. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7339. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7340. import { Color3 } from "babylonjs/Maths/math.color";
  7341. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7342. /**
  7343. * Uniform buffer objects.
  7344. *
  7345. * Handles blocks of uniform on the GPU.
  7346. *
  7347. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7348. *
  7349. * For more information, please refer to :
  7350. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7351. */
  7352. export class UniformBuffer {
  7353. private _engine;
  7354. private _buffer;
  7355. private _data;
  7356. private _bufferData;
  7357. private _dynamic?;
  7358. private _uniformLocations;
  7359. private _uniformSizes;
  7360. private _uniformLocationPointer;
  7361. private _needSync;
  7362. private _noUBO;
  7363. private _currentEffect;
  7364. /** @hidden */
  7365. _alreadyBound: boolean;
  7366. private static _MAX_UNIFORM_SIZE;
  7367. private static _tempBuffer;
  7368. /**
  7369. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7370. * This is dynamic to allow compat with webgl 1 and 2.
  7371. * You will need to pass the name of the uniform as well as the value.
  7372. */
  7373. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7374. /**
  7375. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7376. * This is dynamic to allow compat with webgl 1 and 2.
  7377. * You will need to pass the name of the uniform as well as the value.
  7378. */
  7379. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7380. /**
  7381. * Lambda to Update a single float in a uniform buffer.
  7382. * This is dynamic to allow compat with webgl 1 and 2.
  7383. * You will need to pass the name of the uniform as well as the value.
  7384. */
  7385. updateFloat: (name: string, x: number) => void;
  7386. /**
  7387. * Lambda to Update a vec2 of float in a uniform buffer.
  7388. * This is dynamic to allow compat with webgl 1 and 2.
  7389. * You will need to pass the name of the uniform as well as the value.
  7390. */
  7391. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7392. /**
  7393. * Lambda to Update a vec3 of float in a uniform buffer.
  7394. * This is dynamic to allow compat with webgl 1 and 2.
  7395. * You will need to pass the name of the uniform as well as the value.
  7396. */
  7397. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7398. /**
  7399. * Lambda to Update a vec4 of float in a uniform buffer.
  7400. * This is dynamic to allow compat with webgl 1 and 2.
  7401. * You will need to pass the name of the uniform as well as the value.
  7402. */
  7403. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7404. /**
  7405. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7406. * This is dynamic to allow compat with webgl 1 and 2.
  7407. * You will need to pass the name of the uniform as well as the value.
  7408. */
  7409. updateMatrix: (name: string, mat: Matrix) => void;
  7410. /**
  7411. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7412. * This is dynamic to allow compat with webgl 1 and 2.
  7413. * You will need to pass the name of the uniform as well as the value.
  7414. */
  7415. updateVector3: (name: string, vector: Vector3) => void;
  7416. /**
  7417. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7418. * This is dynamic to allow compat with webgl 1 and 2.
  7419. * You will need to pass the name of the uniform as well as the value.
  7420. */
  7421. updateVector4: (name: string, vector: Vector4) => void;
  7422. /**
  7423. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7424. * This is dynamic to allow compat with webgl 1 and 2.
  7425. * You will need to pass the name of the uniform as well as the value.
  7426. */
  7427. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7428. /**
  7429. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7430. * This is dynamic to allow compat with webgl 1 and 2.
  7431. * You will need to pass the name of the uniform as well as the value.
  7432. */
  7433. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7434. /**
  7435. * Instantiates a new Uniform buffer objects.
  7436. *
  7437. * Handles blocks of uniform on the GPU.
  7438. *
  7439. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7440. *
  7441. * For more information, please refer to :
  7442. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7443. * @param engine Define the engine the buffer is associated with
  7444. * @param data Define the data contained in the buffer
  7445. * @param dynamic Define if the buffer is updatable
  7446. */
  7447. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7448. /**
  7449. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7450. * or just falling back on setUniformXXX calls.
  7451. */
  7452. get useUbo(): boolean;
  7453. /**
  7454. * Indicates if the WebGL underlying uniform buffer is in sync
  7455. * with the javascript cache data.
  7456. */
  7457. get isSync(): boolean;
  7458. /**
  7459. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7460. * Also, a dynamic UniformBuffer will disable cache verification and always
  7461. * update the underlying WebGL uniform buffer to the GPU.
  7462. * @returns if Dynamic, otherwise false
  7463. */
  7464. isDynamic(): boolean;
  7465. /**
  7466. * The data cache on JS side.
  7467. * @returns the underlying data as a float array
  7468. */
  7469. getData(): Float32Array;
  7470. /**
  7471. * The underlying WebGL Uniform buffer.
  7472. * @returns the webgl buffer
  7473. */
  7474. getBuffer(): Nullable<DataBuffer>;
  7475. /**
  7476. * std140 layout specifies how to align data within an UBO structure.
  7477. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7478. * for specs.
  7479. */
  7480. private _fillAlignment;
  7481. /**
  7482. * Adds an uniform in the buffer.
  7483. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7484. * for the layout to be correct !
  7485. * @param name Name of the uniform, as used in the uniform block in the shader.
  7486. * @param size Data size, or data directly.
  7487. */
  7488. addUniform(name: string, size: number | number[]): void;
  7489. /**
  7490. * Adds a Matrix 4x4 to the uniform buffer.
  7491. * @param name Name of the uniform, as used in the uniform block in the shader.
  7492. * @param mat A 4x4 matrix.
  7493. */
  7494. addMatrix(name: string, mat: Matrix): void;
  7495. /**
  7496. * Adds a vec2 to the uniform buffer.
  7497. * @param name Name of the uniform, as used in the uniform block in the shader.
  7498. * @param x Define the x component value of the vec2
  7499. * @param y Define the y component value of the vec2
  7500. */
  7501. addFloat2(name: string, x: number, y: number): void;
  7502. /**
  7503. * Adds a vec3 to the uniform buffer.
  7504. * @param name Name of the uniform, as used in the uniform block in the shader.
  7505. * @param x Define the x component value of the vec3
  7506. * @param y Define the y component value of the vec3
  7507. * @param z Define the z component value of the vec3
  7508. */
  7509. addFloat3(name: string, x: number, y: number, z: number): void;
  7510. /**
  7511. * Adds a vec3 to the uniform buffer.
  7512. * @param name Name of the uniform, as used in the uniform block in the shader.
  7513. * @param color Define the vec3 from a Color
  7514. */
  7515. addColor3(name: string, color: Color3): void;
  7516. /**
  7517. * Adds a vec4 to the uniform buffer.
  7518. * @param name Name of the uniform, as used in the uniform block in the shader.
  7519. * @param color Define the rgb components from a Color
  7520. * @param alpha Define the a component of the vec4
  7521. */
  7522. addColor4(name: string, color: Color3, alpha: number): void;
  7523. /**
  7524. * Adds a vec3 to the uniform buffer.
  7525. * @param name Name of the uniform, as used in the uniform block in the shader.
  7526. * @param vector Define the vec3 components from a Vector
  7527. */
  7528. addVector3(name: string, vector: Vector3): void;
  7529. /**
  7530. * Adds a Matrix 3x3 to the uniform buffer.
  7531. * @param name Name of the uniform, as used in the uniform block in the shader.
  7532. */
  7533. addMatrix3x3(name: string): void;
  7534. /**
  7535. * Adds a Matrix 2x2 to the uniform buffer.
  7536. * @param name Name of the uniform, as used in the uniform block in the shader.
  7537. */
  7538. addMatrix2x2(name: string): void;
  7539. /**
  7540. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7541. */
  7542. create(): void;
  7543. /** @hidden */
  7544. _rebuild(): void;
  7545. /**
  7546. * Updates the WebGL Uniform Buffer on the GPU.
  7547. * If the `dynamic` flag is set to true, no cache comparison is done.
  7548. * Otherwise, the buffer will be updated only if the cache differs.
  7549. */
  7550. update(): void;
  7551. /**
  7552. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7553. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7554. * @param data Define the flattened data
  7555. * @param size Define the size of the data.
  7556. */
  7557. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7558. private _valueCache;
  7559. private _cacheMatrix;
  7560. private _updateMatrix3x3ForUniform;
  7561. private _updateMatrix3x3ForEffect;
  7562. private _updateMatrix2x2ForEffect;
  7563. private _updateMatrix2x2ForUniform;
  7564. private _updateFloatForEffect;
  7565. private _updateFloatForUniform;
  7566. private _updateFloat2ForEffect;
  7567. private _updateFloat2ForUniform;
  7568. private _updateFloat3ForEffect;
  7569. private _updateFloat3ForUniform;
  7570. private _updateFloat4ForEffect;
  7571. private _updateFloat4ForUniform;
  7572. private _updateMatrixForEffect;
  7573. private _updateMatrixForUniform;
  7574. private _updateVector3ForEffect;
  7575. private _updateVector3ForUniform;
  7576. private _updateVector4ForEffect;
  7577. private _updateVector4ForUniform;
  7578. private _updateColor3ForEffect;
  7579. private _updateColor3ForUniform;
  7580. private _updateColor4ForEffect;
  7581. private _updateColor4ForUniform;
  7582. /**
  7583. * Sets a sampler uniform on the effect.
  7584. * @param name Define the name of the sampler.
  7585. * @param texture Define the texture to set in the sampler
  7586. */
  7587. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7588. /**
  7589. * Directly updates the value of the uniform in the cache AND on the GPU.
  7590. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7591. * @param data Define the flattened data
  7592. */
  7593. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7594. /**
  7595. * Binds this uniform buffer to an effect.
  7596. * @param effect Define the effect to bind the buffer to
  7597. * @param name Name of the uniform block in the shader.
  7598. */
  7599. bindToEffect(effect: Effect, name: string): void;
  7600. /**
  7601. * Disposes the uniform buffer.
  7602. */
  7603. dispose(): void;
  7604. }
  7605. }
  7606. declare module "babylonjs/Misc/iInspectable" {
  7607. /**
  7608. * Enum that determines the text-wrapping mode to use.
  7609. */
  7610. export enum InspectableType {
  7611. /**
  7612. * Checkbox for booleans
  7613. */
  7614. Checkbox = 0,
  7615. /**
  7616. * Sliders for numbers
  7617. */
  7618. Slider = 1,
  7619. /**
  7620. * Vector3
  7621. */
  7622. Vector3 = 2,
  7623. /**
  7624. * Quaternions
  7625. */
  7626. Quaternion = 3,
  7627. /**
  7628. * Color3
  7629. */
  7630. Color3 = 4,
  7631. /**
  7632. * String
  7633. */
  7634. String = 5
  7635. }
  7636. /**
  7637. * Interface used to define custom inspectable properties.
  7638. * This interface is used by the inspector to display custom property grids
  7639. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7640. */
  7641. export interface IInspectable {
  7642. /**
  7643. * Gets the label to display
  7644. */
  7645. label: string;
  7646. /**
  7647. * Gets the name of the property to edit
  7648. */
  7649. propertyName: string;
  7650. /**
  7651. * Gets the type of the editor to use
  7652. */
  7653. type: InspectableType;
  7654. /**
  7655. * Gets the minimum value of the property when using in "slider" mode
  7656. */
  7657. min?: number;
  7658. /**
  7659. * Gets the maximum value of the property when using in "slider" mode
  7660. */
  7661. max?: number;
  7662. /**
  7663. * Gets the setp to use when using in "slider" mode
  7664. */
  7665. step?: number;
  7666. }
  7667. }
  7668. declare module "babylonjs/Misc/timingTools" {
  7669. /**
  7670. * Class used to provide helper for timing
  7671. */
  7672. export class TimingTools {
  7673. /**
  7674. * Polyfill for setImmediate
  7675. * @param action defines the action to execute after the current execution block
  7676. */
  7677. static SetImmediate(action: () => void): void;
  7678. }
  7679. }
  7680. declare module "babylonjs/Misc/instantiationTools" {
  7681. /**
  7682. * Class used to enable instatition of objects by class name
  7683. */
  7684. export class InstantiationTools {
  7685. /**
  7686. * Use this object to register external classes like custom textures or material
  7687. * to allow the laoders to instantiate them
  7688. */
  7689. static RegisteredExternalClasses: {
  7690. [key: string]: Object;
  7691. };
  7692. /**
  7693. * Tries to instantiate a new object from a given class name
  7694. * @param className defines the class name to instantiate
  7695. * @returns the new object or null if the system was not able to do the instantiation
  7696. */
  7697. static Instantiate(className: string): any;
  7698. }
  7699. }
  7700. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7701. /**
  7702. * Define options used to create a depth texture
  7703. */
  7704. export class DepthTextureCreationOptions {
  7705. /** Specifies whether or not a stencil should be allocated in the texture */
  7706. generateStencil?: boolean;
  7707. /** Specifies whether or not bilinear filtering is enable on the texture */
  7708. bilinearFiltering?: boolean;
  7709. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7710. comparisonFunction?: number;
  7711. /** Specifies if the created texture is a cube texture */
  7712. isCube?: boolean;
  7713. }
  7714. }
  7715. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7716. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7717. import { Nullable } from "babylonjs/types";
  7718. import { Scene } from "babylonjs/scene";
  7719. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7720. module "babylonjs/Engines/thinEngine" {
  7721. interface ThinEngine {
  7722. /**
  7723. * Creates a depth stencil cube texture.
  7724. * This is only available in WebGL 2.
  7725. * @param size The size of face edge in the cube texture.
  7726. * @param options The options defining the cube texture.
  7727. * @returns The cube texture
  7728. */
  7729. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7730. /**
  7731. * Creates a cube texture
  7732. * @param rootUrl defines the url where the files to load is located
  7733. * @param scene defines the current scene
  7734. * @param files defines the list of files to load (1 per face)
  7735. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7736. * @param onLoad defines an optional callback raised when the texture is loaded
  7737. * @param onError defines an optional callback raised if there is an issue to load the texture
  7738. * @param format defines the format of the data
  7739. * @param forcedExtension defines the extension to use to pick the right loader
  7740. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7741. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7742. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7743. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7744. * @returns the cube texture as an InternalTexture
  7745. */
  7746. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7747. /**
  7748. * Creates a cube texture
  7749. * @param rootUrl defines the url where the files to load is located
  7750. * @param scene defines the current scene
  7751. * @param files defines the list of files to load (1 per face)
  7752. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7753. * @param onLoad defines an optional callback raised when the texture is loaded
  7754. * @param onError defines an optional callback raised if there is an issue to load the texture
  7755. * @param format defines the format of the data
  7756. * @param forcedExtension defines the extension to use to pick the right loader
  7757. * @returns the cube texture as an InternalTexture
  7758. */
  7759. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7760. /**
  7761. * Creates a cube texture
  7762. * @param rootUrl defines the url where the files to load is located
  7763. * @param scene defines the current scene
  7764. * @param files defines the list of files to load (1 per face)
  7765. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7766. * @param onLoad defines an optional callback raised when the texture is loaded
  7767. * @param onError defines an optional callback raised if there is an issue to load the texture
  7768. * @param format defines the format of the data
  7769. * @param forcedExtension defines the extension to use to pick the right loader
  7770. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7771. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7772. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7773. * @returns the cube texture as an InternalTexture
  7774. */
  7775. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7776. /** @hidden */
  7777. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7778. /** @hidden */
  7779. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7780. /** @hidden */
  7781. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7782. /** @hidden */
  7783. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7784. /**
  7785. * @hidden
  7786. */
  7787. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7788. }
  7789. }
  7790. }
  7791. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7792. import { Nullable } from "babylonjs/types";
  7793. import { Scene } from "babylonjs/scene";
  7794. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7795. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7796. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7797. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7798. import { Observable } from "babylonjs/Misc/observable";
  7799. /**
  7800. * Class for creating a cube texture
  7801. */
  7802. export class CubeTexture extends BaseTexture {
  7803. private _delayedOnLoad;
  7804. /**
  7805. * Observable triggered once the texture has been loaded.
  7806. */
  7807. onLoadObservable: Observable<CubeTexture>;
  7808. /**
  7809. * The url of the texture
  7810. */
  7811. url: string;
  7812. /**
  7813. * Gets or sets the center of the bounding box associated with the cube texture.
  7814. * It must define where the camera used to render the texture was set
  7815. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7816. */
  7817. boundingBoxPosition: Vector3;
  7818. private _boundingBoxSize;
  7819. /**
  7820. * Gets or sets the size of the bounding box associated with the cube texture
  7821. * When defined, the cubemap will switch to local mode
  7822. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7823. * @example https://www.babylonjs-playground.com/#RNASML
  7824. */
  7825. set boundingBoxSize(value: Vector3);
  7826. /**
  7827. * Returns the bounding box size
  7828. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7829. */
  7830. get boundingBoxSize(): Vector3;
  7831. protected _rotationY: number;
  7832. /**
  7833. * Sets texture matrix rotation angle around Y axis in radians.
  7834. */
  7835. set rotationY(value: number);
  7836. /**
  7837. * Gets texture matrix rotation angle around Y axis radians.
  7838. */
  7839. get rotationY(): number;
  7840. /**
  7841. * Are mip maps generated for this texture or not.
  7842. */
  7843. get noMipmap(): boolean;
  7844. private _noMipmap;
  7845. private _files;
  7846. protected _forcedExtension: Nullable<string>;
  7847. private _extensions;
  7848. private _textureMatrix;
  7849. private _format;
  7850. private _createPolynomials;
  7851. /**
  7852. * Creates a cube texture from an array of image urls
  7853. * @param files defines an array of image urls
  7854. * @param scene defines the hosting scene
  7855. * @param noMipmap specifies if mip maps are not used
  7856. * @returns a cube texture
  7857. */
  7858. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7859. /**
  7860. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7861. * @param url defines the url of the prefiltered texture
  7862. * @param scene defines the scene the texture is attached to
  7863. * @param forcedExtension defines the extension of the file if different from the url
  7864. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7865. * @return the prefiltered texture
  7866. */
  7867. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7868. /**
  7869. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7870. * as prefiltered data.
  7871. * @param rootUrl defines the url of the texture or the root name of the six images
  7872. * @param null defines the scene or engine the texture is attached to
  7873. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7874. * @param noMipmap defines if mipmaps should be created or not
  7875. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7876. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7877. * @param onError defines a callback triggered in case of error during load
  7878. * @param format defines the internal format to use for the texture once loaded
  7879. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7880. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7881. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7882. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7883. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7884. * @return the cube texture
  7885. */
  7886. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7887. /**
  7888. * Get the current class name of the texture useful for serialization or dynamic coding.
  7889. * @returns "CubeTexture"
  7890. */
  7891. getClassName(): string;
  7892. /**
  7893. * Update the url (and optional buffer) of this texture if url was null during construction.
  7894. * @param url the url of the texture
  7895. * @param forcedExtension defines the extension to use
  7896. * @param onLoad callback called when the texture is loaded (defaults to null)
  7897. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7898. */
  7899. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7900. /**
  7901. * Delays loading of the cube texture
  7902. * @param forcedExtension defines the extension to use
  7903. */
  7904. delayLoad(forcedExtension?: string): void;
  7905. /**
  7906. * Returns the reflection texture matrix
  7907. * @returns the reflection texture matrix
  7908. */
  7909. getReflectionTextureMatrix(): Matrix;
  7910. /**
  7911. * Sets the reflection texture matrix
  7912. * @param value Reflection texture matrix
  7913. */
  7914. setReflectionTextureMatrix(value: Matrix): void;
  7915. /**
  7916. * Parses text to create a cube texture
  7917. * @param parsedTexture define the serialized text to read from
  7918. * @param scene defines the hosting scene
  7919. * @param rootUrl defines the root url of the cube texture
  7920. * @returns a cube texture
  7921. */
  7922. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7923. /**
  7924. * Makes a clone, or deep copy, of the cube texture
  7925. * @returns a new cube texture
  7926. */
  7927. clone(): CubeTexture;
  7928. }
  7929. }
  7930. declare module "babylonjs/Materials/materialDefines" {
  7931. /**
  7932. * Manages the defines for the Material
  7933. */
  7934. export class MaterialDefines {
  7935. /** @hidden */
  7936. protected _keys: string[];
  7937. private _isDirty;
  7938. /** @hidden */
  7939. _renderId: number;
  7940. /** @hidden */
  7941. _areLightsDirty: boolean;
  7942. /** @hidden */
  7943. _areLightsDisposed: boolean;
  7944. /** @hidden */
  7945. _areAttributesDirty: boolean;
  7946. /** @hidden */
  7947. _areTexturesDirty: boolean;
  7948. /** @hidden */
  7949. _areFresnelDirty: boolean;
  7950. /** @hidden */
  7951. _areMiscDirty: boolean;
  7952. /** @hidden */
  7953. _areImageProcessingDirty: boolean;
  7954. /** @hidden */
  7955. _normals: boolean;
  7956. /** @hidden */
  7957. _uvs: boolean;
  7958. /** @hidden */
  7959. _needNormals: boolean;
  7960. /** @hidden */
  7961. _needUVs: boolean;
  7962. [id: string]: any;
  7963. /**
  7964. * Specifies if the material needs to be re-calculated
  7965. */
  7966. get isDirty(): boolean;
  7967. /**
  7968. * Marks the material to indicate that it has been re-calculated
  7969. */
  7970. markAsProcessed(): void;
  7971. /**
  7972. * Marks the material to indicate that it needs to be re-calculated
  7973. */
  7974. markAsUnprocessed(): void;
  7975. /**
  7976. * Marks the material to indicate all of its defines need to be re-calculated
  7977. */
  7978. markAllAsDirty(): void;
  7979. /**
  7980. * Marks the material to indicate that image processing needs to be re-calculated
  7981. */
  7982. markAsImageProcessingDirty(): void;
  7983. /**
  7984. * Marks the material to indicate the lights need to be re-calculated
  7985. * @param disposed Defines whether the light is dirty due to dispose or not
  7986. */
  7987. markAsLightDirty(disposed?: boolean): void;
  7988. /**
  7989. * Marks the attribute state as changed
  7990. */
  7991. markAsAttributesDirty(): void;
  7992. /**
  7993. * Marks the texture state as changed
  7994. */
  7995. markAsTexturesDirty(): void;
  7996. /**
  7997. * Marks the fresnel state as changed
  7998. */
  7999. markAsFresnelDirty(): void;
  8000. /**
  8001. * Marks the misc state as changed
  8002. */
  8003. markAsMiscDirty(): void;
  8004. /**
  8005. * Rebuilds the material defines
  8006. */
  8007. rebuild(): void;
  8008. /**
  8009. * Specifies if two material defines are equal
  8010. * @param other - A material define instance to compare to
  8011. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8012. */
  8013. isEqual(other: MaterialDefines): boolean;
  8014. /**
  8015. * Clones this instance's defines to another instance
  8016. * @param other - material defines to clone values to
  8017. */
  8018. cloneTo(other: MaterialDefines): void;
  8019. /**
  8020. * Resets the material define values
  8021. */
  8022. reset(): void;
  8023. /**
  8024. * Converts the material define values to a string
  8025. * @returns - String of material define information
  8026. */
  8027. toString(): string;
  8028. }
  8029. }
  8030. declare module "babylonjs/Materials/colorCurves" {
  8031. import { Effect } from "babylonjs/Materials/effect";
  8032. /**
  8033. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8034. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8035. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8036. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8037. */
  8038. export class ColorCurves {
  8039. private _dirty;
  8040. private _tempColor;
  8041. private _globalCurve;
  8042. private _highlightsCurve;
  8043. private _midtonesCurve;
  8044. private _shadowsCurve;
  8045. private _positiveCurve;
  8046. private _negativeCurve;
  8047. private _globalHue;
  8048. private _globalDensity;
  8049. private _globalSaturation;
  8050. private _globalExposure;
  8051. /**
  8052. * Gets the global Hue value.
  8053. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8054. */
  8055. get globalHue(): number;
  8056. /**
  8057. * Sets the global Hue value.
  8058. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8059. */
  8060. set globalHue(value: number);
  8061. /**
  8062. * Gets the global Density value.
  8063. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8064. * Values less than zero provide a filter of opposite hue.
  8065. */
  8066. get globalDensity(): number;
  8067. /**
  8068. * Sets the global Density value.
  8069. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8070. * Values less than zero provide a filter of opposite hue.
  8071. */
  8072. set globalDensity(value: number);
  8073. /**
  8074. * Gets the global Saturation value.
  8075. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8076. */
  8077. get globalSaturation(): number;
  8078. /**
  8079. * Sets the global Saturation value.
  8080. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8081. */
  8082. set globalSaturation(value: number);
  8083. /**
  8084. * Gets the global Exposure value.
  8085. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8086. */
  8087. get globalExposure(): number;
  8088. /**
  8089. * Sets the global Exposure value.
  8090. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8091. */
  8092. set globalExposure(value: number);
  8093. private _highlightsHue;
  8094. private _highlightsDensity;
  8095. private _highlightsSaturation;
  8096. private _highlightsExposure;
  8097. /**
  8098. * Gets the highlights Hue value.
  8099. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8100. */
  8101. get highlightsHue(): number;
  8102. /**
  8103. * Sets the highlights Hue value.
  8104. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8105. */
  8106. set highlightsHue(value: number);
  8107. /**
  8108. * Gets the highlights Density value.
  8109. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8110. * Values less than zero provide a filter of opposite hue.
  8111. */
  8112. get highlightsDensity(): number;
  8113. /**
  8114. * Sets the highlights Density value.
  8115. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8116. * Values less than zero provide a filter of opposite hue.
  8117. */
  8118. set highlightsDensity(value: number);
  8119. /**
  8120. * Gets the highlights Saturation value.
  8121. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8122. */
  8123. get highlightsSaturation(): number;
  8124. /**
  8125. * Sets the highlights Saturation value.
  8126. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8127. */
  8128. set highlightsSaturation(value: number);
  8129. /**
  8130. * Gets the highlights Exposure value.
  8131. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8132. */
  8133. get highlightsExposure(): number;
  8134. /**
  8135. * Sets the highlights Exposure value.
  8136. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8137. */
  8138. set highlightsExposure(value: number);
  8139. private _midtonesHue;
  8140. private _midtonesDensity;
  8141. private _midtonesSaturation;
  8142. private _midtonesExposure;
  8143. /**
  8144. * Gets the midtones Hue value.
  8145. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8146. */
  8147. get midtonesHue(): number;
  8148. /**
  8149. * Sets the midtones Hue value.
  8150. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8151. */
  8152. set midtonesHue(value: number);
  8153. /**
  8154. * Gets the midtones Density value.
  8155. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8156. * Values less than zero provide a filter of opposite hue.
  8157. */
  8158. get midtonesDensity(): number;
  8159. /**
  8160. * Sets the midtones Density value.
  8161. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8162. * Values less than zero provide a filter of opposite hue.
  8163. */
  8164. set midtonesDensity(value: number);
  8165. /**
  8166. * Gets the midtones Saturation value.
  8167. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8168. */
  8169. get midtonesSaturation(): number;
  8170. /**
  8171. * Sets the midtones Saturation value.
  8172. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8173. */
  8174. set midtonesSaturation(value: number);
  8175. /**
  8176. * Gets the midtones Exposure value.
  8177. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8178. */
  8179. get midtonesExposure(): number;
  8180. /**
  8181. * Sets the midtones Exposure value.
  8182. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8183. */
  8184. set midtonesExposure(value: number);
  8185. private _shadowsHue;
  8186. private _shadowsDensity;
  8187. private _shadowsSaturation;
  8188. private _shadowsExposure;
  8189. /**
  8190. * Gets the shadows Hue value.
  8191. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8192. */
  8193. get shadowsHue(): number;
  8194. /**
  8195. * Sets the shadows Hue value.
  8196. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8197. */
  8198. set shadowsHue(value: number);
  8199. /**
  8200. * Gets the shadows Density value.
  8201. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8202. * Values less than zero provide a filter of opposite hue.
  8203. */
  8204. get shadowsDensity(): number;
  8205. /**
  8206. * Sets the shadows Density value.
  8207. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8208. * Values less than zero provide a filter of opposite hue.
  8209. */
  8210. set shadowsDensity(value: number);
  8211. /**
  8212. * Gets the shadows Saturation value.
  8213. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8214. */
  8215. get shadowsSaturation(): number;
  8216. /**
  8217. * Sets the shadows Saturation value.
  8218. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8219. */
  8220. set shadowsSaturation(value: number);
  8221. /**
  8222. * Gets the shadows Exposure value.
  8223. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8224. */
  8225. get shadowsExposure(): number;
  8226. /**
  8227. * Sets the shadows Exposure value.
  8228. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8229. */
  8230. set shadowsExposure(value: number);
  8231. /**
  8232. * Returns the class name
  8233. * @returns The class name
  8234. */
  8235. getClassName(): string;
  8236. /**
  8237. * Binds the color curves to the shader.
  8238. * @param colorCurves The color curve to bind
  8239. * @param effect The effect to bind to
  8240. * @param positiveUniform The positive uniform shader parameter
  8241. * @param neutralUniform The neutral uniform shader parameter
  8242. * @param negativeUniform The negative uniform shader parameter
  8243. */
  8244. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8245. /**
  8246. * Prepare the list of uniforms associated with the ColorCurves effects.
  8247. * @param uniformsList The list of uniforms used in the effect
  8248. */
  8249. static PrepareUniforms(uniformsList: string[]): void;
  8250. /**
  8251. * Returns color grading data based on a hue, density, saturation and exposure value.
  8252. * @param filterHue The hue of the color filter.
  8253. * @param filterDensity The density of the color filter.
  8254. * @param saturation The saturation.
  8255. * @param exposure The exposure.
  8256. * @param result The result data container.
  8257. */
  8258. private getColorGradingDataToRef;
  8259. /**
  8260. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8261. * @param value The input slider value in range [-100,100].
  8262. * @returns Adjusted value.
  8263. */
  8264. private static applyColorGradingSliderNonlinear;
  8265. /**
  8266. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8267. * @param hue The hue (H) input.
  8268. * @param saturation The saturation (S) input.
  8269. * @param brightness The brightness (B) input.
  8270. * @result An RGBA color represented as Vector4.
  8271. */
  8272. private static fromHSBToRef;
  8273. /**
  8274. * Returns a value clamped between min and max
  8275. * @param value The value to clamp
  8276. * @param min The minimum of value
  8277. * @param max The maximum of value
  8278. * @returns The clamped value.
  8279. */
  8280. private static clamp;
  8281. /**
  8282. * Clones the current color curve instance.
  8283. * @return The cloned curves
  8284. */
  8285. clone(): ColorCurves;
  8286. /**
  8287. * Serializes the current color curve instance to a json representation.
  8288. * @return a JSON representation
  8289. */
  8290. serialize(): any;
  8291. /**
  8292. * Parses the color curve from a json representation.
  8293. * @param source the JSON source to parse
  8294. * @return The parsed curves
  8295. */
  8296. static Parse(source: any): ColorCurves;
  8297. }
  8298. }
  8299. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8300. import { Observable } from "babylonjs/Misc/observable";
  8301. import { Nullable } from "babylonjs/types";
  8302. import { Color4 } from "babylonjs/Maths/math.color";
  8303. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8304. import { Effect } from "babylonjs/Materials/effect";
  8305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8306. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8307. /**
  8308. * Interface to follow in your material defines to integrate easily the
  8309. * Image proccessing functions.
  8310. * @hidden
  8311. */
  8312. export interface IImageProcessingConfigurationDefines {
  8313. IMAGEPROCESSING: boolean;
  8314. VIGNETTE: boolean;
  8315. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8316. VIGNETTEBLENDMODEOPAQUE: boolean;
  8317. TONEMAPPING: boolean;
  8318. TONEMAPPING_ACES: boolean;
  8319. CONTRAST: boolean;
  8320. EXPOSURE: boolean;
  8321. COLORCURVES: boolean;
  8322. COLORGRADING: boolean;
  8323. COLORGRADING3D: boolean;
  8324. SAMPLER3DGREENDEPTH: boolean;
  8325. SAMPLER3DBGRMAP: boolean;
  8326. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8327. }
  8328. /**
  8329. * @hidden
  8330. */
  8331. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8332. IMAGEPROCESSING: boolean;
  8333. VIGNETTE: boolean;
  8334. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8335. VIGNETTEBLENDMODEOPAQUE: boolean;
  8336. TONEMAPPING: boolean;
  8337. TONEMAPPING_ACES: boolean;
  8338. CONTRAST: boolean;
  8339. COLORCURVES: boolean;
  8340. COLORGRADING: boolean;
  8341. COLORGRADING3D: boolean;
  8342. SAMPLER3DGREENDEPTH: boolean;
  8343. SAMPLER3DBGRMAP: boolean;
  8344. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8345. EXPOSURE: boolean;
  8346. constructor();
  8347. }
  8348. /**
  8349. * This groups together the common properties used for image processing either in direct forward pass
  8350. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8351. * or not.
  8352. */
  8353. export class ImageProcessingConfiguration {
  8354. /**
  8355. * Default tone mapping applied in BabylonJS.
  8356. */
  8357. static readonly TONEMAPPING_STANDARD: number;
  8358. /**
  8359. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8360. * to other engines rendering to increase portability.
  8361. */
  8362. static readonly TONEMAPPING_ACES: number;
  8363. /**
  8364. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8365. */
  8366. colorCurves: Nullable<ColorCurves>;
  8367. private _colorCurvesEnabled;
  8368. /**
  8369. * Gets wether the color curves effect is enabled.
  8370. */
  8371. get colorCurvesEnabled(): boolean;
  8372. /**
  8373. * Sets wether the color curves effect is enabled.
  8374. */
  8375. set colorCurvesEnabled(value: boolean);
  8376. private _colorGradingTexture;
  8377. /**
  8378. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8379. */
  8380. get colorGradingTexture(): Nullable<BaseTexture>;
  8381. /**
  8382. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8383. */
  8384. set colorGradingTexture(value: Nullable<BaseTexture>);
  8385. private _colorGradingEnabled;
  8386. /**
  8387. * Gets wether the color grading effect is enabled.
  8388. */
  8389. get colorGradingEnabled(): boolean;
  8390. /**
  8391. * Sets wether the color grading effect is enabled.
  8392. */
  8393. set colorGradingEnabled(value: boolean);
  8394. private _colorGradingWithGreenDepth;
  8395. /**
  8396. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8397. */
  8398. get colorGradingWithGreenDepth(): boolean;
  8399. /**
  8400. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8401. */
  8402. set colorGradingWithGreenDepth(value: boolean);
  8403. private _colorGradingBGR;
  8404. /**
  8405. * Gets wether the color grading texture contains BGR values.
  8406. */
  8407. get colorGradingBGR(): boolean;
  8408. /**
  8409. * Sets wether the color grading texture contains BGR values.
  8410. */
  8411. set colorGradingBGR(value: boolean);
  8412. /** @hidden */
  8413. _exposure: number;
  8414. /**
  8415. * Gets the Exposure used in the effect.
  8416. */
  8417. get exposure(): number;
  8418. /**
  8419. * Sets the Exposure used in the effect.
  8420. */
  8421. set exposure(value: number);
  8422. private _toneMappingEnabled;
  8423. /**
  8424. * Gets wether the tone mapping effect is enabled.
  8425. */
  8426. get toneMappingEnabled(): boolean;
  8427. /**
  8428. * Sets wether the tone mapping effect is enabled.
  8429. */
  8430. set toneMappingEnabled(value: boolean);
  8431. private _toneMappingType;
  8432. /**
  8433. * Gets the type of tone mapping effect.
  8434. */
  8435. get toneMappingType(): number;
  8436. /**
  8437. * Sets the type of tone mapping effect used in BabylonJS.
  8438. */
  8439. set toneMappingType(value: number);
  8440. protected _contrast: number;
  8441. /**
  8442. * Gets the contrast used in the effect.
  8443. */
  8444. get contrast(): number;
  8445. /**
  8446. * Sets the contrast used in the effect.
  8447. */
  8448. set contrast(value: number);
  8449. /**
  8450. * Vignette stretch size.
  8451. */
  8452. vignetteStretch: number;
  8453. /**
  8454. * Vignette centre X Offset.
  8455. */
  8456. vignetteCentreX: number;
  8457. /**
  8458. * Vignette centre Y Offset.
  8459. */
  8460. vignetteCentreY: number;
  8461. /**
  8462. * Vignette weight or intensity of the vignette effect.
  8463. */
  8464. vignetteWeight: number;
  8465. /**
  8466. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8467. * if vignetteEnabled is set to true.
  8468. */
  8469. vignetteColor: Color4;
  8470. /**
  8471. * Camera field of view used by the Vignette effect.
  8472. */
  8473. vignetteCameraFov: number;
  8474. private _vignetteBlendMode;
  8475. /**
  8476. * Gets the vignette blend mode allowing different kind of effect.
  8477. */
  8478. get vignetteBlendMode(): number;
  8479. /**
  8480. * Sets the vignette blend mode allowing different kind of effect.
  8481. */
  8482. set vignetteBlendMode(value: number);
  8483. private _vignetteEnabled;
  8484. /**
  8485. * Gets wether the vignette effect is enabled.
  8486. */
  8487. get vignetteEnabled(): boolean;
  8488. /**
  8489. * Sets wether the vignette effect is enabled.
  8490. */
  8491. set vignetteEnabled(value: boolean);
  8492. private _applyByPostProcess;
  8493. /**
  8494. * Gets wether the image processing is applied through a post process or not.
  8495. */
  8496. get applyByPostProcess(): boolean;
  8497. /**
  8498. * Sets wether the image processing is applied through a post process or not.
  8499. */
  8500. set applyByPostProcess(value: boolean);
  8501. private _isEnabled;
  8502. /**
  8503. * Gets wether the image processing is enabled or not.
  8504. */
  8505. get isEnabled(): boolean;
  8506. /**
  8507. * Sets wether the image processing is enabled or not.
  8508. */
  8509. set isEnabled(value: boolean);
  8510. /**
  8511. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8512. */
  8513. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8514. /**
  8515. * Method called each time the image processing information changes requires to recompile the effect.
  8516. */
  8517. protected _updateParameters(): void;
  8518. /**
  8519. * Gets the current class name.
  8520. * @return "ImageProcessingConfiguration"
  8521. */
  8522. getClassName(): string;
  8523. /**
  8524. * Prepare the list of uniforms associated with the Image Processing effects.
  8525. * @param uniforms The list of uniforms used in the effect
  8526. * @param defines the list of defines currently in use
  8527. */
  8528. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8529. /**
  8530. * Prepare the list of samplers associated with the Image Processing effects.
  8531. * @param samplersList The list of uniforms used in the effect
  8532. * @param defines the list of defines currently in use
  8533. */
  8534. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8535. /**
  8536. * Prepare the list of defines associated to the shader.
  8537. * @param defines the list of defines to complete
  8538. * @param forPostProcess Define if we are currently in post process mode or not
  8539. */
  8540. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8541. /**
  8542. * Returns true if all the image processing information are ready.
  8543. * @returns True if ready, otherwise, false
  8544. */
  8545. isReady(): boolean;
  8546. /**
  8547. * Binds the image processing to the shader.
  8548. * @param effect The effect to bind to
  8549. * @param overrideAspectRatio Override the aspect ratio of the effect
  8550. */
  8551. bind(effect: Effect, overrideAspectRatio?: number): void;
  8552. /**
  8553. * Clones the current image processing instance.
  8554. * @return The cloned image processing
  8555. */
  8556. clone(): ImageProcessingConfiguration;
  8557. /**
  8558. * Serializes the current image processing instance to a json representation.
  8559. * @return a JSON representation
  8560. */
  8561. serialize(): any;
  8562. /**
  8563. * Parses the image processing from a json representation.
  8564. * @param source the JSON source to parse
  8565. * @return The parsed image processing
  8566. */
  8567. static Parse(source: any): ImageProcessingConfiguration;
  8568. private static _VIGNETTEMODE_MULTIPLY;
  8569. private static _VIGNETTEMODE_OPAQUE;
  8570. /**
  8571. * Used to apply the vignette as a mix with the pixel color.
  8572. */
  8573. static get VIGNETTEMODE_MULTIPLY(): number;
  8574. /**
  8575. * Used to apply the vignette as a replacement of the pixel color.
  8576. */
  8577. static get VIGNETTEMODE_OPAQUE(): number;
  8578. }
  8579. }
  8580. declare module "babylonjs/Shaders/postprocess.vertex" {
  8581. /** @hidden */
  8582. export var postprocessVertexShader: {
  8583. name: string;
  8584. shader: string;
  8585. };
  8586. }
  8587. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8588. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8589. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8590. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8591. module "babylonjs/Engines/thinEngine" {
  8592. interface ThinEngine {
  8593. /**
  8594. * Creates a new render target texture
  8595. * @param size defines the size of the texture
  8596. * @param options defines the options used to create the texture
  8597. * @returns a new render target texture stored in an InternalTexture
  8598. */
  8599. createRenderTargetTexture(size: number | {
  8600. width: number;
  8601. height: number;
  8602. layers?: number;
  8603. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8604. /**
  8605. * Creates a depth stencil texture.
  8606. * This is only available in WebGL 2 or with the depth texture extension available.
  8607. * @param size The size of face edge in the texture.
  8608. * @param options The options defining the texture.
  8609. * @returns The texture
  8610. */
  8611. createDepthStencilTexture(size: number | {
  8612. width: number;
  8613. height: number;
  8614. layers?: number;
  8615. }, options: DepthTextureCreationOptions): InternalTexture;
  8616. /** @hidden */
  8617. _createDepthStencilTexture(size: number | {
  8618. width: number;
  8619. height: number;
  8620. layers?: number;
  8621. }, options: DepthTextureCreationOptions): InternalTexture;
  8622. }
  8623. }
  8624. }
  8625. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8626. /**
  8627. * Defines the kind of connection point for node based material
  8628. */
  8629. export enum NodeMaterialBlockConnectionPointTypes {
  8630. /** Float */
  8631. Float = 1,
  8632. /** Int */
  8633. Int = 2,
  8634. /** Vector2 */
  8635. Vector2 = 4,
  8636. /** Vector3 */
  8637. Vector3 = 8,
  8638. /** Vector4 */
  8639. Vector4 = 16,
  8640. /** Color3 */
  8641. Color3 = 32,
  8642. /** Color4 */
  8643. Color4 = 64,
  8644. /** Matrix */
  8645. Matrix = 128,
  8646. /** Custom object */
  8647. Object = 256,
  8648. /** Detect type based on connection */
  8649. AutoDetect = 1024,
  8650. /** Output type that will be defined by input type */
  8651. BasedOnInput = 2048
  8652. }
  8653. }
  8654. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8655. /**
  8656. * Enum used to define the target of a block
  8657. */
  8658. export enum NodeMaterialBlockTargets {
  8659. /** Vertex shader */
  8660. Vertex = 1,
  8661. /** Fragment shader */
  8662. Fragment = 2,
  8663. /** Neutral */
  8664. Neutral = 4,
  8665. /** Vertex and Fragment */
  8666. VertexAndFragment = 3
  8667. }
  8668. }
  8669. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8670. /**
  8671. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8672. */
  8673. export enum NodeMaterialBlockConnectionPointMode {
  8674. /** Value is an uniform */
  8675. Uniform = 0,
  8676. /** Value is a mesh attribute */
  8677. Attribute = 1,
  8678. /** Value is a varying between vertex and fragment shaders */
  8679. Varying = 2,
  8680. /** Mode is undefined */
  8681. Undefined = 3
  8682. }
  8683. }
  8684. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8685. /**
  8686. * Enum used to define system values e.g. values automatically provided by the system
  8687. */
  8688. export enum NodeMaterialSystemValues {
  8689. /** World */
  8690. World = 1,
  8691. /** View */
  8692. View = 2,
  8693. /** Projection */
  8694. Projection = 3,
  8695. /** ViewProjection */
  8696. ViewProjection = 4,
  8697. /** WorldView */
  8698. WorldView = 5,
  8699. /** WorldViewProjection */
  8700. WorldViewProjection = 6,
  8701. /** CameraPosition */
  8702. CameraPosition = 7,
  8703. /** Fog Color */
  8704. FogColor = 8,
  8705. /** Delta time */
  8706. DeltaTime = 9
  8707. }
  8708. }
  8709. declare module "babylonjs/Maths/math.axis" {
  8710. import { Vector3 } from "babylonjs/Maths/math.vector";
  8711. /** Defines supported spaces */
  8712. export enum Space {
  8713. /** Local (object) space */
  8714. LOCAL = 0,
  8715. /** World space */
  8716. WORLD = 1,
  8717. /** Bone space */
  8718. BONE = 2
  8719. }
  8720. /** Defines the 3 main axes */
  8721. export class Axis {
  8722. /** X axis */
  8723. static X: Vector3;
  8724. /** Y axis */
  8725. static Y: Vector3;
  8726. /** Z axis */
  8727. static Z: Vector3;
  8728. }
  8729. }
  8730. declare module "babylonjs/Maths/math.frustum" {
  8731. import { Matrix } from "babylonjs/Maths/math.vector";
  8732. import { DeepImmutable } from "babylonjs/types";
  8733. import { Plane } from "babylonjs/Maths/math.plane";
  8734. /**
  8735. * Represents a camera frustum
  8736. */
  8737. export class Frustum {
  8738. /**
  8739. * Gets the planes representing the frustum
  8740. * @param transform matrix to be applied to the returned planes
  8741. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8742. */
  8743. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8744. /**
  8745. * Gets the near frustum plane transformed by the transform matrix
  8746. * @param transform transformation matrix to be applied to the resulting frustum plane
  8747. * @param frustumPlane the resuling frustum plane
  8748. */
  8749. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8750. /**
  8751. * Gets the far frustum plane transformed by the transform matrix
  8752. * @param transform transformation matrix to be applied to the resulting frustum plane
  8753. * @param frustumPlane the resuling frustum plane
  8754. */
  8755. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8756. /**
  8757. * Gets the left frustum plane transformed by the transform matrix
  8758. * @param transform transformation matrix to be applied to the resulting frustum plane
  8759. * @param frustumPlane the resuling frustum plane
  8760. */
  8761. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8762. /**
  8763. * Gets the right frustum plane transformed by the transform matrix
  8764. * @param transform transformation matrix to be applied to the resulting frustum plane
  8765. * @param frustumPlane the resuling frustum plane
  8766. */
  8767. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8768. /**
  8769. * Gets the top frustum plane transformed by the transform matrix
  8770. * @param transform transformation matrix to be applied to the resulting frustum plane
  8771. * @param frustumPlane the resuling frustum plane
  8772. */
  8773. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8774. /**
  8775. * Gets the bottom frustum plane transformed by the transform matrix
  8776. * @param transform transformation matrix to be applied to the resulting frustum plane
  8777. * @param frustumPlane the resuling frustum plane
  8778. */
  8779. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8780. /**
  8781. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8782. * @param transform transformation matrix to be applied to the resulting frustum planes
  8783. * @param frustumPlanes the resuling frustum planes
  8784. */
  8785. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8786. }
  8787. }
  8788. declare module "babylonjs/Maths/math.size" {
  8789. /**
  8790. * Interface for the size containing width and height
  8791. */
  8792. export interface ISize {
  8793. /**
  8794. * Width
  8795. */
  8796. width: number;
  8797. /**
  8798. * Heighht
  8799. */
  8800. height: number;
  8801. }
  8802. /**
  8803. * Size containing widht and height
  8804. */
  8805. export class Size implements ISize {
  8806. /**
  8807. * Width
  8808. */
  8809. width: number;
  8810. /**
  8811. * Height
  8812. */
  8813. height: number;
  8814. /**
  8815. * Creates a Size object from the given width and height (floats).
  8816. * @param width width of the new size
  8817. * @param height height of the new size
  8818. */
  8819. constructor(width: number, height: number);
  8820. /**
  8821. * Returns a string with the Size width and height
  8822. * @returns a string with the Size width and height
  8823. */
  8824. toString(): string;
  8825. /**
  8826. * "Size"
  8827. * @returns the string "Size"
  8828. */
  8829. getClassName(): string;
  8830. /**
  8831. * Returns the Size hash code.
  8832. * @returns a hash code for a unique width and height
  8833. */
  8834. getHashCode(): number;
  8835. /**
  8836. * Updates the current size from the given one.
  8837. * @param src the given size
  8838. */
  8839. copyFrom(src: Size): void;
  8840. /**
  8841. * Updates in place the current Size from the given floats.
  8842. * @param width width of the new size
  8843. * @param height height of the new size
  8844. * @returns the updated Size.
  8845. */
  8846. copyFromFloats(width: number, height: number): Size;
  8847. /**
  8848. * Updates in place the current Size from the given floats.
  8849. * @param width width to set
  8850. * @param height height to set
  8851. * @returns the updated Size.
  8852. */
  8853. set(width: number, height: number): Size;
  8854. /**
  8855. * Multiplies the width and height by numbers
  8856. * @param w factor to multiple the width by
  8857. * @param h factor to multiple the height by
  8858. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8859. */
  8860. multiplyByFloats(w: number, h: number): Size;
  8861. /**
  8862. * Clones the size
  8863. * @returns a new Size copied from the given one.
  8864. */
  8865. clone(): Size;
  8866. /**
  8867. * True if the current Size and the given one width and height are strictly equal.
  8868. * @param other the other size to compare against
  8869. * @returns True if the current Size and the given one width and height are strictly equal.
  8870. */
  8871. equals(other: Size): boolean;
  8872. /**
  8873. * The surface of the Size : width * height (float).
  8874. */
  8875. get surface(): number;
  8876. /**
  8877. * Create a new size of zero
  8878. * @returns a new Size set to (0.0, 0.0)
  8879. */
  8880. static Zero(): Size;
  8881. /**
  8882. * Sums the width and height of two sizes
  8883. * @param otherSize size to add to this size
  8884. * @returns a new Size set as the addition result of the current Size and the given one.
  8885. */
  8886. add(otherSize: Size): Size;
  8887. /**
  8888. * Subtracts the width and height of two
  8889. * @param otherSize size to subtract to this size
  8890. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8891. */
  8892. subtract(otherSize: Size): Size;
  8893. /**
  8894. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8895. * @param start starting size to lerp between
  8896. * @param end end size to lerp between
  8897. * @param amount amount to lerp between the start and end values
  8898. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8899. */
  8900. static Lerp(start: Size, end: Size, amount: number): Size;
  8901. }
  8902. }
  8903. declare module "babylonjs/Maths/math.vertexFormat" {
  8904. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8905. /**
  8906. * Contains position and normal vectors for a vertex
  8907. */
  8908. export class PositionNormalVertex {
  8909. /** the position of the vertex (defaut: 0,0,0) */
  8910. position: Vector3;
  8911. /** the normal of the vertex (defaut: 0,1,0) */
  8912. normal: Vector3;
  8913. /**
  8914. * Creates a PositionNormalVertex
  8915. * @param position the position of the vertex (defaut: 0,0,0)
  8916. * @param normal the normal of the vertex (defaut: 0,1,0)
  8917. */
  8918. constructor(
  8919. /** the position of the vertex (defaut: 0,0,0) */
  8920. position?: Vector3,
  8921. /** the normal of the vertex (defaut: 0,1,0) */
  8922. normal?: Vector3);
  8923. /**
  8924. * Clones the PositionNormalVertex
  8925. * @returns the cloned PositionNormalVertex
  8926. */
  8927. clone(): PositionNormalVertex;
  8928. }
  8929. /**
  8930. * Contains position, normal and uv vectors for a vertex
  8931. */
  8932. export class PositionNormalTextureVertex {
  8933. /** the position of the vertex (defaut: 0,0,0) */
  8934. position: Vector3;
  8935. /** the normal of the vertex (defaut: 0,1,0) */
  8936. normal: Vector3;
  8937. /** the uv of the vertex (default: 0,0) */
  8938. uv: Vector2;
  8939. /**
  8940. * Creates a PositionNormalTextureVertex
  8941. * @param position the position of the vertex (defaut: 0,0,0)
  8942. * @param normal the normal of the vertex (defaut: 0,1,0)
  8943. * @param uv the uv of the vertex (default: 0,0)
  8944. */
  8945. constructor(
  8946. /** the position of the vertex (defaut: 0,0,0) */
  8947. position?: Vector3,
  8948. /** the normal of the vertex (defaut: 0,1,0) */
  8949. normal?: Vector3,
  8950. /** the uv of the vertex (default: 0,0) */
  8951. uv?: Vector2);
  8952. /**
  8953. * Clones the PositionNormalTextureVertex
  8954. * @returns the cloned PositionNormalTextureVertex
  8955. */
  8956. clone(): PositionNormalTextureVertex;
  8957. }
  8958. }
  8959. declare module "babylonjs/Maths/math" {
  8960. export * from "babylonjs/Maths/math.axis";
  8961. export * from "babylonjs/Maths/math.color";
  8962. export * from "babylonjs/Maths/math.constants";
  8963. export * from "babylonjs/Maths/math.frustum";
  8964. export * from "babylonjs/Maths/math.path";
  8965. export * from "babylonjs/Maths/math.plane";
  8966. export * from "babylonjs/Maths/math.size";
  8967. export * from "babylonjs/Maths/math.vector";
  8968. export * from "babylonjs/Maths/math.vertexFormat";
  8969. export * from "babylonjs/Maths/math.viewport";
  8970. }
  8971. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  8972. /**
  8973. * Enum defining the type of animations supported by InputBlock
  8974. */
  8975. export enum AnimatedInputBlockTypes {
  8976. /** No animation */
  8977. None = 0,
  8978. /** Time based animation. Will only work for floats */
  8979. Time = 1
  8980. }
  8981. }
  8982. declare module "babylonjs/Lights/shadowLight" {
  8983. import { Camera } from "babylonjs/Cameras/camera";
  8984. import { Scene } from "babylonjs/scene";
  8985. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8987. import { Light } from "babylonjs/Lights/light";
  8988. /**
  8989. * Interface describing all the common properties and methods a shadow light needs to implement.
  8990. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8991. * as well as binding the different shadow properties to the effects.
  8992. */
  8993. export interface IShadowLight extends Light {
  8994. /**
  8995. * The light id in the scene (used in scene.findLighById for instance)
  8996. */
  8997. id: string;
  8998. /**
  8999. * The position the shdow will be casted from.
  9000. */
  9001. position: Vector3;
  9002. /**
  9003. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9004. */
  9005. direction: Vector3;
  9006. /**
  9007. * The transformed position. Position of the light in world space taking parenting in account.
  9008. */
  9009. transformedPosition: Vector3;
  9010. /**
  9011. * The transformed direction. Direction of the light in world space taking parenting in account.
  9012. */
  9013. transformedDirection: Vector3;
  9014. /**
  9015. * The friendly name of the light in the scene.
  9016. */
  9017. name: string;
  9018. /**
  9019. * Defines the shadow projection clipping minimum z value.
  9020. */
  9021. shadowMinZ: number;
  9022. /**
  9023. * Defines the shadow projection clipping maximum z value.
  9024. */
  9025. shadowMaxZ: number;
  9026. /**
  9027. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9028. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9029. */
  9030. computeTransformedInformation(): boolean;
  9031. /**
  9032. * Gets the scene the light belongs to.
  9033. * @returns The scene
  9034. */
  9035. getScene(): Scene;
  9036. /**
  9037. * Callback defining a custom Projection Matrix Builder.
  9038. * This can be used to override the default projection matrix computation.
  9039. */
  9040. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9041. /**
  9042. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9043. * @param matrix The materix to updated with the projection information
  9044. * @param viewMatrix The transform matrix of the light
  9045. * @param renderList The list of mesh to render in the map
  9046. * @returns The current light
  9047. */
  9048. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9049. /**
  9050. * Gets the current depth scale used in ESM.
  9051. * @returns The scale
  9052. */
  9053. getDepthScale(): number;
  9054. /**
  9055. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9056. * @returns true if a cube texture needs to be use
  9057. */
  9058. needCube(): boolean;
  9059. /**
  9060. * Detects if the projection matrix requires to be recomputed this frame.
  9061. * @returns true if it requires to be recomputed otherwise, false.
  9062. */
  9063. needProjectionMatrixCompute(): boolean;
  9064. /**
  9065. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9066. */
  9067. forceProjectionMatrixCompute(): void;
  9068. /**
  9069. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9070. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9071. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9072. */
  9073. getShadowDirection(faceIndex?: number): Vector3;
  9074. /**
  9075. * Gets the minZ used for shadow according to both the scene and the light.
  9076. * @param activeCamera The camera we are returning the min for
  9077. * @returns the depth min z
  9078. */
  9079. getDepthMinZ(activeCamera: Camera): number;
  9080. /**
  9081. * Gets the maxZ used for shadow according to both the scene and the light.
  9082. * @param activeCamera The camera we are returning the max for
  9083. * @returns the depth max z
  9084. */
  9085. getDepthMaxZ(activeCamera: Camera): number;
  9086. }
  9087. /**
  9088. * Base implementation IShadowLight
  9089. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9090. */
  9091. export abstract class ShadowLight extends Light implements IShadowLight {
  9092. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9093. protected _position: Vector3;
  9094. protected _setPosition(value: Vector3): void;
  9095. /**
  9096. * Sets the position the shadow will be casted from. Also use as the light position for both
  9097. * point and spot lights.
  9098. */
  9099. get position(): Vector3;
  9100. /**
  9101. * Sets the position the shadow will be casted from. Also use as the light position for both
  9102. * point and spot lights.
  9103. */
  9104. set position(value: Vector3);
  9105. protected _direction: Vector3;
  9106. protected _setDirection(value: Vector3): void;
  9107. /**
  9108. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9109. * Also use as the light direction on spot and directional lights.
  9110. */
  9111. get direction(): Vector3;
  9112. /**
  9113. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9114. * Also use as the light direction on spot and directional lights.
  9115. */
  9116. set direction(value: Vector3);
  9117. protected _shadowMinZ: number;
  9118. /**
  9119. * Gets the shadow projection clipping minimum z value.
  9120. */
  9121. get shadowMinZ(): number;
  9122. /**
  9123. * Sets the shadow projection clipping minimum z value.
  9124. */
  9125. set shadowMinZ(value: number);
  9126. protected _shadowMaxZ: number;
  9127. /**
  9128. * Sets the shadow projection clipping maximum z value.
  9129. */
  9130. get shadowMaxZ(): number;
  9131. /**
  9132. * Gets the shadow projection clipping maximum z value.
  9133. */
  9134. set shadowMaxZ(value: number);
  9135. /**
  9136. * Callback defining a custom Projection Matrix Builder.
  9137. * This can be used to override the default projection matrix computation.
  9138. */
  9139. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9140. /**
  9141. * The transformed position. Position of the light in world space taking parenting in account.
  9142. */
  9143. transformedPosition: Vector3;
  9144. /**
  9145. * The transformed direction. Direction of the light in world space taking parenting in account.
  9146. */
  9147. transformedDirection: Vector3;
  9148. private _needProjectionMatrixCompute;
  9149. /**
  9150. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9151. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9152. */
  9153. computeTransformedInformation(): boolean;
  9154. /**
  9155. * Return the depth scale used for the shadow map.
  9156. * @returns the depth scale.
  9157. */
  9158. getDepthScale(): number;
  9159. /**
  9160. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9161. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9162. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9163. */
  9164. getShadowDirection(faceIndex?: number): Vector3;
  9165. /**
  9166. * Returns the ShadowLight absolute position in the World.
  9167. * @returns the position vector in world space
  9168. */
  9169. getAbsolutePosition(): Vector3;
  9170. /**
  9171. * Sets the ShadowLight direction toward the passed target.
  9172. * @param target The point to target in local space
  9173. * @returns the updated ShadowLight direction
  9174. */
  9175. setDirectionToTarget(target: Vector3): Vector3;
  9176. /**
  9177. * Returns the light rotation in euler definition.
  9178. * @returns the x y z rotation in local space.
  9179. */
  9180. getRotation(): Vector3;
  9181. /**
  9182. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9183. * @returns true if a cube texture needs to be use
  9184. */
  9185. needCube(): boolean;
  9186. /**
  9187. * Detects if the projection matrix requires to be recomputed this frame.
  9188. * @returns true if it requires to be recomputed otherwise, false.
  9189. */
  9190. needProjectionMatrixCompute(): boolean;
  9191. /**
  9192. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9193. */
  9194. forceProjectionMatrixCompute(): void;
  9195. /** @hidden */
  9196. _initCache(): void;
  9197. /** @hidden */
  9198. _isSynchronized(): boolean;
  9199. /**
  9200. * Computes the world matrix of the node
  9201. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9202. * @returns the world matrix
  9203. */
  9204. computeWorldMatrix(force?: boolean): Matrix;
  9205. /**
  9206. * Gets the minZ used for shadow according to both the scene and the light.
  9207. * @param activeCamera The camera we are returning the min for
  9208. * @returns the depth min z
  9209. */
  9210. getDepthMinZ(activeCamera: Camera): number;
  9211. /**
  9212. * Gets the maxZ used for shadow according to both the scene and the light.
  9213. * @param activeCamera The camera we are returning the max for
  9214. * @returns the depth max z
  9215. */
  9216. getDepthMaxZ(activeCamera: Camera): number;
  9217. /**
  9218. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9219. * @param matrix The materix to updated with the projection information
  9220. * @param viewMatrix The transform matrix of the light
  9221. * @param renderList The list of mesh to render in the map
  9222. * @returns The current light
  9223. */
  9224. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9225. }
  9226. }
  9227. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9228. /** @hidden */
  9229. export var packingFunctions: {
  9230. name: string;
  9231. shader: string;
  9232. };
  9233. }
  9234. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9235. /** @hidden */
  9236. export var bayerDitherFunctions: {
  9237. name: string;
  9238. shader: string;
  9239. };
  9240. }
  9241. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9242. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9243. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9244. /** @hidden */
  9245. export var shadowMapFragmentDeclaration: {
  9246. name: string;
  9247. shader: string;
  9248. };
  9249. }
  9250. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9251. /** @hidden */
  9252. export var clipPlaneFragmentDeclaration: {
  9253. name: string;
  9254. shader: string;
  9255. };
  9256. }
  9257. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9258. /** @hidden */
  9259. export var clipPlaneFragment: {
  9260. name: string;
  9261. shader: string;
  9262. };
  9263. }
  9264. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9265. /** @hidden */
  9266. export var shadowMapFragment: {
  9267. name: string;
  9268. shader: string;
  9269. };
  9270. }
  9271. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9272. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9273. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9274. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9275. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9276. /** @hidden */
  9277. export var shadowMapPixelShader: {
  9278. name: string;
  9279. shader: string;
  9280. };
  9281. }
  9282. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9283. /** @hidden */
  9284. export var bonesDeclaration: {
  9285. name: string;
  9286. shader: string;
  9287. };
  9288. }
  9289. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9290. /** @hidden */
  9291. export var morphTargetsVertexGlobalDeclaration: {
  9292. name: string;
  9293. shader: string;
  9294. };
  9295. }
  9296. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9297. /** @hidden */
  9298. export var morphTargetsVertexDeclaration: {
  9299. name: string;
  9300. shader: string;
  9301. };
  9302. }
  9303. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9304. /** @hidden */
  9305. export var instancesDeclaration: {
  9306. name: string;
  9307. shader: string;
  9308. };
  9309. }
  9310. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9311. /** @hidden */
  9312. export var helperFunctions: {
  9313. name: string;
  9314. shader: string;
  9315. };
  9316. }
  9317. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9318. /** @hidden */
  9319. export var shadowMapVertexDeclaration: {
  9320. name: string;
  9321. shader: string;
  9322. };
  9323. }
  9324. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9325. /** @hidden */
  9326. export var clipPlaneVertexDeclaration: {
  9327. name: string;
  9328. shader: string;
  9329. };
  9330. }
  9331. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9332. /** @hidden */
  9333. export var morphTargetsVertex: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9339. /** @hidden */
  9340. export var instancesVertex: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9346. /** @hidden */
  9347. export var bonesVertex: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9353. /** @hidden */
  9354. export var shadowMapVertexNormalBias: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9360. /** @hidden */
  9361. export var shadowMapVertexMetric: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9367. /** @hidden */
  9368. export var clipPlaneVertex: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9374. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9375. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9376. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9377. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9378. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9379. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9380. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9381. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9382. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9383. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9384. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9385. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9386. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9387. /** @hidden */
  9388. export var shadowMapVertexShader: {
  9389. name: string;
  9390. shader: string;
  9391. };
  9392. }
  9393. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9394. /** @hidden */
  9395. export var depthBoxBlurPixelShader: {
  9396. name: string;
  9397. shader: string;
  9398. };
  9399. }
  9400. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9401. /** @hidden */
  9402. export var shadowMapFragmentSoftTransparentShadow: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Materials/effectFallbacks" {
  9408. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9409. import { Effect } from "babylonjs/Materials/effect";
  9410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9411. /**
  9412. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9413. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9414. */
  9415. export class EffectFallbacks implements IEffectFallbacks {
  9416. private _defines;
  9417. private _currentRank;
  9418. private _maxRank;
  9419. private _mesh;
  9420. /**
  9421. * Removes the fallback from the bound mesh.
  9422. */
  9423. unBindMesh(): void;
  9424. /**
  9425. * Adds a fallback on the specified property.
  9426. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9427. * @param define The name of the define in the shader
  9428. */
  9429. addFallback(rank: number, define: string): void;
  9430. /**
  9431. * Sets the mesh to use CPU skinning when needing to fallback.
  9432. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9433. * @param mesh The mesh to use the fallbacks.
  9434. */
  9435. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9436. /**
  9437. * Checks to see if more fallbacks are still availible.
  9438. */
  9439. get hasMoreFallbacks(): boolean;
  9440. /**
  9441. * Removes the defines that should be removed when falling back.
  9442. * @param currentDefines defines the current define statements for the shader.
  9443. * @param effect defines the current effect we try to compile
  9444. * @returns The resulting defines with defines of the current rank removed.
  9445. */
  9446. reduce(currentDefines: string, effect: Effect): string;
  9447. }
  9448. }
  9449. declare module "babylonjs/Actions/action" {
  9450. import { Observable } from "babylonjs/Misc/observable";
  9451. import { Condition } from "babylonjs/Actions/condition";
  9452. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9453. import { ActionManager } from "babylonjs/Actions/actionManager";
  9454. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9455. /**
  9456. * Interface used to define Action
  9457. */
  9458. export interface IAction {
  9459. /**
  9460. * Trigger for the action
  9461. */
  9462. trigger: number;
  9463. /** Options of the trigger */
  9464. triggerOptions: any;
  9465. /**
  9466. * Gets the trigger parameters
  9467. * @returns the trigger parameters
  9468. */
  9469. getTriggerParameter(): any;
  9470. /**
  9471. * Internal only - executes current action event
  9472. * @hidden
  9473. */
  9474. _executeCurrent(evt?: ActionEvent): void;
  9475. /**
  9476. * Serialize placeholder for child classes
  9477. * @param parent of child
  9478. * @returns the serialized object
  9479. */
  9480. serialize(parent: any): any;
  9481. /**
  9482. * Internal only
  9483. * @hidden
  9484. */
  9485. _prepare(): void;
  9486. /**
  9487. * Internal only - manager for action
  9488. * @hidden
  9489. */
  9490. _actionManager: AbstractActionManager;
  9491. /**
  9492. * Adds action to chain of actions, may be a DoNothingAction
  9493. * @param action defines the next action to execute
  9494. * @returns The action passed in
  9495. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9496. */
  9497. then(action: IAction): IAction;
  9498. }
  9499. /**
  9500. * The action to be carried out following a trigger
  9501. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9502. */
  9503. export class Action implements IAction {
  9504. /** the trigger, with or without parameters, for the action */
  9505. triggerOptions: any;
  9506. /**
  9507. * Trigger for the action
  9508. */
  9509. trigger: number;
  9510. /**
  9511. * Internal only - manager for action
  9512. * @hidden
  9513. */
  9514. _actionManager: ActionManager;
  9515. private _nextActiveAction;
  9516. private _child;
  9517. private _condition?;
  9518. private _triggerParameter;
  9519. /**
  9520. * An event triggered prior to action being executed.
  9521. */
  9522. onBeforeExecuteObservable: Observable<Action>;
  9523. /**
  9524. * Creates a new Action
  9525. * @param triggerOptions the trigger, with or without parameters, for the action
  9526. * @param condition an optional determinant of action
  9527. */
  9528. constructor(
  9529. /** the trigger, with or without parameters, for the action */
  9530. triggerOptions: any, condition?: Condition);
  9531. /**
  9532. * Internal only
  9533. * @hidden
  9534. */
  9535. _prepare(): void;
  9536. /**
  9537. * Gets the trigger parameters
  9538. * @returns the trigger parameters
  9539. */
  9540. getTriggerParameter(): any;
  9541. /**
  9542. * Internal only - executes current action event
  9543. * @hidden
  9544. */
  9545. _executeCurrent(evt?: ActionEvent): void;
  9546. /**
  9547. * Execute placeholder for child classes
  9548. * @param evt optional action event
  9549. */
  9550. execute(evt?: ActionEvent): void;
  9551. /**
  9552. * Skips to next active action
  9553. */
  9554. skipToNextActiveAction(): void;
  9555. /**
  9556. * Adds action to chain of actions, may be a DoNothingAction
  9557. * @param action defines the next action to execute
  9558. * @returns The action passed in
  9559. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9560. */
  9561. then(action: Action): Action;
  9562. /**
  9563. * Internal only
  9564. * @hidden
  9565. */
  9566. _getProperty(propertyPath: string): string;
  9567. /**
  9568. * Internal only
  9569. * @hidden
  9570. */
  9571. _getEffectiveTarget(target: any, propertyPath: string): any;
  9572. /**
  9573. * Serialize placeholder for child classes
  9574. * @param parent of child
  9575. * @returns the serialized object
  9576. */
  9577. serialize(parent: any): any;
  9578. /**
  9579. * Internal only called by serialize
  9580. * @hidden
  9581. */
  9582. protected _serialize(serializedAction: any, parent?: any): any;
  9583. /**
  9584. * Internal only
  9585. * @hidden
  9586. */
  9587. static _SerializeValueAsString: (value: any) => string;
  9588. /**
  9589. * Internal only
  9590. * @hidden
  9591. */
  9592. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  9593. name: string;
  9594. targetType: string;
  9595. value: string;
  9596. };
  9597. }
  9598. }
  9599. declare module "babylonjs/Actions/condition" {
  9600. import { ActionManager } from "babylonjs/Actions/actionManager";
  9601. /**
  9602. * A Condition applied to an Action
  9603. */
  9604. export class Condition {
  9605. /**
  9606. * Internal only - manager for action
  9607. * @hidden
  9608. */
  9609. _actionManager: ActionManager;
  9610. /**
  9611. * Internal only
  9612. * @hidden
  9613. */
  9614. _evaluationId: number;
  9615. /**
  9616. * Internal only
  9617. * @hidden
  9618. */
  9619. _currentResult: boolean;
  9620. /**
  9621. * Creates a new Condition
  9622. * @param actionManager the manager of the action the condition is applied to
  9623. */
  9624. constructor(actionManager: ActionManager);
  9625. /**
  9626. * Check if the current condition is valid
  9627. * @returns a boolean
  9628. */
  9629. isValid(): boolean;
  9630. /**
  9631. * Internal only
  9632. * @hidden
  9633. */
  9634. _getProperty(propertyPath: string): string;
  9635. /**
  9636. * Internal only
  9637. * @hidden
  9638. */
  9639. _getEffectiveTarget(target: any, propertyPath: string): any;
  9640. /**
  9641. * Serialize placeholder for child classes
  9642. * @returns the serialized object
  9643. */
  9644. serialize(): any;
  9645. /**
  9646. * Internal only
  9647. * @hidden
  9648. */
  9649. protected _serialize(serializedCondition: any): any;
  9650. }
  9651. /**
  9652. * Defines specific conditional operators as extensions of Condition
  9653. */
  9654. export class ValueCondition extends Condition {
  9655. /** path to specify the property of the target the conditional operator uses */
  9656. propertyPath: string;
  9657. /** the value compared by the conditional operator against the current value of the property */
  9658. value: any;
  9659. /** the conditional operator, default ValueCondition.IsEqual */
  9660. operator: number;
  9661. /**
  9662. * Internal only
  9663. * @hidden
  9664. */
  9665. private static _IsEqual;
  9666. /**
  9667. * Internal only
  9668. * @hidden
  9669. */
  9670. private static _IsDifferent;
  9671. /**
  9672. * Internal only
  9673. * @hidden
  9674. */
  9675. private static _IsGreater;
  9676. /**
  9677. * Internal only
  9678. * @hidden
  9679. */
  9680. private static _IsLesser;
  9681. /**
  9682. * returns the number for IsEqual
  9683. */
  9684. static get IsEqual(): number;
  9685. /**
  9686. * Returns the number for IsDifferent
  9687. */
  9688. static get IsDifferent(): number;
  9689. /**
  9690. * Returns the number for IsGreater
  9691. */
  9692. static get IsGreater(): number;
  9693. /**
  9694. * Returns the number for IsLesser
  9695. */
  9696. static get IsLesser(): number;
  9697. /**
  9698. * Internal only The action manager for the condition
  9699. * @hidden
  9700. */
  9701. _actionManager: ActionManager;
  9702. /**
  9703. * Internal only
  9704. * @hidden
  9705. */
  9706. private _target;
  9707. /**
  9708. * Internal only
  9709. * @hidden
  9710. */
  9711. private _effectiveTarget;
  9712. /**
  9713. * Internal only
  9714. * @hidden
  9715. */
  9716. private _property;
  9717. /**
  9718. * Creates a new ValueCondition
  9719. * @param actionManager manager for the action the condition applies to
  9720. * @param target for the action
  9721. * @param propertyPath path to specify the property of the target the conditional operator uses
  9722. * @param value the value compared by the conditional operator against the current value of the property
  9723. * @param operator the conditional operator, default ValueCondition.IsEqual
  9724. */
  9725. constructor(actionManager: ActionManager, target: any,
  9726. /** path to specify the property of the target the conditional operator uses */
  9727. propertyPath: string,
  9728. /** the value compared by the conditional operator against the current value of the property */
  9729. value: any,
  9730. /** the conditional operator, default ValueCondition.IsEqual */
  9731. operator?: number);
  9732. /**
  9733. * Compares the given value with the property value for the specified conditional operator
  9734. * @returns the result of the comparison
  9735. */
  9736. isValid(): boolean;
  9737. /**
  9738. * Serialize the ValueCondition into a JSON compatible object
  9739. * @returns serialization object
  9740. */
  9741. serialize(): any;
  9742. /**
  9743. * Gets the name of the conditional operator for the ValueCondition
  9744. * @param operator the conditional operator
  9745. * @returns the name
  9746. */
  9747. static GetOperatorName(operator: number): string;
  9748. }
  9749. /**
  9750. * Defines a predicate condition as an extension of Condition
  9751. */
  9752. export class PredicateCondition extends Condition {
  9753. /** defines the predicate function used to validate the condition */
  9754. predicate: () => boolean;
  9755. /**
  9756. * Internal only - manager for action
  9757. * @hidden
  9758. */
  9759. _actionManager: ActionManager;
  9760. /**
  9761. * Creates a new PredicateCondition
  9762. * @param actionManager manager for the action the condition applies to
  9763. * @param predicate defines the predicate function used to validate the condition
  9764. */
  9765. constructor(actionManager: ActionManager,
  9766. /** defines the predicate function used to validate the condition */
  9767. predicate: () => boolean);
  9768. /**
  9769. * @returns the validity of the predicate condition
  9770. */
  9771. isValid(): boolean;
  9772. }
  9773. /**
  9774. * Defines a state condition as an extension of Condition
  9775. */
  9776. export class StateCondition extends Condition {
  9777. /** Value to compare with target state */
  9778. value: string;
  9779. /**
  9780. * Internal only - manager for action
  9781. * @hidden
  9782. */
  9783. _actionManager: ActionManager;
  9784. /**
  9785. * Internal only
  9786. * @hidden
  9787. */
  9788. private _target;
  9789. /**
  9790. * Creates a new StateCondition
  9791. * @param actionManager manager for the action the condition applies to
  9792. * @param target of the condition
  9793. * @param value to compare with target state
  9794. */
  9795. constructor(actionManager: ActionManager, target: any,
  9796. /** Value to compare with target state */
  9797. value: string);
  9798. /**
  9799. * Gets a boolean indicating if the current condition is met
  9800. * @returns the validity of the state
  9801. */
  9802. isValid(): boolean;
  9803. /**
  9804. * Serialize the StateCondition into a JSON compatible object
  9805. * @returns serialization object
  9806. */
  9807. serialize(): any;
  9808. }
  9809. }
  9810. declare module "babylonjs/Actions/directActions" {
  9811. import { Action } from "babylonjs/Actions/action";
  9812. import { Condition } from "babylonjs/Actions/condition";
  9813. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9814. /**
  9815. * This defines an action responsible to toggle a boolean once triggered.
  9816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9817. */
  9818. export class SwitchBooleanAction extends Action {
  9819. /**
  9820. * The path to the boolean property in the target object
  9821. */
  9822. propertyPath: string;
  9823. private _target;
  9824. private _effectiveTarget;
  9825. private _property;
  9826. /**
  9827. * Instantiate the action
  9828. * @param triggerOptions defines the trigger options
  9829. * @param target defines the object containing the boolean
  9830. * @param propertyPath defines the path to the boolean property in the target object
  9831. * @param condition defines the trigger related conditions
  9832. */
  9833. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9834. /** @hidden */
  9835. _prepare(): void;
  9836. /**
  9837. * Execute the action toggle the boolean value.
  9838. */
  9839. execute(): void;
  9840. /**
  9841. * Serializes the actions and its related information.
  9842. * @param parent defines the object to serialize in
  9843. * @returns the serialized object
  9844. */
  9845. serialize(parent: any): any;
  9846. }
  9847. /**
  9848. * This defines an action responsible to set a the state field of the target
  9849. * to a desired value once triggered.
  9850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9851. */
  9852. export class SetStateAction extends Action {
  9853. /**
  9854. * The value to store in the state field.
  9855. */
  9856. value: string;
  9857. private _target;
  9858. /**
  9859. * Instantiate the action
  9860. * @param triggerOptions defines the trigger options
  9861. * @param target defines the object containing the state property
  9862. * @param value defines the value to store in the state field
  9863. * @param condition defines the trigger related conditions
  9864. */
  9865. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9866. /**
  9867. * Execute the action and store the value on the target state property.
  9868. */
  9869. execute(): void;
  9870. /**
  9871. * Serializes the actions and its related information.
  9872. * @param parent defines the object to serialize in
  9873. * @returns the serialized object
  9874. */
  9875. serialize(parent: any): any;
  9876. }
  9877. /**
  9878. * This defines an action responsible to set a property of the target
  9879. * to a desired value once triggered.
  9880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9881. */
  9882. export class SetValueAction extends Action {
  9883. /**
  9884. * The path of the property to set in the target.
  9885. */
  9886. propertyPath: string;
  9887. /**
  9888. * The value to set in the property
  9889. */
  9890. value: any;
  9891. private _target;
  9892. private _effectiveTarget;
  9893. private _property;
  9894. /**
  9895. * Instantiate the action
  9896. * @param triggerOptions defines the trigger options
  9897. * @param target defines the object containing the property
  9898. * @param propertyPath defines the path of the property to set in the target
  9899. * @param value defines the value to set in the property
  9900. * @param condition defines the trigger related conditions
  9901. */
  9902. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9903. /** @hidden */
  9904. _prepare(): void;
  9905. /**
  9906. * Execute the action and set the targetted property to the desired value.
  9907. */
  9908. execute(): void;
  9909. /**
  9910. * Serializes the actions and its related information.
  9911. * @param parent defines the object to serialize in
  9912. * @returns the serialized object
  9913. */
  9914. serialize(parent: any): any;
  9915. }
  9916. /**
  9917. * This defines an action responsible to increment the target value
  9918. * to a desired value once triggered.
  9919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9920. */
  9921. export class IncrementValueAction extends Action {
  9922. /**
  9923. * The path of the property to increment in the target.
  9924. */
  9925. propertyPath: string;
  9926. /**
  9927. * The value we should increment the property by.
  9928. */
  9929. value: any;
  9930. private _target;
  9931. private _effectiveTarget;
  9932. private _property;
  9933. /**
  9934. * Instantiate the action
  9935. * @param triggerOptions defines the trigger options
  9936. * @param target defines the object containing the property
  9937. * @param propertyPath defines the path of the property to increment in the target
  9938. * @param value defines the value value we should increment the property by
  9939. * @param condition defines the trigger related conditions
  9940. */
  9941. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9942. /** @hidden */
  9943. _prepare(): void;
  9944. /**
  9945. * Execute the action and increment the target of the value amount.
  9946. */
  9947. execute(): void;
  9948. /**
  9949. * Serializes the actions and its related information.
  9950. * @param parent defines the object to serialize in
  9951. * @returns the serialized object
  9952. */
  9953. serialize(parent: any): any;
  9954. }
  9955. /**
  9956. * This defines an action responsible to start an animation once triggered.
  9957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9958. */
  9959. export class PlayAnimationAction extends Action {
  9960. /**
  9961. * Where the animation should start (animation frame)
  9962. */
  9963. from: number;
  9964. /**
  9965. * Where the animation should stop (animation frame)
  9966. */
  9967. to: number;
  9968. /**
  9969. * Define if the animation should loop or stop after the first play.
  9970. */
  9971. loop?: boolean;
  9972. private _target;
  9973. /**
  9974. * Instantiate the action
  9975. * @param triggerOptions defines the trigger options
  9976. * @param target defines the target animation or animation name
  9977. * @param from defines from where the animation should start (animation frame)
  9978. * @param end defines where the animation should stop (animation frame)
  9979. * @param loop defines if the animation should loop or stop after the first play
  9980. * @param condition defines the trigger related conditions
  9981. */
  9982. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9983. /** @hidden */
  9984. _prepare(): void;
  9985. /**
  9986. * Execute the action and play the animation.
  9987. */
  9988. execute(): void;
  9989. /**
  9990. * Serializes the actions and its related information.
  9991. * @param parent defines the object to serialize in
  9992. * @returns the serialized object
  9993. */
  9994. serialize(parent: any): any;
  9995. }
  9996. /**
  9997. * This defines an action responsible to stop an animation once triggered.
  9998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9999. */
  10000. export class StopAnimationAction extends Action {
  10001. private _target;
  10002. /**
  10003. * Instantiate the action
  10004. * @param triggerOptions defines the trigger options
  10005. * @param target defines the target animation or animation name
  10006. * @param condition defines the trigger related conditions
  10007. */
  10008. constructor(triggerOptions: any, target: any, condition?: Condition);
  10009. /** @hidden */
  10010. _prepare(): void;
  10011. /**
  10012. * Execute the action and stop the animation.
  10013. */
  10014. execute(): void;
  10015. /**
  10016. * Serializes the actions and its related information.
  10017. * @param parent defines the object to serialize in
  10018. * @returns the serialized object
  10019. */
  10020. serialize(parent: any): any;
  10021. }
  10022. /**
  10023. * This defines an action responsible that does nothing once triggered.
  10024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10025. */
  10026. export class DoNothingAction extends Action {
  10027. /**
  10028. * Instantiate the action
  10029. * @param triggerOptions defines the trigger options
  10030. * @param condition defines the trigger related conditions
  10031. */
  10032. constructor(triggerOptions?: any, condition?: Condition);
  10033. /**
  10034. * Execute the action and do nothing.
  10035. */
  10036. execute(): void;
  10037. /**
  10038. * Serializes the actions and its related information.
  10039. * @param parent defines the object to serialize in
  10040. * @returns the serialized object
  10041. */
  10042. serialize(parent: any): any;
  10043. }
  10044. /**
  10045. * This defines an action responsible to trigger several actions once triggered.
  10046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10047. */
  10048. export class CombineAction extends Action {
  10049. /**
  10050. * The list of aggregated animations to run.
  10051. */
  10052. children: Action[];
  10053. /**
  10054. * Instantiate the action
  10055. * @param triggerOptions defines the trigger options
  10056. * @param children defines the list of aggregated animations to run
  10057. * @param condition defines the trigger related conditions
  10058. */
  10059. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10060. /** @hidden */
  10061. _prepare(): void;
  10062. /**
  10063. * Execute the action and executes all the aggregated actions.
  10064. */
  10065. execute(evt: ActionEvent): void;
  10066. /**
  10067. * Serializes the actions and its related information.
  10068. * @param parent defines the object to serialize in
  10069. * @returns the serialized object
  10070. */
  10071. serialize(parent: any): any;
  10072. }
  10073. /**
  10074. * This defines an action responsible to run code (external event) once triggered.
  10075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10076. */
  10077. export class ExecuteCodeAction extends Action {
  10078. /**
  10079. * The callback function to run.
  10080. */
  10081. func: (evt: ActionEvent) => void;
  10082. /**
  10083. * Instantiate the action
  10084. * @param triggerOptions defines the trigger options
  10085. * @param func defines the callback function to run
  10086. * @param condition defines the trigger related conditions
  10087. */
  10088. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10089. /**
  10090. * Execute the action and run the attached code.
  10091. */
  10092. execute(evt: ActionEvent): void;
  10093. }
  10094. /**
  10095. * This defines an action responsible to set the parent property of the target once triggered.
  10096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10097. */
  10098. export class SetParentAction extends Action {
  10099. private _parent;
  10100. private _target;
  10101. /**
  10102. * Instantiate the action
  10103. * @param triggerOptions defines the trigger options
  10104. * @param target defines the target containing the parent property
  10105. * @param parent defines from where the animation should start (animation frame)
  10106. * @param condition defines the trigger related conditions
  10107. */
  10108. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10109. /** @hidden */
  10110. _prepare(): void;
  10111. /**
  10112. * Execute the action and set the parent property.
  10113. */
  10114. execute(): void;
  10115. /**
  10116. * Serializes the actions and its related information.
  10117. * @param parent defines the object to serialize in
  10118. * @returns the serialized object
  10119. */
  10120. serialize(parent: any): any;
  10121. }
  10122. }
  10123. declare module "babylonjs/Actions/actionManager" {
  10124. import { Nullable } from "babylonjs/types";
  10125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10126. import { Scene } from "babylonjs/scene";
  10127. import { IAction } from "babylonjs/Actions/action";
  10128. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10129. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10130. /**
  10131. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10132. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10134. */
  10135. export class ActionManager extends AbstractActionManager {
  10136. /**
  10137. * Nothing
  10138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10139. */
  10140. static readonly NothingTrigger: number;
  10141. /**
  10142. * On pick
  10143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10144. */
  10145. static readonly OnPickTrigger: number;
  10146. /**
  10147. * On left pick
  10148. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10149. */
  10150. static readonly OnLeftPickTrigger: number;
  10151. /**
  10152. * On right pick
  10153. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10154. */
  10155. static readonly OnRightPickTrigger: number;
  10156. /**
  10157. * On center pick
  10158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10159. */
  10160. static readonly OnCenterPickTrigger: number;
  10161. /**
  10162. * On pick down
  10163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10164. */
  10165. static readonly OnPickDownTrigger: number;
  10166. /**
  10167. * On double pick
  10168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10169. */
  10170. static readonly OnDoublePickTrigger: number;
  10171. /**
  10172. * On pick up
  10173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10174. */
  10175. static readonly OnPickUpTrigger: number;
  10176. /**
  10177. * On pick out.
  10178. * This trigger will only be raised if you also declared a OnPickDown
  10179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10180. */
  10181. static readonly OnPickOutTrigger: number;
  10182. /**
  10183. * On long press
  10184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10185. */
  10186. static readonly OnLongPressTrigger: number;
  10187. /**
  10188. * On pointer over
  10189. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10190. */
  10191. static readonly OnPointerOverTrigger: number;
  10192. /**
  10193. * On pointer out
  10194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10195. */
  10196. static readonly OnPointerOutTrigger: number;
  10197. /**
  10198. * On every frame
  10199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10200. */
  10201. static readonly OnEveryFrameTrigger: number;
  10202. /**
  10203. * On intersection enter
  10204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10205. */
  10206. static readonly OnIntersectionEnterTrigger: number;
  10207. /**
  10208. * On intersection exit
  10209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10210. */
  10211. static readonly OnIntersectionExitTrigger: number;
  10212. /**
  10213. * On key down
  10214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10215. */
  10216. static readonly OnKeyDownTrigger: number;
  10217. /**
  10218. * On key up
  10219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10220. */
  10221. static readonly OnKeyUpTrigger: number;
  10222. private _scene;
  10223. /**
  10224. * Creates a new action manager
  10225. * @param scene defines the hosting scene
  10226. */
  10227. constructor(scene: Scene);
  10228. /**
  10229. * Releases all associated resources
  10230. */
  10231. dispose(): void;
  10232. /**
  10233. * Gets hosting scene
  10234. * @returns the hosting scene
  10235. */
  10236. getScene(): Scene;
  10237. /**
  10238. * Does this action manager handles actions of any of the given triggers
  10239. * @param triggers defines the triggers to be tested
  10240. * @return a boolean indicating whether one (or more) of the triggers is handled
  10241. */
  10242. hasSpecificTriggers(triggers: number[]): boolean;
  10243. /**
  10244. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10245. * speed.
  10246. * @param triggerA defines the trigger to be tested
  10247. * @param triggerB defines the trigger to be tested
  10248. * @return a boolean indicating whether one (or more) of the triggers is handled
  10249. */
  10250. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10251. /**
  10252. * Does this action manager handles actions of a given trigger
  10253. * @param trigger defines the trigger to be tested
  10254. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10255. * @return whether the trigger is handled
  10256. */
  10257. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10258. /**
  10259. * Does this action manager has pointer triggers
  10260. */
  10261. get hasPointerTriggers(): boolean;
  10262. /**
  10263. * Does this action manager has pick triggers
  10264. */
  10265. get hasPickTriggers(): boolean;
  10266. /**
  10267. * Registers an action to this action manager
  10268. * @param action defines the action to be registered
  10269. * @return the action amended (prepared) after registration
  10270. */
  10271. registerAction(action: IAction): Nullable<IAction>;
  10272. /**
  10273. * Unregisters an action to this action manager
  10274. * @param action defines the action to be unregistered
  10275. * @return a boolean indicating whether the action has been unregistered
  10276. */
  10277. unregisterAction(action: IAction): Boolean;
  10278. /**
  10279. * Process a specific trigger
  10280. * @param trigger defines the trigger to process
  10281. * @param evt defines the event details to be processed
  10282. */
  10283. processTrigger(trigger: number, evt?: IActionEvent): void;
  10284. /** @hidden */
  10285. _getEffectiveTarget(target: any, propertyPath: string): any;
  10286. /** @hidden */
  10287. _getProperty(propertyPath: string): string;
  10288. /**
  10289. * Serialize this manager to a JSON object
  10290. * @param name defines the property name to store this manager
  10291. * @returns a JSON representation of this manager
  10292. */
  10293. serialize(name: string): any;
  10294. /**
  10295. * Creates a new ActionManager from a JSON data
  10296. * @param parsedActions defines the JSON data to read from
  10297. * @param object defines the hosting mesh
  10298. * @param scene defines the hosting scene
  10299. */
  10300. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10301. /**
  10302. * Get a trigger name by index
  10303. * @param trigger defines the trigger index
  10304. * @returns a trigger name
  10305. */
  10306. static GetTriggerName(trigger: number): string;
  10307. }
  10308. }
  10309. declare module "babylonjs/Sprites/sprite" {
  10310. import { Vector3 } from "babylonjs/Maths/math.vector";
  10311. import { Nullable } from "babylonjs/types";
  10312. import { ActionManager } from "babylonjs/Actions/actionManager";
  10313. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10314. import { Color4 } from "babylonjs/Maths/math.color";
  10315. import { Observable } from "babylonjs/Misc/observable";
  10316. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10317. import { Animation } from "babylonjs/Animations/animation";
  10318. /**
  10319. * Class used to represent a sprite
  10320. * @see http://doc.babylonjs.com/babylon101/sprites
  10321. */
  10322. export class Sprite implements IAnimatable {
  10323. /** defines the name */
  10324. name: string;
  10325. /** Gets or sets the current world position */
  10326. position: Vector3;
  10327. /** Gets or sets the main color */
  10328. color: Color4;
  10329. /** Gets or sets the width */
  10330. width: number;
  10331. /** Gets or sets the height */
  10332. height: number;
  10333. /** Gets or sets rotation angle */
  10334. angle: number;
  10335. /** Gets or sets the cell index in the sprite sheet */
  10336. cellIndex: number;
  10337. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10338. cellRef: string;
  10339. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10340. invertU: boolean;
  10341. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10342. invertV: boolean;
  10343. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10344. disposeWhenFinishedAnimating: boolean;
  10345. /** Gets the list of attached animations */
  10346. animations: Nullable<Array<Animation>>;
  10347. /** Gets or sets a boolean indicating if the sprite can be picked */
  10348. isPickable: boolean;
  10349. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10350. useAlphaForPicking: boolean;
  10351. /** @hidden */
  10352. _xOffset: number;
  10353. /** @hidden */
  10354. _yOffset: number;
  10355. /** @hidden */
  10356. _xSize: number;
  10357. /** @hidden */
  10358. _ySize: number;
  10359. /**
  10360. * Gets or sets the associated action manager
  10361. */
  10362. actionManager: Nullable<ActionManager>;
  10363. /**
  10364. * An event triggered when the control has been disposed
  10365. */
  10366. onDisposeObservable: Observable<Sprite>;
  10367. private _animationStarted;
  10368. private _loopAnimation;
  10369. private _fromIndex;
  10370. private _toIndex;
  10371. private _delay;
  10372. private _direction;
  10373. private _manager;
  10374. private _time;
  10375. private _onAnimationEnd;
  10376. /**
  10377. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10378. */
  10379. isVisible: boolean;
  10380. /**
  10381. * Gets or sets the sprite size
  10382. */
  10383. get size(): number;
  10384. set size(value: number);
  10385. /**
  10386. * Returns a boolean indicating if the animation is started
  10387. */
  10388. get animationStarted(): boolean;
  10389. /**
  10390. * Gets or sets the unique id of the sprite
  10391. */
  10392. uniqueId: number;
  10393. /**
  10394. * Gets the manager of this sprite
  10395. */
  10396. get manager(): ISpriteManager;
  10397. /**
  10398. * Creates a new Sprite
  10399. * @param name defines the name
  10400. * @param manager defines the manager
  10401. */
  10402. constructor(
  10403. /** defines the name */
  10404. name: string, manager: ISpriteManager);
  10405. /**
  10406. * Returns the string "Sprite"
  10407. * @returns "Sprite"
  10408. */
  10409. getClassName(): string;
  10410. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10411. get fromIndex(): number;
  10412. set fromIndex(value: number);
  10413. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10414. get toIndex(): number;
  10415. set toIndex(value: number);
  10416. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10417. get loopAnimation(): boolean;
  10418. set loopAnimation(value: boolean);
  10419. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10420. get delay(): number;
  10421. set delay(value: number);
  10422. /**
  10423. * Starts an animation
  10424. * @param from defines the initial key
  10425. * @param to defines the end key
  10426. * @param loop defines if the animation must loop
  10427. * @param delay defines the start delay (in ms)
  10428. * @param onAnimationEnd defines a callback to call when animation ends
  10429. */
  10430. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10431. /** Stops current animation (if any) */
  10432. stopAnimation(): void;
  10433. /** @hidden */
  10434. _animate(deltaTime: number): void;
  10435. /** Release associated resources */
  10436. dispose(): void;
  10437. /**
  10438. * Serializes the sprite to a JSON object
  10439. * @returns the JSON object
  10440. */
  10441. serialize(): any;
  10442. /**
  10443. * Parses a JSON object to create a new sprite
  10444. * @param parsedSprite The JSON object to parse
  10445. * @param manager defines the hosting manager
  10446. * @returns the new sprite
  10447. */
  10448. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10449. }
  10450. }
  10451. declare module "babylonjs/Collisions/pickingInfo" {
  10452. import { Nullable } from "babylonjs/types";
  10453. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10455. import { Sprite } from "babylonjs/Sprites/sprite";
  10456. import { Ray } from "babylonjs/Culling/ray";
  10457. /**
  10458. * Information about the result of picking within a scene
  10459. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10460. */
  10461. export class PickingInfo {
  10462. /** @hidden */
  10463. _pickingUnavailable: boolean;
  10464. /**
  10465. * If the pick collided with an object
  10466. */
  10467. hit: boolean;
  10468. /**
  10469. * Distance away where the pick collided
  10470. */
  10471. distance: number;
  10472. /**
  10473. * The location of pick collision
  10474. */
  10475. pickedPoint: Nullable<Vector3>;
  10476. /**
  10477. * The mesh corresponding the the pick collision
  10478. */
  10479. pickedMesh: Nullable<AbstractMesh>;
  10480. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10481. bu: number;
  10482. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10483. bv: number;
  10484. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10485. faceId: number;
  10486. /** Id of the the submesh that was picked */
  10487. subMeshId: number;
  10488. /** If a sprite was picked, this will be the sprite the pick collided with */
  10489. pickedSprite: Nullable<Sprite>;
  10490. /**
  10491. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10492. */
  10493. originMesh: Nullable<AbstractMesh>;
  10494. /**
  10495. * The ray that was used to perform the picking.
  10496. */
  10497. ray: Nullable<Ray>;
  10498. /**
  10499. * Gets the normal correspodning to the face the pick collided with
  10500. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10501. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10502. * @returns The normal correspodning to the face the pick collided with
  10503. */
  10504. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10505. /**
  10506. * Gets the texture coordinates of where the pick occured
  10507. * @returns the vector containing the coordnates of the texture
  10508. */
  10509. getTextureCoordinates(): Nullable<Vector2>;
  10510. }
  10511. }
  10512. declare module "babylonjs/Culling/ray" {
  10513. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10514. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10516. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10517. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10518. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10519. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10520. import { Plane } from "babylonjs/Maths/math.plane";
  10521. /**
  10522. * Class representing a ray with position and direction
  10523. */
  10524. export class Ray {
  10525. /** origin point */
  10526. origin: Vector3;
  10527. /** direction */
  10528. direction: Vector3;
  10529. /** length of the ray */
  10530. length: number;
  10531. private static readonly TmpVector3;
  10532. private _tmpRay;
  10533. /**
  10534. * Creates a new ray
  10535. * @param origin origin point
  10536. * @param direction direction
  10537. * @param length length of the ray
  10538. */
  10539. constructor(
  10540. /** origin point */
  10541. origin: Vector3,
  10542. /** direction */
  10543. direction: Vector3,
  10544. /** length of the ray */
  10545. length?: number);
  10546. /**
  10547. * Checks if the ray intersects a box
  10548. * This does not account for the ray lenght by design to improve perfs.
  10549. * @param minimum bound of the box
  10550. * @param maximum bound of the box
  10551. * @param intersectionTreshold extra extend to be added to the box in all direction
  10552. * @returns if the box was hit
  10553. */
  10554. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10555. /**
  10556. * Checks if the ray intersects a box
  10557. * This does not account for the ray lenght by design to improve perfs.
  10558. * @param box the bounding box to check
  10559. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10560. * @returns if the box was hit
  10561. */
  10562. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10563. /**
  10564. * If the ray hits a sphere
  10565. * @param sphere the bounding sphere to check
  10566. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10567. * @returns true if it hits the sphere
  10568. */
  10569. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10570. /**
  10571. * If the ray hits a triange
  10572. * @param vertex0 triangle vertex
  10573. * @param vertex1 triangle vertex
  10574. * @param vertex2 triangle vertex
  10575. * @returns intersection information if hit
  10576. */
  10577. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10578. /**
  10579. * Checks if ray intersects a plane
  10580. * @param plane the plane to check
  10581. * @returns the distance away it was hit
  10582. */
  10583. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10584. /**
  10585. * Calculate the intercept of a ray on a given axis
  10586. * @param axis to check 'x' | 'y' | 'z'
  10587. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10588. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10589. */
  10590. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10591. /**
  10592. * Checks if ray intersects a mesh
  10593. * @param mesh the mesh to check
  10594. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10595. * @returns picking info of the intersecton
  10596. */
  10597. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10598. /**
  10599. * Checks if ray intersects a mesh
  10600. * @param meshes the meshes to check
  10601. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10602. * @param results array to store result in
  10603. * @returns Array of picking infos
  10604. */
  10605. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10606. private _comparePickingInfo;
  10607. private static smallnum;
  10608. private static rayl;
  10609. /**
  10610. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10611. * @param sega the first point of the segment to test the intersection against
  10612. * @param segb the second point of the segment to test the intersection against
  10613. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10614. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10615. */
  10616. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10617. /**
  10618. * Update the ray from viewport position
  10619. * @param x position
  10620. * @param y y position
  10621. * @param viewportWidth viewport width
  10622. * @param viewportHeight viewport height
  10623. * @param world world matrix
  10624. * @param view view matrix
  10625. * @param projection projection matrix
  10626. * @returns this ray updated
  10627. */
  10628. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10629. /**
  10630. * Creates a ray with origin and direction of 0,0,0
  10631. * @returns the new ray
  10632. */
  10633. static Zero(): Ray;
  10634. /**
  10635. * Creates a new ray from screen space and viewport
  10636. * @param x position
  10637. * @param y y position
  10638. * @param viewportWidth viewport width
  10639. * @param viewportHeight viewport height
  10640. * @param world world matrix
  10641. * @param view view matrix
  10642. * @param projection projection matrix
  10643. * @returns new ray
  10644. */
  10645. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10646. /**
  10647. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10648. * transformed to the given world matrix.
  10649. * @param origin The origin point
  10650. * @param end The end point
  10651. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10652. * @returns the new ray
  10653. */
  10654. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10655. /**
  10656. * Transforms a ray by a matrix
  10657. * @param ray ray to transform
  10658. * @param matrix matrix to apply
  10659. * @returns the resulting new ray
  10660. */
  10661. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10662. /**
  10663. * Transforms a ray by a matrix
  10664. * @param ray ray to transform
  10665. * @param matrix matrix to apply
  10666. * @param result ray to store result in
  10667. */
  10668. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10669. /**
  10670. * Unproject a ray from screen space to object space
  10671. * @param sourceX defines the screen space x coordinate to use
  10672. * @param sourceY defines the screen space y coordinate to use
  10673. * @param viewportWidth defines the current width of the viewport
  10674. * @param viewportHeight defines the current height of the viewport
  10675. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10676. * @param view defines the view matrix to use
  10677. * @param projection defines the projection matrix to use
  10678. */
  10679. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10680. }
  10681. /**
  10682. * Type used to define predicate used to select faces when a mesh intersection is detected
  10683. */
  10684. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10685. module "babylonjs/scene" {
  10686. interface Scene {
  10687. /** @hidden */
  10688. _tempPickingRay: Nullable<Ray>;
  10689. /** @hidden */
  10690. _cachedRayForTransform: Ray;
  10691. /** @hidden */
  10692. _pickWithRayInverseMatrix: Matrix;
  10693. /** @hidden */
  10694. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10695. /** @hidden */
  10696. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10697. }
  10698. }
  10699. }
  10700. declare module "babylonjs/sceneComponent" {
  10701. import { Scene } from "babylonjs/scene";
  10702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10703. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10704. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10705. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10706. import { Nullable } from "babylonjs/types";
  10707. import { Camera } from "babylonjs/Cameras/camera";
  10708. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10709. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10710. import { AbstractScene } from "babylonjs/abstractScene";
  10711. import { Mesh } from "babylonjs/Meshes/mesh";
  10712. /**
  10713. * Groups all the scene component constants in one place to ease maintenance.
  10714. * @hidden
  10715. */
  10716. export class SceneComponentConstants {
  10717. static readonly NAME_EFFECTLAYER: string;
  10718. static readonly NAME_LAYER: string;
  10719. static readonly NAME_LENSFLARESYSTEM: string;
  10720. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10721. static readonly NAME_PARTICLESYSTEM: string;
  10722. static readonly NAME_GAMEPAD: string;
  10723. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10724. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10725. static readonly NAME_DEPTHRENDERER: string;
  10726. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10727. static readonly NAME_SPRITE: string;
  10728. static readonly NAME_OUTLINERENDERER: string;
  10729. static readonly NAME_PROCEDURALTEXTURE: string;
  10730. static readonly NAME_SHADOWGENERATOR: string;
  10731. static readonly NAME_OCTREE: string;
  10732. static readonly NAME_PHYSICSENGINE: string;
  10733. static readonly NAME_AUDIO: string;
  10734. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10735. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10736. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10737. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10738. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10739. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10740. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10741. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10742. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10743. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10744. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10745. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10746. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10747. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10748. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10749. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10750. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10751. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10752. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10753. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10754. static readonly STEP_AFTERRENDER_AUDIO: number;
  10755. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10756. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10757. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10758. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10759. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10760. static readonly STEP_POINTERMOVE_SPRITE: number;
  10761. static readonly STEP_POINTERDOWN_SPRITE: number;
  10762. static readonly STEP_POINTERUP_SPRITE: number;
  10763. }
  10764. /**
  10765. * This represents a scene component.
  10766. *
  10767. * This is used to decouple the dependency the scene is having on the different workloads like
  10768. * layers, post processes...
  10769. */
  10770. export interface ISceneComponent {
  10771. /**
  10772. * The name of the component. Each component must have a unique name.
  10773. */
  10774. name: string;
  10775. /**
  10776. * The scene the component belongs to.
  10777. */
  10778. scene: Scene;
  10779. /**
  10780. * Register the component to one instance of a scene.
  10781. */
  10782. register(): void;
  10783. /**
  10784. * Rebuilds the elements related to this component in case of
  10785. * context lost for instance.
  10786. */
  10787. rebuild(): void;
  10788. /**
  10789. * Disposes the component and the associated ressources.
  10790. */
  10791. dispose(): void;
  10792. }
  10793. /**
  10794. * This represents a SERIALIZABLE scene component.
  10795. *
  10796. * This extends Scene Component to add Serialization methods on top.
  10797. */
  10798. export interface ISceneSerializableComponent extends ISceneComponent {
  10799. /**
  10800. * Adds all the elements from the container to the scene
  10801. * @param container the container holding the elements
  10802. */
  10803. addFromContainer(container: AbstractScene): void;
  10804. /**
  10805. * Removes all the elements in the container from the scene
  10806. * @param container contains the elements to remove
  10807. * @param dispose if the removed element should be disposed (default: false)
  10808. */
  10809. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10810. /**
  10811. * Serializes the component data to the specified json object
  10812. * @param serializationObject The object to serialize to
  10813. */
  10814. serialize(serializationObject: any): void;
  10815. }
  10816. /**
  10817. * Strong typing of a Mesh related stage step action
  10818. */
  10819. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10820. /**
  10821. * Strong typing of a Evaluate Sub Mesh related stage step action
  10822. */
  10823. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10824. /**
  10825. * Strong typing of a Active Mesh related stage step action
  10826. */
  10827. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10828. /**
  10829. * Strong typing of a Camera related stage step action
  10830. */
  10831. export type CameraStageAction = (camera: Camera) => void;
  10832. /**
  10833. * Strong typing of a Camera Frame buffer related stage step action
  10834. */
  10835. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10836. /**
  10837. * Strong typing of a Render Target related stage step action
  10838. */
  10839. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10840. /**
  10841. * Strong typing of a RenderingGroup related stage step action
  10842. */
  10843. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10844. /**
  10845. * Strong typing of a Mesh Render related stage step action
  10846. */
  10847. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10848. /**
  10849. * Strong typing of a simple stage step action
  10850. */
  10851. export type SimpleStageAction = () => void;
  10852. /**
  10853. * Strong typing of a render target action.
  10854. */
  10855. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10856. /**
  10857. * Strong typing of a pointer move action.
  10858. */
  10859. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10860. /**
  10861. * Strong typing of a pointer up/down action.
  10862. */
  10863. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10864. /**
  10865. * Representation of a stage in the scene (Basically a list of ordered steps)
  10866. * @hidden
  10867. */
  10868. export class Stage<T extends Function> extends Array<{
  10869. index: number;
  10870. component: ISceneComponent;
  10871. action: T;
  10872. }> {
  10873. /**
  10874. * Hide ctor from the rest of the world.
  10875. * @param items The items to add.
  10876. */
  10877. private constructor();
  10878. /**
  10879. * Creates a new Stage.
  10880. * @returns A new instance of a Stage
  10881. */
  10882. static Create<T extends Function>(): Stage<T>;
  10883. /**
  10884. * Registers a step in an ordered way in the targeted stage.
  10885. * @param index Defines the position to register the step in
  10886. * @param component Defines the component attached to the step
  10887. * @param action Defines the action to launch during the step
  10888. */
  10889. registerStep(index: number, component: ISceneComponent, action: T): void;
  10890. /**
  10891. * Clears all the steps from the stage.
  10892. */
  10893. clear(): void;
  10894. }
  10895. }
  10896. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10897. import { Nullable } from "babylonjs/types";
  10898. import { Observable } from "babylonjs/Misc/observable";
  10899. import { Scene } from "babylonjs/scene";
  10900. import { Sprite } from "babylonjs/Sprites/sprite";
  10901. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10902. import { Ray } from "babylonjs/Culling/ray";
  10903. import { Camera } from "babylonjs/Cameras/camera";
  10904. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10905. import { ISceneComponent } from "babylonjs/sceneComponent";
  10906. module "babylonjs/scene" {
  10907. interface Scene {
  10908. /** @hidden */
  10909. _pointerOverSprite: Nullable<Sprite>;
  10910. /** @hidden */
  10911. _pickedDownSprite: Nullable<Sprite>;
  10912. /** @hidden */
  10913. _tempSpritePickingRay: Nullable<Ray>;
  10914. /**
  10915. * All of the sprite managers added to this scene
  10916. * @see http://doc.babylonjs.com/babylon101/sprites
  10917. */
  10918. spriteManagers: Array<ISpriteManager>;
  10919. /**
  10920. * An event triggered when sprites rendering is about to start
  10921. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10922. */
  10923. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10924. /**
  10925. * An event triggered when sprites rendering is done
  10926. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10927. */
  10928. onAfterSpritesRenderingObservable: Observable<Scene>;
  10929. /** @hidden */
  10930. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10931. /** Launch a ray to try to pick a sprite in the scene
  10932. * @param x position on screen
  10933. * @param y position on screen
  10934. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10935. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10936. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10937. * @returns a PickingInfo
  10938. */
  10939. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10940. /** Use the given ray to pick a sprite in the scene
  10941. * @param ray The ray (in world space) to use to pick meshes
  10942. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10943. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10944. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10945. * @returns a PickingInfo
  10946. */
  10947. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10948. /** @hidden */
  10949. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10950. /** Launch a ray to try to pick sprites in the scene
  10951. * @param x position on screen
  10952. * @param y position on screen
  10953. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10954. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10955. * @returns a PickingInfo array
  10956. */
  10957. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10958. /** Use the given ray to pick sprites in the scene
  10959. * @param ray The ray (in world space) to use to pick meshes
  10960. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10961. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10962. * @returns a PickingInfo array
  10963. */
  10964. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10965. /**
  10966. * Force the sprite under the pointer
  10967. * @param sprite defines the sprite to use
  10968. */
  10969. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10970. /**
  10971. * Gets the sprite under the pointer
  10972. * @returns a Sprite or null if no sprite is under the pointer
  10973. */
  10974. getPointerOverSprite(): Nullable<Sprite>;
  10975. }
  10976. }
  10977. /**
  10978. * Defines the sprite scene component responsible to manage sprites
  10979. * in a given scene.
  10980. */
  10981. export class SpriteSceneComponent implements ISceneComponent {
  10982. /**
  10983. * The component name helpfull to identify the component in the list of scene components.
  10984. */
  10985. readonly name: string;
  10986. /**
  10987. * The scene the component belongs to.
  10988. */
  10989. scene: Scene;
  10990. /** @hidden */
  10991. private _spritePredicate;
  10992. /**
  10993. * Creates a new instance of the component for the given scene
  10994. * @param scene Defines the scene to register the component in
  10995. */
  10996. constructor(scene: Scene);
  10997. /**
  10998. * Registers the component in a given scene
  10999. */
  11000. register(): void;
  11001. /**
  11002. * Rebuilds the elements related to this component in case of
  11003. * context lost for instance.
  11004. */
  11005. rebuild(): void;
  11006. /**
  11007. * Disposes the component and the associated ressources.
  11008. */
  11009. dispose(): void;
  11010. private _pickSpriteButKeepRay;
  11011. private _pointerMove;
  11012. private _pointerDown;
  11013. private _pointerUp;
  11014. }
  11015. }
  11016. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11017. /** @hidden */
  11018. export var fogFragmentDeclaration: {
  11019. name: string;
  11020. shader: string;
  11021. };
  11022. }
  11023. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11024. /** @hidden */
  11025. export var fogFragment: {
  11026. name: string;
  11027. shader: string;
  11028. };
  11029. }
  11030. declare module "babylonjs/Shaders/sprites.fragment" {
  11031. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11032. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11033. /** @hidden */
  11034. export var spritesPixelShader: {
  11035. name: string;
  11036. shader: string;
  11037. };
  11038. }
  11039. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11040. /** @hidden */
  11041. export var fogVertexDeclaration: {
  11042. name: string;
  11043. shader: string;
  11044. };
  11045. }
  11046. declare module "babylonjs/Shaders/sprites.vertex" {
  11047. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11048. /** @hidden */
  11049. export var spritesVertexShader: {
  11050. name: string;
  11051. shader: string;
  11052. };
  11053. }
  11054. declare module "babylonjs/Sprites/spriteManager" {
  11055. import { IDisposable, Scene } from "babylonjs/scene";
  11056. import { Nullable } from "babylonjs/types";
  11057. import { Observable } from "babylonjs/Misc/observable";
  11058. import { Sprite } from "babylonjs/Sprites/sprite";
  11059. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11060. import { Camera } from "babylonjs/Cameras/camera";
  11061. import { Texture } from "babylonjs/Materials/Textures/texture";
  11062. import "babylonjs/Shaders/sprites.fragment";
  11063. import "babylonjs/Shaders/sprites.vertex";
  11064. import { Ray } from "babylonjs/Culling/ray";
  11065. /**
  11066. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11067. */
  11068. export interface ISpriteManager extends IDisposable {
  11069. /**
  11070. * Gets manager's name
  11071. */
  11072. name: string;
  11073. /**
  11074. * Restricts the camera to viewing objects with the same layerMask.
  11075. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11076. */
  11077. layerMask: number;
  11078. /**
  11079. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11080. */
  11081. isPickable: boolean;
  11082. /**
  11083. * Gets the hosting scene
  11084. */
  11085. scene: Scene;
  11086. /**
  11087. * Specifies the rendering group id for this mesh (0 by default)
  11088. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11089. */
  11090. renderingGroupId: number;
  11091. /**
  11092. * Defines the list of sprites managed by the manager.
  11093. */
  11094. sprites: Array<Sprite>;
  11095. /**
  11096. * Gets or sets the spritesheet texture
  11097. */
  11098. texture: Texture;
  11099. /** Defines the default width of a cell in the spritesheet */
  11100. cellWidth: number;
  11101. /** Defines the default height of a cell in the spritesheet */
  11102. cellHeight: number;
  11103. /**
  11104. * Tests the intersection of a sprite with a specific ray.
  11105. * @param ray The ray we are sending to test the collision
  11106. * @param camera The camera space we are sending rays in
  11107. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11108. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11109. * @returns picking info or null.
  11110. */
  11111. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11112. /**
  11113. * Intersects the sprites with a ray
  11114. * @param ray defines the ray to intersect with
  11115. * @param camera defines the current active camera
  11116. * @param predicate defines a predicate used to select candidate sprites
  11117. * @returns null if no hit or a PickingInfo array
  11118. */
  11119. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11120. /**
  11121. * Renders the list of sprites on screen.
  11122. */
  11123. render(): void;
  11124. }
  11125. /**
  11126. * Class used to manage multiple sprites on the same spritesheet
  11127. * @see http://doc.babylonjs.com/babylon101/sprites
  11128. */
  11129. export class SpriteManager implements ISpriteManager {
  11130. /** defines the manager's name */
  11131. name: string;
  11132. /** Define the Url to load snippets */
  11133. static SnippetUrl: string;
  11134. /** Snippet ID if the manager was created from the snippet server */
  11135. snippetId: string;
  11136. /** Gets the list of sprites */
  11137. sprites: Sprite[];
  11138. /** Gets or sets the rendering group id (0 by default) */
  11139. renderingGroupId: number;
  11140. /** Gets or sets camera layer mask */
  11141. layerMask: number;
  11142. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11143. fogEnabled: boolean;
  11144. /** Gets or sets a boolean indicating if the sprites are pickable */
  11145. isPickable: boolean;
  11146. /** Defines the default width of a cell in the spritesheet */
  11147. cellWidth: number;
  11148. /** Defines the default height of a cell in the spritesheet */
  11149. cellHeight: number;
  11150. /** Associative array from JSON sprite data file */
  11151. private _cellData;
  11152. /** Array of sprite names from JSON sprite data file */
  11153. private _spriteMap;
  11154. /** True when packed cell data from JSON file is ready*/
  11155. private _packedAndReady;
  11156. private _textureContent;
  11157. /**
  11158. * An event triggered when the manager is disposed.
  11159. */
  11160. onDisposeObservable: Observable<SpriteManager>;
  11161. private _onDisposeObserver;
  11162. /**
  11163. * Callback called when the manager is disposed
  11164. */
  11165. set onDispose(callback: () => void);
  11166. private _capacity;
  11167. private _fromPacked;
  11168. private _spriteTexture;
  11169. private _epsilon;
  11170. private _scene;
  11171. private _vertexData;
  11172. private _buffer;
  11173. private _vertexBuffers;
  11174. private _indexBuffer;
  11175. private _effectBase;
  11176. private _effectFog;
  11177. /**
  11178. * Gets or sets the unique id of the sprite
  11179. */
  11180. uniqueId: number;
  11181. /**
  11182. * Gets the array of sprites
  11183. */
  11184. get children(): Sprite[];
  11185. /**
  11186. * Gets the hosting scene
  11187. */
  11188. get scene(): Scene;
  11189. /**
  11190. * Gets the capacity of the manager
  11191. */
  11192. get capacity(): number;
  11193. /**
  11194. * Gets or sets the spritesheet texture
  11195. */
  11196. get texture(): Texture;
  11197. set texture(value: Texture);
  11198. private _blendMode;
  11199. /**
  11200. * Blend mode use to render the particle, it can be any of
  11201. * the static Constants.ALPHA_x properties provided in this class.
  11202. * Default value is Constants.ALPHA_COMBINE
  11203. */
  11204. get blendMode(): number;
  11205. set blendMode(blendMode: number);
  11206. /** Disables writing to the depth buffer when rendering the sprites.
  11207. * It can be handy to disable depth writing when using textures without alpha channel
  11208. * and setting some specific blend modes.
  11209. */
  11210. disableDepthWrite: boolean;
  11211. /**
  11212. * Creates a new sprite manager
  11213. * @param name defines the manager's name
  11214. * @param imgUrl defines the sprite sheet url
  11215. * @param capacity defines the maximum allowed number of sprites
  11216. * @param cellSize defines the size of a sprite cell
  11217. * @param scene defines the hosting scene
  11218. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11219. * @param samplingMode defines the smapling mode to use with spritesheet
  11220. * @param fromPacked set to false; do not alter
  11221. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11222. */
  11223. constructor(
  11224. /** defines the manager's name */
  11225. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11226. /**
  11227. * Returns the string "SpriteManager"
  11228. * @returns "SpriteManager"
  11229. */
  11230. getClassName(): string;
  11231. private _makePacked;
  11232. private _appendSpriteVertex;
  11233. private _checkTextureAlpha;
  11234. /**
  11235. * Intersects the sprites with a ray
  11236. * @param ray defines the ray to intersect with
  11237. * @param camera defines the current active camera
  11238. * @param predicate defines a predicate used to select candidate sprites
  11239. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11240. * @returns null if no hit or a PickingInfo
  11241. */
  11242. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11243. /**
  11244. * Intersects the sprites with a ray
  11245. * @param ray defines the ray to intersect with
  11246. * @param camera defines the current active camera
  11247. * @param predicate defines a predicate used to select candidate sprites
  11248. * @returns null if no hit or a PickingInfo array
  11249. */
  11250. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11251. /**
  11252. * Render all child sprites
  11253. */
  11254. render(): void;
  11255. /**
  11256. * Release associated resources
  11257. */
  11258. dispose(): void;
  11259. /**
  11260. * Serializes the sprite manager to a JSON object
  11261. * @param serializeTexture defines if the texture must be serialized as well
  11262. * @returns the JSON object
  11263. */
  11264. serialize(serializeTexture?: boolean): any;
  11265. /**
  11266. * Parses a JSON object to create a new sprite manager.
  11267. * @param parsedManager The JSON object to parse
  11268. * @param scene The scene to create the sprite managerin
  11269. * @param rootUrl The root url to use to load external dependencies like texture
  11270. * @returns the new sprite manager
  11271. */
  11272. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11273. /**
  11274. * Creates a sprite manager from a snippet saved in a remote file
  11275. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11276. * @param url defines the url to load from
  11277. * @param scene defines the hosting scene
  11278. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11279. * @returns a promise that will resolve to the new sprite manager
  11280. */
  11281. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11282. /**
  11283. * Creates a sprite manager from a snippet saved by the sprite editor
  11284. * @param snippetId defines the snippet to load
  11285. * @param scene defines the hosting scene
  11286. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11287. * @returns a promise that will resolve to the new sprite manager
  11288. */
  11289. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11290. }
  11291. }
  11292. declare module "babylonjs/Misc/gradients" {
  11293. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11294. /** Interface used by value gradients (color, factor, ...) */
  11295. export interface IValueGradient {
  11296. /**
  11297. * Gets or sets the gradient value (between 0 and 1)
  11298. */
  11299. gradient: number;
  11300. }
  11301. /** Class used to store color4 gradient */
  11302. export class ColorGradient implements IValueGradient {
  11303. /**
  11304. * Gets or sets the gradient value (between 0 and 1)
  11305. */
  11306. gradient: number;
  11307. /**
  11308. * Gets or sets first associated color
  11309. */
  11310. color1: Color4;
  11311. /**
  11312. * Gets or sets second associated color
  11313. */
  11314. color2?: Color4 | undefined;
  11315. /**
  11316. * Creates a new color4 gradient
  11317. * @param gradient gets or sets the gradient value (between 0 and 1)
  11318. * @param color1 gets or sets first associated color
  11319. * @param color2 gets or sets first second color
  11320. */
  11321. constructor(
  11322. /**
  11323. * Gets or sets the gradient value (between 0 and 1)
  11324. */
  11325. gradient: number,
  11326. /**
  11327. * Gets or sets first associated color
  11328. */
  11329. color1: Color4,
  11330. /**
  11331. * Gets or sets second associated color
  11332. */
  11333. color2?: Color4 | undefined);
  11334. /**
  11335. * Will get a color picked randomly between color1 and color2.
  11336. * If color2 is undefined then color1 will be used
  11337. * @param result defines the target Color4 to store the result in
  11338. */
  11339. getColorToRef(result: Color4): void;
  11340. }
  11341. /** Class used to store color 3 gradient */
  11342. export class Color3Gradient implements IValueGradient {
  11343. /**
  11344. * Gets or sets the gradient value (between 0 and 1)
  11345. */
  11346. gradient: number;
  11347. /**
  11348. * Gets or sets the associated color
  11349. */
  11350. color: Color3;
  11351. /**
  11352. * Creates a new color3 gradient
  11353. * @param gradient gets or sets the gradient value (between 0 and 1)
  11354. * @param color gets or sets associated color
  11355. */
  11356. constructor(
  11357. /**
  11358. * Gets or sets the gradient value (between 0 and 1)
  11359. */
  11360. gradient: number,
  11361. /**
  11362. * Gets or sets the associated color
  11363. */
  11364. color: Color3);
  11365. }
  11366. /** Class used to store factor gradient */
  11367. export class FactorGradient implements IValueGradient {
  11368. /**
  11369. * Gets or sets the gradient value (between 0 and 1)
  11370. */
  11371. gradient: number;
  11372. /**
  11373. * Gets or sets first associated factor
  11374. */
  11375. factor1: number;
  11376. /**
  11377. * Gets or sets second associated factor
  11378. */
  11379. factor2?: number | undefined;
  11380. /**
  11381. * Creates a new factor gradient
  11382. * @param gradient gets or sets the gradient value (between 0 and 1)
  11383. * @param factor1 gets or sets first associated factor
  11384. * @param factor2 gets or sets second associated factor
  11385. */
  11386. constructor(
  11387. /**
  11388. * Gets or sets the gradient value (between 0 and 1)
  11389. */
  11390. gradient: number,
  11391. /**
  11392. * Gets or sets first associated factor
  11393. */
  11394. factor1: number,
  11395. /**
  11396. * Gets or sets second associated factor
  11397. */
  11398. factor2?: number | undefined);
  11399. /**
  11400. * Will get a number picked randomly between factor1 and factor2.
  11401. * If factor2 is undefined then factor1 will be used
  11402. * @returns the picked number
  11403. */
  11404. getFactor(): number;
  11405. }
  11406. /**
  11407. * Helper used to simplify some generic gradient tasks
  11408. */
  11409. export class GradientHelper {
  11410. /**
  11411. * Gets the current gradient from an array of IValueGradient
  11412. * @param ratio defines the current ratio to get
  11413. * @param gradients defines the array of IValueGradient
  11414. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11415. */
  11416. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11417. }
  11418. }
  11419. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  11420. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11421. import { Nullable } from "babylonjs/types";
  11422. module "babylonjs/Engines/thinEngine" {
  11423. interface ThinEngine {
  11424. /**
  11425. * Creates a dynamic texture
  11426. * @param width defines the width of the texture
  11427. * @param height defines the height of the texture
  11428. * @param generateMipMaps defines if the engine should generate the mip levels
  11429. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11430. * @returns the dynamic texture inside an InternalTexture
  11431. */
  11432. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11433. /**
  11434. * Update the content of a dynamic texture
  11435. * @param texture defines the texture to update
  11436. * @param canvas defines the canvas containing the source
  11437. * @param invertY defines if data must be stored with Y axis inverted
  11438. * @param premulAlpha defines if alpha is stored as premultiplied
  11439. * @param format defines the format of the data
  11440. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11441. */
  11442. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11443. }
  11444. }
  11445. }
  11446. declare module "babylonjs/Misc/canvasGenerator" {
  11447. /**
  11448. * Helper class used to generate a canvas to manipulate images
  11449. */
  11450. export class CanvasGenerator {
  11451. /**
  11452. * Create a new canvas (or offscreen canvas depending on the context)
  11453. * @param width defines the expected width
  11454. * @param height defines the expected height
  11455. * @return a new canvas or offscreen canvas
  11456. */
  11457. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  11458. }
  11459. }
  11460. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  11461. import { Scene } from "babylonjs/scene";
  11462. import { Texture } from "babylonjs/Materials/Textures/texture";
  11463. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  11464. /**
  11465. * A class extending Texture allowing drawing on a texture
  11466. * @see http://doc.babylonjs.com/how_to/dynamictexture
  11467. */
  11468. export class DynamicTexture extends Texture {
  11469. private _generateMipMaps;
  11470. private _canvas;
  11471. private _context;
  11472. /**
  11473. * Creates a DynamicTexture
  11474. * @param name defines the name of the texture
  11475. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  11476. * @param scene defines the scene where you want the texture
  11477. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  11478. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  11479. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  11480. */
  11481. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  11482. /**
  11483. * Get the current class name of the texture useful for serialization or dynamic coding.
  11484. * @returns "DynamicTexture"
  11485. */
  11486. getClassName(): string;
  11487. /**
  11488. * Gets the current state of canRescale
  11489. */
  11490. get canRescale(): boolean;
  11491. private _recreate;
  11492. /**
  11493. * Scales the texture
  11494. * @param ratio the scale factor to apply to both width and height
  11495. */
  11496. scale(ratio: number): void;
  11497. /**
  11498. * Resizes the texture
  11499. * @param width the new width
  11500. * @param height the new height
  11501. */
  11502. scaleTo(width: number, height: number): void;
  11503. /**
  11504. * Gets the context of the canvas used by the texture
  11505. * @returns the canvas context of the dynamic texture
  11506. */
  11507. getContext(): CanvasRenderingContext2D;
  11508. /**
  11509. * Clears the texture
  11510. */
  11511. clear(): void;
  11512. /**
  11513. * Updates the texture
  11514. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11515. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  11516. */
  11517. update(invertY?: boolean, premulAlpha?: boolean): void;
  11518. /**
  11519. * Draws text onto the texture
  11520. * @param text defines the text to be drawn
  11521. * @param x defines the placement of the text from the left
  11522. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  11523. * @param font defines the font to be used with font-style, font-size, font-name
  11524. * @param color defines the color used for the text
  11525. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  11526. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11527. * @param update defines whether texture is immediately update (default is true)
  11528. */
  11529. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  11530. /**
  11531. * Clones the texture
  11532. * @returns the clone of the texture.
  11533. */
  11534. clone(): DynamicTexture;
  11535. /**
  11536. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  11537. * @returns a serialized dynamic texture object
  11538. */
  11539. serialize(): any;
  11540. /** @hidden */
  11541. _rebuild(): void;
  11542. }
  11543. }
  11544. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11545. import { Nullable } from "babylonjs/types";
  11546. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11547. import { Scene } from "babylonjs/scene";
  11548. module "babylonjs/Engines/thinEngine" {
  11549. interface ThinEngine {
  11550. /**
  11551. * Creates a raw texture
  11552. * @param data defines the data to store in the texture
  11553. * @param width defines the width of the texture
  11554. * @param height defines the height of the texture
  11555. * @param format defines the format of the data
  11556. * @param generateMipMaps defines if the engine should generate the mip levels
  11557. * @param invertY defines if data must be stored with Y axis inverted
  11558. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11559. * @param compression defines the compression used (null by default)
  11560. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11561. * @returns the raw texture inside an InternalTexture
  11562. */
  11563. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11564. /**
  11565. * Update a raw texture
  11566. * @param texture defines the texture to update
  11567. * @param data defines the data to store in the texture
  11568. * @param format defines the format of the data
  11569. * @param invertY defines if data must be stored with Y axis inverted
  11570. */
  11571. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11572. /**
  11573. * Update a raw texture
  11574. * @param texture defines the texture to update
  11575. * @param data defines the data to store in the texture
  11576. * @param format defines the format of the data
  11577. * @param invertY defines if data must be stored with Y axis inverted
  11578. * @param compression defines the compression used (null by default)
  11579. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11580. */
  11581. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11582. /**
  11583. * Creates a new raw cube texture
  11584. * @param data defines the array of data to use to create each face
  11585. * @param size defines the size of the textures
  11586. * @param format defines the format of the data
  11587. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11588. * @param generateMipMaps defines if the engine should generate the mip levels
  11589. * @param invertY defines if data must be stored with Y axis inverted
  11590. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11591. * @param compression defines the compression used (null by default)
  11592. * @returns the cube texture as an InternalTexture
  11593. */
  11594. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11595. /**
  11596. * Update a raw cube texture
  11597. * @param texture defines the texture to udpdate
  11598. * @param data defines the data to store
  11599. * @param format defines the data format
  11600. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11601. * @param invertY defines if data must be stored with Y axis inverted
  11602. */
  11603. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11604. /**
  11605. * Update a raw cube texture
  11606. * @param texture defines the texture to udpdate
  11607. * @param data defines the data to store
  11608. * @param format defines the data format
  11609. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11610. * @param invertY defines if data must be stored with Y axis inverted
  11611. * @param compression defines the compression used (null by default)
  11612. */
  11613. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11614. /**
  11615. * Update a raw cube texture
  11616. * @param texture defines the texture to udpdate
  11617. * @param data defines the data to store
  11618. * @param format defines the data format
  11619. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11620. * @param invertY defines if data must be stored with Y axis inverted
  11621. * @param compression defines the compression used (null by default)
  11622. * @param level defines which level of the texture to update
  11623. */
  11624. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11625. /**
  11626. * Creates a new raw cube texture from a specified url
  11627. * @param url defines the url where the data is located
  11628. * @param scene defines the current scene
  11629. * @param size defines the size of the textures
  11630. * @param format defines the format of the data
  11631. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11632. * @param noMipmap defines if the engine should avoid generating the mip levels
  11633. * @param callback defines a callback used to extract texture data from loaded data
  11634. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11635. * @param onLoad defines a callback called when texture is loaded
  11636. * @param onError defines a callback called if there is an error
  11637. * @returns the cube texture as an InternalTexture
  11638. */
  11639. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  11640. /**
  11641. * Creates a new raw cube texture from a specified url
  11642. * @param url defines the url where the data is located
  11643. * @param scene defines the current scene
  11644. * @param size defines the size of the textures
  11645. * @param format defines the format of the data
  11646. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11647. * @param noMipmap defines if the engine should avoid generating the mip levels
  11648. * @param callback defines a callback used to extract texture data from loaded data
  11649. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11650. * @param onLoad defines a callback called when texture is loaded
  11651. * @param onError defines a callback called if there is an error
  11652. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11653. * @param invertY defines if data must be stored with Y axis inverted
  11654. * @returns the cube texture as an InternalTexture
  11655. */
  11656. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  11657. /**
  11658. * Creates a new raw 3D texture
  11659. * @param data defines the data used to create the texture
  11660. * @param width defines the width of the texture
  11661. * @param height defines the height of the texture
  11662. * @param depth defines the depth of the texture
  11663. * @param format defines the format of the texture
  11664. * @param generateMipMaps defines if the engine must generate mip levels
  11665. * @param invertY defines if data must be stored with Y axis inverted
  11666. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11667. * @param compression defines the compressed used (can be null)
  11668. * @param textureType defines the compressed used (can be null)
  11669. * @returns a new raw 3D texture (stored in an InternalTexture)
  11670. */
  11671. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11672. /**
  11673. * Update a raw 3D texture
  11674. * @param texture defines the texture to update
  11675. * @param data defines the data to store
  11676. * @param format defines the data format
  11677. * @param invertY defines if data must be stored with Y axis inverted
  11678. */
  11679. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11680. /**
  11681. * Update a raw 3D texture
  11682. * @param texture defines the texture to update
  11683. * @param data defines the data to store
  11684. * @param format defines the data format
  11685. * @param invertY defines if data must be stored with Y axis inverted
  11686. * @param compression defines the used compression (can be null)
  11687. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11688. */
  11689. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11690. /**
  11691. * Creates a new raw 2D array texture
  11692. * @param data defines the data used to create the texture
  11693. * @param width defines the width of the texture
  11694. * @param height defines the height of the texture
  11695. * @param depth defines the number of layers of the texture
  11696. * @param format defines the format of the texture
  11697. * @param generateMipMaps defines if the engine must generate mip levels
  11698. * @param invertY defines if data must be stored with Y axis inverted
  11699. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11700. * @param compression defines the compressed used (can be null)
  11701. * @param textureType defines the compressed used (can be null)
  11702. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11703. */
  11704. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11705. /**
  11706. * Update a raw 2D array texture
  11707. * @param texture defines the texture to update
  11708. * @param data defines the data to store
  11709. * @param format defines the data format
  11710. * @param invertY defines if data must be stored with Y axis inverted
  11711. */
  11712. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11713. /**
  11714. * Update a raw 2D array texture
  11715. * @param texture defines the texture to update
  11716. * @param data defines the data to store
  11717. * @param format defines the data format
  11718. * @param invertY defines if data must be stored with Y axis inverted
  11719. * @param compression defines the used compression (can be null)
  11720. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11721. */
  11722. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11723. }
  11724. }
  11725. }
  11726. declare module "babylonjs/Materials/Textures/rawTexture" {
  11727. import { Scene } from "babylonjs/scene";
  11728. import { Texture } from "babylonjs/Materials/Textures/texture";
  11729. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11730. /**
  11731. * Raw texture can help creating a texture directly from an array of data.
  11732. * This can be super useful if you either get the data from an uncompressed source or
  11733. * if you wish to create your texture pixel by pixel.
  11734. */
  11735. export class RawTexture extends Texture {
  11736. /**
  11737. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11738. */
  11739. format: number;
  11740. /**
  11741. * Instantiates a new RawTexture.
  11742. * Raw texture can help creating a texture directly from an array of data.
  11743. * This can be super useful if you either get the data from an uncompressed source or
  11744. * if you wish to create your texture pixel by pixel.
  11745. * @param data define the array of data to use to create the texture
  11746. * @param width define the width of the texture
  11747. * @param height define the height of the texture
  11748. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11749. * @param scene define the scene the texture belongs to
  11750. * @param generateMipMaps define whether mip maps should be generated or not
  11751. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11752. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11753. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11754. */
  11755. constructor(data: ArrayBufferView, width: number, height: number,
  11756. /**
  11757. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11758. */
  11759. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11760. /**
  11761. * Updates the texture underlying data.
  11762. * @param data Define the new data of the texture
  11763. */
  11764. update(data: ArrayBufferView): void;
  11765. /**
  11766. * Creates a luminance texture from some data.
  11767. * @param data Define the texture data
  11768. * @param width Define the width of the texture
  11769. * @param height Define the height of the texture
  11770. * @param scene Define the scene the texture belongs to
  11771. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11772. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11773. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11774. * @returns the luminance texture
  11775. */
  11776. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11777. /**
  11778. * Creates a luminance alpha texture from some data.
  11779. * @param data Define the texture data
  11780. * @param width Define the width of the texture
  11781. * @param height Define the height of the texture
  11782. * @param scene Define the scene the texture belongs to
  11783. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11784. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11785. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11786. * @returns the luminance alpha texture
  11787. */
  11788. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11789. /**
  11790. * Creates an alpha texture from some data.
  11791. * @param data Define the texture data
  11792. * @param width Define the width of the texture
  11793. * @param height Define the height of the texture
  11794. * @param scene Define the scene the texture belongs to
  11795. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11796. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11797. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11798. * @returns the alpha texture
  11799. */
  11800. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11801. /**
  11802. * Creates a RGB texture from some data.
  11803. * @param data Define the texture data
  11804. * @param width Define the width of the texture
  11805. * @param height Define the height of the texture
  11806. * @param scene Define the scene the texture belongs to
  11807. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11808. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11809. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11810. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11811. * @returns the RGB alpha texture
  11812. */
  11813. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11814. /**
  11815. * Creates a RGBA texture from some data.
  11816. * @param data Define the texture data
  11817. * @param width Define the width of the texture
  11818. * @param height Define the height of the texture
  11819. * @param scene Define the scene the texture belongs to
  11820. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11821. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11822. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11823. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11824. * @returns the RGBA texture
  11825. */
  11826. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11827. /**
  11828. * Creates a R texture from some data.
  11829. * @param data Define the texture data
  11830. * @param width Define the width of the texture
  11831. * @param height Define the height of the texture
  11832. * @param scene Define the scene the texture belongs to
  11833. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11834. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11835. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11836. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11837. * @returns the R texture
  11838. */
  11839. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11840. }
  11841. }
  11842. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11843. import { Scene } from "babylonjs/scene";
  11844. import { ISceneComponent } from "babylonjs/sceneComponent";
  11845. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11846. module "babylonjs/abstractScene" {
  11847. interface AbstractScene {
  11848. /**
  11849. * The list of procedural textures added to the scene
  11850. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11851. */
  11852. proceduralTextures: Array<ProceduralTexture>;
  11853. }
  11854. }
  11855. /**
  11856. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11857. * in a given scene.
  11858. */
  11859. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11860. /**
  11861. * The component name helpfull to identify the component in the list of scene components.
  11862. */
  11863. readonly name: string;
  11864. /**
  11865. * The scene the component belongs to.
  11866. */
  11867. scene: Scene;
  11868. /**
  11869. * Creates a new instance of the component for the given scene
  11870. * @param scene Defines the scene to register the component in
  11871. */
  11872. constructor(scene: Scene);
  11873. /**
  11874. * Registers the component in a given scene
  11875. */
  11876. register(): void;
  11877. /**
  11878. * Rebuilds the elements related to this component in case of
  11879. * context lost for instance.
  11880. */
  11881. rebuild(): void;
  11882. /**
  11883. * Disposes the component and the associated ressources.
  11884. */
  11885. dispose(): void;
  11886. private _beforeClear;
  11887. }
  11888. }
  11889. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11890. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11891. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11892. module "babylonjs/Engines/thinEngine" {
  11893. interface ThinEngine {
  11894. /**
  11895. * Creates a new render target cube texture
  11896. * @param size defines the size of the texture
  11897. * @param options defines the options used to create the texture
  11898. * @returns a new render target cube texture stored in an InternalTexture
  11899. */
  11900. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11901. }
  11902. }
  11903. }
  11904. declare module "babylonjs/Shaders/procedural.vertex" {
  11905. /** @hidden */
  11906. export var proceduralVertexShader: {
  11907. name: string;
  11908. shader: string;
  11909. };
  11910. }
  11911. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11912. import { Observable } from "babylonjs/Misc/observable";
  11913. import { Nullable } from "babylonjs/types";
  11914. import { Scene } from "babylonjs/scene";
  11915. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11916. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11917. import { Effect } from "babylonjs/Materials/effect";
  11918. import { Texture } from "babylonjs/Materials/Textures/texture";
  11919. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11920. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11921. import "babylonjs/Shaders/procedural.vertex";
  11922. /**
  11923. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  11924. * This is the base class of any Procedural texture and contains most of the shareable code.
  11925. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11926. */
  11927. export class ProceduralTexture extends Texture {
  11928. isCube: boolean;
  11929. /**
  11930. * Define if the texture is enabled or not (disabled texture will not render)
  11931. */
  11932. isEnabled: boolean;
  11933. /**
  11934. * Define if the texture must be cleared before rendering (default is true)
  11935. */
  11936. autoClear: boolean;
  11937. /**
  11938. * Callback called when the texture is generated
  11939. */
  11940. onGenerated: () => void;
  11941. /**
  11942. * Event raised when the texture is generated
  11943. */
  11944. onGeneratedObservable: Observable<ProceduralTexture>;
  11945. /** @hidden */
  11946. _generateMipMaps: boolean;
  11947. /** @hidden **/
  11948. _effect: Effect;
  11949. /** @hidden */
  11950. _textures: {
  11951. [key: string]: Texture;
  11952. };
  11953. /** @hidden */
  11954. protected _fallbackTexture: Nullable<Texture>;
  11955. private _size;
  11956. private _currentRefreshId;
  11957. private _frameId;
  11958. private _refreshRate;
  11959. private _vertexBuffers;
  11960. private _indexBuffer;
  11961. private _uniforms;
  11962. private _samplers;
  11963. private _fragment;
  11964. private _floats;
  11965. private _ints;
  11966. private _floatsArrays;
  11967. private _colors3;
  11968. private _colors4;
  11969. private _vectors2;
  11970. private _vectors3;
  11971. private _matrices;
  11972. private _fallbackTextureUsed;
  11973. private _fullEngine;
  11974. private _cachedDefines;
  11975. private _contentUpdateId;
  11976. private _contentData;
  11977. /**
  11978. * Instantiates a new procedural texture.
  11979. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  11980. * This is the base class of any Procedural texture and contains most of the shareable code.
  11981. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11982. * @param name Define the name of the texture
  11983. * @param size Define the size of the texture to create
  11984. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11985. * @param scene Define the scene the texture belongs to
  11986. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11987. * @param generateMipMaps Define if the texture should creates mip maps or not
  11988. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11989. */
  11990. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11991. /**
  11992. * The effect that is created when initializing the post process.
  11993. * @returns The created effect corresponding the the postprocess.
  11994. */
  11995. getEffect(): Effect;
  11996. /**
  11997. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11998. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11999. */
  12000. getContent(): Nullable<ArrayBufferView>;
  12001. private _createIndexBuffer;
  12002. /** @hidden */
  12003. _rebuild(): void;
  12004. /**
  12005. * Resets the texture in order to recreate its associated resources.
  12006. * This can be called in case of context loss
  12007. */
  12008. reset(): void;
  12009. protected _getDefines(): string;
  12010. /**
  12011. * Is the texture ready to be used ? (rendered at least once)
  12012. * @returns true if ready, otherwise, false.
  12013. */
  12014. isReady(): boolean;
  12015. /**
  12016. * Resets the refresh counter of the texture and start bak from scratch.
  12017. * Could be useful to regenerate the texture if it is setup to render only once.
  12018. */
  12019. resetRefreshCounter(): void;
  12020. /**
  12021. * Set the fragment shader to use in order to render the texture.
  12022. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12023. */
  12024. setFragment(fragment: any): void;
  12025. /**
  12026. * Define the refresh rate of the texture or the rendering frequency.
  12027. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12028. */
  12029. get refreshRate(): number;
  12030. set refreshRate(value: number);
  12031. /** @hidden */
  12032. _shouldRender(): boolean;
  12033. /**
  12034. * Get the size the texture is rendering at.
  12035. * @returns the size (texture is always squared)
  12036. */
  12037. getRenderSize(): number;
  12038. /**
  12039. * Resize the texture to new value.
  12040. * @param size Define the new size the texture should have
  12041. * @param generateMipMaps Define whether the new texture should create mip maps
  12042. */
  12043. resize(size: number, generateMipMaps: boolean): void;
  12044. private _checkUniform;
  12045. /**
  12046. * Set a texture in the shader program used to render.
  12047. * @param name Define the name of the uniform samplers as defined in the shader
  12048. * @param texture Define the texture to bind to this sampler
  12049. * @return the texture itself allowing "fluent" like uniform updates
  12050. */
  12051. setTexture(name: string, texture: Texture): ProceduralTexture;
  12052. /**
  12053. * Set a float in the shader.
  12054. * @param name Define the name of the uniform as defined in the shader
  12055. * @param value Define the value to give to the uniform
  12056. * @return the texture itself allowing "fluent" like uniform updates
  12057. */
  12058. setFloat(name: string, value: number): ProceduralTexture;
  12059. /**
  12060. * Set a int in the shader.
  12061. * @param name Define the name of the uniform as defined in the shader
  12062. * @param value Define the value to give to the uniform
  12063. * @return the texture itself allowing "fluent" like uniform updates
  12064. */
  12065. setInt(name: string, value: number): ProceduralTexture;
  12066. /**
  12067. * Set an array of floats in the shader.
  12068. * @param name Define the name of the uniform as defined in the shader
  12069. * @param value Define the value to give to the uniform
  12070. * @return the texture itself allowing "fluent" like uniform updates
  12071. */
  12072. setFloats(name: string, value: number[]): ProceduralTexture;
  12073. /**
  12074. * Set a vec3 in the shader from a Color3.
  12075. * @param name Define the name of the uniform as defined in the shader
  12076. * @param value Define the value to give to the uniform
  12077. * @return the texture itself allowing "fluent" like uniform updates
  12078. */
  12079. setColor3(name: string, value: Color3): ProceduralTexture;
  12080. /**
  12081. * Set a vec4 in the shader from a Color4.
  12082. * @param name Define the name of the uniform as defined in the shader
  12083. * @param value Define the value to give to the uniform
  12084. * @return the texture itself allowing "fluent" like uniform updates
  12085. */
  12086. setColor4(name: string, value: Color4): ProceduralTexture;
  12087. /**
  12088. * Set a vec2 in the shader from a Vector2.
  12089. * @param name Define the name of the uniform as defined in the shader
  12090. * @param value Define the value to give to the uniform
  12091. * @return the texture itself allowing "fluent" like uniform updates
  12092. */
  12093. setVector2(name: string, value: Vector2): ProceduralTexture;
  12094. /**
  12095. * Set a vec3 in the shader from a Vector3.
  12096. * @param name Define the name of the uniform as defined in the shader
  12097. * @param value Define the value to give to the uniform
  12098. * @return the texture itself allowing "fluent" like uniform updates
  12099. */
  12100. setVector3(name: string, value: Vector3): ProceduralTexture;
  12101. /**
  12102. * Set a mat4 in the shader from a MAtrix.
  12103. * @param name Define the name of the uniform as defined in the shader
  12104. * @param value Define the value to give to the uniform
  12105. * @return the texture itself allowing "fluent" like uniform updates
  12106. */
  12107. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12108. /**
  12109. * Render the texture to its associated render target.
  12110. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12111. */
  12112. render(useCameraPostProcess?: boolean): void;
  12113. /**
  12114. * Clone the texture.
  12115. * @returns the cloned texture
  12116. */
  12117. clone(): ProceduralTexture;
  12118. /**
  12119. * Dispose the texture and release its asoociated resources.
  12120. */
  12121. dispose(): void;
  12122. }
  12123. }
  12124. declare module "babylonjs/Particles/baseParticleSystem" {
  12125. import { Nullable } from "babylonjs/types";
  12126. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12128. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12129. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12130. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12131. import { Scene } from "babylonjs/scene";
  12132. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12133. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12134. import { Texture } from "babylonjs/Materials/Textures/texture";
  12135. import { Color4 } from "babylonjs/Maths/math.color";
  12136. import { Animation } from "babylonjs/Animations/animation";
  12137. /**
  12138. * This represents the base class for particle system in Babylon.
  12139. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12140. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12141. * @example https://doc.babylonjs.com/babylon101/particles
  12142. */
  12143. export class BaseParticleSystem {
  12144. /**
  12145. * Source color is added to the destination color without alpha affecting the result
  12146. */
  12147. static BLENDMODE_ONEONE: number;
  12148. /**
  12149. * Blend current color and particle color using particle’s alpha
  12150. */
  12151. static BLENDMODE_STANDARD: number;
  12152. /**
  12153. * Add current color and particle color multiplied by particle’s alpha
  12154. */
  12155. static BLENDMODE_ADD: number;
  12156. /**
  12157. * Multiply current color with particle color
  12158. */
  12159. static BLENDMODE_MULTIPLY: number;
  12160. /**
  12161. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12162. */
  12163. static BLENDMODE_MULTIPLYADD: number;
  12164. /**
  12165. * List of animations used by the particle system.
  12166. */
  12167. animations: Animation[];
  12168. /**
  12169. * Gets or sets the unique id of the particle system
  12170. */
  12171. uniqueId: number;
  12172. /**
  12173. * The id of the Particle system.
  12174. */
  12175. id: string;
  12176. /**
  12177. * The friendly name of the Particle system.
  12178. */
  12179. name: string;
  12180. /**
  12181. * Snippet ID if the particle system was created from the snippet server
  12182. */
  12183. snippetId: string;
  12184. /**
  12185. * The rendering group used by the Particle system to chose when to render.
  12186. */
  12187. renderingGroupId: number;
  12188. /**
  12189. * The emitter represents the Mesh or position we are attaching the particle system to.
  12190. */
  12191. emitter: Nullable<AbstractMesh | Vector3>;
  12192. /**
  12193. * The maximum number of particles to emit per frame
  12194. */
  12195. emitRate: number;
  12196. /**
  12197. * If you want to launch only a few particles at once, that can be done, as well.
  12198. */
  12199. manualEmitCount: number;
  12200. /**
  12201. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12202. */
  12203. updateSpeed: number;
  12204. /**
  12205. * The amount of time the particle system is running (depends of the overall update speed).
  12206. */
  12207. targetStopDuration: number;
  12208. /**
  12209. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12210. */
  12211. disposeOnStop: boolean;
  12212. /**
  12213. * Minimum power of emitting particles.
  12214. */
  12215. minEmitPower: number;
  12216. /**
  12217. * Maximum power of emitting particles.
  12218. */
  12219. maxEmitPower: number;
  12220. /**
  12221. * Minimum life time of emitting particles.
  12222. */
  12223. minLifeTime: number;
  12224. /**
  12225. * Maximum life time of emitting particles.
  12226. */
  12227. maxLifeTime: number;
  12228. /**
  12229. * Minimum Size of emitting particles.
  12230. */
  12231. minSize: number;
  12232. /**
  12233. * Maximum Size of emitting particles.
  12234. */
  12235. maxSize: number;
  12236. /**
  12237. * Minimum scale of emitting particles on X axis.
  12238. */
  12239. minScaleX: number;
  12240. /**
  12241. * Maximum scale of emitting particles on X axis.
  12242. */
  12243. maxScaleX: number;
  12244. /**
  12245. * Minimum scale of emitting particles on Y axis.
  12246. */
  12247. minScaleY: number;
  12248. /**
  12249. * Maximum scale of emitting particles on Y axis.
  12250. */
  12251. maxScaleY: number;
  12252. /**
  12253. * Gets or sets the minimal initial rotation in radians.
  12254. */
  12255. minInitialRotation: number;
  12256. /**
  12257. * Gets or sets the maximal initial rotation in radians.
  12258. */
  12259. maxInitialRotation: number;
  12260. /**
  12261. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12262. */
  12263. minAngularSpeed: number;
  12264. /**
  12265. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12266. */
  12267. maxAngularSpeed: number;
  12268. /**
  12269. * The texture used to render each particle. (this can be a spritesheet)
  12270. */
  12271. particleTexture: Nullable<Texture>;
  12272. /**
  12273. * The layer mask we are rendering the particles through.
  12274. */
  12275. layerMask: number;
  12276. /**
  12277. * This can help using your own shader to render the particle system.
  12278. * The according effect will be created
  12279. */
  12280. customShader: any;
  12281. /**
  12282. * By default particle system starts as soon as they are created. This prevents the
  12283. * automatic start to happen and let you decide when to start emitting particles.
  12284. */
  12285. preventAutoStart: boolean;
  12286. private _noiseTexture;
  12287. /**
  12288. * Gets or sets a texture used to add random noise to particle positions
  12289. */
  12290. get noiseTexture(): Nullable<ProceduralTexture>;
  12291. set noiseTexture(value: Nullable<ProceduralTexture>);
  12292. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12293. noiseStrength: Vector3;
  12294. /**
  12295. * Callback triggered when the particle animation is ending.
  12296. */
  12297. onAnimationEnd: Nullable<() => void>;
  12298. /**
  12299. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12300. */
  12301. blendMode: number;
  12302. /**
  12303. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12304. * to override the particles.
  12305. */
  12306. forceDepthWrite: boolean;
  12307. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  12308. preWarmCycles: number;
  12309. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12310. preWarmStepOffset: number;
  12311. /**
  12312. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  12313. */
  12314. spriteCellChangeSpeed: number;
  12315. /**
  12316. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12317. */
  12318. startSpriteCellID: number;
  12319. /**
  12320. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12321. */
  12322. endSpriteCellID: number;
  12323. /**
  12324. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12325. */
  12326. spriteCellWidth: number;
  12327. /**
  12328. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12329. */
  12330. spriteCellHeight: number;
  12331. /**
  12332. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12333. */
  12334. spriteRandomStartCell: boolean;
  12335. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12336. translationPivot: Vector2;
  12337. /** @hidden */
  12338. protected _isAnimationSheetEnabled: boolean;
  12339. /**
  12340. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12341. */
  12342. beginAnimationOnStart: boolean;
  12343. /**
  12344. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12345. */
  12346. beginAnimationFrom: number;
  12347. /**
  12348. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12349. */
  12350. beginAnimationTo: number;
  12351. /**
  12352. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12353. */
  12354. beginAnimationLoop: boolean;
  12355. /**
  12356. * Gets or sets a world offset applied to all particles
  12357. */
  12358. worldOffset: Vector3;
  12359. /**
  12360. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12361. */
  12362. get isAnimationSheetEnabled(): boolean;
  12363. set isAnimationSheetEnabled(value: boolean);
  12364. /**
  12365. * Get hosting scene
  12366. * @returns the scene
  12367. */
  12368. getScene(): Scene;
  12369. /**
  12370. * You can use gravity if you want to give an orientation to your particles.
  12371. */
  12372. gravity: Vector3;
  12373. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12374. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12375. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12376. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12377. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12378. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12379. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12380. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12381. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12382. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12383. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12384. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12385. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12386. /**
  12387. * Defines the delay in milliseconds before starting the system (0 by default)
  12388. */
  12389. startDelay: number;
  12390. /**
  12391. * Gets the current list of drag gradients.
  12392. * You must use addDragGradient and removeDragGradient to udpate this list
  12393. * @returns the list of drag gradients
  12394. */
  12395. getDragGradients(): Nullable<Array<FactorGradient>>;
  12396. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12397. limitVelocityDamping: number;
  12398. /**
  12399. * Gets the current list of limit velocity gradients.
  12400. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12401. * @returns the list of limit velocity gradients
  12402. */
  12403. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12404. /**
  12405. * Gets the current list of color gradients.
  12406. * You must use addColorGradient and removeColorGradient to udpate this list
  12407. * @returns the list of color gradients
  12408. */
  12409. getColorGradients(): Nullable<Array<ColorGradient>>;
  12410. /**
  12411. * Gets the current list of size gradients.
  12412. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12413. * @returns the list of size gradients
  12414. */
  12415. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12416. /**
  12417. * Gets the current list of color remap gradients.
  12418. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12419. * @returns the list of color remap gradients
  12420. */
  12421. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12422. /**
  12423. * Gets the current list of alpha remap gradients.
  12424. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12425. * @returns the list of alpha remap gradients
  12426. */
  12427. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12428. /**
  12429. * Gets the current list of life time gradients.
  12430. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12431. * @returns the list of life time gradients
  12432. */
  12433. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12434. /**
  12435. * Gets the current list of angular speed gradients.
  12436. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12437. * @returns the list of angular speed gradients
  12438. */
  12439. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12440. /**
  12441. * Gets the current list of velocity gradients.
  12442. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12443. * @returns the list of velocity gradients
  12444. */
  12445. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12446. /**
  12447. * Gets the current list of start size gradients.
  12448. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12449. * @returns the list of start size gradients
  12450. */
  12451. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12452. /**
  12453. * Gets the current list of emit rate gradients.
  12454. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12455. * @returns the list of emit rate gradients
  12456. */
  12457. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12458. /**
  12459. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12460. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12461. */
  12462. get direction1(): Vector3;
  12463. set direction1(value: Vector3);
  12464. /**
  12465. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12466. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12467. */
  12468. get direction2(): Vector3;
  12469. set direction2(value: Vector3);
  12470. /**
  12471. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12472. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12473. */
  12474. get minEmitBox(): Vector3;
  12475. set minEmitBox(value: Vector3);
  12476. /**
  12477. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12478. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12479. */
  12480. get maxEmitBox(): Vector3;
  12481. set maxEmitBox(value: Vector3);
  12482. /**
  12483. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12484. */
  12485. color1: Color4;
  12486. /**
  12487. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12488. */
  12489. color2: Color4;
  12490. /**
  12491. * Color the particle will have at the end of its lifetime
  12492. */
  12493. colorDead: Color4;
  12494. /**
  12495. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12496. */
  12497. textureMask: Color4;
  12498. /**
  12499. * The particle emitter type defines the emitter used by the particle system.
  12500. * It can be for example box, sphere, or cone...
  12501. */
  12502. particleEmitterType: IParticleEmitterType;
  12503. /** @hidden */
  12504. _isSubEmitter: boolean;
  12505. /**
  12506. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12507. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12508. */
  12509. billboardMode: number;
  12510. protected _isBillboardBased: boolean;
  12511. /**
  12512. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12513. */
  12514. get isBillboardBased(): boolean;
  12515. set isBillboardBased(value: boolean);
  12516. /**
  12517. * The scene the particle system belongs to.
  12518. */
  12519. protected _scene: Scene;
  12520. /**
  12521. * Local cache of defines for image processing.
  12522. */
  12523. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12524. /**
  12525. * Default configuration related to image processing available in the standard Material.
  12526. */
  12527. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12528. /**
  12529. * Gets the image processing configuration used either in this material.
  12530. */
  12531. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12532. /**
  12533. * Sets the Default image processing configuration used either in the this material.
  12534. *
  12535. * If sets to null, the scene one is in use.
  12536. */
  12537. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12538. /**
  12539. * Attaches a new image processing configuration to the Standard Material.
  12540. * @param configuration
  12541. */
  12542. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12543. /** @hidden */
  12544. protected _reset(): void;
  12545. /** @hidden */
  12546. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12547. /**
  12548. * Instantiates a particle system.
  12549. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12550. * @param name The name of the particle system
  12551. */
  12552. constructor(name: string);
  12553. /**
  12554. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12555. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12556. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12557. * @returns the emitter
  12558. */
  12559. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12560. /**
  12561. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12562. * @param radius The radius of the hemisphere to emit from
  12563. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12564. * @returns the emitter
  12565. */
  12566. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12567. /**
  12568. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12569. * @param radius The radius of the sphere to emit from
  12570. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12571. * @returns the emitter
  12572. */
  12573. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12574. /**
  12575. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12576. * @param radius The radius of the sphere to emit from
  12577. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12578. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12579. * @returns the emitter
  12580. */
  12581. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12582. /**
  12583. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12584. * @param radius The radius of the emission cylinder
  12585. * @param height The height of the emission cylinder
  12586. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12587. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12588. * @returns the emitter
  12589. */
  12590. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12591. /**
  12592. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12593. * @param radius The radius of the cylinder to emit from
  12594. * @param height The height of the emission cylinder
  12595. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12596. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12597. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12598. * @returns the emitter
  12599. */
  12600. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12601. /**
  12602. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12603. * @param radius The radius of the cone to emit from
  12604. * @param angle The base angle of the cone
  12605. * @returns the emitter
  12606. */
  12607. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12608. /**
  12609. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12610. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12611. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12612. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12613. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12614. * @returns the emitter
  12615. */
  12616. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12617. }
  12618. }
  12619. declare module "babylonjs/Particles/subEmitter" {
  12620. import { Scene } from "babylonjs/scene";
  12621. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12622. /**
  12623. * Type of sub emitter
  12624. */
  12625. export enum SubEmitterType {
  12626. /**
  12627. * Attached to the particle over it's lifetime
  12628. */
  12629. ATTACHED = 0,
  12630. /**
  12631. * Created when the particle dies
  12632. */
  12633. END = 1
  12634. }
  12635. /**
  12636. * Sub emitter class used to emit particles from an existing particle
  12637. */
  12638. export class SubEmitter {
  12639. /**
  12640. * the particle system to be used by the sub emitter
  12641. */
  12642. particleSystem: ParticleSystem;
  12643. /**
  12644. * Type of the submitter (Default: END)
  12645. */
  12646. type: SubEmitterType;
  12647. /**
  12648. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  12649. * Note: This only is supported when using an emitter of type Mesh
  12650. */
  12651. inheritDirection: boolean;
  12652. /**
  12653. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12654. */
  12655. inheritedVelocityAmount: number;
  12656. /**
  12657. * Creates a sub emitter
  12658. * @param particleSystem the particle system to be used by the sub emitter
  12659. */
  12660. constructor(
  12661. /**
  12662. * the particle system to be used by the sub emitter
  12663. */
  12664. particleSystem: ParticleSystem);
  12665. /**
  12666. * Clones the sub emitter
  12667. * @returns the cloned sub emitter
  12668. */
  12669. clone(): SubEmitter;
  12670. /**
  12671. * Serialize current object to a JSON object
  12672. * @returns the serialized object
  12673. */
  12674. serialize(): any;
  12675. /** @hidden */
  12676. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12677. /**
  12678. * Creates a new SubEmitter from a serialized JSON version
  12679. * @param serializationObject defines the JSON object to read from
  12680. * @param scene defines the hosting scene
  12681. * @param rootUrl defines the rootUrl for data loading
  12682. * @returns a new SubEmitter
  12683. */
  12684. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12685. /** Release associated resources */
  12686. dispose(): void;
  12687. }
  12688. }
  12689. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12690. /** @hidden */
  12691. export var imageProcessingDeclaration: {
  12692. name: string;
  12693. shader: string;
  12694. };
  12695. }
  12696. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12697. /** @hidden */
  12698. export var imageProcessingFunctions: {
  12699. name: string;
  12700. shader: string;
  12701. };
  12702. }
  12703. declare module "babylonjs/Shaders/particles.fragment" {
  12704. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12705. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12706. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12707. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12708. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12709. /** @hidden */
  12710. export var particlesPixelShader: {
  12711. name: string;
  12712. shader: string;
  12713. };
  12714. }
  12715. declare module "babylonjs/Shaders/particles.vertex" {
  12716. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12717. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12718. /** @hidden */
  12719. export var particlesVertexShader: {
  12720. name: string;
  12721. shader: string;
  12722. };
  12723. }
  12724. declare module "babylonjs/Particles/particleSystem" {
  12725. import { Nullable } from "babylonjs/types";
  12726. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12727. import { Observable } from "babylonjs/Misc/observable";
  12728. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12729. import { Effect } from "babylonjs/Materials/effect";
  12730. import { Scene, IDisposable } from "babylonjs/scene";
  12731. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12732. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12733. import { Particle } from "babylonjs/Particles/particle";
  12734. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12735. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12736. import "babylonjs/Shaders/particles.fragment";
  12737. import "babylonjs/Shaders/particles.vertex";
  12738. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12739. /**
  12740. * This represents a particle system in Babylon.
  12741. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12742. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12743. * @example https://doc.babylonjs.com/babylon101/particles
  12744. */
  12745. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12746. /**
  12747. * Billboard mode will only apply to Y axis
  12748. */
  12749. static readonly BILLBOARDMODE_Y: number;
  12750. /**
  12751. * Billboard mode will apply to all axes
  12752. */
  12753. static readonly BILLBOARDMODE_ALL: number;
  12754. /**
  12755. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12756. */
  12757. static readonly BILLBOARDMODE_STRETCHED: number;
  12758. /**
  12759. * This function can be defined to provide custom update for active particles.
  12760. * This function will be called instead of regular update (age, position, color, etc.).
  12761. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12762. */
  12763. updateFunction: (particles: Particle[]) => void;
  12764. private _emitterWorldMatrix;
  12765. /**
  12766. * This function can be defined to specify initial direction for every new particle.
  12767. * It by default use the emitterType defined function
  12768. */
  12769. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12770. /**
  12771. * This function can be defined to specify initial position for every new particle.
  12772. * It by default use the emitterType defined function
  12773. */
  12774. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12775. /**
  12776. * @hidden
  12777. */
  12778. _inheritedVelocityOffset: Vector3;
  12779. /**
  12780. * An event triggered when the system is disposed
  12781. */
  12782. onDisposeObservable: Observable<IParticleSystem>;
  12783. private _onDisposeObserver;
  12784. /**
  12785. * Sets a callback that will be triggered when the system is disposed
  12786. */
  12787. set onDispose(callback: () => void);
  12788. private _particles;
  12789. private _epsilon;
  12790. private _capacity;
  12791. private _stockParticles;
  12792. private _newPartsExcess;
  12793. private _vertexData;
  12794. private _vertexBuffer;
  12795. private _vertexBuffers;
  12796. private _spriteBuffer;
  12797. private _indexBuffer;
  12798. private _effect;
  12799. private _customEffect;
  12800. private _cachedDefines;
  12801. private _scaledColorStep;
  12802. private _colorDiff;
  12803. private _scaledDirection;
  12804. private _scaledGravity;
  12805. private _currentRenderId;
  12806. private _alive;
  12807. private _useInstancing;
  12808. private _started;
  12809. private _stopped;
  12810. private _actualFrame;
  12811. private _scaledUpdateSpeed;
  12812. private _vertexBufferSize;
  12813. /** @hidden */
  12814. _currentEmitRateGradient: Nullable<FactorGradient>;
  12815. /** @hidden */
  12816. _currentEmitRate1: number;
  12817. /** @hidden */
  12818. _currentEmitRate2: number;
  12819. /** @hidden */
  12820. _currentStartSizeGradient: Nullable<FactorGradient>;
  12821. /** @hidden */
  12822. _currentStartSize1: number;
  12823. /** @hidden */
  12824. _currentStartSize2: number;
  12825. private readonly _rawTextureWidth;
  12826. private _rampGradientsTexture;
  12827. private _useRampGradients;
  12828. /** Gets or sets a boolean indicating that ramp gradients must be used
  12829. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12830. */
  12831. get useRampGradients(): boolean;
  12832. set useRampGradients(value: boolean);
  12833. /**
  12834. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  12835. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  12836. */
  12837. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12838. private _subEmitters;
  12839. /**
  12840. * @hidden
  12841. * If the particle systems emitter should be disposed when the particle system is disposed
  12842. */
  12843. _disposeEmitterOnDispose: boolean;
  12844. /**
  12845. * The current active Sub-systems, this property is used by the root particle system only.
  12846. */
  12847. activeSubSystems: Array<ParticleSystem>;
  12848. /**
  12849. * Specifies if the particles are updated in emitter local space or world space
  12850. */
  12851. isLocal: boolean;
  12852. private _rootParticleSystem;
  12853. /**
  12854. * Gets the current list of active particles
  12855. */
  12856. get particles(): Particle[];
  12857. /**
  12858. * Gets the number of particles active at the same time.
  12859. * @returns The number of active particles.
  12860. */
  12861. getActiveCount(): number;
  12862. /**
  12863. * Returns the string "ParticleSystem"
  12864. * @returns a string containing the class name
  12865. */
  12866. getClassName(): string;
  12867. /**
  12868. * Gets a boolean indicating that the system is stopping
  12869. * @returns true if the system is currently stopping
  12870. */
  12871. isStopping(): boolean;
  12872. /**
  12873. * Gets the custom effect used to render the particles
  12874. * @param blendMode Blend mode for which the effect should be retrieved
  12875. * @returns The effect
  12876. */
  12877. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12878. /**
  12879. * Sets the custom effect used to render the particles
  12880. * @param effect The effect to set
  12881. * @param blendMode Blend mode for which the effect should be set
  12882. */
  12883. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12884. /** @hidden */
  12885. private _onBeforeDrawParticlesObservable;
  12886. /**
  12887. * Observable that will be called just before the particles are drawn
  12888. */
  12889. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12890. /**
  12891. * Gets the name of the particle vertex shader
  12892. */
  12893. get vertexShaderName(): string;
  12894. /**
  12895. * Instantiates a particle system.
  12896. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12897. * @param name The name of the particle system
  12898. * @param capacity The max number of particles alive at the same time
  12899. * @param scene The scene the particle system belongs to
  12900. * @param customEffect a custom effect used to change the way particles are rendered by default
  12901. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12902. * @param epsilon Offset used to render the particles
  12903. */
  12904. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12905. private _addFactorGradient;
  12906. private _removeFactorGradient;
  12907. /**
  12908. * Adds a new life time gradient
  12909. * @param gradient defines the gradient to use (between 0 and 1)
  12910. * @param factor defines the life time factor to affect to the specified gradient
  12911. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12912. * @returns the current particle system
  12913. */
  12914. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12915. /**
  12916. * Remove a specific life time gradient
  12917. * @param gradient defines the gradient to remove
  12918. * @returns the current particle system
  12919. */
  12920. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12921. /**
  12922. * Adds a new size gradient
  12923. * @param gradient defines the gradient to use (between 0 and 1)
  12924. * @param factor defines the size factor to affect to the specified gradient
  12925. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12926. * @returns the current particle system
  12927. */
  12928. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12929. /**
  12930. * Remove a specific size gradient
  12931. * @param gradient defines the gradient to remove
  12932. * @returns the current particle system
  12933. */
  12934. removeSizeGradient(gradient: number): IParticleSystem;
  12935. /**
  12936. * Adds a new color remap gradient
  12937. * @param gradient defines the gradient to use (between 0 and 1)
  12938. * @param min defines the color remap minimal range
  12939. * @param max defines the color remap maximal range
  12940. * @returns the current particle system
  12941. */
  12942. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12943. /**
  12944. * Remove a specific color remap gradient
  12945. * @param gradient defines the gradient to remove
  12946. * @returns the current particle system
  12947. */
  12948. removeColorRemapGradient(gradient: number): IParticleSystem;
  12949. /**
  12950. * Adds a new alpha remap gradient
  12951. * @param gradient defines the gradient to use (between 0 and 1)
  12952. * @param min defines the alpha remap minimal range
  12953. * @param max defines the alpha remap maximal range
  12954. * @returns the current particle system
  12955. */
  12956. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12957. /**
  12958. * Remove a specific alpha remap gradient
  12959. * @param gradient defines the gradient to remove
  12960. * @returns the current particle system
  12961. */
  12962. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12963. /**
  12964. * Adds a new angular speed gradient
  12965. * @param gradient defines the gradient to use (between 0 and 1)
  12966. * @param factor defines the angular speed to affect to the specified gradient
  12967. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12968. * @returns the current particle system
  12969. */
  12970. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12971. /**
  12972. * Remove a specific angular speed gradient
  12973. * @param gradient defines the gradient to remove
  12974. * @returns the current particle system
  12975. */
  12976. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12977. /**
  12978. * Adds a new velocity gradient
  12979. * @param gradient defines the gradient to use (between 0 and 1)
  12980. * @param factor defines the velocity to affect to the specified gradient
  12981. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12982. * @returns the current particle system
  12983. */
  12984. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12985. /**
  12986. * Remove a specific velocity gradient
  12987. * @param gradient defines the gradient to remove
  12988. * @returns the current particle system
  12989. */
  12990. removeVelocityGradient(gradient: number): IParticleSystem;
  12991. /**
  12992. * Adds a new limit velocity gradient
  12993. * @param gradient defines the gradient to use (between 0 and 1)
  12994. * @param factor defines the limit velocity value to affect to the specified gradient
  12995. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12996. * @returns the current particle system
  12997. */
  12998. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12999. /**
  13000. * Remove a specific limit velocity gradient
  13001. * @param gradient defines the gradient to remove
  13002. * @returns the current particle system
  13003. */
  13004. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13005. /**
  13006. * Adds a new drag gradient
  13007. * @param gradient defines the gradient to use (between 0 and 1)
  13008. * @param factor defines the drag value to affect to the specified gradient
  13009. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13010. * @returns the current particle system
  13011. */
  13012. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13013. /**
  13014. * Remove a specific drag gradient
  13015. * @param gradient defines the gradient to remove
  13016. * @returns the current particle system
  13017. */
  13018. removeDragGradient(gradient: number): IParticleSystem;
  13019. /**
  13020. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13021. * @param gradient defines the gradient to use (between 0 and 1)
  13022. * @param factor defines the emit rate value to affect to the specified gradient
  13023. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13024. * @returns the current particle system
  13025. */
  13026. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13027. /**
  13028. * Remove a specific emit rate gradient
  13029. * @param gradient defines the gradient to remove
  13030. * @returns the current particle system
  13031. */
  13032. removeEmitRateGradient(gradient: number): IParticleSystem;
  13033. /**
  13034. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13035. * @param gradient defines the gradient to use (between 0 and 1)
  13036. * @param factor defines the start size value to affect to the specified gradient
  13037. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13038. * @returns the current particle system
  13039. */
  13040. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13041. /**
  13042. * Remove a specific start size gradient
  13043. * @param gradient defines the gradient to remove
  13044. * @returns the current particle system
  13045. */
  13046. removeStartSizeGradient(gradient: number): IParticleSystem;
  13047. private _createRampGradientTexture;
  13048. /**
  13049. * Gets the current list of ramp gradients.
  13050. * You must use addRampGradient and removeRampGradient to udpate this list
  13051. * @returns the list of ramp gradients
  13052. */
  13053. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13054. /** Force the system to rebuild all gradients that need to be resync */
  13055. forceRefreshGradients(): void;
  13056. private _syncRampGradientTexture;
  13057. /**
  13058. * Adds a new ramp gradient used to remap particle colors
  13059. * @param gradient defines the gradient to use (between 0 and 1)
  13060. * @param color defines the color to affect to the specified gradient
  13061. * @returns the current particle system
  13062. */
  13063. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13064. /**
  13065. * Remove a specific ramp gradient
  13066. * @param gradient defines the gradient to remove
  13067. * @returns the current particle system
  13068. */
  13069. removeRampGradient(gradient: number): ParticleSystem;
  13070. /**
  13071. * Adds a new color gradient
  13072. * @param gradient defines the gradient to use (between 0 and 1)
  13073. * @param color1 defines the color to affect to the specified gradient
  13074. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13075. * @returns this particle system
  13076. */
  13077. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13078. /**
  13079. * Remove a specific color gradient
  13080. * @param gradient defines the gradient to remove
  13081. * @returns this particle system
  13082. */
  13083. removeColorGradient(gradient: number): IParticleSystem;
  13084. private _fetchR;
  13085. protected _reset(): void;
  13086. private _resetEffect;
  13087. private _createVertexBuffers;
  13088. private _createIndexBuffer;
  13089. /**
  13090. * Gets the maximum number of particles active at the same time.
  13091. * @returns The max number of active particles.
  13092. */
  13093. getCapacity(): number;
  13094. /**
  13095. * Gets whether there are still active particles in the system.
  13096. * @returns True if it is alive, otherwise false.
  13097. */
  13098. isAlive(): boolean;
  13099. /**
  13100. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13101. * @returns True if it has been started, otherwise false.
  13102. */
  13103. isStarted(): boolean;
  13104. private _prepareSubEmitterInternalArray;
  13105. /**
  13106. * Starts the particle system and begins to emit
  13107. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13108. */
  13109. start(delay?: number): void;
  13110. /**
  13111. * Stops the particle system.
  13112. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  13113. */
  13114. stop(stopSubEmitters?: boolean): void;
  13115. /**
  13116. * Remove all active particles
  13117. */
  13118. reset(): void;
  13119. /**
  13120. * @hidden (for internal use only)
  13121. */
  13122. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13123. /**
  13124. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13125. * Its lifetime will start back at 0.
  13126. */
  13127. recycleParticle: (particle: Particle) => void;
  13128. private _stopSubEmitters;
  13129. private _createParticle;
  13130. private _removeFromRoot;
  13131. private _emitFromParticle;
  13132. private _update;
  13133. /** @hidden */
  13134. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13135. /** @hidden */
  13136. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13137. /**
  13138. * Fill the defines array according to the current settings of the particle system
  13139. * @param defines Array to be updated
  13140. * @param blendMode blend mode to take into account when updating the array
  13141. */
  13142. fillDefines(defines: Array<string>, blendMode: number): void;
  13143. /**
  13144. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13145. * @param uniforms Uniforms array to fill
  13146. * @param attributes Attributes array to fill
  13147. * @param samplers Samplers array to fill
  13148. */
  13149. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13150. /** @hidden */
  13151. private _getEffect;
  13152. /**
  13153. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13154. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13155. */
  13156. animate(preWarmOnly?: boolean): void;
  13157. private _appendParticleVertices;
  13158. /**
  13159. * Rebuilds the particle system.
  13160. */
  13161. rebuild(): void;
  13162. /**
  13163. * Is this system ready to be used/rendered
  13164. * @return true if the system is ready
  13165. */
  13166. isReady(): boolean;
  13167. private _render;
  13168. /**
  13169. * Renders the particle system in its current state.
  13170. * @returns the current number of particles
  13171. */
  13172. render(): number;
  13173. /**
  13174. * Disposes the particle system and free the associated resources
  13175. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13176. */
  13177. dispose(disposeTexture?: boolean): void;
  13178. /**
  13179. * Clones the particle system.
  13180. * @param name The name of the cloned object
  13181. * @param newEmitter The new emitter to use
  13182. * @returns the cloned particle system
  13183. */
  13184. clone(name: string, newEmitter: any): ParticleSystem;
  13185. /**
  13186. * Serializes the particle system to a JSON object
  13187. * @param serializeTexture defines if the texture must be serialized as well
  13188. * @returns the JSON object
  13189. */
  13190. serialize(serializeTexture?: boolean): any;
  13191. /** @hidden */
  13192. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13193. /** @hidden */
  13194. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  13195. /**
  13196. * Parses a JSON object to create a particle system.
  13197. * @param parsedParticleSystem The JSON object to parse
  13198. * @param scene The scene to create the particle system in
  13199. * @param rootUrl The root url to use to load external dependencies like texture
  13200. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13201. * @returns the Parsed particle system
  13202. */
  13203. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13204. }
  13205. }
  13206. declare module "babylonjs/Particles/particle" {
  13207. import { Nullable } from "babylonjs/types";
  13208. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13209. import { Color4 } from "babylonjs/Maths/math.color";
  13210. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13211. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13212. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13213. /**
  13214. * A particle represents one of the element emitted by a particle system.
  13215. * This is mainly define by its coordinates, direction, velocity and age.
  13216. */
  13217. export class Particle {
  13218. /**
  13219. * The particle system the particle belongs to.
  13220. */
  13221. particleSystem: ParticleSystem;
  13222. private static _Count;
  13223. /**
  13224. * Unique ID of the particle
  13225. */
  13226. id: number;
  13227. /**
  13228. * The world position of the particle in the scene.
  13229. */
  13230. position: Vector3;
  13231. /**
  13232. * The world direction of the particle in the scene.
  13233. */
  13234. direction: Vector3;
  13235. /**
  13236. * The color of the particle.
  13237. */
  13238. color: Color4;
  13239. /**
  13240. * The color change of the particle per step.
  13241. */
  13242. colorStep: Color4;
  13243. /**
  13244. * Defines how long will the life of the particle be.
  13245. */
  13246. lifeTime: number;
  13247. /**
  13248. * The current age of the particle.
  13249. */
  13250. age: number;
  13251. /**
  13252. * The current size of the particle.
  13253. */
  13254. size: number;
  13255. /**
  13256. * The current scale of the particle.
  13257. */
  13258. scale: Vector2;
  13259. /**
  13260. * The current angle of the particle.
  13261. */
  13262. angle: number;
  13263. /**
  13264. * Defines how fast is the angle changing.
  13265. */
  13266. angularSpeed: number;
  13267. /**
  13268. * Defines the cell index used by the particle to be rendered from a sprite.
  13269. */
  13270. cellIndex: number;
  13271. /**
  13272. * The information required to support color remapping
  13273. */
  13274. remapData: Vector4;
  13275. /** @hidden */
  13276. _randomCellOffset?: number;
  13277. /** @hidden */
  13278. _initialDirection: Nullable<Vector3>;
  13279. /** @hidden */
  13280. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13281. /** @hidden */
  13282. _initialStartSpriteCellID: number;
  13283. /** @hidden */
  13284. _initialEndSpriteCellID: number;
  13285. /** @hidden */
  13286. _currentColorGradient: Nullable<ColorGradient>;
  13287. /** @hidden */
  13288. _currentColor1: Color4;
  13289. /** @hidden */
  13290. _currentColor2: Color4;
  13291. /** @hidden */
  13292. _currentSizeGradient: Nullable<FactorGradient>;
  13293. /** @hidden */
  13294. _currentSize1: number;
  13295. /** @hidden */
  13296. _currentSize2: number;
  13297. /** @hidden */
  13298. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13299. /** @hidden */
  13300. _currentAngularSpeed1: number;
  13301. /** @hidden */
  13302. _currentAngularSpeed2: number;
  13303. /** @hidden */
  13304. _currentVelocityGradient: Nullable<FactorGradient>;
  13305. /** @hidden */
  13306. _currentVelocity1: number;
  13307. /** @hidden */
  13308. _currentVelocity2: number;
  13309. /** @hidden */
  13310. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13311. /** @hidden */
  13312. _currentLimitVelocity1: number;
  13313. /** @hidden */
  13314. _currentLimitVelocity2: number;
  13315. /** @hidden */
  13316. _currentDragGradient: Nullable<FactorGradient>;
  13317. /** @hidden */
  13318. _currentDrag1: number;
  13319. /** @hidden */
  13320. _currentDrag2: number;
  13321. /** @hidden */
  13322. _randomNoiseCoordinates1: Vector3;
  13323. /** @hidden */
  13324. _randomNoiseCoordinates2: Vector3;
  13325. /** @hidden */
  13326. _localPosition?: Vector3;
  13327. /**
  13328. * Creates a new instance Particle
  13329. * @param particleSystem the particle system the particle belongs to
  13330. */
  13331. constructor(
  13332. /**
  13333. * The particle system the particle belongs to.
  13334. */
  13335. particleSystem: ParticleSystem);
  13336. private updateCellInfoFromSystem;
  13337. /**
  13338. * Defines how the sprite cell index is updated for the particle
  13339. */
  13340. updateCellIndex(): void;
  13341. /** @hidden */
  13342. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13343. /** @hidden */
  13344. _inheritParticleInfoToSubEmitters(): void;
  13345. /** @hidden */
  13346. _reset(): void;
  13347. /**
  13348. * Copy the properties of particle to another one.
  13349. * @param other the particle to copy the information to.
  13350. */
  13351. copyTo(other: Particle): void;
  13352. }
  13353. }
  13354. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13355. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13356. import { Effect } from "babylonjs/Materials/effect";
  13357. import { Particle } from "babylonjs/Particles/particle";
  13358. import { Scene } from "babylonjs/scene";
  13359. /**
  13360. * Particle emitter represents a volume emitting particles.
  13361. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13362. */
  13363. export interface IParticleEmitterType {
  13364. /**
  13365. * Called by the particle System when the direction is computed for the created particle.
  13366. * @param worldMatrix is the world matrix of the particle system
  13367. * @param directionToUpdate is the direction vector to update with the result
  13368. * @param particle is the particle we are computed the direction for
  13369. * @param isLocal defines if the direction should be set in local space
  13370. */
  13371. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13372. /**
  13373. * Called by the particle System when the position is computed for the created particle.
  13374. * @param worldMatrix is the world matrix of the particle system
  13375. * @param positionToUpdate is the position vector to update with the result
  13376. * @param particle is the particle we are computed the position for
  13377. * @param isLocal defines if the position should be set in local space
  13378. */
  13379. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13380. /**
  13381. * Clones the current emitter and returns a copy of it
  13382. * @returns the new emitter
  13383. */
  13384. clone(): IParticleEmitterType;
  13385. /**
  13386. * Called by the GPUParticleSystem to setup the update shader
  13387. * @param effect defines the update shader
  13388. */
  13389. applyToShader(effect: Effect): void;
  13390. /**
  13391. * Returns a string to use to update the GPU particles update shader
  13392. * @returns the effect defines string
  13393. */
  13394. getEffectDefines(): string;
  13395. /**
  13396. * Returns a string representing the class name
  13397. * @returns a string containing the class name
  13398. */
  13399. getClassName(): string;
  13400. /**
  13401. * Serializes the particle system to a JSON object.
  13402. * @returns the JSON object
  13403. */
  13404. serialize(): any;
  13405. /**
  13406. * Parse properties from a JSON object
  13407. * @param serializationObject defines the JSON object
  13408. * @param scene defines the hosting scene
  13409. */
  13410. parse(serializationObject: any, scene: Scene): void;
  13411. }
  13412. }
  13413. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13414. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13415. import { Effect } from "babylonjs/Materials/effect";
  13416. import { Particle } from "babylonjs/Particles/particle";
  13417. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13418. /**
  13419. * Particle emitter emitting particles from the inside of a box.
  13420. * It emits the particles randomly between 2 given directions.
  13421. */
  13422. export class BoxParticleEmitter implements IParticleEmitterType {
  13423. /**
  13424. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13425. */
  13426. direction1: Vector3;
  13427. /**
  13428. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13429. */
  13430. direction2: Vector3;
  13431. /**
  13432. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13433. */
  13434. minEmitBox: Vector3;
  13435. /**
  13436. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13437. */
  13438. maxEmitBox: Vector3;
  13439. /**
  13440. * Creates a new instance BoxParticleEmitter
  13441. */
  13442. constructor();
  13443. /**
  13444. * Called by the particle System when the direction is computed for the created particle.
  13445. * @param worldMatrix is the world matrix of the particle system
  13446. * @param directionToUpdate is the direction vector to update with the result
  13447. * @param particle is the particle we are computed the direction for
  13448. * @param isLocal defines if the direction should be set in local space
  13449. */
  13450. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13451. /**
  13452. * Called by the particle System when the position is computed for the created particle.
  13453. * @param worldMatrix is the world matrix of the particle system
  13454. * @param positionToUpdate is the position vector to update with the result
  13455. * @param particle is the particle we are computed the position for
  13456. * @param isLocal defines if the position should be set in local space
  13457. */
  13458. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13459. /**
  13460. * Clones the current emitter and returns a copy of it
  13461. * @returns the new emitter
  13462. */
  13463. clone(): BoxParticleEmitter;
  13464. /**
  13465. * Called by the GPUParticleSystem to setup the update shader
  13466. * @param effect defines the update shader
  13467. */
  13468. applyToShader(effect: Effect): void;
  13469. /**
  13470. * Returns a string to use to update the GPU particles update shader
  13471. * @returns a string containng the defines string
  13472. */
  13473. getEffectDefines(): string;
  13474. /**
  13475. * Returns the string "BoxParticleEmitter"
  13476. * @returns a string containing the class name
  13477. */
  13478. getClassName(): string;
  13479. /**
  13480. * Serializes the particle system to a JSON object.
  13481. * @returns the JSON object
  13482. */
  13483. serialize(): any;
  13484. /**
  13485. * Parse properties from a JSON object
  13486. * @param serializationObject defines the JSON object
  13487. */
  13488. parse(serializationObject: any): void;
  13489. }
  13490. }
  13491. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13492. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13493. import { Effect } from "babylonjs/Materials/effect";
  13494. import { Particle } from "babylonjs/Particles/particle";
  13495. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13496. /**
  13497. * Particle emitter emitting particles from the inside of a cone.
  13498. * It emits the particles alongside the cone volume from the base to the particle.
  13499. * The emission direction might be randomized.
  13500. */
  13501. export class ConeParticleEmitter implements IParticleEmitterType {
  13502. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13503. directionRandomizer: number;
  13504. private _radius;
  13505. private _angle;
  13506. private _height;
  13507. /**
  13508. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13509. */
  13510. radiusRange: number;
  13511. /**
  13512. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13513. */
  13514. heightRange: number;
  13515. /**
  13516. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13517. */
  13518. emitFromSpawnPointOnly: boolean;
  13519. /**
  13520. * Gets or sets the radius of the emission cone
  13521. */
  13522. get radius(): number;
  13523. set radius(value: number);
  13524. /**
  13525. * Gets or sets the angle of the emission cone
  13526. */
  13527. get angle(): number;
  13528. set angle(value: number);
  13529. private _buildHeight;
  13530. /**
  13531. * Creates a new instance ConeParticleEmitter
  13532. * @param radius the radius of the emission cone (1 by default)
  13533. * @param angle the cone base angle (PI by default)
  13534. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13535. */
  13536. constructor(radius?: number, angle?: number,
  13537. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13538. directionRandomizer?: number);
  13539. /**
  13540. * Called by the particle System when the direction is computed for the created particle.
  13541. * @param worldMatrix is the world matrix of the particle system
  13542. * @param directionToUpdate is the direction vector to update with the result
  13543. * @param particle is the particle we are computed the direction for
  13544. * @param isLocal defines if the direction should be set in local space
  13545. */
  13546. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13547. /**
  13548. * Called by the particle System when the position is computed for the created particle.
  13549. * @param worldMatrix is the world matrix of the particle system
  13550. * @param positionToUpdate is the position vector to update with the result
  13551. * @param particle is the particle we are computed the position for
  13552. * @param isLocal defines if the position should be set in local space
  13553. */
  13554. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13555. /**
  13556. * Clones the current emitter and returns a copy of it
  13557. * @returns the new emitter
  13558. */
  13559. clone(): ConeParticleEmitter;
  13560. /**
  13561. * Called by the GPUParticleSystem to setup the update shader
  13562. * @param effect defines the update shader
  13563. */
  13564. applyToShader(effect: Effect): void;
  13565. /**
  13566. * Returns a string to use to update the GPU particles update shader
  13567. * @returns a string containng the defines string
  13568. */
  13569. getEffectDefines(): string;
  13570. /**
  13571. * Returns the string "ConeParticleEmitter"
  13572. * @returns a string containing the class name
  13573. */
  13574. getClassName(): string;
  13575. /**
  13576. * Serializes the particle system to a JSON object.
  13577. * @returns the JSON object
  13578. */
  13579. serialize(): any;
  13580. /**
  13581. * Parse properties from a JSON object
  13582. * @param serializationObject defines the JSON object
  13583. */
  13584. parse(serializationObject: any): void;
  13585. }
  13586. }
  13587. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13588. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13589. import { Effect } from "babylonjs/Materials/effect";
  13590. import { Particle } from "babylonjs/Particles/particle";
  13591. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13592. /**
  13593. * Particle emitter emitting particles from the inside of a cylinder.
  13594. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13595. */
  13596. export class CylinderParticleEmitter implements IParticleEmitterType {
  13597. /**
  13598. * The radius of the emission cylinder.
  13599. */
  13600. radius: number;
  13601. /**
  13602. * The height of the emission cylinder.
  13603. */
  13604. height: number;
  13605. /**
  13606. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13607. */
  13608. radiusRange: number;
  13609. /**
  13610. * How much to randomize the particle direction [0-1].
  13611. */
  13612. directionRandomizer: number;
  13613. /**
  13614. * Creates a new instance CylinderParticleEmitter
  13615. * @param radius the radius of the emission cylinder (1 by default)
  13616. * @param height the height of the emission cylinder (1 by default)
  13617. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13618. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13619. */
  13620. constructor(
  13621. /**
  13622. * The radius of the emission cylinder.
  13623. */
  13624. radius?: number,
  13625. /**
  13626. * The height of the emission cylinder.
  13627. */
  13628. height?: number,
  13629. /**
  13630. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13631. */
  13632. radiusRange?: number,
  13633. /**
  13634. * How much to randomize the particle direction [0-1].
  13635. */
  13636. directionRandomizer?: number);
  13637. /**
  13638. * Called by the particle System when the direction is computed for the created particle.
  13639. * @param worldMatrix is the world matrix of the particle system
  13640. * @param directionToUpdate is the direction vector to update with the result
  13641. * @param particle is the particle we are computed the direction for
  13642. * @param isLocal defines if the direction should be set in local space
  13643. */
  13644. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13645. /**
  13646. * Called by the particle System when the position is computed for the created particle.
  13647. * @param worldMatrix is the world matrix of the particle system
  13648. * @param positionToUpdate is the position vector to update with the result
  13649. * @param particle is the particle we are computed the position for
  13650. * @param isLocal defines if the position should be set in local space
  13651. */
  13652. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13653. /**
  13654. * Clones the current emitter and returns a copy of it
  13655. * @returns the new emitter
  13656. */
  13657. clone(): CylinderParticleEmitter;
  13658. /**
  13659. * Called by the GPUParticleSystem to setup the update shader
  13660. * @param effect defines the update shader
  13661. */
  13662. applyToShader(effect: Effect): void;
  13663. /**
  13664. * Returns a string to use to update the GPU particles update shader
  13665. * @returns a string containng the defines string
  13666. */
  13667. getEffectDefines(): string;
  13668. /**
  13669. * Returns the string "CylinderParticleEmitter"
  13670. * @returns a string containing the class name
  13671. */
  13672. getClassName(): string;
  13673. /**
  13674. * Serializes the particle system to a JSON object.
  13675. * @returns the JSON object
  13676. */
  13677. serialize(): any;
  13678. /**
  13679. * Parse properties from a JSON object
  13680. * @param serializationObject defines the JSON object
  13681. */
  13682. parse(serializationObject: any): void;
  13683. }
  13684. /**
  13685. * Particle emitter emitting particles from the inside of a cylinder.
  13686. * It emits the particles randomly between two vectors.
  13687. */
  13688. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13689. /**
  13690. * The min limit of the emission direction.
  13691. */
  13692. direction1: Vector3;
  13693. /**
  13694. * The max limit of the emission direction.
  13695. */
  13696. direction2: Vector3;
  13697. /**
  13698. * Creates a new instance CylinderDirectedParticleEmitter
  13699. * @param radius the radius of the emission cylinder (1 by default)
  13700. * @param height the height of the emission cylinder (1 by default)
  13701. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13702. * @param direction1 the min limit of the emission direction (up vector by default)
  13703. * @param direction2 the max limit of the emission direction (up vector by default)
  13704. */
  13705. constructor(radius?: number, height?: number, radiusRange?: number,
  13706. /**
  13707. * The min limit of the emission direction.
  13708. */
  13709. direction1?: Vector3,
  13710. /**
  13711. * The max limit of the emission direction.
  13712. */
  13713. direction2?: Vector3);
  13714. /**
  13715. * Called by the particle System when the direction is computed for the created particle.
  13716. * @param worldMatrix is the world matrix of the particle system
  13717. * @param directionToUpdate is the direction vector to update with the result
  13718. * @param particle is the particle we are computed the direction for
  13719. */
  13720. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13721. /**
  13722. * Clones the current emitter and returns a copy of it
  13723. * @returns the new emitter
  13724. */
  13725. clone(): CylinderDirectedParticleEmitter;
  13726. /**
  13727. * Called by the GPUParticleSystem to setup the update shader
  13728. * @param effect defines the update shader
  13729. */
  13730. applyToShader(effect: Effect): void;
  13731. /**
  13732. * Returns a string to use to update the GPU particles update shader
  13733. * @returns a string containng the defines string
  13734. */
  13735. getEffectDefines(): string;
  13736. /**
  13737. * Returns the string "CylinderDirectedParticleEmitter"
  13738. * @returns a string containing the class name
  13739. */
  13740. getClassName(): string;
  13741. /**
  13742. * Serializes the particle system to a JSON object.
  13743. * @returns the JSON object
  13744. */
  13745. serialize(): any;
  13746. /**
  13747. * Parse properties from a JSON object
  13748. * @param serializationObject defines the JSON object
  13749. */
  13750. parse(serializationObject: any): void;
  13751. }
  13752. }
  13753. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13754. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13755. import { Effect } from "babylonjs/Materials/effect";
  13756. import { Particle } from "babylonjs/Particles/particle";
  13757. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13758. /**
  13759. * Particle emitter emitting particles from the inside of a hemisphere.
  13760. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13761. */
  13762. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13763. /**
  13764. * The radius of the emission hemisphere.
  13765. */
  13766. radius: number;
  13767. /**
  13768. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13769. */
  13770. radiusRange: number;
  13771. /**
  13772. * How much to randomize the particle direction [0-1].
  13773. */
  13774. directionRandomizer: number;
  13775. /**
  13776. * Creates a new instance HemisphericParticleEmitter
  13777. * @param radius the radius of the emission hemisphere (1 by default)
  13778. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13779. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13780. */
  13781. constructor(
  13782. /**
  13783. * The radius of the emission hemisphere.
  13784. */
  13785. radius?: number,
  13786. /**
  13787. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13788. */
  13789. radiusRange?: number,
  13790. /**
  13791. * How much to randomize the particle direction [0-1].
  13792. */
  13793. directionRandomizer?: number);
  13794. /**
  13795. * Called by the particle System when the direction is computed for the created particle.
  13796. * @param worldMatrix is the world matrix of the particle system
  13797. * @param directionToUpdate is the direction vector to update with the result
  13798. * @param particle is the particle we are computed the direction for
  13799. * @param isLocal defines if the direction should be set in local space
  13800. */
  13801. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13802. /**
  13803. * Called by the particle System when the position is computed for the created particle.
  13804. * @param worldMatrix is the world matrix of the particle system
  13805. * @param positionToUpdate is the position vector to update with the result
  13806. * @param particle is the particle we are computed the position for
  13807. * @param isLocal defines if the position should be set in local space
  13808. */
  13809. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13810. /**
  13811. * Clones the current emitter and returns a copy of it
  13812. * @returns the new emitter
  13813. */
  13814. clone(): HemisphericParticleEmitter;
  13815. /**
  13816. * Called by the GPUParticleSystem to setup the update shader
  13817. * @param effect defines the update shader
  13818. */
  13819. applyToShader(effect: Effect): void;
  13820. /**
  13821. * Returns a string to use to update the GPU particles update shader
  13822. * @returns a string containng the defines string
  13823. */
  13824. getEffectDefines(): string;
  13825. /**
  13826. * Returns the string "HemisphericParticleEmitter"
  13827. * @returns a string containing the class name
  13828. */
  13829. getClassName(): string;
  13830. /**
  13831. * Serializes the particle system to a JSON object.
  13832. * @returns the JSON object
  13833. */
  13834. serialize(): any;
  13835. /**
  13836. * Parse properties from a JSON object
  13837. * @param serializationObject defines the JSON object
  13838. */
  13839. parse(serializationObject: any): void;
  13840. }
  13841. }
  13842. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13843. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13844. import { Effect } from "babylonjs/Materials/effect";
  13845. import { Particle } from "babylonjs/Particles/particle";
  13846. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13847. /**
  13848. * Particle emitter emitting particles from a point.
  13849. * It emits the particles randomly between 2 given directions.
  13850. */
  13851. export class PointParticleEmitter implements IParticleEmitterType {
  13852. /**
  13853. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13854. */
  13855. direction1: Vector3;
  13856. /**
  13857. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13858. */
  13859. direction2: Vector3;
  13860. /**
  13861. * Creates a new instance PointParticleEmitter
  13862. */
  13863. constructor();
  13864. /**
  13865. * Called by the particle System when the direction is computed for the created particle.
  13866. * @param worldMatrix is the world matrix of the particle system
  13867. * @param directionToUpdate is the direction vector to update with the result
  13868. * @param particle is the particle we are computed the direction for
  13869. * @param isLocal defines if the direction should be set in local space
  13870. */
  13871. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13872. /**
  13873. * Called by the particle System when the position is computed for the created particle.
  13874. * @param worldMatrix is the world matrix of the particle system
  13875. * @param positionToUpdate is the position vector to update with the result
  13876. * @param particle is the particle we are computed the position for
  13877. * @param isLocal defines if the position should be set in local space
  13878. */
  13879. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13880. /**
  13881. * Clones the current emitter and returns a copy of it
  13882. * @returns the new emitter
  13883. */
  13884. clone(): PointParticleEmitter;
  13885. /**
  13886. * Called by the GPUParticleSystem to setup the update shader
  13887. * @param effect defines the update shader
  13888. */
  13889. applyToShader(effect: Effect): void;
  13890. /**
  13891. * Returns a string to use to update the GPU particles update shader
  13892. * @returns a string containng the defines string
  13893. */
  13894. getEffectDefines(): string;
  13895. /**
  13896. * Returns the string "PointParticleEmitter"
  13897. * @returns a string containing the class name
  13898. */
  13899. getClassName(): string;
  13900. /**
  13901. * Serializes the particle system to a JSON object.
  13902. * @returns the JSON object
  13903. */
  13904. serialize(): any;
  13905. /**
  13906. * Parse properties from a JSON object
  13907. * @param serializationObject defines the JSON object
  13908. */
  13909. parse(serializationObject: any): void;
  13910. }
  13911. }
  13912. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13913. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13914. import { Effect } from "babylonjs/Materials/effect";
  13915. import { Particle } from "babylonjs/Particles/particle";
  13916. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13917. /**
  13918. * Particle emitter emitting particles from the inside of a sphere.
  13919. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13920. */
  13921. export class SphereParticleEmitter implements IParticleEmitterType {
  13922. /**
  13923. * The radius of the emission sphere.
  13924. */
  13925. radius: number;
  13926. /**
  13927. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13928. */
  13929. radiusRange: number;
  13930. /**
  13931. * How much to randomize the particle direction [0-1].
  13932. */
  13933. directionRandomizer: number;
  13934. /**
  13935. * Creates a new instance SphereParticleEmitter
  13936. * @param radius the radius of the emission sphere (1 by default)
  13937. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13938. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13939. */
  13940. constructor(
  13941. /**
  13942. * The radius of the emission sphere.
  13943. */
  13944. radius?: number,
  13945. /**
  13946. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13947. */
  13948. radiusRange?: number,
  13949. /**
  13950. * How much to randomize the particle direction [0-1].
  13951. */
  13952. directionRandomizer?: number);
  13953. /**
  13954. * Called by the particle System when the direction is computed for the created particle.
  13955. * @param worldMatrix is the world matrix of the particle system
  13956. * @param directionToUpdate is the direction vector to update with the result
  13957. * @param particle is the particle we are computed the direction for
  13958. * @param isLocal defines if the direction should be set in local space
  13959. */
  13960. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13961. /**
  13962. * Called by the particle System when the position is computed for the created particle.
  13963. * @param worldMatrix is the world matrix of the particle system
  13964. * @param positionToUpdate is the position vector to update with the result
  13965. * @param particle is the particle we are computed the position for
  13966. * @param isLocal defines if the position should be set in local space
  13967. */
  13968. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13969. /**
  13970. * Clones the current emitter and returns a copy of it
  13971. * @returns the new emitter
  13972. */
  13973. clone(): SphereParticleEmitter;
  13974. /**
  13975. * Called by the GPUParticleSystem to setup the update shader
  13976. * @param effect defines the update shader
  13977. */
  13978. applyToShader(effect: Effect): void;
  13979. /**
  13980. * Returns a string to use to update the GPU particles update shader
  13981. * @returns a string containng the defines string
  13982. */
  13983. getEffectDefines(): string;
  13984. /**
  13985. * Returns the string "SphereParticleEmitter"
  13986. * @returns a string containing the class name
  13987. */
  13988. getClassName(): string;
  13989. /**
  13990. * Serializes the particle system to a JSON object.
  13991. * @returns the JSON object
  13992. */
  13993. serialize(): any;
  13994. /**
  13995. * Parse properties from a JSON object
  13996. * @param serializationObject defines the JSON object
  13997. */
  13998. parse(serializationObject: any): void;
  13999. }
  14000. /**
  14001. * Particle emitter emitting particles from the inside of a sphere.
  14002. * It emits the particles randomly between two vectors.
  14003. */
  14004. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14005. /**
  14006. * The min limit of the emission direction.
  14007. */
  14008. direction1: Vector3;
  14009. /**
  14010. * The max limit of the emission direction.
  14011. */
  14012. direction2: Vector3;
  14013. /**
  14014. * Creates a new instance SphereDirectedParticleEmitter
  14015. * @param radius the radius of the emission sphere (1 by default)
  14016. * @param direction1 the min limit of the emission direction (up vector by default)
  14017. * @param direction2 the max limit of the emission direction (up vector by default)
  14018. */
  14019. constructor(radius?: number,
  14020. /**
  14021. * The min limit of the emission direction.
  14022. */
  14023. direction1?: Vector3,
  14024. /**
  14025. * The max limit of the emission direction.
  14026. */
  14027. direction2?: Vector3);
  14028. /**
  14029. * Called by the particle System when the direction is computed for the created particle.
  14030. * @param worldMatrix is the world matrix of the particle system
  14031. * @param directionToUpdate is the direction vector to update with the result
  14032. * @param particle is the particle we are computed the direction for
  14033. */
  14034. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14035. /**
  14036. * Clones the current emitter and returns a copy of it
  14037. * @returns the new emitter
  14038. */
  14039. clone(): SphereDirectedParticleEmitter;
  14040. /**
  14041. * Called by the GPUParticleSystem to setup the update shader
  14042. * @param effect defines the update shader
  14043. */
  14044. applyToShader(effect: Effect): void;
  14045. /**
  14046. * Returns a string to use to update the GPU particles update shader
  14047. * @returns a string containng the defines string
  14048. */
  14049. getEffectDefines(): string;
  14050. /**
  14051. * Returns the string "SphereDirectedParticleEmitter"
  14052. * @returns a string containing the class name
  14053. */
  14054. getClassName(): string;
  14055. /**
  14056. * Serializes the particle system to a JSON object.
  14057. * @returns the JSON object
  14058. */
  14059. serialize(): any;
  14060. /**
  14061. * Parse properties from a JSON object
  14062. * @param serializationObject defines the JSON object
  14063. */
  14064. parse(serializationObject: any): void;
  14065. }
  14066. }
  14067. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14068. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14069. import { Effect } from "babylonjs/Materials/effect";
  14070. import { Particle } from "babylonjs/Particles/particle";
  14071. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14072. import { Nullable } from "babylonjs/types";
  14073. /**
  14074. * Particle emitter emitting particles from a custom list of positions.
  14075. */
  14076. export class CustomParticleEmitter implements IParticleEmitterType {
  14077. /**
  14078. * Gets or sets the position generator that will create the inital position of each particle.
  14079. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14080. */
  14081. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14082. /**
  14083. * Gets or sets the destination generator that will create the final destination of each particle.
  14084. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14085. */
  14086. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14087. /**
  14088. * Creates a new instance CustomParticleEmitter
  14089. */
  14090. constructor();
  14091. /**
  14092. * Called by the particle System when the direction is computed for the created particle.
  14093. * @param worldMatrix is the world matrix of the particle system
  14094. * @param directionToUpdate is the direction vector to update with the result
  14095. * @param particle is the particle we are computed the direction for
  14096. * @param isLocal defines if the direction should be set in local space
  14097. */
  14098. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14099. /**
  14100. * Called by the particle System when the position is computed for the created particle.
  14101. * @param worldMatrix is the world matrix of the particle system
  14102. * @param positionToUpdate is the position vector to update with the result
  14103. * @param particle is the particle we are computed the position for
  14104. * @param isLocal defines if the position should be set in local space
  14105. */
  14106. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14107. /**
  14108. * Clones the current emitter and returns a copy of it
  14109. * @returns the new emitter
  14110. */
  14111. clone(): CustomParticleEmitter;
  14112. /**
  14113. * Called by the GPUParticleSystem to setup the update shader
  14114. * @param effect defines the update shader
  14115. */
  14116. applyToShader(effect: Effect): void;
  14117. /**
  14118. * Returns a string to use to update the GPU particles update shader
  14119. * @returns a string containng the defines string
  14120. */
  14121. getEffectDefines(): string;
  14122. /**
  14123. * Returns the string "PointParticleEmitter"
  14124. * @returns a string containing the class name
  14125. */
  14126. getClassName(): string;
  14127. /**
  14128. * Serializes the particle system to a JSON object.
  14129. * @returns the JSON object
  14130. */
  14131. serialize(): any;
  14132. /**
  14133. * Parse properties from a JSON object
  14134. * @param serializationObject defines the JSON object
  14135. */
  14136. parse(serializationObject: any): void;
  14137. }
  14138. }
  14139. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14140. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14141. import { Effect } from "babylonjs/Materials/effect";
  14142. import { Particle } from "babylonjs/Particles/particle";
  14143. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14144. import { Nullable } from "babylonjs/types";
  14145. import { Scene } from "babylonjs/scene";
  14146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14147. /**
  14148. * Particle emitter emitting particles from the inside of a box.
  14149. * It emits the particles randomly between 2 given directions.
  14150. */
  14151. export class MeshParticleEmitter implements IParticleEmitterType {
  14152. private _indices;
  14153. private _positions;
  14154. private _normals;
  14155. private _storedNormal;
  14156. private _mesh;
  14157. /**
  14158. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14159. */
  14160. direction1: Vector3;
  14161. /**
  14162. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14163. */
  14164. direction2: Vector3;
  14165. /**
  14166. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14167. */
  14168. useMeshNormalsForDirection: boolean;
  14169. /** Defines the mesh to use as source */
  14170. get mesh(): Nullable<AbstractMesh>;
  14171. set mesh(value: Nullable<AbstractMesh>);
  14172. /**
  14173. * Creates a new instance MeshParticleEmitter
  14174. * @param mesh defines the mesh to use as source
  14175. */
  14176. constructor(mesh?: Nullable<AbstractMesh>);
  14177. /**
  14178. * Called by the particle System when the direction is computed for the created particle.
  14179. * @param worldMatrix is the world matrix of the particle system
  14180. * @param directionToUpdate is the direction vector to update with the result
  14181. * @param particle is the particle we are computed the direction for
  14182. * @param isLocal defines if the direction should be set in local space
  14183. */
  14184. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14185. /**
  14186. * Called by the particle System when the position is computed for the created particle.
  14187. * @param worldMatrix is the world matrix of the particle system
  14188. * @param positionToUpdate is the position vector to update with the result
  14189. * @param particle is the particle we are computed the position for
  14190. * @param isLocal defines if the position should be set in local space
  14191. */
  14192. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14193. /**
  14194. * Clones the current emitter and returns a copy of it
  14195. * @returns the new emitter
  14196. */
  14197. clone(): MeshParticleEmitter;
  14198. /**
  14199. * Called by the GPUParticleSystem to setup the update shader
  14200. * @param effect defines the update shader
  14201. */
  14202. applyToShader(effect: Effect): void;
  14203. /**
  14204. * Returns a string to use to update the GPU particles update shader
  14205. * @returns a string containng the defines string
  14206. */
  14207. getEffectDefines(): string;
  14208. /**
  14209. * Returns the string "BoxParticleEmitter"
  14210. * @returns a string containing the class name
  14211. */
  14212. getClassName(): string;
  14213. /**
  14214. * Serializes the particle system to a JSON object.
  14215. * @returns the JSON object
  14216. */
  14217. serialize(): any;
  14218. /**
  14219. * Parse properties from a JSON object
  14220. * @param serializationObject defines the JSON object
  14221. * @param scene defines the hosting scene
  14222. */
  14223. parse(serializationObject: any, scene: Scene): void;
  14224. }
  14225. }
  14226. declare module "babylonjs/Particles/EmitterTypes/index" {
  14227. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14228. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14229. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14230. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14231. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14232. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14233. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14234. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14235. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14236. }
  14237. declare module "babylonjs/Particles/IParticleSystem" {
  14238. import { Nullable } from "babylonjs/types";
  14239. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  14240. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14242. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14243. import { Texture } from "babylonjs/Materials/Textures/texture";
  14244. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14245. import { Scene } from "babylonjs/scene";
  14246. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14247. import { Effect } from "babylonjs/Materials/effect";
  14248. import { Observable } from "babylonjs/Misc/observable";
  14249. import { Animation } from "babylonjs/Animations/animation";
  14250. /**
  14251. * Interface representing a particle system in Babylon.js.
  14252. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14253. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14254. */
  14255. export interface IParticleSystem {
  14256. /**
  14257. * List of animations used by the particle system.
  14258. */
  14259. animations: Animation[];
  14260. /**
  14261. * The id of the Particle system.
  14262. */
  14263. id: string;
  14264. /**
  14265. * The name of the Particle system.
  14266. */
  14267. name: string;
  14268. /**
  14269. * The emitter represents the Mesh or position we are attaching the particle system to.
  14270. */
  14271. emitter: Nullable<AbstractMesh | Vector3>;
  14272. /**
  14273. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14274. */
  14275. isBillboardBased: boolean;
  14276. /**
  14277. * The rendering group used by the Particle system to chose when to render.
  14278. */
  14279. renderingGroupId: number;
  14280. /**
  14281. * The layer mask we are rendering the particles through.
  14282. */
  14283. layerMask: number;
  14284. /**
  14285. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14286. */
  14287. updateSpeed: number;
  14288. /**
  14289. * The amount of time the particle system is running (depends of the overall update speed).
  14290. */
  14291. targetStopDuration: number;
  14292. /**
  14293. * The texture used to render each particle. (this can be a spritesheet)
  14294. */
  14295. particleTexture: Nullable<Texture>;
  14296. /**
  14297. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14298. */
  14299. blendMode: number;
  14300. /**
  14301. * Minimum life time of emitting particles.
  14302. */
  14303. minLifeTime: number;
  14304. /**
  14305. * Maximum life time of emitting particles.
  14306. */
  14307. maxLifeTime: number;
  14308. /**
  14309. * Minimum Size of emitting particles.
  14310. */
  14311. minSize: number;
  14312. /**
  14313. * Maximum Size of emitting particles.
  14314. */
  14315. maxSize: number;
  14316. /**
  14317. * Minimum scale of emitting particles on X axis.
  14318. */
  14319. minScaleX: number;
  14320. /**
  14321. * Maximum scale of emitting particles on X axis.
  14322. */
  14323. maxScaleX: number;
  14324. /**
  14325. * Minimum scale of emitting particles on Y axis.
  14326. */
  14327. minScaleY: number;
  14328. /**
  14329. * Maximum scale of emitting particles on Y axis.
  14330. */
  14331. maxScaleY: number;
  14332. /**
  14333. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14334. */
  14335. color1: Color4;
  14336. /**
  14337. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14338. */
  14339. color2: Color4;
  14340. /**
  14341. * Color the particle will have at the end of its lifetime.
  14342. */
  14343. colorDead: Color4;
  14344. /**
  14345. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14346. */
  14347. emitRate: number;
  14348. /**
  14349. * You can use gravity if you want to give an orientation to your particles.
  14350. */
  14351. gravity: Vector3;
  14352. /**
  14353. * Minimum power of emitting particles.
  14354. */
  14355. minEmitPower: number;
  14356. /**
  14357. * Maximum power of emitting particles.
  14358. */
  14359. maxEmitPower: number;
  14360. /**
  14361. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14362. */
  14363. minAngularSpeed: number;
  14364. /**
  14365. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14366. */
  14367. maxAngularSpeed: number;
  14368. /**
  14369. * Gets or sets the minimal initial rotation in radians.
  14370. */
  14371. minInitialRotation: number;
  14372. /**
  14373. * Gets or sets the maximal initial rotation in radians.
  14374. */
  14375. maxInitialRotation: number;
  14376. /**
  14377. * The particle emitter type defines the emitter used by the particle system.
  14378. * It can be for example box, sphere, or cone...
  14379. */
  14380. particleEmitterType: Nullable<IParticleEmitterType>;
  14381. /**
  14382. * Defines the delay in milliseconds before starting the system (0 by default)
  14383. */
  14384. startDelay: number;
  14385. /**
  14386. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  14387. */
  14388. preWarmCycles: number;
  14389. /**
  14390. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14391. */
  14392. preWarmStepOffset: number;
  14393. /**
  14394. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  14395. */
  14396. spriteCellChangeSpeed: number;
  14397. /**
  14398. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14399. */
  14400. startSpriteCellID: number;
  14401. /**
  14402. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14403. */
  14404. endSpriteCellID: number;
  14405. /**
  14406. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14407. */
  14408. spriteCellWidth: number;
  14409. /**
  14410. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14411. */
  14412. spriteCellHeight: number;
  14413. /**
  14414. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14415. */
  14416. spriteRandomStartCell: boolean;
  14417. /**
  14418. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14419. */
  14420. isAnimationSheetEnabled: boolean;
  14421. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14422. translationPivot: Vector2;
  14423. /**
  14424. * Gets or sets a texture used to add random noise to particle positions
  14425. */
  14426. noiseTexture: Nullable<BaseTexture>;
  14427. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14428. noiseStrength: Vector3;
  14429. /**
  14430. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14431. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14432. */
  14433. billboardMode: number;
  14434. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14435. limitVelocityDamping: number;
  14436. /**
  14437. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14438. */
  14439. beginAnimationOnStart: boolean;
  14440. /**
  14441. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14442. */
  14443. beginAnimationFrom: number;
  14444. /**
  14445. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14446. */
  14447. beginAnimationTo: number;
  14448. /**
  14449. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14450. */
  14451. beginAnimationLoop: boolean;
  14452. /**
  14453. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14454. */
  14455. disposeOnStop: boolean;
  14456. /**
  14457. * Specifies if the particles are updated in emitter local space or world space
  14458. */
  14459. isLocal: boolean;
  14460. /** Snippet ID if the particle system was created from the snippet server */
  14461. snippetId: string;
  14462. /**
  14463. * Gets the maximum number of particles active at the same time.
  14464. * @returns The max number of active particles.
  14465. */
  14466. getCapacity(): number;
  14467. /**
  14468. * Gets the number of particles active at the same time.
  14469. * @returns The number of active particles.
  14470. */
  14471. getActiveCount(): number;
  14472. /**
  14473. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14474. * @returns True if it has been started, otherwise false.
  14475. */
  14476. isStarted(): boolean;
  14477. /**
  14478. * Animates the particle system for this frame.
  14479. */
  14480. animate(): void;
  14481. /**
  14482. * Renders the particle system in its current state.
  14483. * @returns the current number of particles
  14484. */
  14485. render(): number;
  14486. /**
  14487. * Dispose the particle system and frees its associated resources.
  14488. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14489. */
  14490. dispose(disposeTexture?: boolean): void;
  14491. /**
  14492. * An event triggered when the system is disposed
  14493. */
  14494. onDisposeObservable: Observable<IParticleSystem>;
  14495. /**
  14496. * Clones the particle system.
  14497. * @param name The name of the cloned object
  14498. * @param newEmitter The new emitter to use
  14499. * @returns the cloned particle system
  14500. */
  14501. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14502. /**
  14503. * Serializes the particle system to a JSON object
  14504. * @param serializeTexture defines if the texture must be serialized as well
  14505. * @returns the JSON object
  14506. */
  14507. serialize(serializeTexture: boolean): any;
  14508. /**
  14509. * Rebuild the particle system
  14510. */
  14511. rebuild(): void;
  14512. /** Force the system to rebuild all gradients that need to be resync */
  14513. forceRefreshGradients(): void;
  14514. /**
  14515. * Starts the particle system and begins to emit
  14516. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14517. */
  14518. start(delay?: number): void;
  14519. /**
  14520. * Stops the particle system.
  14521. */
  14522. stop(): void;
  14523. /**
  14524. * Remove all active particles
  14525. */
  14526. reset(): void;
  14527. /**
  14528. * Gets a boolean indicating that the system is stopping
  14529. * @returns true if the system is currently stopping
  14530. */
  14531. isStopping(): boolean;
  14532. /**
  14533. * Is this system ready to be used/rendered
  14534. * @return true if the system is ready
  14535. */
  14536. isReady(): boolean;
  14537. /**
  14538. * Returns the string "ParticleSystem"
  14539. * @returns a string containing the class name
  14540. */
  14541. getClassName(): string;
  14542. /**
  14543. * Gets the custom effect used to render the particles
  14544. * @param blendMode Blend mode for which the effect should be retrieved
  14545. * @returns The effect
  14546. */
  14547. getCustomEffect(blendMode: number): Nullable<Effect>;
  14548. /**
  14549. * Sets the custom effect used to render the particles
  14550. * @param effect The effect to set
  14551. * @param blendMode Blend mode for which the effect should be set
  14552. */
  14553. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14554. /**
  14555. * Fill the defines array according to the current settings of the particle system
  14556. * @param defines Array to be updated
  14557. * @param blendMode blend mode to take into account when updating the array
  14558. */
  14559. fillDefines(defines: Array<string>, blendMode: number): void;
  14560. /**
  14561. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14562. * @param uniforms Uniforms array to fill
  14563. * @param attributes Attributes array to fill
  14564. * @param samplers Samplers array to fill
  14565. */
  14566. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14567. /**
  14568. * Observable that will be called just before the particles are drawn
  14569. */
  14570. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14571. /**
  14572. * Gets the name of the particle vertex shader
  14573. */
  14574. vertexShaderName: string;
  14575. /**
  14576. * Adds a new color gradient
  14577. * @param gradient defines the gradient to use (between 0 and 1)
  14578. * @param color1 defines the color to affect to the specified gradient
  14579. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14580. * @returns the current particle system
  14581. */
  14582. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14583. /**
  14584. * Remove a specific color gradient
  14585. * @param gradient defines the gradient to remove
  14586. * @returns the current particle system
  14587. */
  14588. removeColorGradient(gradient: number): IParticleSystem;
  14589. /**
  14590. * Adds a new size gradient
  14591. * @param gradient defines the gradient to use (between 0 and 1)
  14592. * @param factor defines the size factor to affect to the specified gradient
  14593. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14594. * @returns the current particle system
  14595. */
  14596. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14597. /**
  14598. * Remove a specific size gradient
  14599. * @param gradient defines the gradient to remove
  14600. * @returns the current particle system
  14601. */
  14602. removeSizeGradient(gradient: number): IParticleSystem;
  14603. /**
  14604. * Gets the current list of color gradients.
  14605. * You must use addColorGradient and removeColorGradient to udpate this list
  14606. * @returns the list of color gradients
  14607. */
  14608. getColorGradients(): Nullable<Array<ColorGradient>>;
  14609. /**
  14610. * Gets the current list of size gradients.
  14611. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14612. * @returns the list of size gradients
  14613. */
  14614. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14615. /**
  14616. * Gets the current list of angular speed gradients.
  14617. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14618. * @returns the list of angular speed gradients
  14619. */
  14620. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14621. /**
  14622. * Adds a new angular speed gradient
  14623. * @param gradient defines the gradient to use (between 0 and 1)
  14624. * @param factor defines the angular speed to affect to the specified gradient
  14625. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14626. * @returns the current particle system
  14627. */
  14628. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14629. /**
  14630. * Remove a specific angular speed gradient
  14631. * @param gradient defines the gradient to remove
  14632. * @returns the current particle system
  14633. */
  14634. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14635. /**
  14636. * Gets the current list of velocity gradients.
  14637. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14638. * @returns the list of velocity gradients
  14639. */
  14640. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14641. /**
  14642. * Adds a new velocity gradient
  14643. * @param gradient defines the gradient to use (between 0 and 1)
  14644. * @param factor defines the velocity to affect to the specified gradient
  14645. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14646. * @returns the current particle system
  14647. */
  14648. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14649. /**
  14650. * Remove a specific velocity gradient
  14651. * @param gradient defines the gradient to remove
  14652. * @returns the current particle system
  14653. */
  14654. removeVelocityGradient(gradient: number): IParticleSystem;
  14655. /**
  14656. * Gets the current list of limit velocity gradients.
  14657. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14658. * @returns the list of limit velocity gradients
  14659. */
  14660. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14661. /**
  14662. * Adds a new limit velocity gradient
  14663. * @param gradient defines the gradient to use (between 0 and 1)
  14664. * @param factor defines the limit velocity to affect to the specified gradient
  14665. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14666. * @returns the current particle system
  14667. */
  14668. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14669. /**
  14670. * Remove a specific limit velocity gradient
  14671. * @param gradient defines the gradient to remove
  14672. * @returns the current particle system
  14673. */
  14674. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14675. /**
  14676. * Adds a new drag gradient
  14677. * @param gradient defines the gradient to use (between 0 and 1)
  14678. * @param factor defines the drag to affect to the specified gradient
  14679. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14680. * @returns the current particle system
  14681. */
  14682. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14683. /**
  14684. * Remove a specific drag gradient
  14685. * @param gradient defines the gradient to remove
  14686. * @returns the current particle system
  14687. */
  14688. removeDragGradient(gradient: number): IParticleSystem;
  14689. /**
  14690. * Gets the current list of drag gradients.
  14691. * You must use addDragGradient and removeDragGradient to udpate this list
  14692. * @returns the list of drag gradients
  14693. */
  14694. getDragGradients(): Nullable<Array<FactorGradient>>;
  14695. /**
  14696. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14697. * @param gradient defines the gradient to use (between 0 and 1)
  14698. * @param factor defines the emit rate to affect to the specified gradient
  14699. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14700. * @returns the current particle system
  14701. */
  14702. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14703. /**
  14704. * Remove a specific emit rate gradient
  14705. * @param gradient defines the gradient to remove
  14706. * @returns the current particle system
  14707. */
  14708. removeEmitRateGradient(gradient: number): IParticleSystem;
  14709. /**
  14710. * Gets the current list of emit rate gradients.
  14711. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14712. * @returns the list of emit rate gradients
  14713. */
  14714. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14715. /**
  14716. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14717. * @param gradient defines the gradient to use (between 0 and 1)
  14718. * @param factor defines the start size to affect to the specified gradient
  14719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14720. * @returns the current particle system
  14721. */
  14722. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14723. /**
  14724. * Remove a specific start size gradient
  14725. * @param gradient defines the gradient to remove
  14726. * @returns the current particle system
  14727. */
  14728. removeStartSizeGradient(gradient: number): IParticleSystem;
  14729. /**
  14730. * Gets the current list of start size gradients.
  14731. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14732. * @returns the list of start size gradients
  14733. */
  14734. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14735. /**
  14736. * Adds a new life time gradient
  14737. * @param gradient defines the gradient to use (between 0 and 1)
  14738. * @param factor defines the life time factor to affect to the specified gradient
  14739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14740. * @returns the current particle system
  14741. */
  14742. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14743. /**
  14744. * Remove a specific life time gradient
  14745. * @param gradient defines the gradient to remove
  14746. * @returns the current particle system
  14747. */
  14748. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14749. /**
  14750. * Gets the current list of life time gradients.
  14751. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14752. * @returns the list of life time gradients
  14753. */
  14754. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14755. /**
  14756. * Gets the current list of color gradients.
  14757. * You must use addColorGradient and removeColorGradient to udpate this list
  14758. * @returns the list of color gradients
  14759. */
  14760. getColorGradients(): Nullable<Array<ColorGradient>>;
  14761. /**
  14762. * Adds a new ramp gradient used to remap particle colors
  14763. * @param gradient defines the gradient to use (between 0 and 1)
  14764. * @param color defines the color to affect to the specified gradient
  14765. * @returns the current particle system
  14766. */
  14767. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14768. /**
  14769. * Gets the current list of ramp gradients.
  14770. * You must use addRampGradient and removeRampGradient to udpate this list
  14771. * @returns the list of ramp gradients
  14772. */
  14773. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14774. /** Gets or sets a boolean indicating that ramp gradients must be used
  14775. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14776. */
  14777. useRampGradients: boolean;
  14778. /**
  14779. * Adds a new color remap gradient
  14780. * @param gradient defines the gradient to use (between 0 and 1)
  14781. * @param min defines the color remap minimal range
  14782. * @param max defines the color remap maximal range
  14783. * @returns the current particle system
  14784. */
  14785. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14786. /**
  14787. * Gets the current list of color remap gradients.
  14788. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14789. * @returns the list of color remap gradients
  14790. */
  14791. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14792. /**
  14793. * Adds a new alpha remap gradient
  14794. * @param gradient defines the gradient to use (between 0 and 1)
  14795. * @param min defines the alpha remap minimal range
  14796. * @param max defines the alpha remap maximal range
  14797. * @returns the current particle system
  14798. */
  14799. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14800. /**
  14801. * Gets the current list of alpha remap gradients.
  14802. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14803. * @returns the list of alpha remap gradients
  14804. */
  14805. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14806. /**
  14807. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14808. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14809. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14810. * @returns the emitter
  14811. */
  14812. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14813. /**
  14814. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14815. * @param radius The radius of the hemisphere to emit from
  14816. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14817. * @returns the emitter
  14818. */
  14819. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14820. /**
  14821. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14822. * @param radius The radius of the sphere to emit from
  14823. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14824. * @returns the emitter
  14825. */
  14826. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14827. /**
  14828. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14829. * @param radius The radius of the sphere to emit from
  14830. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14831. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14832. * @returns the emitter
  14833. */
  14834. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14835. /**
  14836. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14837. * @param radius The radius of the emission cylinder
  14838. * @param height The height of the emission cylinder
  14839. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14840. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14841. * @returns the emitter
  14842. */
  14843. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14844. /**
  14845. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14846. * @param radius The radius of the cylinder to emit from
  14847. * @param height The height of the emission cylinder
  14848. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14849. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14850. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14851. * @returns the emitter
  14852. */
  14853. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14854. /**
  14855. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14856. * @param radius The radius of the cone to emit from
  14857. * @param angle The base angle of the cone
  14858. * @returns the emitter
  14859. */
  14860. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14861. /**
  14862. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14863. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14864. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14865. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14866. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14867. * @returns the emitter
  14868. */
  14869. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14870. /**
  14871. * Get hosting scene
  14872. * @returns the scene
  14873. */
  14874. getScene(): Scene;
  14875. }
  14876. }
  14877. declare module "babylonjs/Meshes/transformNode" {
  14878. import { DeepImmutable } from "babylonjs/types";
  14879. import { Observable } from "babylonjs/Misc/observable";
  14880. import { Nullable } from "babylonjs/types";
  14881. import { Camera } from "babylonjs/Cameras/camera";
  14882. import { Scene } from "babylonjs/scene";
  14883. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14884. import { Node } from "babylonjs/node";
  14885. import { Bone } from "babylonjs/Bones/bone";
  14886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14887. import { Space } from "babylonjs/Maths/math.axis";
  14888. /**
  14889. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  14890. * @see https://doc.babylonjs.com/how_to/transformnode
  14891. */
  14892. export class TransformNode extends Node {
  14893. /**
  14894. * Object will not rotate to face the camera
  14895. */
  14896. static BILLBOARDMODE_NONE: number;
  14897. /**
  14898. * Object will rotate to face the camera but only on the x axis
  14899. */
  14900. static BILLBOARDMODE_X: number;
  14901. /**
  14902. * Object will rotate to face the camera but only on the y axis
  14903. */
  14904. static BILLBOARDMODE_Y: number;
  14905. /**
  14906. * Object will rotate to face the camera but only on the z axis
  14907. */
  14908. static BILLBOARDMODE_Z: number;
  14909. /**
  14910. * Object will rotate to face the camera
  14911. */
  14912. static BILLBOARDMODE_ALL: number;
  14913. /**
  14914. * Object will rotate to face the camera's position instead of orientation
  14915. */
  14916. static BILLBOARDMODE_USE_POSITION: number;
  14917. private _forward;
  14918. private _forwardInverted;
  14919. private _up;
  14920. private _right;
  14921. private _rightInverted;
  14922. private _position;
  14923. private _rotation;
  14924. private _rotationQuaternion;
  14925. protected _scaling: Vector3;
  14926. protected _isDirty: boolean;
  14927. private _transformToBoneReferal;
  14928. private _isAbsoluteSynced;
  14929. private _billboardMode;
  14930. /**
  14931. * Gets or sets the billboard mode. Default is 0.
  14932. *
  14933. * | Value | Type | Description |
  14934. * | --- | --- | --- |
  14935. * | 0 | BILLBOARDMODE_NONE | |
  14936. * | 1 | BILLBOARDMODE_X | |
  14937. * | 2 | BILLBOARDMODE_Y | |
  14938. * | 4 | BILLBOARDMODE_Z | |
  14939. * | 7 | BILLBOARDMODE_ALL | |
  14940. *
  14941. */
  14942. get billboardMode(): number;
  14943. set billboardMode(value: number);
  14944. private _preserveParentRotationForBillboard;
  14945. /**
  14946. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14947. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14948. */
  14949. get preserveParentRotationForBillboard(): boolean;
  14950. set preserveParentRotationForBillboard(value: boolean);
  14951. /**
  14952. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  14953. */
  14954. scalingDeterminant: number;
  14955. private _infiniteDistance;
  14956. /**
  14957. * Gets or sets the distance of the object to max, often used by skybox
  14958. */
  14959. get infiniteDistance(): boolean;
  14960. set infiniteDistance(value: boolean);
  14961. /**
  14962. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14963. * By default the system will update normals to compensate
  14964. */
  14965. ignoreNonUniformScaling: boolean;
  14966. /**
  14967. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  14968. */
  14969. reIntegrateRotationIntoRotationQuaternion: boolean;
  14970. /** @hidden */
  14971. _poseMatrix: Nullable<Matrix>;
  14972. /** @hidden */
  14973. _localMatrix: Matrix;
  14974. private _usePivotMatrix;
  14975. private _absolutePosition;
  14976. private _absoluteScaling;
  14977. private _absoluteRotationQuaternion;
  14978. private _pivotMatrix;
  14979. private _pivotMatrixInverse;
  14980. protected _postMultiplyPivotMatrix: boolean;
  14981. protected _isWorldMatrixFrozen: boolean;
  14982. /** @hidden */
  14983. _indexInSceneTransformNodesArray: number;
  14984. /**
  14985. * An event triggered after the world matrix is updated
  14986. */
  14987. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14988. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14989. /**
  14990. * Gets a string identifying the name of the class
  14991. * @returns "TransformNode" string
  14992. */
  14993. getClassName(): string;
  14994. /**
  14995. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14996. */
  14997. get position(): Vector3;
  14998. set position(newPosition: Vector3);
  14999. /**
  15000. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  15001. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15002. */
  15003. get rotation(): Vector3;
  15004. set rotation(newRotation: Vector3);
  15005. /**
  15006. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  15007. */
  15008. get scaling(): Vector3;
  15009. set scaling(newScaling: Vector3);
  15010. /**
  15011. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  15012. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15013. */
  15014. get rotationQuaternion(): Nullable<Quaternion>;
  15015. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15016. /**
  15017. * The forward direction of that transform in world space.
  15018. */
  15019. get forward(): Vector3;
  15020. /**
  15021. * The up direction of that transform in world space.
  15022. */
  15023. get up(): Vector3;
  15024. /**
  15025. * The right direction of that transform in world space.
  15026. */
  15027. get right(): Vector3;
  15028. /**
  15029. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15030. * @param matrix the matrix to copy the pose from
  15031. * @returns this TransformNode.
  15032. */
  15033. updatePoseMatrix(matrix: Matrix): TransformNode;
  15034. /**
  15035. * Returns the mesh Pose matrix.
  15036. * @returns the pose matrix
  15037. */
  15038. getPoseMatrix(): Matrix;
  15039. /** @hidden */
  15040. _isSynchronized(): boolean;
  15041. /** @hidden */
  15042. _initCache(): void;
  15043. /**
  15044. * Flag the transform node as dirty (Forcing it to update everything)
  15045. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15046. * @returns this transform node
  15047. */
  15048. markAsDirty(property: string): TransformNode;
  15049. /**
  15050. * Returns the current mesh absolute position.
  15051. * Returns a Vector3.
  15052. */
  15053. get absolutePosition(): Vector3;
  15054. /**
  15055. * Returns the current mesh absolute scaling.
  15056. * Returns a Vector3.
  15057. */
  15058. get absoluteScaling(): Vector3;
  15059. /**
  15060. * Returns the current mesh absolute rotation.
  15061. * Returns a Quaternion.
  15062. */
  15063. get absoluteRotationQuaternion(): Quaternion;
  15064. /**
  15065. * Sets a new matrix to apply before all other transformation
  15066. * @param matrix defines the transform matrix
  15067. * @returns the current TransformNode
  15068. */
  15069. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15070. /**
  15071. * Sets a new pivot matrix to the current node
  15072. * @param matrix defines the new pivot matrix to use
  15073. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  15074. * @returns the current TransformNode
  15075. */
  15076. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15077. /**
  15078. * Returns the mesh pivot matrix.
  15079. * Default : Identity.
  15080. * @returns the matrix
  15081. */
  15082. getPivotMatrix(): Matrix;
  15083. /**
  15084. * Instantiate (when possible) or clone that node with its hierarchy
  15085. * @param newParent defines the new parent to use for the instance (or clone)
  15086. * @param options defines options to configure how copy is done
  15087. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15088. * @returns an instance (or a clone) of the current node with its hiearchy
  15089. */
  15090. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15091. doNotInstantiate: boolean;
  15092. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15093. /**
  15094. * Prevents the World matrix to be computed any longer
  15095. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15096. * @returns the TransformNode.
  15097. */
  15098. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15099. /**
  15100. * Allows back the World matrix computation.
  15101. * @returns the TransformNode.
  15102. */
  15103. unfreezeWorldMatrix(): this;
  15104. /**
  15105. * True if the World matrix has been frozen.
  15106. */
  15107. get isWorldMatrixFrozen(): boolean;
  15108. /**
  15109. * Retuns the mesh absolute position in the World.
  15110. * @returns a Vector3.
  15111. */
  15112. getAbsolutePosition(): Vector3;
  15113. /**
  15114. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15115. * @param absolutePosition the absolute position to set
  15116. * @returns the TransformNode.
  15117. */
  15118. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15119. /**
  15120. * Sets the mesh position in its local space.
  15121. * @param vector3 the position to set in localspace
  15122. * @returns the TransformNode.
  15123. */
  15124. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15125. /**
  15126. * Returns the mesh position in the local space from the current World matrix values.
  15127. * @returns a new Vector3.
  15128. */
  15129. getPositionExpressedInLocalSpace(): Vector3;
  15130. /**
  15131. * Translates the mesh along the passed Vector3 in its local space.
  15132. * @param vector3 the distance to translate in localspace
  15133. * @returns the TransformNode.
  15134. */
  15135. locallyTranslate(vector3: Vector3): TransformNode;
  15136. private static _lookAtVectorCache;
  15137. /**
  15138. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15139. * @param targetPoint the position (must be in same space as current mesh) to look at
  15140. * @param yawCor optional yaw (y-axis) correction in radians
  15141. * @param pitchCor optional pitch (x-axis) correction in radians
  15142. * @param rollCor optional roll (z-axis) correction in radians
  15143. * @param space the choosen space of the target
  15144. * @returns the TransformNode.
  15145. */
  15146. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15147. /**
  15148. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15149. * This Vector3 is expressed in the World space.
  15150. * @param localAxis axis to rotate
  15151. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15152. */
  15153. getDirection(localAxis: Vector3): Vector3;
  15154. /**
  15155. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15156. * localAxis is expressed in the mesh local space.
  15157. * result is computed in the Wordl space from the mesh World matrix.
  15158. * @param localAxis axis to rotate
  15159. * @param result the resulting transformnode
  15160. * @returns this TransformNode.
  15161. */
  15162. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15163. /**
  15164. * Sets this transform node rotation to the given local axis.
  15165. * @param localAxis the axis in local space
  15166. * @param yawCor optional yaw (y-axis) correction in radians
  15167. * @param pitchCor optional pitch (x-axis) correction in radians
  15168. * @param rollCor optional roll (z-axis) correction in radians
  15169. * @returns this TransformNode
  15170. */
  15171. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15172. /**
  15173. * Sets a new pivot point to the current node
  15174. * @param point defines the new pivot point to use
  15175. * @param space defines if the point is in world or local space (local by default)
  15176. * @returns the current TransformNode
  15177. */
  15178. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15179. /**
  15180. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15181. * @returns the pivot point
  15182. */
  15183. getPivotPoint(): Vector3;
  15184. /**
  15185. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15186. * @param result the vector3 to store the result
  15187. * @returns this TransformNode.
  15188. */
  15189. getPivotPointToRef(result: Vector3): TransformNode;
  15190. /**
  15191. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15192. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15193. */
  15194. getAbsolutePivotPoint(): Vector3;
  15195. /**
  15196. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15197. * @param result vector3 to store the result
  15198. * @returns this TransformNode.
  15199. */
  15200. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15201. /**
  15202. * Defines the passed node as the parent of the current node.
  15203. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15204. * @see https://doc.babylonjs.com/how_to/parenting
  15205. * @param node the node ot set as the parent
  15206. * @returns this TransformNode.
  15207. */
  15208. setParent(node: Nullable<Node>): TransformNode;
  15209. private _nonUniformScaling;
  15210. /**
  15211. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15212. */
  15213. get nonUniformScaling(): boolean;
  15214. /** @hidden */
  15215. _updateNonUniformScalingState(value: boolean): boolean;
  15216. /**
  15217. * Attach the current TransformNode to another TransformNode associated with a bone
  15218. * @param bone Bone affecting the TransformNode
  15219. * @param affectedTransformNode TransformNode associated with the bone
  15220. * @returns this object
  15221. */
  15222. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15223. /**
  15224. * Detach the transform node if its associated with a bone
  15225. * @returns this object
  15226. */
  15227. detachFromBone(): TransformNode;
  15228. private static _rotationAxisCache;
  15229. /**
  15230. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15231. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15232. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15233. * The passed axis is also normalized.
  15234. * @param axis the axis to rotate around
  15235. * @param amount the amount to rotate in radians
  15236. * @param space Space to rotate in (Default: local)
  15237. * @returns the TransformNode.
  15238. */
  15239. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15240. /**
  15241. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15242. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15243. * The passed axis is also normalized. .
  15244. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15245. * @param point the point to rotate around
  15246. * @param axis the axis to rotate around
  15247. * @param amount the amount to rotate in radians
  15248. * @returns the TransformNode
  15249. */
  15250. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15251. /**
  15252. * Translates the mesh along the axis vector for the passed distance in the given space.
  15253. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15254. * @param axis the axis to translate in
  15255. * @param distance the distance to translate
  15256. * @param space Space to rotate in (Default: local)
  15257. * @returns the TransformNode.
  15258. */
  15259. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15260. /**
  15261. * Adds a rotation step to the mesh current rotation.
  15262. * x, y, z are Euler angles expressed in radians.
  15263. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15264. * This means this rotation is made in the mesh local space only.
  15265. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15266. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15267. * ```javascript
  15268. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15269. * ```
  15270. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15271. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  15272. * @param x Rotation to add
  15273. * @param y Rotation to add
  15274. * @param z Rotation to add
  15275. * @returns the TransformNode.
  15276. */
  15277. addRotation(x: number, y: number, z: number): TransformNode;
  15278. /**
  15279. * @hidden
  15280. */
  15281. protected _getEffectiveParent(): Nullable<Node>;
  15282. /**
  15283. * Computes the world matrix of the node
  15284. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15285. * @returns the world matrix
  15286. */
  15287. computeWorldMatrix(force?: boolean): Matrix;
  15288. /**
  15289. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15290. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15291. */
  15292. resetLocalMatrix(independentOfChildren?: boolean): void;
  15293. protected _afterComputeWorldMatrix(): void;
  15294. /**
  15295. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15296. * @param func callback function to add
  15297. *
  15298. * @returns the TransformNode.
  15299. */
  15300. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15301. /**
  15302. * Removes a registered callback function.
  15303. * @param func callback function to remove
  15304. * @returns the TransformNode.
  15305. */
  15306. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15307. /**
  15308. * Gets the position of the current mesh in camera space
  15309. * @param camera defines the camera to use
  15310. * @returns a position
  15311. */
  15312. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15313. /**
  15314. * Returns the distance from the mesh to the active camera
  15315. * @param camera defines the camera to use
  15316. * @returns the distance
  15317. */
  15318. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15319. /**
  15320. * Clone the current transform node
  15321. * @param name Name of the new clone
  15322. * @param newParent New parent for the clone
  15323. * @param doNotCloneChildren Do not clone children hierarchy
  15324. * @returns the new transform node
  15325. */
  15326. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15327. /**
  15328. * Serializes the objects information.
  15329. * @param currentSerializationObject defines the object to serialize in
  15330. * @returns the serialized object
  15331. */
  15332. serialize(currentSerializationObject?: any): any;
  15333. /**
  15334. * Returns a new TransformNode object parsed from the source provided.
  15335. * @param parsedTransformNode is the source.
  15336. * @param scene the scne the object belongs to
  15337. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15338. * @returns a new TransformNode object parsed from the source provided.
  15339. */
  15340. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15341. /**
  15342. * Get all child-transformNodes of this node
  15343. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  15344. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  15345. * @returns an array of TransformNode
  15346. */
  15347. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15348. /**
  15349. * Releases resources associated with this transform node.
  15350. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15351. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15352. */
  15353. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15354. /**
  15355. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15356. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15357. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15358. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15359. * @returns the current mesh
  15360. */
  15361. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15362. private _syncAbsoluteScalingAndRotation;
  15363. }
  15364. }
  15365. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15366. /**
  15367. * Class used to override all child animations of a given target
  15368. */
  15369. export class AnimationPropertiesOverride {
  15370. /**
  15371. * Gets or sets a value indicating if animation blending must be used
  15372. */
  15373. enableBlending: boolean;
  15374. /**
  15375. * Gets or sets the blending speed to use when enableBlending is true
  15376. */
  15377. blendingSpeed: number;
  15378. /**
  15379. * Gets or sets the default loop mode to use
  15380. */
  15381. loopMode: number;
  15382. }
  15383. }
  15384. declare module "babylonjs/Bones/bone" {
  15385. import { Skeleton } from "babylonjs/Bones/skeleton";
  15386. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15387. import { Nullable } from "babylonjs/types";
  15388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15389. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15390. import { Node } from "babylonjs/node";
  15391. import { Space } from "babylonjs/Maths/math.axis";
  15392. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15393. /**
  15394. * Class used to store bone information
  15395. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15396. */
  15397. export class Bone extends Node {
  15398. /**
  15399. * defines the bone name
  15400. */
  15401. name: string;
  15402. private static _tmpVecs;
  15403. private static _tmpQuat;
  15404. private static _tmpMats;
  15405. /**
  15406. * Gets the list of child bones
  15407. */
  15408. children: Bone[];
  15409. /** Gets the animations associated with this bone */
  15410. animations: import("babylonjs/Animations/animation").Animation[];
  15411. /**
  15412. * Gets or sets bone length
  15413. */
  15414. length: number;
  15415. /**
  15416. * @hidden Internal only
  15417. * Set this value to map this bone to a different index in the transform matrices
  15418. * Set this value to -1 to exclude the bone from the transform matrices
  15419. */
  15420. _index: Nullable<number>;
  15421. private _skeleton;
  15422. private _localMatrix;
  15423. private _restPose;
  15424. private _baseMatrix;
  15425. private _absoluteTransform;
  15426. private _invertedAbsoluteTransform;
  15427. private _parent;
  15428. private _scalingDeterminant;
  15429. private _worldTransform;
  15430. private _localScaling;
  15431. private _localRotation;
  15432. private _localPosition;
  15433. private _needToDecompose;
  15434. private _needToCompose;
  15435. /** @hidden */
  15436. _linkedTransformNode: Nullable<TransformNode>;
  15437. /** @hidden */
  15438. _waitingTransformNodeId: Nullable<string>;
  15439. /** @hidden */
  15440. get _matrix(): Matrix;
  15441. /** @hidden */
  15442. set _matrix(value: Matrix);
  15443. /**
  15444. * Create a new bone
  15445. * @param name defines the bone name
  15446. * @param skeleton defines the parent skeleton
  15447. * @param parentBone defines the parent (can be null if the bone is the root)
  15448. * @param localMatrix defines the local matrix
  15449. * @param restPose defines the rest pose matrix
  15450. * @param baseMatrix defines the base matrix
  15451. * @param index defines index of the bone in the hiearchy
  15452. */
  15453. constructor(
  15454. /**
  15455. * defines the bone name
  15456. */
  15457. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15458. /**
  15459. * Gets the current object class name.
  15460. * @return the class name
  15461. */
  15462. getClassName(): string;
  15463. /**
  15464. * Gets the parent skeleton
  15465. * @returns a skeleton
  15466. */
  15467. getSkeleton(): Skeleton;
  15468. /**
  15469. * Gets parent bone
  15470. * @returns a bone or null if the bone is the root of the bone hierarchy
  15471. */
  15472. getParent(): Nullable<Bone>;
  15473. /**
  15474. * Returns an array containing the root bones
  15475. * @returns an array containing the root bones
  15476. */
  15477. getChildren(): Array<Bone>;
  15478. /**
  15479. * Gets the node index in matrix array generated for rendering
  15480. * @returns the node index
  15481. */
  15482. getIndex(): number;
  15483. /**
  15484. * Sets the parent bone
  15485. * @param parent defines the parent (can be null if the bone is the root)
  15486. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15487. */
  15488. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15489. /**
  15490. * Gets the local matrix
  15491. * @returns a matrix
  15492. */
  15493. getLocalMatrix(): Matrix;
  15494. /**
  15495. * Gets the base matrix (initial matrix which remains unchanged)
  15496. * @returns a matrix
  15497. */
  15498. getBaseMatrix(): Matrix;
  15499. /**
  15500. * Gets the rest pose matrix
  15501. * @returns a matrix
  15502. */
  15503. getRestPose(): Matrix;
  15504. /**
  15505. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15506. */
  15507. getWorldMatrix(): Matrix;
  15508. /**
  15509. * Sets the local matrix to rest pose matrix
  15510. */
  15511. returnToRest(): void;
  15512. /**
  15513. * Gets the inverse of the absolute transform matrix.
  15514. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15515. * @returns a matrix
  15516. */
  15517. getInvertedAbsoluteTransform(): Matrix;
  15518. /**
  15519. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15520. * @returns a matrix
  15521. */
  15522. getAbsoluteTransform(): Matrix;
  15523. /**
  15524. * Links with the given transform node.
  15525. * The local matrix of this bone is copied from the transform node every frame.
  15526. * @param transformNode defines the transform node to link to
  15527. */
  15528. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15529. /**
  15530. * Gets the node used to drive the bone's transformation
  15531. * @returns a transform node or null
  15532. */
  15533. getTransformNode(): Nullable<TransformNode>;
  15534. /** Gets or sets current position (in local space) */
  15535. get position(): Vector3;
  15536. set position(newPosition: Vector3);
  15537. /** Gets or sets current rotation (in local space) */
  15538. get rotation(): Vector3;
  15539. set rotation(newRotation: Vector3);
  15540. /** Gets or sets current rotation quaternion (in local space) */
  15541. get rotationQuaternion(): Quaternion;
  15542. set rotationQuaternion(newRotation: Quaternion);
  15543. /** Gets or sets current scaling (in local space) */
  15544. get scaling(): Vector3;
  15545. set scaling(newScaling: Vector3);
  15546. /**
  15547. * Gets the animation properties override
  15548. */
  15549. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15550. private _decompose;
  15551. private _compose;
  15552. /**
  15553. * Update the base and local matrices
  15554. * @param matrix defines the new base or local matrix
  15555. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15556. * @param updateLocalMatrix defines if the local matrix should be updated
  15557. */
  15558. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15559. /** @hidden */
  15560. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15561. /**
  15562. * Flag the bone as dirty (Forcing it to update everything)
  15563. */
  15564. markAsDirty(): void;
  15565. /** @hidden */
  15566. _markAsDirtyAndCompose(): void;
  15567. private _markAsDirtyAndDecompose;
  15568. /**
  15569. * Translate the bone in local or world space
  15570. * @param vec The amount to translate the bone
  15571. * @param space The space that the translation is in
  15572. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15573. */
  15574. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15575. /**
  15576. * Set the postion of the bone in local or world space
  15577. * @param position The position to set the bone
  15578. * @param space The space that the position is in
  15579. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15580. */
  15581. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15582. /**
  15583. * Set the absolute position of the bone (world space)
  15584. * @param position The position to set the bone
  15585. * @param mesh The mesh that this bone is attached to
  15586. */
  15587. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15588. /**
  15589. * Scale the bone on the x, y and z axes (in local space)
  15590. * @param x The amount to scale the bone on the x axis
  15591. * @param y The amount to scale the bone on the y axis
  15592. * @param z The amount to scale the bone on the z axis
  15593. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15594. */
  15595. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15596. /**
  15597. * Set the bone scaling in local space
  15598. * @param scale defines the scaling vector
  15599. */
  15600. setScale(scale: Vector3): void;
  15601. /**
  15602. * Gets the current scaling in local space
  15603. * @returns the current scaling vector
  15604. */
  15605. getScale(): Vector3;
  15606. /**
  15607. * Gets the current scaling in local space and stores it in a target vector
  15608. * @param result defines the target vector
  15609. */
  15610. getScaleToRef(result: Vector3): void;
  15611. /**
  15612. * Set the yaw, pitch, and roll of the bone in local or world space
  15613. * @param yaw The rotation of the bone on the y axis
  15614. * @param pitch The rotation of the bone on the x axis
  15615. * @param roll The rotation of the bone on the z axis
  15616. * @param space The space that the axes of rotation are in
  15617. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15618. */
  15619. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15620. /**
  15621. * Add a rotation to the bone on an axis in local or world space
  15622. * @param axis The axis to rotate the bone on
  15623. * @param amount The amount to rotate the bone
  15624. * @param space The space that the axis is in
  15625. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15626. */
  15627. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15628. /**
  15629. * Set the rotation of the bone to a particular axis angle in local or world space
  15630. * @param axis The axis to rotate the bone on
  15631. * @param angle The angle that the bone should be rotated to
  15632. * @param space The space that the axis is in
  15633. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15634. */
  15635. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15636. /**
  15637. * Set the euler rotation of the bone in local of world space
  15638. * @param rotation The euler rotation that the bone should be set to
  15639. * @param space The space that the rotation is in
  15640. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15641. */
  15642. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15643. /**
  15644. * Set the quaternion rotation of the bone in local of world space
  15645. * @param quat The quaternion rotation that the bone should be set to
  15646. * @param space The space that the rotation is in
  15647. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15648. */
  15649. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15650. /**
  15651. * Set the rotation matrix of the bone in local of world space
  15652. * @param rotMat The rotation matrix that the bone should be set to
  15653. * @param space The space that the rotation is in
  15654. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15655. */
  15656. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15657. private _rotateWithMatrix;
  15658. private _getNegativeRotationToRef;
  15659. /**
  15660. * Get the position of the bone in local or world space
  15661. * @param space The space that the returned position is in
  15662. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15663. * @returns The position of the bone
  15664. */
  15665. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15666. /**
  15667. * Copy the position of the bone to a vector3 in local or world space
  15668. * @param space The space that the returned position is in
  15669. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15670. * @param result The vector3 to copy the position to
  15671. */
  15672. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15673. /**
  15674. * Get the absolute position of the bone (world space)
  15675. * @param mesh The mesh that this bone is attached to
  15676. * @returns The absolute position of the bone
  15677. */
  15678. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15679. /**
  15680. * Copy the absolute position of the bone (world space) to the result param
  15681. * @param mesh The mesh that this bone is attached to
  15682. * @param result The vector3 to copy the absolute position to
  15683. */
  15684. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15685. /**
  15686. * Compute the absolute transforms of this bone and its children
  15687. */
  15688. computeAbsoluteTransforms(): void;
  15689. /**
  15690. * Get the world direction from an axis that is in the local space of the bone
  15691. * @param localAxis The local direction that is used to compute the world direction
  15692. * @param mesh The mesh that this bone is attached to
  15693. * @returns The world direction
  15694. */
  15695. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15696. /**
  15697. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15698. * @param localAxis The local direction that is used to compute the world direction
  15699. * @param mesh The mesh that this bone is attached to
  15700. * @param result The vector3 that the world direction will be copied to
  15701. */
  15702. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15703. /**
  15704. * Get the euler rotation of the bone in local or world space
  15705. * @param space The space that the rotation should be in
  15706. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15707. * @returns The euler rotation
  15708. */
  15709. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15710. /**
  15711. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15712. * @param space The space that the rotation should be in
  15713. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15714. * @param result The vector3 that the rotation should be copied to
  15715. */
  15716. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15717. /**
  15718. * Get the quaternion rotation of the bone in either local or world space
  15719. * @param space The space that the rotation should be in
  15720. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15721. * @returns The quaternion rotation
  15722. */
  15723. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15724. /**
  15725. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15726. * @param space The space that the rotation should be in
  15727. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15728. * @param result The quaternion that the rotation should be copied to
  15729. */
  15730. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15731. /**
  15732. * Get the rotation matrix of the bone in local or world space
  15733. * @param space The space that the rotation should be in
  15734. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15735. * @returns The rotation matrix
  15736. */
  15737. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15738. /**
  15739. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15740. * @param space The space that the rotation should be in
  15741. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15742. * @param result The quaternion that the rotation should be copied to
  15743. */
  15744. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15745. /**
  15746. * Get the world position of a point that is in the local space of the bone
  15747. * @param position The local position
  15748. * @param mesh The mesh that this bone is attached to
  15749. * @returns The world position
  15750. */
  15751. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15752. /**
  15753. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15754. * @param position The local position
  15755. * @param mesh The mesh that this bone is attached to
  15756. * @param result The vector3 that the world position should be copied to
  15757. */
  15758. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15759. /**
  15760. * Get the local position of a point that is in world space
  15761. * @param position The world position
  15762. * @param mesh The mesh that this bone is attached to
  15763. * @returns The local position
  15764. */
  15765. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15766. /**
  15767. * Get the local position of a point that is in world space and copy it to the result param
  15768. * @param position The world position
  15769. * @param mesh The mesh that this bone is attached to
  15770. * @param result The vector3 that the local position should be copied to
  15771. */
  15772. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15773. }
  15774. }
  15775. declare module "babylonjs/Animations/runtimeAnimation" {
  15776. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15777. import { Animatable } from "babylonjs/Animations/animatable";
  15778. import { Scene } from "babylonjs/scene";
  15779. /**
  15780. * Defines a runtime animation
  15781. */
  15782. export class RuntimeAnimation {
  15783. private _events;
  15784. /**
  15785. * The current frame of the runtime animation
  15786. */
  15787. private _currentFrame;
  15788. /**
  15789. * The animation used by the runtime animation
  15790. */
  15791. private _animation;
  15792. /**
  15793. * The target of the runtime animation
  15794. */
  15795. private _target;
  15796. /**
  15797. * The initiating animatable
  15798. */
  15799. private _host;
  15800. /**
  15801. * The original value of the runtime animation
  15802. */
  15803. private _originalValue;
  15804. /**
  15805. * The original blend value of the runtime animation
  15806. */
  15807. private _originalBlendValue;
  15808. /**
  15809. * The offsets cache of the runtime animation
  15810. */
  15811. private _offsetsCache;
  15812. /**
  15813. * The high limits cache of the runtime animation
  15814. */
  15815. private _highLimitsCache;
  15816. /**
  15817. * Specifies if the runtime animation has been stopped
  15818. */
  15819. private _stopped;
  15820. /**
  15821. * The blending factor of the runtime animation
  15822. */
  15823. private _blendingFactor;
  15824. /**
  15825. * The BabylonJS scene
  15826. */
  15827. private _scene;
  15828. /**
  15829. * The current value of the runtime animation
  15830. */
  15831. private _currentValue;
  15832. /** @hidden */
  15833. _animationState: _IAnimationState;
  15834. /**
  15835. * The active target of the runtime animation
  15836. */
  15837. private _activeTargets;
  15838. private _currentActiveTarget;
  15839. private _directTarget;
  15840. /**
  15841. * The target path of the runtime animation
  15842. */
  15843. private _targetPath;
  15844. /**
  15845. * The weight of the runtime animation
  15846. */
  15847. private _weight;
  15848. /**
  15849. * The ratio offset of the runtime animation
  15850. */
  15851. private _ratioOffset;
  15852. /**
  15853. * The previous delay of the runtime animation
  15854. */
  15855. private _previousDelay;
  15856. /**
  15857. * The previous ratio of the runtime animation
  15858. */
  15859. private _previousRatio;
  15860. private _enableBlending;
  15861. private _keys;
  15862. private _minFrame;
  15863. private _maxFrame;
  15864. private _minValue;
  15865. private _maxValue;
  15866. private _targetIsArray;
  15867. /**
  15868. * Gets the current frame of the runtime animation
  15869. */
  15870. get currentFrame(): number;
  15871. /**
  15872. * Gets the weight of the runtime animation
  15873. */
  15874. get weight(): number;
  15875. /**
  15876. * Gets the current value of the runtime animation
  15877. */
  15878. get currentValue(): any;
  15879. /**
  15880. * Gets the target path of the runtime animation
  15881. */
  15882. get targetPath(): string;
  15883. /**
  15884. * Gets the actual target of the runtime animation
  15885. */
  15886. get target(): any;
  15887. /**
  15888. * Gets the additive state of the runtime animation
  15889. */
  15890. get isAdditive(): boolean;
  15891. /** @hidden */
  15892. _onLoop: () => void;
  15893. /**
  15894. * Create a new RuntimeAnimation object
  15895. * @param target defines the target of the animation
  15896. * @param animation defines the source animation object
  15897. * @param scene defines the hosting scene
  15898. * @param host defines the initiating Animatable
  15899. */
  15900. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15901. private _preparePath;
  15902. /**
  15903. * Gets the animation from the runtime animation
  15904. */
  15905. get animation(): Animation;
  15906. /**
  15907. * Resets the runtime animation to the beginning
  15908. * @param restoreOriginal defines whether to restore the target property to the original value
  15909. */
  15910. reset(restoreOriginal?: boolean): void;
  15911. /**
  15912. * Specifies if the runtime animation is stopped
  15913. * @returns Boolean specifying if the runtime animation is stopped
  15914. */
  15915. isStopped(): boolean;
  15916. /**
  15917. * Disposes of the runtime animation
  15918. */
  15919. dispose(): void;
  15920. /**
  15921. * Apply the interpolated value to the target
  15922. * @param currentValue defines the value computed by the animation
  15923. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15924. */
  15925. setValue(currentValue: any, weight: number): void;
  15926. private _getOriginalValues;
  15927. private _setValue;
  15928. /**
  15929. * Gets the loop pmode of the runtime animation
  15930. * @returns Loop Mode
  15931. */
  15932. private _getCorrectLoopMode;
  15933. /**
  15934. * Move the current animation to a given frame
  15935. * @param frame defines the frame to move to
  15936. */
  15937. goToFrame(frame: number): void;
  15938. /**
  15939. * @hidden Internal use only
  15940. */
  15941. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15942. /**
  15943. * Execute the current animation
  15944. * @param delay defines the delay to add to the current frame
  15945. * @param from defines the lower bound of the animation range
  15946. * @param to defines the upper bound of the animation range
  15947. * @param loop defines if the current animation must loop
  15948. * @param speedRatio defines the current speed ratio
  15949. * @param weight defines the weight of the animation (default is -1 so no weight)
  15950. * @param onLoop optional callback called when animation loops
  15951. * @returns a boolean indicating if the animation is running
  15952. */
  15953. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15954. }
  15955. }
  15956. declare module "babylonjs/Animations/animatable" {
  15957. import { Animation } from "babylonjs/Animations/animation";
  15958. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15959. import { Nullable } from "babylonjs/types";
  15960. import { Observable } from "babylonjs/Misc/observable";
  15961. import { Scene } from "babylonjs/scene";
  15962. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15963. import { Node } from "babylonjs/node";
  15964. /**
  15965. * Class used to store an actual running animation
  15966. */
  15967. export class Animatable {
  15968. /** defines the target object */
  15969. target: any;
  15970. /** defines the starting frame number (default is 0) */
  15971. fromFrame: number;
  15972. /** defines the ending frame number (default is 100) */
  15973. toFrame: number;
  15974. /** defines if the animation must loop (default is false) */
  15975. loopAnimation: boolean;
  15976. /** defines a callback to call when animation ends if it is not looping */
  15977. onAnimationEnd?: (() => void) | null | undefined;
  15978. /** defines a callback to call when animation loops */
  15979. onAnimationLoop?: (() => void) | null | undefined;
  15980. /** defines whether the animation should be evaluated additively */
  15981. isAdditive: boolean;
  15982. private _localDelayOffset;
  15983. private _pausedDelay;
  15984. private _runtimeAnimations;
  15985. private _paused;
  15986. private _scene;
  15987. private _speedRatio;
  15988. private _weight;
  15989. private _syncRoot;
  15990. /**
  15991. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15992. * This will only apply for non looping animation (default is true)
  15993. */
  15994. disposeOnEnd: boolean;
  15995. /**
  15996. * Gets a boolean indicating if the animation has started
  15997. */
  15998. animationStarted: boolean;
  15999. /**
  16000. * Observer raised when the animation ends
  16001. */
  16002. onAnimationEndObservable: Observable<Animatable>;
  16003. /**
  16004. * Observer raised when the animation loops
  16005. */
  16006. onAnimationLoopObservable: Observable<Animatable>;
  16007. /**
  16008. * Gets the root Animatable used to synchronize and normalize animations
  16009. */
  16010. get syncRoot(): Nullable<Animatable>;
  16011. /**
  16012. * Gets the current frame of the first RuntimeAnimation
  16013. * Used to synchronize Animatables
  16014. */
  16015. get masterFrame(): number;
  16016. /**
  16017. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16018. */
  16019. get weight(): number;
  16020. set weight(value: number);
  16021. /**
  16022. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16023. */
  16024. get speedRatio(): number;
  16025. set speedRatio(value: number);
  16026. /**
  16027. * Creates a new Animatable
  16028. * @param scene defines the hosting scene
  16029. * @param target defines the target object
  16030. * @param fromFrame defines the starting frame number (default is 0)
  16031. * @param toFrame defines the ending frame number (default is 100)
  16032. * @param loopAnimation defines if the animation must loop (default is false)
  16033. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16034. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16035. * @param animations defines a group of animation to add to the new Animatable
  16036. * @param onAnimationLoop defines a callback to call when animation loops
  16037. * @param isAdditive defines whether the animation should be evaluated additively
  16038. */
  16039. constructor(scene: Scene,
  16040. /** defines the target object */
  16041. target: any,
  16042. /** defines the starting frame number (default is 0) */
  16043. fromFrame?: number,
  16044. /** defines the ending frame number (default is 100) */
  16045. toFrame?: number,
  16046. /** defines if the animation must loop (default is false) */
  16047. loopAnimation?: boolean, speedRatio?: number,
  16048. /** defines a callback to call when animation ends if it is not looping */
  16049. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16050. /** defines a callback to call when animation loops */
  16051. onAnimationLoop?: (() => void) | null | undefined,
  16052. /** defines whether the animation should be evaluated additively */
  16053. isAdditive?: boolean);
  16054. /**
  16055. * Synchronize and normalize current Animatable with a source Animatable
  16056. * This is useful when using animation weights and when animations are not of the same length
  16057. * @param root defines the root Animatable to synchronize with
  16058. * @returns the current Animatable
  16059. */
  16060. syncWith(root: Animatable): Animatable;
  16061. /**
  16062. * Gets the list of runtime animations
  16063. * @returns an array of RuntimeAnimation
  16064. */
  16065. getAnimations(): RuntimeAnimation[];
  16066. /**
  16067. * Adds more animations to the current animatable
  16068. * @param target defines the target of the animations
  16069. * @param animations defines the new animations to add
  16070. */
  16071. appendAnimations(target: any, animations: Animation[]): void;
  16072. /**
  16073. * Gets the source animation for a specific property
  16074. * @param property defines the propertyu to look for
  16075. * @returns null or the source animation for the given property
  16076. */
  16077. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16078. /**
  16079. * Gets the runtime animation for a specific property
  16080. * @param property defines the propertyu to look for
  16081. * @returns null or the runtime animation for the given property
  16082. */
  16083. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16084. /**
  16085. * Resets the animatable to its original state
  16086. */
  16087. reset(): void;
  16088. /**
  16089. * Allows the animatable to blend with current running animations
  16090. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16091. * @param blendingSpeed defines the blending speed to use
  16092. */
  16093. enableBlending(blendingSpeed: number): void;
  16094. /**
  16095. * Disable animation blending
  16096. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16097. */
  16098. disableBlending(): void;
  16099. /**
  16100. * Jump directly to a given frame
  16101. * @param frame defines the frame to jump to
  16102. */
  16103. goToFrame(frame: number): void;
  16104. /**
  16105. * Pause the animation
  16106. */
  16107. pause(): void;
  16108. /**
  16109. * Restart the animation
  16110. */
  16111. restart(): void;
  16112. private _raiseOnAnimationEnd;
  16113. /**
  16114. * Stop and delete the current animation
  16115. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16116. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  16117. */
  16118. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16119. /**
  16120. * Wait asynchronously for the animation to end
  16121. * @returns a promise which will be fullfilled when the animation ends
  16122. */
  16123. waitAsync(): Promise<Animatable>;
  16124. /** @hidden */
  16125. _animate(delay: number): boolean;
  16126. }
  16127. module "babylonjs/scene" {
  16128. interface Scene {
  16129. /** @hidden */
  16130. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16131. /** @hidden */
  16132. _processLateAnimationBindingsForMatrices(holder: {
  16133. totalWeight: number;
  16134. totalAdditiveWeight: number;
  16135. animations: RuntimeAnimation[];
  16136. additiveAnimations: RuntimeAnimation[];
  16137. originalValue: Matrix;
  16138. }): any;
  16139. /** @hidden */
  16140. _processLateAnimationBindingsForQuaternions(holder: {
  16141. totalWeight: number;
  16142. totalAdditiveWeight: number;
  16143. animations: RuntimeAnimation[];
  16144. additiveAnimations: RuntimeAnimation[];
  16145. originalValue: Quaternion;
  16146. }, refQuaternion: Quaternion): Quaternion;
  16147. /** @hidden */
  16148. _processLateAnimationBindings(): void;
  16149. /**
  16150. * Will start the animation sequence of a given target
  16151. * @param target defines the target
  16152. * @param from defines from which frame should animation start
  16153. * @param to defines until which frame should animation run.
  16154. * @param weight defines the weight to apply to the animation (1.0 by default)
  16155. * @param loop defines if the animation loops
  16156. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16157. * @param onAnimationEnd defines the function to be executed when the animation ends
  16158. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16159. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16160. * @param onAnimationLoop defines the callback to call when an animation loops
  16161. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16162. * @returns the animatable object created for this animation
  16163. */
  16164. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16165. /**
  16166. * Will start the animation sequence of a given target
  16167. * @param target defines the target
  16168. * @param from defines from which frame should animation start
  16169. * @param to defines until which frame should animation run.
  16170. * @param loop defines if the animation loops
  16171. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16172. * @param onAnimationEnd defines the function to be executed when the animation ends
  16173. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16174. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16175. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16176. * @param onAnimationLoop defines the callback to call when an animation loops
  16177. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16178. * @returns the animatable object created for this animation
  16179. */
  16180. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16181. /**
  16182. * Will start the animation sequence of a given target and its hierarchy
  16183. * @param target defines the target
  16184. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  16185. * @param from defines from which frame should animation start
  16186. * @param to defines until which frame should animation run.
  16187. * @param loop defines if the animation loops
  16188. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16189. * @param onAnimationEnd defines the function to be executed when the animation ends
  16190. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16191. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16192. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16193. * @param onAnimationLoop defines the callback to call when an animation loops
  16194. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16195. * @returns the list of created animatables
  16196. */
  16197. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16198. /**
  16199. * Begin a new animation on a given node
  16200. * @param target defines the target where the animation will take place
  16201. * @param animations defines the list of animations to start
  16202. * @param from defines the initial value
  16203. * @param to defines the final value
  16204. * @param loop defines if you want animation to loop (off by default)
  16205. * @param speedRatio defines the speed ratio to apply to all animations
  16206. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16207. * @param onAnimationLoop defines the callback to call when an animation loops
  16208. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16209. * @returns the list of created animatables
  16210. */
  16211. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16212. /**
  16213. * Begin a new animation on a given node and its hierarchy
  16214. * @param target defines the root node where the animation will take place
  16215. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  16216. * @param animations defines the list of animations to start
  16217. * @param from defines the initial value
  16218. * @param to defines the final value
  16219. * @param loop defines if you want animation to loop (off by default)
  16220. * @param speedRatio defines the speed ratio to apply to all animations
  16221. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16222. * @param onAnimationLoop defines the callback to call when an animation loops
  16223. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16224. * @returns the list of animatables created for all nodes
  16225. */
  16226. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16227. /**
  16228. * Gets the animatable associated with a specific target
  16229. * @param target defines the target of the animatable
  16230. * @returns the required animatable if found
  16231. */
  16232. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16233. /**
  16234. * Gets all animatables associated with a given target
  16235. * @param target defines the target to look animatables for
  16236. * @returns an array of Animatables
  16237. */
  16238. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16239. /**
  16240. * Stops and removes all animations that have been applied to the scene
  16241. */
  16242. stopAllAnimations(): void;
  16243. /**
  16244. * Gets the current delta time used by animation engine
  16245. */
  16246. deltaTime: number;
  16247. }
  16248. }
  16249. module "babylonjs/Bones/bone" {
  16250. interface Bone {
  16251. /**
  16252. * Copy an animation range from another bone
  16253. * @param source defines the source bone
  16254. * @param rangeName defines the range name to copy
  16255. * @param frameOffset defines the frame offset
  16256. * @param rescaleAsRequired defines if rescaling must be applied if required
  16257. * @param skelDimensionsRatio defines the scaling ratio
  16258. * @returns true if operation was successful
  16259. */
  16260. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16261. }
  16262. }
  16263. }
  16264. declare module "babylonjs/Bones/skeleton" {
  16265. import { Bone } from "babylonjs/Bones/bone";
  16266. import { Observable } from "babylonjs/Misc/observable";
  16267. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16268. import { Scene } from "babylonjs/scene";
  16269. import { Nullable } from "babylonjs/types";
  16270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16271. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16272. import { Animatable } from "babylonjs/Animations/animatable";
  16273. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16274. import { Animation } from "babylonjs/Animations/animation";
  16275. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16276. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16277. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16278. /**
  16279. * Class used to handle skinning animations
  16280. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16281. */
  16282. export class Skeleton implements IAnimatable {
  16283. /** defines the skeleton name */
  16284. name: string;
  16285. /** defines the skeleton Id */
  16286. id: string;
  16287. /**
  16288. * Defines the list of child bones
  16289. */
  16290. bones: Bone[];
  16291. /**
  16292. * Defines an estimate of the dimension of the skeleton at rest
  16293. */
  16294. dimensionsAtRest: Vector3;
  16295. /**
  16296. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16297. */
  16298. needInitialSkinMatrix: boolean;
  16299. /**
  16300. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16301. */
  16302. overrideMesh: Nullable<AbstractMesh>;
  16303. /**
  16304. * Gets the list of animations attached to this skeleton
  16305. */
  16306. animations: Array<Animation>;
  16307. private _scene;
  16308. private _isDirty;
  16309. private _transformMatrices;
  16310. private _transformMatrixTexture;
  16311. private _meshesWithPoseMatrix;
  16312. private _animatables;
  16313. private _identity;
  16314. private _synchronizedWithMesh;
  16315. private _ranges;
  16316. private _lastAbsoluteTransformsUpdateId;
  16317. private _canUseTextureForBones;
  16318. private _uniqueId;
  16319. /** @hidden */
  16320. _numBonesWithLinkedTransformNode: number;
  16321. /** @hidden */
  16322. _hasWaitingData: Nullable<boolean>;
  16323. /**
  16324. * Specifies if the skeleton should be serialized
  16325. */
  16326. doNotSerialize: boolean;
  16327. private _useTextureToStoreBoneMatrices;
  16328. /**
  16329. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16330. * Please note that this option is not available if the hardware does not support it
  16331. */
  16332. get useTextureToStoreBoneMatrices(): boolean;
  16333. set useTextureToStoreBoneMatrices(value: boolean);
  16334. private _animationPropertiesOverride;
  16335. /**
  16336. * Gets or sets the animation properties override
  16337. */
  16338. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16339. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16340. /**
  16341. * List of inspectable custom properties (used by the Inspector)
  16342. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16343. */
  16344. inspectableCustomProperties: IInspectable[];
  16345. /**
  16346. * An observable triggered before computing the skeleton's matrices
  16347. */
  16348. onBeforeComputeObservable: Observable<Skeleton>;
  16349. /**
  16350. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16351. */
  16352. get isUsingTextureForMatrices(): boolean;
  16353. /**
  16354. * Gets the unique ID of this skeleton
  16355. */
  16356. get uniqueId(): number;
  16357. /**
  16358. * Creates a new skeleton
  16359. * @param name defines the skeleton name
  16360. * @param id defines the skeleton Id
  16361. * @param scene defines the hosting scene
  16362. */
  16363. constructor(
  16364. /** defines the skeleton name */
  16365. name: string,
  16366. /** defines the skeleton Id */
  16367. id: string, scene: Scene);
  16368. /**
  16369. * Gets the current object class name.
  16370. * @return the class name
  16371. */
  16372. getClassName(): string;
  16373. /**
  16374. * Returns an array containing the root bones
  16375. * @returns an array containing the root bones
  16376. */
  16377. getChildren(): Array<Bone>;
  16378. /**
  16379. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16380. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16381. * @returns a Float32Array containing matrices data
  16382. */
  16383. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16384. /**
  16385. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16386. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16387. * @returns a raw texture containing the data
  16388. */
  16389. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16390. /**
  16391. * Gets the current hosting scene
  16392. * @returns a scene object
  16393. */
  16394. getScene(): Scene;
  16395. /**
  16396. * Gets a string representing the current skeleton data
  16397. * @param fullDetails defines a boolean indicating if we want a verbose version
  16398. * @returns a string representing the current skeleton data
  16399. */
  16400. toString(fullDetails?: boolean): string;
  16401. /**
  16402. * Get bone's index searching by name
  16403. * @param name defines bone's name to search for
  16404. * @return the indice of the bone. Returns -1 if not found
  16405. */
  16406. getBoneIndexByName(name: string): number;
  16407. /**
  16408. * Creater a new animation range
  16409. * @param name defines the name of the range
  16410. * @param from defines the start key
  16411. * @param to defines the end key
  16412. */
  16413. createAnimationRange(name: string, from: number, to: number): void;
  16414. /**
  16415. * Delete a specific animation range
  16416. * @param name defines the name of the range
  16417. * @param deleteFrames defines if frames must be removed as well
  16418. */
  16419. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16420. /**
  16421. * Gets a specific animation range
  16422. * @param name defines the name of the range to look for
  16423. * @returns the requested animation range or null if not found
  16424. */
  16425. getAnimationRange(name: string): Nullable<AnimationRange>;
  16426. /**
  16427. * Gets the list of all animation ranges defined on this skeleton
  16428. * @returns an array
  16429. */
  16430. getAnimationRanges(): Nullable<AnimationRange>[];
  16431. /**
  16432. * Copy animation range from a source skeleton.
  16433. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16434. * @param source defines the source skeleton
  16435. * @param name defines the name of the range to copy
  16436. * @param rescaleAsRequired defines if rescaling must be applied if required
  16437. * @returns true if operation was successful
  16438. */
  16439. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16440. /**
  16441. * Forces the skeleton to go to rest pose
  16442. */
  16443. returnToRest(): void;
  16444. private _getHighestAnimationFrame;
  16445. /**
  16446. * Begin a specific animation range
  16447. * @param name defines the name of the range to start
  16448. * @param loop defines if looping must be turned on (false by default)
  16449. * @param speedRatio defines the speed ratio to apply (1 by default)
  16450. * @param onAnimationEnd defines a callback which will be called when animation will end
  16451. * @returns a new animatable
  16452. */
  16453. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16454. /**
  16455. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16456. * @param skeleton defines the Skeleton containing the animation range to convert
  16457. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16458. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16459. * @returns the original skeleton
  16460. */
  16461. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16462. /** @hidden */
  16463. _markAsDirty(): void;
  16464. /** @hidden */
  16465. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16466. /** @hidden */
  16467. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16468. private _computeTransformMatrices;
  16469. /**
  16470. * Build all resources required to render a skeleton
  16471. */
  16472. prepare(): void;
  16473. /**
  16474. * Gets the list of animatables currently running for this skeleton
  16475. * @returns an array of animatables
  16476. */
  16477. getAnimatables(): IAnimatable[];
  16478. /**
  16479. * Clone the current skeleton
  16480. * @param name defines the name of the new skeleton
  16481. * @param id defines the id of the new skeleton
  16482. * @returns the new skeleton
  16483. */
  16484. clone(name: string, id?: string): Skeleton;
  16485. /**
  16486. * Enable animation blending for this skeleton
  16487. * @param blendingSpeed defines the blending speed to apply
  16488. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16489. */
  16490. enableBlending(blendingSpeed?: number): void;
  16491. /**
  16492. * Releases all resources associated with the current skeleton
  16493. */
  16494. dispose(): void;
  16495. /**
  16496. * Serialize the skeleton in a JSON object
  16497. * @returns a JSON object
  16498. */
  16499. serialize(): any;
  16500. /**
  16501. * Creates a new skeleton from serialized data
  16502. * @param parsedSkeleton defines the serialized data
  16503. * @param scene defines the hosting scene
  16504. * @returns a new skeleton
  16505. */
  16506. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16507. /**
  16508. * Compute all node absolute transforms
  16509. * @param forceUpdate defines if computation must be done even if cache is up to date
  16510. */
  16511. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16512. /**
  16513. * Gets the root pose matrix
  16514. * @returns a matrix
  16515. */
  16516. getPoseMatrix(): Nullable<Matrix>;
  16517. /**
  16518. * Sorts bones per internal index
  16519. */
  16520. sortBones(): void;
  16521. private _sortBones;
  16522. }
  16523. }
  16524. declare module "babylonjs/Meshes/instancedMesh" {
  16525. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16526. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16527. import { Camera } from "babylonjs/Cameras/camera";
  16528. import { Node } from "babylonjs/node";
  16529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16530. import { Mesh } from "babylonjs/Meshes/mesh";
  16531. import { Material } from "babylonjs/Materials/material";
  16532. import { Skeleton } from "babylonjs/Bones/skeleton";
  16533. import { Light } from "babylonjs/Lights/light";
  16534. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16535. /**
  16536. * Creates an instance based on a source mesh.
  16537. */
  16538. export class InstancedMesh extends AbstractMesh {
  16539. private _sourceMesh;
  16540. private _currentLOD;
  16541. /** @hidden */
  16542. _indexInSourceMeshInstanceArray: number;
  16543. constructor(name: string, source: Mesh);
  16544. /**
  16545. * Returns the string "InstancedMesh".
  16546. */
  16547. getClassName(): string;
  16548. /** Gets the list of lights affecting that mesh */
  16549. get lightSources(): Light[];
  16550. _resyncLightSources(): void;
  16551. _resyncLightSource(light: Light): void;
  16552. _removeLightSource(light: Light, dispose: boolean): void;
  16553. /**
  16554. * If the source mesh receives shadows
  16555. */
  16556. get receiveShadows(): boolean;
  16557. /**
  16558. * The material of the source mesh
  16559. */
  16560. get material(): Nullable<Material>;
  16561. /**
  16562. * Visibility of the source mesh
  16563. */
  16564. get visibility(): number;
  16565. /**
  16566. * Skeleton of the source mesh
  16567. */
  16568. get skeleton(): Nullable<Skeleton>;
  16569. /**
  16570. * Rendering ground id of the source mesh
  16571. */
  16572. get renderingGroupId(): number;
  16573. set renderingGroupId(value: number);
  16574. /**
  16575. * Returns the total number of vertices (integer).
  16576. */
  16577. getTotalVertices(): number;
  16578. /**
  16579. * Returns a positive integer : the total number of indices in this mesh geometry.
  16580. * @returns the numner of indices or zero if the mesh has no geometry.
  16581. */
  16582. getTotalIndices(): number;
  16583. /**
  16584. * The source mesh of the instance
  16585. */
  16586. get sourceMesh(): Mesh;
  16587. /**
  16588. * Creates a new InstancedMesh object from the mesh model.
  16589. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16590. * @param name defines the name of the new instance
  16591. * @returns a new InstancedMesh
  16592. */
  16593. createInstance(name: string): InstancedMesh;
  16594. /**
  16595. * Is this node ready to be used/rendered
  16596. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16597. * @return {boolean} is it ready
  16598. */
  16599. isReady(completeCheck?: boolean): boolean;
  16600. /**
  16601. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16602. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16603. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  16604. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16605. */
  16606. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16607. /**
  16608. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16609. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16610. * The `data` are either a numeric array either a Float32Array.
  16611. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16612. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  16613. * Note that a new underlying VertexBuffer object is created each call.
  16614. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16615. *
  16616. * Possible `kind` values :
  16617. * - VertexBuffer.PositionKind
  16618. * - VertexBuffer.UVKind
  16619. * - VertexBuffer.UV2Kind
  16620. * - VertexBuffer.UV3Kind
  16621. * - VertexBuffer.UV4Kind
  16622. * - VertexBuffer.UV5Kind
  16623. * - VertexBuffer.UV6Kind
  16624. * - VertexBuffer.ColorKind
  16625. * - VertexBuffer.MatricesIndicesKind
  16626. * - VertexBuffer.MatricesIndicesExtraKind
  16627. * - VertexBuffer.MatricesWeightsKind
  16628. * - VertexBuffer.MatricesWeightsExtraKind
  16629. *
  16630. * Returns the Mesh.
  16631. */
  16632. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16633. /**
  16634. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16635. * If the mesh has no geometry, it is simply returned as it is.
  16636. * The `data` are either a numeric array either a Float32Array.
  16637. * No new underlying VertexBuffer object is created.
  16638. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16639. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16640. *
  16641. * Possible `kind` values :
  16642. * - VertexBuffer.PositionKind
  16643. * - VertexBuffer.UVKind
  16644. * - VertexBuffer.UV2Kind
  16645. * - VertexBuffer.UV3Kind
  16646. * - VertexBuffer.UV4Kind
  16647. * - VertexBuffer.UV5Kind
  16648. * - VertexBuffer.UV6Kind
  16649. * - VertexBuffer.ColorKind
  16650. * - VertexBuffer.MatricesIndicesKind
  16651. * - VertexBuffer.MatricesIndicesExtraKind
  16652. * - VertexBuffer.MatricesWeightsKind
  16653. * - VertexBuffer.MatricesWeightsExtraKind
  16654. *
  16655. * Returns the Mesh.
  16656. */
  16657. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16658. /**
  16659. * Sets the mesh indices.
  16660. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16661. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16662. * This method creates a new index buffer each call.
  16663. * Returns the Mesh.
  16664. */
  16665. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16666. /**
  16667. * Boolean : True if the mesh owns the requested kind of data.
  16668. */
  16669. isVerticesDataPresent(kind: string): boolean;
  16670. /**
  16671. * Returns an array of indices (IndicesArray).
  16672. */
  16673. getIndices(): Nullable<IndicesArray>;
  16674. get _positions(): Nullable<Vector3[]>;
  16675. /**
  16676. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16677. * This means the mesh underlying bounding box and sphere are recomputed.
  16678. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16679. * @returns the current mesh
  16680. */
  16681. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16682. /** @hidden */
  16683. _preActivate(): InstancedMesh;
  16684. /** @hidden */
  16685. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16686. /** @hidden */
  16687. _postActivate(): void;
  16688. getWorldMatrix(): Matrix;
  16689. get isAnInstance(): boolean;
  16690. /**
  16691. * Returns the current associated LOD AbstractMesh.
  16692. */
  16693. getLOD(camera: Camera): AbstractMesh;
  16694. /** @hidden */
  16695. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16696. /** @hidden */
  16697. _syncSubMeshes(): InstancedMesh;
  16698. /** @hidden */
  16699. _generatePointsArray(): boolean;
  16700. /**
  16701. * Creates a new InstancedMesh from the current mesh.
  16702. * - name (string) : the cloned mesh name
  16703. * - newParent (optional Node) : the optional Node to parent the clone to.
  16704. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16705. *
  16706. * Returns the clone.
  16707. */
  16708. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16709. /**
  16710. * Disposes the InstancedMesh.
  16711. * Returns nothing.
  16712. */
  16713. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16714. }
  16715. module "babylonjs/Meshes/mesh" {
  16716. interface Mesh {
  16717. /**
  16718. * Register a custom buffer that will be instanced
  16719. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16720. * @param kind defines the buffer kind
  16721. * @param stride defines the stride in floats
  16722. */
  16723. registerInstancedBuffer(kind: string, stride: number): void;
  16724. /** @hidden */
  16725. _userInstancedBuffersStorage: {
  16726. data: {
  16727. [key: string]: Float32Array;
  16728. };
  16729. sizes: {
  16730. [key: string]: number;
  16731. };
  16732. vertexBuffers: {
  16733. [key: string]: Nullable<VertexBuffer>;
  16734. };
  16735. strides: {
  16736. [key: string]: number;
  16737. };
  16738. };
  16739. }
  16740. }
  16741. module "babylonjs/Meshes/abstractMesh" {
  16742. interface AbstractMesh {
  16743. /**
  16744. * Object used to store instanced buffers defined by user
  16745. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16746. */
  16747. instancedBuffers: {
  16748. [key: string]: any;
  16749. };
  16750. }
  16751. }
  16752. }
  16753. declare module "babylonjs/Materials/shaderMaterial" {
  16754. import { Nullable } from "babylonjs/types";
  16755. import { Scene } from "babylonjs/scene";
  16756. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16758. import { Mesh } from "babylonjs/Meshes/mesh";
  16759. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16760. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16761. import { Effect } from "babylonjs/Materials/effect";
  16762. import { Material } from "babylonjs/Materials/material";
  16763. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16764. /**
  16765. * Defines the options associated with the creation of a shader material.
  16766. */
  16767. export interface IShaderMaterialOptions {
  16768. /**
  16769. * Does the material work in alpha blend mode
  16770. */
  16771. needAlphaBlending: boolean;
  16772. /**
  16773. * Does the material work in alpha test mode
  16774. */
  16775. needAlphaTesting: boolean;
  16776. /**
  16777. * The list of attribute names used in the shader
  16778. */
  16779. attributes: string[];
  16780. /**
  16781. * The list of unifrom names used in the shader
  16782. */
  16783. uniforms: string[];
  16784. /**
  16785. * The list of UBO names used in the shader
  16786. */
  16787. uniformBuffers: string[];
  16788. /**
  16789. * The list of sampler names used in the shader
  16790. */
  16791. samplers: string[];
  16792. /**
  16793. * The list of defines used in the shader
  16794. */
  16795. defines: string[];
  16796. }
  16797. /**
  16798. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  16799. *
  16800. * This returned material effects how the mesh will look based on the code in the shaders.
  16801. *
  16802. * @see http://doc.babylonjs.com/how_to/shader_material
  16803. */
  16804. export class ShaderMaterial extends Material {
  16805. private _shaderPath;
  16806. private _options;
  16807. private _textures;
  16808. private _textureArrays;
  16809. private _floats;
  16810. private _ints;
  16811. private _floatsArrays;
  16812. private _colors3;
  16813. private _colors3Arrays;
  16814. private _colors4;
  16815. private _colors4Arrays;
  16816. private _vectors2;
  16817. private _vectors3;
  16818. private _vectors4;
  16819. private _matrices;
  16820. private _matrixArrays;
  16821. private _matrices3x3;
  16822. private _matrices2x2;
  16823. private _vectors2Arrays;
  16824. private _vectors3Arrays;
  16825. private _vectors4Arrays;
  16826. private _cachedWorldViewMatrix;
  16827. private _cachedWorldViewProjectionMatrix;
  16828. private _renderId;
  16829. private _multiview;
  16830. private _cachedDefines;
  16831. /**
  16832. * Instantiate a new shader material.
  16833. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  16834. * This returned material effects how the mesh will look based on the code in the shaders.
  16835. * @see http://doc.babylonjs.com/how_to/shader_material
  16836. * @param name Define the name of the material in the scene
  16837. * @param scene Define the scene the material belongs to
  16838. * @param shaderPath Defines the route to the shader code in one of three ways:
  16839. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16840. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16841. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16842. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16843. * @param options Define the options used to create the shader
  16844. */
  16845. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16846. /**
  16847. * Gets the shader path used to define the shader code
  16848. * It can be modified to trigger a new compilation
  16849. */
  16850. get shaderPath(): any;
  16851. /**
  16852. * Sets the shader path used to define the shader code
  16853. * It can be modified to trigger a new compilation
  16854. */
  16855. set shaderPath(shaderPath: any);
  16856. /**
  16857. * Gets the options used to compile the shader.
  16858. * They can be modified to trigger a new compilation
  16859. */
  16860. get options(): IShaderMaterialOptions;
  16861. /**
  16862. * Gets the current class name of the material e.g. "ShaderMaterial"
  16863. * Mainly use in serialization.
  16864. * @returns the class name
  16865. */
  16866. getClassName(): string;
  16867. /**
  16868. * Specifies if the material will require alpha blending
  16869. * @returns a boolean specifying if alpha blending is needed
  16870. */
  16871. needAlphaBlending(): boolean;
  16872. /**
  16873. * Specifies if this material should be rendered in alpha test mode
  16874. * @returns a boolean specifying if an alpha test is needed.
  16875. */
  16876. needAlphaTesting(): boolean;
  16877. private _checkUniform;
  16878. /**
  16879. * Set a texture in the shader.
  16880. * @param name Define the name of the uniform samplers as defined in the shader
  16881. * @param texture Define the texture to bind to this sampler
  16882. * @return the material itself allowing "fluent" like uniform updates
  16883. */
  16884. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16885. /**
  16886. * Set a texture array in the shader.
  16887. * @param name Define the name of the uniform sampler array as defined in the shader
  16888. * @param textures Define the list of textures to bind to this sampler
  16889. * @return the material itself allowing "fluent" like uniform updates
  16890. */
  16891. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16892. /**
  16893. * Set a float in the shader.
  16894. * @param name Define the name of the uniform as defined in the shader
  16895. * @param value Define the value to give to the uniform
  16896. * @return the material itself allowing "fluent" like uniform updates
  16897. */
  16898. setFloat(name: string, value: number): ShaderMaterial;
  16899. /**
  16900. * Set a int in the shader.
  16901. * @param name Define the name of the uniform as defined in the shader
  16902. * @param value Define the value to give to the uniform
  16903. * @return the material itself allowing "fluent" like uniform updates
  16904. */
  16905. setInt(name: string, value: number): ShaderMaterial;
  16906. /**
  16907. * Set an array of floats in the shader.
  16908. * @param name Define the name of the uniform as defined in the shader
  16909. * @param value Define the value to give to the uniform
  16910. * @return the material itself allowing "fluent" like uniform updates
  16911. */
  16912. setFloats(name: string, value: number[]): ShaderMaterial;
  16913. /**
  16914. * Set a vec3 in the shader from a Color3.
  16915. * @param name Define the name of the uniform as defined in the shader
  16916. * @param value Define the value to give to the uniform
  16917. * @return the material itself allowing "fluent" like uniform updates
  16918. */
  16919. setColor3(name: string, value: Color3): ShaderMaterial;
  16920. /**
  16921. * Set a vec3 array in the shader from a Color3 array.
  16922. * @param name Define the name of the uniform as defined in the shader
  16923. * @param value Define the value to give to the uniform
  16924. * @return the material itself allowing "fluent" like uniform updates
  16925. */
  16926. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16927. /**
  16928. * Set a vec4 in the shader from a Color4.
  16929. * @param name Define the name of the uniform as defined in the shader
  16930. * @param value Define the value to give to the uniform
  16931. * @return the material itself allowing "fluent" like uniform updates
  16932. */
  16933. setColor4(name: string, value: Color4): ShaderMaterial;
  16934. /**
  16935. * Set a vec4 array in the shader from a Color4 array.
  16936. * @param name Define the name of the uniform as defined in the shader
  16937. * @param value Define the value to give to the uniform
  16938. * @return the material itself allowing "fluent" like uniform updates
  16939. */
  16940. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16941. /**
  16942. * Set a vec2 in the shader from a Vector2.
  16943. * @param name Define the name of the uniform as defined in the shader
  16944. * @param value Define the value to give to the uniform
  16945. * @return the material itself allowing "fluent" like uniform updates
  16946. */
  16947. setVector2(name: string, value: Vector2): ShaderMaterial;
  16948. /**
  16949. * Set a vec3 in the shader from a Vector3.
  16950. * @param name Define the name of the uniform as defined in the shader
  16951. * @param value Define the value to give to the uniform
  16952. * @return the material itself allowing "fluent" like uniform updates
  16953. */
  16954. setVector3(name: string, value: Vector3): ShaderMaterial;
  16955. /**
  16956. * Set a vec4 in the shader from a Vector4.
  16957. * @param name Define the name of the uniform as defined in the shader
  16958. * @param value Define the value to give to the uniform
  16959. * @return the material itself allowing "fluent" like uniform updates
  16960. */
  16961. setVector4(name: string, value: Vector4): ShaderMaterial;
  16962. /**
  16963. * Set a mat4 in the shader from a Matrix.
  16964. * @param name Define the name of the uniform as defined in the shader
  16965. * @param value Define the value to give to the uniform
  16966. * @return the material itself allowing "fluent" like uniform updates
  16967. */
  16968. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16969. /**
  16970. * Set a float32Array in the shader from a matrix array.
  16971. * @param name Define the name of the uniform as defined in the shader
  16972. * @param value Define the value to give to the uniform
  16973. * @return the material itself allowing "fluent" like uniform updates
  16974. */
  16975. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16976. /**
  16977. * Set a mat3 in the shader from a Float32Array.
  16978. * @param name Define the name of the uniform as defined in the shader
  16979. * @param value Define the value to give to the uniform
  16980. * @return the material itself allowing "fluent" like uniform updates
  16981. */
  16982. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16983. /**
  16984. * Set a mat2 in the shader from a Float32Array.
  16985. * @param name Define the name of the uniform as defined in the shader
  16986. * @param value Define the value to give to the uniform
  16987. * @return the material itself allowing "fluent" like uniform updates
  16988. */
  16989. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16990. /**
  16991. * Set a vec2 array in the shader from a number array.
  16992. * @param name Define the name of the uniform as defined in the shader
  16993. * @param value Define the value to give to the uniform
  16994. * @return the material itself allowing "fluent" like uniform updates
  16995. */
  16996. setArray2(name: string, value: number[]): ShaderMaterial;
  16997. /**
  16998. * Set a vec3 array in the shader from a number array.
  16999. * @param name Define the name of the uniform as defined in the shader
  17000. * @param value Define the value to give to the uniform
  17001. * @return the material itself allowing "fluent" like uniform updates
  17002. */
  17003. setArray3(name: string, value: number[]): ShaderMaterial;
  17004. /**
  17005. * Set a vec4 array in the shader from a number array.
  17006. * @param name Define the name of the uniform as defined in the shader
  17007. * @param value Define the value to give to the uniform
  17008. * @return the material itself allowing "fluent" like uniform updates
  17009. */
  17010. setArray4(name: string, value: number[]): ShaderMaterial;
  17011. private _checkCache;
  17012. /**
  17013. * Specifies that the submesh is ready to be used
  17014. * @param mesh defines the mesh to check
  17015. * @param subMesh defines which submesh to check
  17016. * @param useInstances specifies that instances should be used
  17017. * @returns a boolean indicating that the submesh is ready or not
  17018. */
  17019. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17020. /**
  17021. * Checks if the material is ready to render the requested mesh
  17022. * @param mesh Define the mesh to render
  17023. * @param useInstances Define whether or not the material is used with instances
  17024. * @returns true if ready, otherwise false
  17025. */
  17026. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17027. /**
  17028. * Binds the world matrix to the material
  17029. * @param world defines the world transformation matrix
  17030. * @param effectOverride - If provided, use this effect instead of internal effect
  17031. */
  17032. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17033. /**
  17034. * Binds the submesh to this material by preparing the effect and shader to draw
  17035. * @param world defines the world transformation matrix
  17036. * @param mesh defines the mesh containing the submesh
  17037. * @param subMesh defines the submesh to bind the material to
  17038. */
  17039. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17040. /**
  17041. * Binds the material to the mesh
  17042. * @param world defines the world transformation matrix
  17043. * @param mesh defines the mesh to bind the material to
  17044. * @param effectOverride - If provided, use this effect instead of internal effect
  17045. */
  17046. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17047. protected _afterBind(mesh?: Mesh): void;
  17048. /**
  17049. * Gets the active textures from the material
  17050. * @returns an array of textures
  17051. */
  17052. getActiveTextures(): BaseTexture[];
  17053. /**
  17054. * Specifies if the material uses a texture
  17055. * @param texture defines the texture to check against the material
  17056. * @returns a boolean specifying if the material uses the texture
  17057. */
  17058. hasTexture(texture: BaseTexture): boolean;
  17059. /**
  17060. * Makes a duplicate of the material, and gives it a new name
  17061. * @param name defines the new name for the duplicated material
  17062. * @returns the cloned material
  17063. */
  17064. clone(name: string): ShaderMaterial;
  17065. /**
  17066. * Disposes the material
  17067. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17068. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17069. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17070. */
  17071. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17072. /**
  17073. * Serializes this material in a JSON representation
  17074. * @returns the serialized material object
  17075. */
  17076. serialize(): any;
  17077. /**
  17078. * Creates a shader material from parsed shader material data
  17079. * @param source defines the JSON represnetation of the material
  17080. * @param scene defines the hosting scene
  17081. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17082. * @returns a new material
  17083. */
  17084. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17085. }
  17086. }
  17087. declare module "babylonjs/Shaders/color.fragment" {
  17088. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17089. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17090. /** @hidden */
  17091. export var colorPixelShader: {
  17092. name: string;
  17093. shader: string;
  17094. };
  17095. }
  17096. declare module "babylonjs/Shaders/color.vertex" {
  17097. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17098. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17099. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17100. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17101. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17102. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17103. /** @hidden */
  17104. export var colorVertexShader: {
  17105. name: string;
  17106. shader: string;
  17107. };
  17108. }
  17109. declare module "babylonjs/Meshes/linesMesh" {
  17110. import { Nullable } from "babylonjs/types";
  17111. import { Scene } from "babylonjs/scene";
  17112. import { Color3 } from "babylonjs/Maths/math.color";
  17113. import { Node } from "babylonjs/node";
  17114. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17115. import { Mesh } from "babylonjs/Meshes/mesh";
  17116. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17117. import { Effect } from "babylonjs/Materials/effect";
  17118. import { Material } from "babylonjs/Materials/material";
  17119. import "babylonjs/Shaders/color.fragment";
  17120. import "babylonjs/Shaders/color.vertex";
  17121. /**
  17122. * Line mesh
  17123. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17124. */
  17125. export class LinesMesh extends Mesh {
  17126. /**
  17127. * If vertex color should be applied to the mesh
  17128. */
  17129. readonly useVertexColor?: boolean | undefined;
  17130. /**
  17131. * If vertex alpha should be applied to the mesh
  17132. */
  17133. readonly useVertexAlpha?: boolean | undefined;
  17134. /**
  17135. * Color of the line (Default: White)
  17136. */
  17137. color: Color3;
  17138. /**
  17139. * Alpha of the line (Default: 1)
  17140. */
  17141. alpha: number;
  17142. /**
  17143. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17144. * This margin is expressed in world space coordinates, so its value may vary.
  17145. * Default value is 0.1
  17146. */
  17147. intersectionThreshold: number;
  17148. private _colorShader;
  17149. private color4;
  17150. /**
  17151. * Creates a new LinesMesh
  17152. * @param name defines the name
  17153. * @param scene defines the hosting scene
  17154. * @param parent defines the parent mesh if any
  17155. * @param source defines the optional source LinesMesh used to clone data from
  17156. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17157. * When false, achieved by calling a clone(), also passing False.
  17158. * This will make creation of children, recursive.
  17159. * @param useVertexColor defines if this LinesMesh supports vertex color
  17160. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17161. */
  17162. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17163. /**
  17164. * If vertex color should be applied to the mesh
  17165. */
  17166. useVertexColor?: boolean | undefined,
  17167. /**
  17168. * If vertex alpha should be applied to the mesh
  17169. */
  17170. useVertexAlpha?: boolean | undefined);
  17171. private _addClipPlaneDefine;
  17172. private _removeClipPlaneDefine;
  17173. isReady(): boolean;
  17174. /**
  17175. * Returns the string "LineMesh"
  17176. */
  17177. getClassName(): string;
  17178. /**
  17179. * @hidden
  17180. */
  17181. get material(): Material;
  17182. /**
  17183. * @hidden
  17184. */
  17185. set material(value: Material);
  17186. /**
  17187. * @hidden
  17188. */
  17189. get checkCollisions(): boolean;
  17190. /** @hidden */
  17191. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17192. /** @hidden */
  17193. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17194. /**
  17195. * Disposes of the line mesh
  17196. * @param doNotRecurse If children should be disposed
  17197. */
  17198. dispose(doNotRecurse?: boolean): void;
  17199. /**
  17200. * Returns a new LineMesh object cloned from the current one.
  17201. */
  17202. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17203. /**
  17204. * Creates a new InstancedLinesMesh object from the mesh model.
  17205. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17206. * @param name defines the name of the new instance
  17207. * @returns a new InstancedLinesMesh
  17208. */
  17209. createInstance(name: string): InstancedLinesMesh;
  17210. }
  17211. /**
  17212. * Creates an instance based on a source LinesMesh
  17213. */
  17214. export class InstancedLinesMesh extends InstancedMesh {
  17215. /**
  17216. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17217. * This margin is expressed in world space coordinates, so its value may vary.
  17218. * Initilized with the intersectionThreshold value of the source LinesMesh
  17219. */
  17220. intersectionThreshold: number;
  17221. constructor(name: string, source: LinesMesh);
  17222. /**
  17223. * Returns the string "InstancedLinesMesh".
  17224. */
  17225. getClassName(): string;
  17226. }
  17227. }
  17228. declare module "babylonjs/Shaders/line.fragment" {
  17229. /** @hidden */
  17230. export var linePixelShader: {
  17231. name: string;
  17232. shader: string;
  17233. };
  17234. }
  17235. declare module "babylonjs/Shaders/line.vertex" {
  17236. /** @hidden */
  17237. export var lineVertexShader: {
  17238. name: string;
  17239. shader: string;
  17240. };
  17241. }
  17242. declare module "babylonjs/Rendering/edgesRenderer" {
  17243. import { Nullable } from "babylonjs/types";
  17244. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17246. import { Vector3 } from "babylonjs/Maths/math.vector";
  17247. import { IDisposable } from "babylonjs/scene";
  17248. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17249. import "babylonjs/Shaders/line.fragment";
  17250. import "babylonjs/Shaders/line.vertex";
  17251. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17252. module "babylonjs/Meshes/abstractMesh" {
  17253. interface AbstractMesh {
  17254. /**
  17255. * Gets the edgesRenderer associated with the mesh
  17256. */
  17257. edgesRenderer: Nullable<EdgesRenderer>;
  17258. }
  17259. }
  17260. module "babylonjs/Meshes/linesMesh" {
  17261. interface LinesMesh {
  17262. /**
  17263. * Enables the edge rendering mode on the mesh.
  17264. * This mode makes the mesh edges visible
  17265. * @param epsilon defines the maximal distance between two angles to detect a face
  17266. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17267. * @returns the currentAbstractMesh
  17268. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17269. */
  17270. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17271. }
  17272. }
  17273. module "babylonjs/Meshes/linesMesh" {
  17274. interface InstancedLinesMesh {
  17275. /**
  17276. * Enables the edge rendering mode on the mesh.
  17277. * This mode makes the mesh edges visible
  17278. * @param epsilon defines the maximal distance between two angles to detect a face
  17279. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17280. * @returns the current InstancedLinesMesh
  17281. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17282. */
  17283. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17284. }
  17285. }
  17286. /**
  17287. * Defines the minimum contract an Edges renderer should follow.
  17288. */
  17289. export interface IEdgesRenderer extends IDisposable {
  17290. /**
  17291. * Gets or sets a boolean indicating if the edgesRenderer is active
  17292. */
  17293. isEnabled: boolean;
  17294. /**
  17295. * Renders the edges of the attached mesh,
  17296. */
  17297. render(): void;
  17298. /**
  17299. * Checks wether or not the edges renderer is ready to render.
  17300. * @return true if ready, otherwise false.
  17301. */
  17302. isReady(): boolean;
  17303. }
  17304. /**
  17305. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17306. */
  17307. export class EdgesRenderer implements IEdgesRenderer {
  17308. /**
  17309. * Define the size of the edges with an orthographic camera
  17310. */
  17311. edgesWidthScalerForOrthographic: number;
  17312. /**
  17313. * Define the size of the edges with a perspective camera
  17314. */
  17315. edgesWidthScalerForPerspective: number;
  17316. protected _source: AbstractMesh;
  17317. protected _linesPositions: number[];
  17318. protected _linesNormals: number[];
  17319. protected _linesIndices: number[];
  17320. protected _epsilon: number;
  17321. protected _indicesCount: number;
  17322. protected _lineShader: ShaderMaterial;
  17323. protected _ib: DataBuffer;
  17324. protected _buffers: {
  17325. [key: string]: Nullable<VertexBuffer>;
  17326. };
  17327. protected _checkVerticesInsteadOfIndices: boolean;
  17328. private _meshRebuildObserver;
  17329. private _meshDisposeObserver;
  17330. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17331. isEnabled: boolean;
  17332. /**
  17333. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17334. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17335. * @param source Mesh used to create edges
  17336. * @param epsilon sum of angles in adjacency to check for edge
  17337. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17338. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17339. */
  17340. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17341. protected _prepareRessources(): void;
  17342. /** @hidden */
  17343. _rebuild(): void;
  17344. /**
  17345. * Releases the required resources for the edges renderer
  17346. */
  17347. dispose(): void;
  17348. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17349. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17350. /**
  17351. * Checks if the pair of p0 and p1 is en edge
  17352. * @param faceIndex
  17353. * @param edge
  17354. * @param faceNormals
  17355. * @param p0
  17356. * @param p1
  17357. * @private
  17358. */
  17359. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17360. /**
  17361. * push line into the position, normal and index buffer
  17362. * @protected
  17363. */
  17364. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17365. /**
  17366. * Generates lines edges from adjacencjes
  17367. * @private
  17368. */
  17369. _generateEdgesLines(): void;
  17370. /**
  17371. * Checks wether or not the edges renderer is ready to render.
  17372. * @return true if ready, otherwise false.
  17373. */
  17374. isReady(): boolean;
  17375. /**
  17376. * Renders the edges of the attached mesh,
  17377. */
  17378. render(): void;
  17379. }
  17380. /**
  17381. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17382. */
  17383. export class LineEdgesRenderer extends EdgesRenderer {
  17384. /**
  17385. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17386. * @param source LineMesh used to generate edges
  17387. * @param epsilon not important (specified angle for edge detection)
  17388. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17389. */
  17390. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17391. /**
  17392. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17393. */
  17394. _generateEdgesLines(): void;
  17395. }
  17396. }
  17397. declare module "babylonjs/Rendering/renderingGroup" {
  17398. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17399. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17401. import { Nullable } from "babylonjs/types";
  17402. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17403. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17404. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17405. import { Material } from "babylonjs/Materials/material";
  17406. import { Scene } from "babylonjs/scene";
  17407. /**
  17408. * This represents the object necessary to create a rendering group.
  17409. * This is exclusively used and created by the rendering manager.
  17410. * To modify the behavior, you use the available helpers in your scene or meshes.
  17411. * @hidden
  17412. */
  17413. export class RenderingGroup {
  17414. index: number;
  17415. private static _zeroVector;
  17416. private _scene;
  17417. private _opaqueSubMeshes;
  17418. private _transparentSubMeshes;
  17419. private _alphaTestSubMeshes;
  17420. private _depthOnlySubMeshes;
  17421. private _particleSystems;
  17422. private _spriteManagers;
  17423. private _opaqueSortCompareFn;
  17424. private _alphaTestSortCompareFn;
  17425. private _transparentSortCompareFn;
  17426. private _renderOpaque;
  17427. private _renderAlphaTest;
  17428. private _renderTransparent;
  17429. /** @hidden */
  17430. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17431. onBeforeTransparentRendering: () => void;
  17432. /**
  17433. * Set the opaque sort comparison function.
  17434. * If null the sub meshes will be render in the order they were created
  17435. */
  17436. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17437. /**
  17438. * Set the alpha test sort comparison function.
  17439. * If null the sub meshes will be render in the order they were created
  17440. */
  17441. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17442. /**
  17443. * Set the transparent sort comparison function.
  17444. * If null the sub meshes will be render in the order they were created
  17445. */
  17446. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17447. /**
  17448. * Creates a new rendering group.
  17449. * @param index The rendering group index
  17450. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17451. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17452. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17453. */
  17454. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17455. /**
  17456. * Render all the sub meshes contained in the group.
  17457. * @param customRenderFunction Used to override the default render behaviour of the group.
  17458. * @returns true if rendered some submeshes.
  17459. */
  17460. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17461. /**
  17462. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17463. * @param subMeshes The submeshes to render
  17464. */
  17465. private renderOpaqueSorted;
  17466. /**
  17467. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17468. * @param subMeshes The submeshes to render
  17469. */
  17470. private renderAlphaTestSorted;
  17471. /**
  17472. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17473. * @param subMeshes The submeshes to render
  17474. */
  17475. private renderTransparentSorted;
  17476. /**
  17477. * Renders the submeshes in a specified order.
  17478. * @param subMeshes The submeshes to sort before render
  17479. * @param sortCompareFn The comparison function use to sort
  17480. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17481. * @param transparent Specifies to activate blending if true
  17482. */
  17483. private static renderSorted;
  17484. /**
  17485. * Renders the submeshes in the order they were dispatched (no sort applied).
  17486. * @param subMeshes The submeshes to render
  17487. */
  17488. private static renderUnsorted;
  17489. /**
  17490. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17491. * are rendered back to front if in the same alpha index.
  17492. *
  17493. * @param a The first submesh
  17494. * @param b The second submesh
  17495. * @returns The result of the comparison
  17496. */
  17497. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17498. /**
  17499. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17500. * are rendered back to front.
  17501. *
  17502. * @param a The first submesh
  17503. * @param b The second submesh
  17504. * @returns The result of the comparison
  17505. */
  17506. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17507. /**
  17508. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17509. * are rendered front to back (prevent overdraw).
  17510. *
  17511. * @param a The first submesh
  17512. * @param b The second submesh
  17513. * @returns The result of the comparison
  17514. */
  17515. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17516. /**
  17517. * Resets the different lists of submeshes to prepare a new frame.
  17518. */
  17519. prepare(): void;
  17520. dispose(): void;
  17521. /**
  17522. * Inserts the submesh in its correct queue depending on its material.
  17523. * @param subMesh The submesh to dispatch
  17524. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17525. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17526. */
  17527. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17528. dispatchSprites(spriteManager: ISpriteManager): void;
  17529. dispatchParticles(particleSystem: IParticleSystem): void;
  17530. private _renderParticles;
  17531. private _renderSprites;
  17532. }
  17533. }
  17534. declare module "babylonjs/Rendering/renderingManager" {
  17535. import { Nullable } from "babylonjs/types";
  17536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17537. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17538. import { SmartArray } from "babylonjs/Misc/smartArray";
  17539. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17540. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17541. import { Material } from "babylonjs/Materials/material";
  17542. import { Scene } from "babylonjs/scene";
  17543. import { Camera } from "babylonjs/Cameras/camera";
  17544. /**
  17545. * Interface describing the different options available in the rendering manager
  17546. * regarding Auto Clear between groups.
  17547. */
  17548. export interface IRenderingManagerAutoClearSetup {
  17549. /**
  17550. * Defines whether or not autoclear is enable.
  17551. */
  17552. autoClear: boolean;
  17553. /**
  17554. * Defines whether or not to autoclear the depth buffer.
  17555. */
  17556. depth: boolean;
  17557. /**
  17558. * Defines whether or not to autoclear the stencil buffer.
  17559. */
  17560. stencil: boolean;
  17561. }
  17562. /**
  17563. * This class is used by the onRenderingGroupObservable
  17564. */
  17565. export class RenderingGroupInfo {
  17566. /**
  17567. * The Scene that being rendered
  17568. */
  17569. scene: Scene;
  17570. /**
  17571. * The camera currently used for the rendering pass
  17572. */
  17573. camera: Nullable<Camera>;
  17574. /**
  17575. * The ID of the renderingGroup being processed
  17576. */
  17577. renderingGroupId: number;
  17578. }
  17579. /**
  17580. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17581. * It is enable to manage the different groups as well as the different necessary sort functions.
  17582. * This should not be used directly aside of the few static configurations
  17583. */
  17584. export class RenderingManager {
  17585. /**
  17586. * The max id used for rendering groups (not included)
  17587. */
  17588. static MAX_RENDERINGGROUPS: number;
  17589. /**
  17590. * The min id used for rendering groups (included)
  17591. */
  17592. static MIN_RENDERINGGROUPS: number;
  17593. /**
  17594. * Used to globally prevent autoclearing scenes.
  17595. */
  17596. static AUTOCLEAR: boolean;
  17597. /**
  17598. * @hidden
  17599. */
  17600. _useSceneAutoClearSetup: boolean;
  17601. private _scene;
  17602. private _renderingGroups;
  17603. private _depthStencilBufferAlreadyCleaned;
  17604. private _autoClearDepthStencil;
  17605. private _customOpaqueSortCompareFn;
  17606. private _customAlphaTestSortCompareFn;
  17607. private _customTransparentSortCompareFn;
  17608. private _renderingGroupInfo;
  17609. /**
  17610. * Instantiates a new rendering group for a particular scene
  17611. * @param scene Defines the scene the groups belongs to
  17612. */
  17613. constructor(scene: Scene);
  17614. private _clearDepthStencilBuffer;
  17615. /**
  17616. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17617. * @hidden
  17618. */
  17619. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17620. /**
  17621. * Resets the different information of the group to prepare a new frame
  17622. * @hidden
  17623. */
  17624. reset(): void;
  17625. /**
  17626. * Dispose and release the group and its associated resources.
  17627. * @hidden
  17628. */
  17629. dispose(): void;
  17630. /**
  17631. * Clear the info related to rendering groups preventing retention points during dispose.
  17632. */
  17633. freeRenderingGroups(): void;
  17634. private _prepareRenderingGroup;
  17635. /**
  17636. * Add a sprite manager to the rendering manager in order to render it this frame.
  17637. * @param spriteManager Define the sprite manager to render
  17638. */
  17639. dispatchSprites(spriteManager: ISpriteManager): void;
  17640. /**
  17641. * Add a particle system to the rendering manager in order to render it this frame.
  17642. * @param particleSystem Define the particle system to render
  17643. */
  17644. dispatchParticles(particleSystem: IParticleSystem): void;
  17645. /**
  17646. * Add a submesh to the manager in order to render it this frame
  17647. * @param subMesh The submesh to dispatch
  17648. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17649. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17650. */
  17651. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17652. /**
  17653. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17654. * This allowed control for front to back rendering or reversly depending of the special needs.
  17655. *
  17656. * @param renderingGroupId The rendering group id corresponding to its index
  17657. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17658. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17659. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17660. */
  17661. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  17662. /**
  17663. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17664. *
  17665. * @param renderingGroupId The rendering group id corresponding to its index
  17666. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17667. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17668. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17669. */
  17670. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17671. /**
  17672. * Gets the current auto clear configuration for one rendering group of the rendering
  17673. * manager.
  17674. * @param index the rendering group index to get the information for
  17675. * @returns The auto clear setup for the requested rendering group
  17676. */
  17677. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17678. }
  17679. }
  17680. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17681. import { SmartArray } from "babylonjs/Misc/smartArray";
  17682. import { Nullable } from "babylonjs/types";
  17683. import { Scene } from "babylonjs/scene";
  17684. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17685. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17687. import { Mesh } from "babylonjs/Meshes/mesh";
  17688. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17689. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17690. import { Effect } from "babylonjs/Materials/effect";
  17691. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17692. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17693. import "babylonjs/Shaders/shadowMap.fragment";
  17694. import "babylonjs/Shaders/shadowMap.vertex";
  17695. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17696. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17697. import { Observable } from "babylonjs/Misc/observable";
  17698. /**
  17699. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17700. */
  17701. export interface ICustomShaderOptions {
  17702. /**
  17703. * Gets or sets the custom shader name to use
  17704. */
  17705. shaderName: string;
  17706. /**
  17707. * The list of attribute names used in the shader
  17708. */
  17709. attributes?: string[];
  17710. /**
  17711. * The list of unifrom names used in the shader
  17712. */
  17713. uniforms?: string[];
  17714. /**
  17715. * The list of sampler names used in the shader
  17716. */
  17717. samplers?: string[];
  17718. /**
  17719. * The list of defines used in the shader
  17720. */
  17721. defines?: string[];
  17722. }
  17723. /**
  17724. * Interface to implement to create a shadow generator compatible with BJS.
  17725. */
  17726. export interface IShadowGenerator {
  17727. /**
  17728. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17729. * @returns The render target texture if present otherwise, null
  17730. */
  17731. getShadowMap(): Nullable<RenderTargetTexture>;
  17732. /**
  17733. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17734. * @param subMesh The submesh we want to render in the shadow map
  17735. * @param useInstances Defines wether will draw in the map using instances
  17736. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17737. * @returns true if ready otherwise, false
  17738. */
  17739. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17740. /**
  17741. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17742. * @param defines Defines of the material we want to update
  17743. * @param lightIndex Index of the light in the enabled light list of the material
  17744. */
  17745. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17746. /**
  17747. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17748. * defined in the generator but impacting the effect).
  17749. * It implies the unifroms available on the materials are the standard BJS ones.
  17750. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17751. * @param effect The effect we are binfing the information for
  17752. */
  17753. bindShadowLight(lightIndex: string, effect: Effect): void;
  17754. /**
  17755. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17756. * (eq to shadow prjection matrix * light transform matrix)
  17757. * @returns The transform matrix used to create the shadow map
  17758. */
  17759. getTransformMatrix(): Matrix;
  17760. /**
  17761. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17762. * Cube and 2D textures for instance.
  17763. */
  17764. recreateShadowMap(): void;
  17765. /**
  17766. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17767. * @param onCompiled Callback triggered at the and of the effects compilation
  17768. * @param options Sets of optional options forcing the compilation with different modes
  17769. */
  17770. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17771. useInstances: boolean;
  17772. }>): void;
  17773. /**
  17774. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17775. * @param options Sets of optional options forcing the compilation with different modes
  17776. * @returns A promise that resolves when the compilation completes
  17777. */
  17778. forceCompilationAsync(options?: Partial<{
  17779. useInstances: boolean;
  17780. }>): Promise<void>;
  17781. /**
  17782. * Serializes the shadow generator setup to a json object.
  17783. * @returns The serialized JSON object
  17784. */
  17785. serialize(): any;
  17786. /**
  17787. * Disposes the Shadow map and related Textures and effects.
  17788. */
  17789. dispose(): void;
  17790. }
  17791. /**
  17792. * Default implementation IShadowGenerator.
  17793. * This is the main object responsible of generating shadows in the framework.
  17794. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17795. */
  17796. export class ShadowGenerator implements IShadowGenerator {
  17797. /**
  17798. * Name of the shadow generator class
  17799. */
  17800. static CLASSNAME: string;
  17801. /**
  17802. * Shadow generator mode None: no filtering applied.
  17803. */
  17804. static readonly FILTER_NONE: number;
  17805. /**
  17806. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17807. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17808. */
  17809. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17810. /**
  17811. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17812. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17813. */
  17814. static readonly FILTER_POISSONSAMPLING: number;
  17815. /**
  17816. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17817. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17818. */
  17819. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17820. /**
  17821. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17822. * edge artifacts on steep falloff.
  17823. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17824. */
  17825. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17826. /**
  17827. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17828. * edge artifacts on steep falloff.
  17829. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17830. */
  17831. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17832. /**
  17833. * Shadow generator mode PCF: Percentage Closer Filtering
  17834. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17835. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17836. */
  17837. static readonly FILTER_PCF: number;
  17838. /**
  17839. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17840. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17841. * Contact Hardening
  17842. */
  17843. static readonly FILTER_PCSS: number;
  17844. /**
  17845. * Reserved for PCF and PCSS
  17846. * Highest Quality.
  17847. *
  17848. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17849. *
  17850. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17851. */
  17852. static readonly QUALITY_HIGH: number;
  17853. /**
  17854. * Reserved for PCF and PCSS
  17855. * Good tradeoff for quality/perf cross devices
  17856. *
  17857. * Execute PCF on a 3*3 kernel.
  17858. *
  17859. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17860. */
  17861. static readonly QUALITY_MEDIUM: number;
  17862. /**
  17863. * Reserved for PCF and PCSS
  17864. * The lowest quality but the fastest.
  17865. *
  17866. * Execute PCF on a 1*1 kernel.
  17867. *
  17868. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17869. */
  17870. static readonly QUALITY_LOW: number;
  17871. /** Gets or sets the custom shader name to use */
  17872. customShaderOptions: ICustomShaderOptions;
  17873. /**
  17874. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17875. */
  17876. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17877. /**
  17878. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17879. */
  17880. onAfterShadowMapRenderObservable: Observable<Effect>;
  17881. /**
  17882. * Observable triggered before a mesh is rendered in the shadow map.
  17883. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17884. */
  17885. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17886. /**
  17887. * Observable triggered after a mesh is rendered in the shadow map.
  17888. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17889. */
  17890. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17891. protected _bias: number;
  17892. /**
  17893. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17894. */
  17895. get bias(): number;
  17896. /**
  17897. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17898. */
  17899. set bias(bias: number);
  17900. protected _normalBias: number;
  17901. /**
  17902. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17903. */
  17904. get normalBias(): number;
  17905. /**
  17906. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17907. */
  17908. set normalBias(normalBias: number);
  17909. protected _blurBoxOffset: number;
  17910. /**
  17911. * Gets the blur box offset: offset applied during the blur pass.
  17912. * Only useful if useKernelBlur = false
  17913. */
  17914. get blurBoxOffset(): number;
  17915. /**
  17916. * Sets the blur box offset: offset applied during the blur pass.
  17917. * Only useful if useKernelBlur = false
  17918. */
  17919. set blurBoxOffset(value: number);
  17920. protected _blurScale: number;
  17921. /**
  17922. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17923. * 2 means half of the size.
  17924. */
  17925. get blurScale(): number;
  17926. /**
  17927. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17928. * 2 means half of the size.
  17929. */
  17930. set blurScale(value: number);
  17931. protected _blurKernel: number;
  17932. /**
  17933. * Gets the blur kernel: kernel size of the blur pass.
  17934. * Only useful if useKernelBlur = true
  17935. */
  17936. get blurKernel(): number;
  17937. /**
  17938. * Sets the blur kernel: kernel size of the blur pass.
  17939. * Only useful if useKernelBlur = true
  17940. */
  17941. set blurKernel(value: number);
  17942. protected _useKernelBlur: boolean;
  17943. /**
  17944. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17945. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17946. */
  17947. get useKernelBlur(): boolean;
  17948. /**
  17949. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17950. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17951. */
  17952. set useKernelBlur(value: boolean);
  17953. protected _depthScale: number;
  17954. /**
  17955. * Gets the depth scale used in ESM mode.
  17956. */
  17957. get depthScale(): number;
  17958. /**
  17959. * Sets the depth scale used in ESM mode.
  17960. * This can override the scale stored on the light.
  17961. */
  17962. set depthScale(value: number);
  17963. protected _validateFilter(filter: number): number;
  17964. protected _filter: number;
  17965. /**
  17966. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17967. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17968. */
  17969. get filter(): number;
  17970. /**
  17971. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17972. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17973. */
  17974. set filter(value: number);
  17975. /**
  17976. * Gets if the current filter is set to Poisson Sampling.
  17977. */
  17978. get usePoissonSampling(): boolean;
  17979. /**
  17980. * Sets the current filter to Poisson Sampling.
  17981. */
  17982. set usePoissonSampling(value: boolean);
  17983. /**
  17984. * Gets if the current filter is set to ESM.
  17985. */
  17986. get useExponentialShadowMap(): boolean;
  17987. /**
  17988. * Sets the current filter is to ESM.
  17989. */
  17990. set useExponentialShadowMap(value: boolean);
  17991. /**
  17992. * Gets if the current filter is set to filtered ESM.
  17993. */
  17994. get useBlurExponentialShadowMap(): boolean;
  17995. /**
  17996. * Gets if the current filter is set to filtered ESM.
  17997. */
  17998. set useBlurExponentialShadowMap(value: boolean);
  17999. /**
  18000. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18001. * exponential to prevent steep falloff artifacts).
  18002. */
  18003. get useCloseExponentialShadowMap(): boolean;
  18004. /**
  18005. * Sets the current filter to "close ESM" (using the inverse of the
  18006. * exponential to prevent steep falloff artifacts).
  18007. */
  18008. set useCloseExponentialShadowMap(value: boolean);
  18009. /**
  18010. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18011. * exponential to prevent steep falloff artifacts).
  18012. */
  18013. get useBlurCloseExponentialShadowMap(): boolean;
  18014. /**
  18015. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18016. * exponential to prevent steep falloff artifacts).
  18017. */
  18018. set useBlurCloseExponentialShadowMap(value: boolean);
  18019. /**
  18020. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18021. */
  18022. get usePercentageCloserFiltering(): boolean;
  18023. /**
  18024. * Sets the current filter to "PCF" (percentage closer filtering).
  18025. */
  18026. set usePercentageCloserFiltering(value: boolean);
  18027. protected _filteringQuality: number;
  18028. /**
  18029. * Gets the PCF or PCSS Quality.
  18030. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18031. */
  18032. get filteringQuality(): number;
  18033. /**
  18034. * Sets the PCF or PCSS Quality.
  18035. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18036. */
  18037. set filteringQuality(filteringQuality: number);
  18038. /**
  18039. * Gets if the current filter is set to "PCSS" (contact hardening).
  18040. */
  18041. get useContactHardeningShadow(): boolean;
  18042. /**
  18043. * Sets the current filter to "PCSS" (contact hardening).
  18044. */
  18045. set useContactHardeningShadow(value: boolean);
  18046. protected _contactHardeningLightSizeUVRatio: number;
  18047. /**
  18048. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18049. * Using a ratio helps keeping shape stability independently of the map size.
  18050. *
  18051. * It does not account for the light projection as it was having too much
  18052. * instability during the light setup or during light position changes.
  18053. *
  18054. * Only valid if useContactHardeningShadow is true.
  18055. */
  18056. get contactHardeningLightSizeUVRatio(): number;
  18057. /**
  18058. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18059. * Using a ratio helps keeping shape stability independently of the map size.
  18060. *
  18061. * It does not account for the light projection as it was having too much
  18062. * instability during the light setup or during light position changes.
  18063. *
  18064. * Only valid if useContactHardeningShadow is true.
  18065. */
  18066. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18067. protected _darkness: number;
  18068. /** Gets or sets the actual darkness of a shadow */
  18069. get darkness(): number;
  18070. set darkness(value: number);
  18071. /**
  18072. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18073. * 0 means strongest and 1 would means no shadow.
  18074. * @returns the darkness.
  18075. */
  18076. getDarkness(): number;
  18077. /**
  18078. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18079. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18080. * @returns the shadow generator allowing fluent coding.
  18081. */
  18082. setDarkness(darkness: number): ShadowGenerator;
  18083. protected _transparencyShadow: boolean;
  18084. /** Gets or sets the ability to have transparent shadow */
  18085. get transparencyShadow(): boolean;
  18086. set transparencyShadow(value: boolean);
  18087. /**
  18088. * Sets the ability to have transparent shadow (boolean).
  18089. * @param transparent True if transparent else False
  18090. * @returns the shadow generator allowing fluent coding
  18091. */
  18092. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18093. /**
  18094. * Enables or disables shadows with varying strength based on the transparency
  18095. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18096. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18097. * mesh.visibility * alphaTexture.a
  18098. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18099. */
  18100. enableSoftTransparentShadow: boolean;
  18101. protected _shadowMap: Nullable<RenderTargetTexture>;
  18102. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18103. /**
  18104. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18105. * @returns The render target texture if present otherwise, null
  18106. */
  18107. getShadowMap(): Nullable<RenderTargetTexture>;
  18108. /**
  18109. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18110. * @returns The render target texture if the shadow map is present otherwise, null
  18111. */
  18112. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18113. /**
  18114. * Gets the class name of that object
  18115. * @returns "ShadowGenerator"
  18116. */
  18117. getClassName(): string;
  18118. /**
  18119. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18120. * @param mesh Mesh to add
  18121. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18122. * @returns the Shadow Generator itself
  18123. */
  18124. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18125. /**
  18126. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18127. * @param mesh Mesh to remove
  18128. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18129. * @returns the Shadow Generator itself
  18130. */
  18131. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18132. /**
  18133. * Controls the extent to which the shadows fade out at the edge of the frustum
  18134. */
  18135. frustumEdgeFalloff: number;
  18136. protected _light: IShadowLight;
  18137. /**
  18138. * Returns the associated light object.
  18139. * @returns the light generating the shadow
  18140. */
  18141. getLight(): IShadowLight;
  18142. /**
  18143. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18144. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18145. * It might on the other hand introduce peter panning.
  18146. */
  18147. forceBackFacesOnly: boolean;
  18148. protected _scene: Scene;
  18149. protected _lightDirection: Vector3;
  18150. protected _effect: Effect;
  18151. protected _viewMatrix: Matrix;
  18152. protected _projectionMatrix: Matrix;
  18153. protected _transformMatrix: Matrix;
  18154. protected _cachedPosition: Vector3;
  18155. protected _cachedDirection: Vector3;
  18156. protected _cachedDefines: string;
  18157. protected _currentRenderID: number;
  18158. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18159. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18160. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18161. protected _blurPostProcesses: PostProcess[];
  18162. protected _mapSize: number;
  18163. protected _currentFaceIndex: number;
  18164. protected _currentFaceIndexCache: number;
  18165. protected _textureType: number;
  18166. protected _defaultTextureMatrix: Matrix;
  18167. protected _storedUniqueId: Nullable<number>;
  18168. /** @hidden */
  18169. static _SceneComponentInitialization: (scene: Scene) => void;
  18170. /**
  18171. * Creates a ShadowGenerator object.
  18172. * A ShadowGenerator is the required tool to use the shadows.
  18173. * Each light casting shadows needs to use its own ShadowGenerator.
  18174. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18175. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18176. * @param light The light object generating the shadows.
  18177. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  18178. */
  18179. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18180. protected _initializeGenerator(): void;
  18181. protected _createTargetRenderTexture(): void;
  18182. protected _initializeShadowMap(): void;
  18183. protected _initializeBlurRTTAndPostProcesses(): void;
  18184. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18185. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18186. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18187. protected _applyFilterValues(): void;
  18188. /**
  18189. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18190. * @param onCompiled Callback triggered at the and of the effects compilation
  18191. * @param options Sets of optional options forcing the compilation with different modes
  18192. */
  18193. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18194. useInstances: boolean;
  18195. }>): void;
  18196. /**
  18197. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18198. * @param options Sets of optional options forcing the compilation with different modes
  18199. * @returns A promise that resolves when the compilation completes
  18200. */
  18201. forceCompilationAsync(options?: Partial<{
  18202. useInstances: boolean;
  18203. }>): Promise<void>;
  18204. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18205. private _prepareShadowDefines;
  18206. /**
  18207. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18208. * @param subMesh The submesh we want to render in the shadow map
  18209. * @param useInstances Defines wether will draw in the map using instances
  18210. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18211. * @returns true if ready otherwise, false
  18212. */
  18213. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18214. /**
  18215. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18216. * @param defines Defines of the material we want to update
  18217. * @param lightIndex Index of the light in the enabled light list of the material
  18218. */
  18219. prepareDefines(defines: any, lightIndex: number): void;
  18220. /**
  18221. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18222. * defined in the generator but impacting the effect).
  18223. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18224. * @param effect The effect we are binfing the information for
  18225. */
  18226. bindShadowLight(lightIndex: string, effect: Effect): void;
  18227. /**
  18228. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18229. * (eq to shadow prjection matrix * light transform matrix)
  18230. * @returns The transform matrix used to create the shadow map
  18231. */
  18232. getTransformMatrix(): Matrix;
  18233. /**
  18234. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18235. * Cube and 2D textures for instance.
  18236. */
  18237. recreateShadowMap(): void;
  18238. protected _disposeBlurPostProcesses(): void;
  18239. protected _disposeRTTandPostProcesses(): void;
  18240. /**
  18241. * Disposes the ShadowGenerator.
  18242. * Returns nothing.
  18243. */
  18244. dispose(): void;
  18245. /**
  18246. * Serializes the shadow generator setup to a json object.
  18247. * @returns The serialized JSON object
  18248. */
  18249. serialize(): any;
  18250. /**
  18251. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18252. * @param parsedShadowGenerator The JSON object to parse
  18253. * @param scene The scene to create the shadow map for
  18254. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18255. * @returns The parsed shadow generator
  18256. */
  18257. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18258. }
  18259. }
  18260. declare module "babylonjs/Lights/light" {
  18261. import { Nullable } from "babylonjs/types";
  18262. import { Scene } from "babylonjs/scene";
  18263. import { Vector3 } from "babylonjs/Maths/math.vector";
  18264. import { Color3 } from "babylonjs/Maths/math.color";
  18265. import { Node } from "babylonjs/node";
  18266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18267. import { Effect } from "babylonjs/Materials/effect";
  18268. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18269. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18270. /**
  18271. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18272. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18273. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  18274. */
  18275. export abstract class Light extends Node {
  18276. /**
  18277. * Falloff Default: light is falling off following the material specification:
  18278. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18279. */
  18280. static readonly FALLOFF_DEFAULT: number;
  18281. /**
  18282. * Falloff Physical: light is falling off following the inverse squared distance law.
  18283. */
  18284. static readonly FALLOFF_PHYSICAL: number;
  18285. /**
  18286. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18287. * to enhance interoperability with other engines.
  18288. */
  18289. static readonly FALLOFF_GLTF: number;
  18290. /**
  18291. * Falloff Standard: light is falling off like in the standard material
  18292. * to enhance interoperability with other materials.
  18293. */
  18294. static readonly FALLOFF_STANDARD: number;
  18295. /**
  18296. * If every light affecting the material is in this lightmapMode,
  18297. * material.lightmapTexture adds or multiplies
  18298. * (depends on material.useLightmapAsShadowmap)
  18299. * after every other light calculations.
  18300. */
  18301. static readonly LIGHTMAP_DEFAULT: number;
  18302. /**
  18303. * material.lightmapTexture as only diffuse lighting from this light
  18304. * adds only specular lighting from this light
  18305. * adds dynamic shadows
  18306. */
  18307. static readonly LIGHTMAP_SPECULAR: number;
  18308. /**
  18309. * material.lightmapTexture as only lighting
  18310. * no light calculation from this light
  18311. * only adds dynamic shadows from this light
  18312. */
  18313. static readonly LIGHTMAP_SHADOWSONLY: number;
  18314. /**
  18315. * Each light type uses the default quantity according to its type:
  18316. * point/spot lights use luminous intensity
  18317. * directional lights use illuminance
  18318. */
  18319. static readonly INTENSITYMODE_AUTOMATIC: number;
  18320. /**
  18321. * lumen (lm)
  18322. */
  18323. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18324. /**
  18325. * candela (lm/sr)
  18326. */
  18327. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18328. /**
  18329. * lux (lm/m^2)
  18330. */
  18331. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18332. /**
  18333. * nit (cd/m^2)
  18334. */
  18335. static readonly INTENSITYMODE_LUMINANCE: number;
  18336. /**
  18337. * Light type const id of the point light.
  18338. */
  18339. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18340. /**
  18341. * Light type const id of the directional light.
  18342. */
  18343. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18344. /**
  18345. * Light type const id of the spot light.
  18346. */
  18347. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18348. /**
  18349. * Light type const id of the hemispheric light.
  18350. */
  18351. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18352. /**
  18353. * Diffuse gives the basic color to an object.
  18354. */
  18355. diffuse: Color3;
  18356. /**
  18357. * Specular produces a highlight color on an object.
  18358. * Note: This is note affecting PBR materials.
  18359. */
  18360. specular: Color3;
  18361. /**
  18362. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18363. * falling off base on range or angle.
  18364. * This can be set to any values in Light.FALLOFF_x.
  18365. *
  18366. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18367. * other types of materials.
  18368. */
  18369. falloffType: number;
  18370. /**
  18371. * Strength of the light.
  18372. * Note: By default it is define in the framework own unit.
  18373. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18374. */
  18375. intensity: number;
  18376. private _range;
  18377. protected _inverseSquaredRange: number;
  18378. /**
  18379. * Defines how far from the source the light is impacting in scene units.
  18380. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18381. */
  18382. get range(): number;
  18383. /**
  18384. * Defines how far from the source the light is impacting in scene units.
  18385. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18386. */
  18387. set range(value: number);
  18388. /**
  18389. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18390. * of light.
  18391. */
  18392. private _photometricScale;
  18393. private _intensityMode;
  18394. /**
  18395. * Gets the photometric scale used to interpret the intensity.
  18396. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18397. */
  18398. get intensityMode(): number;
  18399. /**
  18400. * Sets the photometric scale used to interpret the intensity.
  18401. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18402. */
  18403. set intensityMode(value: number);
  18404. private _radius;
  18405. /**
  18406. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18407. */
  18408. get radius(): number;
  18409. /**
  18410. * sets the light radius used by PBR Materials to simulate soft area lights.
  18411. */
  18412. set radius(value: number);
  18413. private _renderPriority;
  18414. /**
  18415. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18416. * exceeding the number allowed of the materials.
  18417. */
  18418. renderPriority: number;
  18419. private _shadowEnabled;
  18420. /**
  18421. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18422. * the current shadow generator.
  18423. */
  18424. get shadowEnabled(): boolean;
  18425. /**
  18426. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18427. * the current shadow generator.
  18428. */
  18429. set shadowEnabled(value: boolean);
  18430. private _includedOnlyMeshes;
  18431. /**
  18432. * Gets the only meshes impacted by this light.
  18433. */
  18434. get includedOnlyMeshes(): AbstractMesh[];
  18435. /**
  18436. * Sets the only meshes impacted by this light.
  18437. */
  18438. set includedOnlyMeshes(value: AbstractMesh[]);
  18439. private _excludedMeshes;
  18440. /**
  18441. * Gets the meshes not impacted by this light.
  18442. */
  18443. get excludedMeshes(): AbstractMesh[];
  18444. /**
  18445. * Sets the meshes not impacted by this light.
  18446. */
  18447. set excludedMeshes(value: AbstractMesh[]);
  18448. private _excludeWithLayerMask;
  18449. /**
  18450. * Gets the layer id use to find what meshes are not impacted by the light.
  18451. * Inactive if 0
  18452. */
  18453. get excludeWithLayerMask(): number;
  18454. /**
  18455. * Sets the layer id use to find what meshes are not impacted by the light.
  18456. * Inactive if 0
  18457. */
  18458. set excludeWithLayerMask(value: number);
  18459. private _includeOnlyWithLayerMask;
  18460. /**
  18461. * Gets the layer id use to find what meshes are impacted by the light.
  18462. * Inactive if 0
  18463. */
  18464. get includeOnlyWithLayerMask(): number;
  18465. /**
  18466. * Sets the layer id use to find what meshes are impacted by the light.
  18467. * Inactive if 0
  18468. */
  18469. set includeOnlyWithLayerMask(value: number);
  18470. private _lightmapMode;
  18471. /**
  18472. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18473. */
  18474. get lightmapMode(): number;
  18475. /**
  18476. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18477. */
  18478. set lightmapMode(value: number);
  18479. /**
  18480. * Shadow generator associted to the light.
  18481. * @hidden Internal use only.
  18482. */
  18483. _shadowGenerator: Nullable<IShadowGenerator>;
  18484. /**
  18485. * @hidden Internal use only.
  18486. */
  18487. _excludedMeshesIds: string[];
  18488. /**
  18489. * @hidden Internal use only.
  18490. */
  18491. _includedOnlyMeshesIds: string[];
  18492. /**
  18493. * The current light unifom buffer.
  18494. * @hidden Internal use only.
  18495. */
  18496. _uniformBuffer: UniformBuffer;
  18497. /** @hidden */
  18498. _renderId: number;
  18499. /**
  18500. * Creates a Light object in the scene.
  18501. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18502. * @param name The firendly name of the light
  18503. * @param scene The scene the light belongs too
  18504. */
  18505. constructor(name: string, scene: Scene);
  18506. protected abstract _buildUniformLayout(): void;
  18507. /**
  18508. * Sets the passed Effect "effect" with the Light information.
  18509. * @param effect The effect to update
  18510. * @param lightIndex The index of the light in the effect to update
  18511. * @returns The light
  18512. */
  18513. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18514. /**
  18515. * Sets the passed Effect "effect" with the Light textures.
  18516. * @param effect The effect to update
  18517. * @param lightIndex The index of the light in the effect to update
  18518. * @returns The light
  18519. */
  18520. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18521. /**
  18522. * Binds the lights information from the scene to the effect for the given mesh.
  18523. * @param lightIndex Light index
  18524. * @param scene The scene where the light belongs to
  18525. * @param effect The effect we are binding the data to
  18526. * @param useSpecular Defines if specular is supported
  18527. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18528. */
  18529. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18530. /**
  18531. * Sets the passed Effect "effect" with the Light information.
  18532. * @param effect The effect to update
  18533. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18534. * @returns The light
  18535. */
  18536. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18537. /**
  18538. * Returns the string "Light".
  18539. * @returns the class name
  18540. */
  18541. getClassName(): string;
  18542. /** @hidden */
  18543. readonly _isLight: boolean;
  18544. /**
  18545. * Converts the light information to a readable string for debug purpose.
  18546. * @param fullDetails Supports for multiple levels of logging within scene loading
  18547. * @returns the human readable light info
  18548. */
  18549. toString(fullDetails?: boolean): string;
  18550. /** @hidden */
  18551. protected _syncParentEnabledState(): void;
  18552. /**
  18553. * Set the enabled state of this node.
  18554. * @param value - the new enabled state
  18555. */
  18556. setEnabled(value: boolean): void;
  18557. /**
  18558. * Returns the Light associated shadow generator if any.
  18559. * @return the associated shadow generator.
  18560. */
  18561. getShadowGenerator(): Nullable<IShadowGenerator>;
  18562. /**
  18563. * Returns a Vector3, the absolute light position in the World.
  18564. * @returns the world space position of the light
  18565. */
  18566. getAbsolutePosition(): Vector3;
  18567. /**
  18568. * Specifies if the light will affect the passed mesh.
  18569. * @param mesh The mesh to test against the light
  18570. * @return true the mesh is affected otherwise, false.
  18571. */
  18572. canAffectMesh(mesh: AbstractMesh): boolean;
  18573. /**
  18574. * Sort function to order lights for rendering.
  18575. * @param a First Light object to compare to second.
  18576. * @param b Second Light object to compare first.
  18577. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18578. */
  18579. static CompareLightsPriority(a: Light, b: Light): number;
  18580. /**
  18581. * Releases resources associated with this node.
  18582. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18583. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18584. */
  18585. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18586. /**
  18587. * Returns the light type ID (integer).
  18588. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18589. */
  18590. getTypeID(): number;
  18591. /**
  18592. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18593. * @returns the scaled intensity in intensity mode unit
  18594. */
  18595. getScaledIntensity(): number;
  18596. /**
  18597. * Returns a new Light object, named "name", from the current one.
  18598. * @param name The name of the cloned light
  18599. * @param newParent The parent of this light, if it has one
  18600. * @returns the new created light
  18601. */
  18602. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18603. /**
  18604. * Serializes the current light into a Serialization object.
  18605. * @returns the serialized object.
  18606. */
  18607. serialize(): any;
  18608. /**
  18609. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18610. * This new light is named "name" and added to the passed scene.
  18611. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18612. * @param name The friendly name of the light
  18613. * @param scene The scene the new light will belong to
  18614. * @returns the constructor function
  18615. */
  18616. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18617. /**
  18618. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18619. * @param parsedLight The JSON representation of the light
  18620. * @param scene The scene to create the parsed light in
  18621. * @returns the created light after parsing
  18622. */
  18623. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18624. private _hookArrayForExcluded;
  18625. private _hookArrayForIncludedOnly;
  18626. private _resyncMeshes;
  18627. /**
  18628. * Forces the meshes to update their light related information in their rendering used effects
  18629. * @hidden Internal Use Only
  18630. */
  18631. _markMeshesAsLightDirty(): void;
  18632. /**
  18633. * Recomputes the cached photometric scale if needed.
  18634. */
  18635. private _computePhotometricScale;
  18636. /**
  18637. * Returns the Photometric Scale according to the light type and intensity mode.
  18638. */
  18639. private _getPhotometricScale;
  18640. /**
  18641. * Reorder the light in the scene according to their defined priority.
  18642. * @hidden Internal Use Only
  18643. */
  18644. _reorderLightsInScene(): void;
  18645. /**
  18646. * Prepares the list of defines specific to the light type.
  18647. * @param defines the list of defines
  18648. * @param lightIndex defines the index of the light for the effect
  18649. */
  18650. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18651. }
  18652. }
  18653. declare module "babylonjs/Cameras/targetCamera" {
  18654. import { Nullable } from "babylonjs/types";
  18655. import { Camera } from "babylonjs/Cameras/camera";
  18656. import { Scene } from "babylonjs/scene";
  18657. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18658. /**
  18659. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18660. * This is the base of the follow, arc rotate cameras and Free camera
  18661. * @see http://doc.babylonjs.com/features/cameras
  18662. */
  18663. export class TargetCamera extends Camera {
  18664. private static _RigCamTransformMatrix;
  18665. private static _TargetTransformMatrix;
  18666. private static _TargetFocalPoint;
  18667. /**
  18668. * Define the current direction the camera is moving to
  18669. */
  18670. cameraDirection: Vector3;
  18671. /**
  18672. * Define the current rotation the camera is rotating to
  18673. */
  18674. cameraRotation: Vector2;
  18675. /**
  18676. * When set, the up vector of the camera will be updated by the rotation of the camera
  18677. */
  18678. updateUpVectorFromRotation: boolean;
  18679. private _tmpQuaternion;
  18680. /**
  18681. * Define the current rotation of the camera
  18682. */
  18683. rotation: Vector3;
  18684. /**
  18685. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18686. */
  18687. rotationQuaternion: Quaternion;
  18688. /**
  18689. * Define the current speed of the camera
  18690. */
  18691. speed: number;
  18692. /**
  18693. * Add constraint to the camera to prevent it to move freely in all directions and
  18694. * around all axis.
  18695. */
  18696. noRotationConstraint: boolean;
  18697. /**
  18698. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18699. * panning
  18700. */
  18701. invertRotation: boolean;
  18702. /**
  18703. * Speed multiplier for inverse camera panning
  18704. */
  18705. inverseRotationSpeed: number;
  18706. /**
  18707. * Define the current target of the camera as an object or a position.
  18708. */
  18709. lockedTarget: any;
  18710. /** @hidden */
  18711. _currentTarget: Vector3;
  18712. /** @hidden */
  18713. _initialFocalDistance: number;
  18714. /** @hidden */
  18715. _viewMatrix: Matrix;
  18716. /** @hidden */
  18717. _camMatrix: Matrix;
  18718. /** @hidden */
  18719. _cameraTransformMatrix: Matrix;
  18720. /** @hidden */
  18721. _cameraRotationMatrix: Matrix;
  18722. /** @hidden */
  18723. _referencePoint: Vector3;
  18724. /** @hidden */
  18725. _transformedReferencePoint: Vector3;
  18726. protected _globalCurrentTarget: Vector3;
  18727. protected _globalCurrentUpVector: Vector3;
  18728. /** @hidden */
  18729. _reset: () => void;
  18730. private _defaultUp;
  18731. /**
  18732. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18733. * This is the base of the follow, arc rotate cameras and Free camera
  18734. * @see http://doc.babylonjs.com/features/cameras
  18735. * @param name Defines the name of the camera in the scene
  18736. * @param position Defines the start position of the camera in the scene
  18737. * @param scene Defines the scene the camera belongs to
  18738. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18739. */
  18740. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18741. /**
  18742. * Gets the position in front of the camera at a given distance.
  18743. * @param distance The distance from the camera we want the position to be
  18744. * @returns the position
  18745. */
  18746. getFrontPosition(distance: number): Vector3;
  18747. /** @hidden */
  18748. _getLockedTargetPosition(): Nullable<Vector3>;
  18749. private _storedPosition;
  18750. private _storedRotation;
  18751. private _storedRotationQuaternion;
  18752. /**
  18753. * Store current camera state of the camera (fov, position, rotation, etc..)
  18754. * @returns the camera
  18755. */
  18756. storeState(): Camera;
  18757. /**
  18758. * Restored camera state. You must call storeState() first
  18759. * @returns whether it was successful or not
  18760. * @hidden
  18761. */
  18762. _restoreStateValues(): boolean;
  18763. /** @hidden */
  18764. _initCache(): void;
  18765. /** @hidden */
  18766. _updateCache(ignoreParentClass?: boolean): void;
  18767. /** @hidden */
  18768. _isSynchronizedViewMatrix(): boolean;
  18769. /** @hidden */
  18770. _computeLocalCameraSpeed(): number;
  18771. /**
  18772. * Defines the target the camera should look at.
  18773. * @param target Defines the new target as a Vector or a mesh
  18774. */
  18775. setTarget(target: Vector3): void;
  18776. /**
  18777. * Return the current target position of the camera. This value is expressed in local space.
  18778. * @returns the target position
  18779. */
  18780. getTarget(): Vector3;
  18781. /** @hidden */
  18782. _decideIfNeedsToMove(): boolean;
  18783. /** @hidden */
  18784. _updatePosition(): void;
  18785. /** @hidden */
  18786. _checkInputs(): void;
  18787. protected _updateCameraRotationMatrix(): void;
  18788. /**
  18789. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  18790. * @returns the current camera
  18791. */
  18792. private _rotateUpVectorWithCameraRotationMatrix;
  18793. private _cachedRotationZ;
  18794. private _cachedQuaternionRotationZ;
  18795. /** @hidden */
  18796. _getViewMatrix(): Matrix;
  18797. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18798. /**
  18799. * @hidden
  18800. */
  18801. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18802. /**
  18803. * @hidden
  18804. */
  18805. _updateRigCameras(): void;
  18806. private _getRigCamPositionAndTarget;
  18807. /**
  18808. * Gets the current object class name.
  18809. * @return the class name
  18810. */
  18811. getClassName(): string;
  18812. }
  18813. }
  18814. declare module "babylonjs/Events/keyboardEvents" {
  18815. /**
  18816. * Gather the list of keyboard event types as constants.
  18817. */
  18818. export class KeyboardEventTypes {
  18819. /**
  18820. * The keydown event is fired when a key becomes active (pressed).
  18821. */
  18822. static readonly KEYDOWN: number;
  18823. /**
  18824. * The keyup event is fired when a key has been released.
  18825. */
  18826. static readonly KEYUP: number;
  18827. }
  18828. /**
  18829. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18830. */
  18831. export class KeyboardInfo {
  18832. /**
  18833. * Defines the type of event (KeyboardEventTypes)
  18834. */
  18835. type: number;
  18836. /**
  18837. * Defines the related dom event
  18838. */
  18839. event: KeyboardEvent;
  18840. /**
  18841. * Instantiates a new keyboard info.
  18842. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18843. * @param type Defines the type of event (KeyboardEventTypes)
  18844. * @param event Defines the related dom event
  18845. */
  18846. constructor(
  18847. /**
  18848. * Defines the type of event (KeyboardEventTypes)
  18849. */
  18850. type: number,
  18851. /**
  18852. * Defines the related dom event
  18853. */
  18854. event: KeyboardEvent);
  18855. }
  18856. /**
  18857. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18858. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18859. */
  18860. export class KeyboardInfoPre extends KeyboardInfo {
  18861. /**
  18862. * Defines the type of event (KeyboardEventTypes)
  18863. */
  18864. type: number;
  18865. /**
  18866. * Defines the related dom event
  18867. */
  18868. event: KeyboardEvent;
  18869. /**
  18870. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18871. */
  18872. skipOnPointerObservable: boolean;
  18873. /**
  18874. * Instantiates a new keyboard pre info.
  18875. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18876. * @param type Defines the type of event (KeyboardEventTypes)
  18877. * @param event Defines the related dom event
  18878. */
  18879. constructor(
  18880. /**
  18881. * Defines the type of event (KeyboardEventTypes)
  18882. */
  18883. type: number,
  18884. /**
  18885. * Defines the related dom event
  18886. */
  18887. event: KeyboardEvent);
  18888. }
  18889. }
  18890. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  18891. import { Nullable } from "babylonjs/types";
  18892. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18893. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18894. /**
  18895. * Manage the keyboard inputs to control the movement of a free camera.
  18896. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18897. */
  18898. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18899. /**
  18900. * Defines the camera the input is attached to.
  18901. */
  18902. camera: FreeCamera;
  18903. /**
  18904. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18905. */
  18906. keysUp: number[];
  18907. /**
  18908. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18909. */
  18910. keysUpward: number[];
  18911. /**
  18912. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18913. */
  18914. keysDown: number[];
  18915. /**
  18916. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18917. */
  18918. keysDownward: number[];
  18919. /**
  18920. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18921. */
  18922. keysLeft: number[];
  18923. /**
  18924. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18925. */
  18926. keysRight: number[];
  18927. private _keys;
  18928. private _onCanvasBlurObserver;
  18929. private _onKeyboardObserver;
  18930. private _engine;
  18931. private _scene;
  18932. /**
  18933. * Attach the input controls to a specific dom element to get the input from.
  18934. * @param element Defines the element the controls should be listened from
  18935. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18936. */
  18937. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18938. /**
  18939. * Detach the current controls from the specified dom element.
  18940. * @param element Defines the element to stop listening the inputs from
  18941. */
  18942. detachControl(element: Nullable<HTMLElement>): void;
  18943. /**
  18944. * Update the current camera state depending on the inputs that have been used this frame.
  18945. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18946. */
  18947. checkInputs(): void;
  18948. /**
  18949. * Gets the class name of the current intput.
  18950. * @returns the class name
  18951. */
  18952. getClassName(): string;
  18953. /** @hidden */
  18954. _onLostFocus(): void;
  18955. /**
  18956. * Get the friendly name associated with the input class.
  18957. * @returns the input friendly name
  18958. */
  18959. getSimpleName(): string;
  18960. }
  18961. }
  18962. declare module "babylonjs/Events/pointerEvents" {
  18963. import { Nullable } from "babylonjs/types";
  18964. import { Vector2 } from "babylonjs/Maths/math.vector";
  18965. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18966. import { Ray } from "babylonjs/Culling/ray";
  18967. /**
  18968. * Gather the list of pointer event types as constants.
  18969. */
  18970. export class PointerEventTypes {
  18971. /**
  18972. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  18973. */
  18974. static readonly POINTERDOWN: number;
  18975. /**
  18976. * The pointerup event is fired when a pointer is no longer active.
  18977. */
  18978. static readonly POINTERUP: number;
  18979. /**
  18980. * The pointermove event is fired when a pointer changes coordinates.
  18981. */
  18982. static readonly POINTERMOVE: number;
  18983. /**
  18984. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18985. */
  18986. static readonly POINTERWHEEL: number;
  18987. /**
  18988. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18989. */
  18990. static readonly POINTERPICK: number;
  18991. /**
  18992. * The pointertap event is fired when a the object has been touched and released without drag.
  18993. */
  18994. static readonly POINTERTAP: number;
  18995. /**
  18996. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18997. */
  18998. static readonly POINTERDOUBLETAP: number;
  18999. }
  19000. /**
  19001. * Base class of pointer info types.
  19002. */
  19003. export class PointerInfoBase {
  19004. /**
  19005. * Defines the type of event (PointerEventTypes)
  19006. */
  19007. type: number;
  19008. /**
  19009. * Defines the related dom event
  19010. */
  19011. event: PointerEvent | MouseWheelEvent;
  19012. /**
  19013. * Instantiates the base class of pointers info.
  19014. * @param type Defines the type of event (PointerEventTypes)
  19015. * @param event Defines the related dom event
  19016. */
  19017. constructor(
  19018. /**
  19019. * Defines the type of event (PointerEventTypes)
  19020. */
  19021. type: number,
  19022. /**
  19023. * Defines the related dom event
  19024. */
  19025. event: PointerEvent | MouseWheelEvent);
  19026. }
  19027. /**
  19028. * This class is used to store pointer related info for the onPrePointerObservable event.
  19029. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19030. */
  19031. export class PointerInfoPre extends PointerInfoBase {
  19032. /**
  19033. * Ray from a pointer if availible (eg. 6dof controller)
  19034. */
  19035. ray: Nullable<Ray>;
  19036. /**
  19037. * Defines the local position of the pointer on the canvas.
  19038. */
  19039. localPosition: Vector2;
  19040. /**
  19041. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19042. */
  19043. skipOnPointerObservable: boolean;
  19044. /**
  19045. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19046. * @param type Defines the type of event (PointerEventTypes)
  19047. * @param event Defines the related dom event
  19048. * @param localX Defines the local x coordinates of the pointer when the event occured
  19049. * @param localY Defines the local y coordinates of the pointer when the event occured
  19050. */
  19051. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19052. }
  19053. /**
  19054. * This type contains all the data related to a pointer event in Babylon.js.
  19055. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  19056. */
  19057. export class PointerInfo extends PointerInfoBase {
  19058. /**
  19059. * Defines the picking info associated to the info (if any)\
  19060. */
  19061. pickInfo: Nullable<PickingInfo>;
  19062. /**
  19063. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19064. * @param type Defines the type of event (PointerEventTypes)
  19065. * @param event Defines the related dom event
  19066. * @param pickInfo Defines the picking info associated to the info (if any)\
  19067. */
  19068. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19069. /**
  19070. * Defines the picking info associated to the info (if any)\
  19071. */
  19072. pickInfo: Nullable<PickingInfo>);
  19073. }
  19074. /**
  19075. * Data relating to a touch event on the screen.
  19076. */
  19077. export interface PointerTouch {
  19078. /**
  19079. * X coordinate of touch.
  19080. */
  19081. x: number;
  19082. /**
  19083. * Y coordinate of touch.
  19084. */
  19085. y: number;
  19086. /**
  19087. * Id of touch. Unique for each finger.
  19088. */
  19089. pointerId: number;
  19090. /**
  19091. * Event type passed from DOM.
  19092. */
  19093. type: any;
  19094. }
  19095. }
  19096. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19097. import { Observable } from "babylonjs/Misc/observable";
  19098. import { Nullable } from "babylonjs/types";
  19099. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19100. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19101. /**
  19102. * Manage the mouse inputs to control the movement of a free camera.
  19103. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19104. */
  19105. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19106. /**
  19107. * Define if touch is enabled in the mouse input
  19108. */
  19109. touchEnabled: boolean;
  19110. /**
  19111. * Defines the camera the input is attached to.
  19112. */
  19113. camera: FreeCamera;
  19114. /**
  19115. * Defines the buttons associated with the input to handle camera move.
  19116. */
  19117. buttons: number[];
  19118. /**
  19119. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19120. */
  19121. angularSensibility: number;
  19122. private _pointerInput;
  19123. private _onMouseMove;
  19124. private _observer;
  19125. private previousPosition;
  19126. /**
  19127. * Observable for when a pointer move event occurs containing the move offset
  19128. */
  19129. onPointerMovedObservable: Observable<{
  19130. offsetX: number;
  19131. offsetY: number;
  19132. }>;
  19133. /**
  19134. * @hidden
  19135. * If the camera should be rotated automatically based on pointer movement
  19136. */
  19137. _allowCameraRotation: boolean;
  19138. /**
  19139. * Manage the mouse inputs to control the movement of a free camera.
  19140. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19141. * @param touchEnabled Defines if touch is enabled or not
  19142. */
  19143. constructor(
  19144. /**
  19145. * Define if touch is enabled in the mouse input
  19146. */
  19147. touchEnabled?: boolean);
  19148. /**
  19149. * Attach the input controls to a specific dom element to get the input from.
  19150. * @param element Defines the element the controls should be listened from
  19151. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19152. */
  19153. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19154. /**
  19155. * Called on JS contextmenu event.
  19156. * Override this method to provide functionality.
  19157. */
  19158. protected onContextMenu(evt: PointerEvent): void;
  19159. /**
  19160. * Detach the current controls from the specified dom element.
  19161. * @param element Defines the element to stop listening the inputs from
  19162. */
  19163. detachControl(element: Nullable<HTMLElement>): void;
  19164. /**
  19165. * Gets the class name of the current intput.
  19166. * @returns the class name
  19167. */
  19168. getClassName(): string;
  19169. /**
  19170. * Get the friendly name associated with the input class.
  19171. * @returns the input friendly name
  19172. */
  19173. getSimpleName(): string;
  19174. }
  19175. }
  19176. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19177. import { Nullable } from "babylonjs/types";
  19178. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19179. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19180. /**
  19181. * Manage the touch inputs to control the movement of a free camera.
  19182. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19183. */
  19184. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19185. /**
  19186. * Defines the camera the input is attached to.
  19187. */
  19188. camera: FreeCamera;
  19189. /**
  19190. * Defines the touch sensibility for rotation.
  19191. * The higher the faster.
  19192. */
  19193. touchAngularSensibility: number;
  19194. /**
  19195. * Defines the touch sensibility for move.
  19196. * The higher the faster.
  19197. */
  19198. touchMoveSensibility: number;
  19199. private _offsetX;
  19200. private _offsetY;
  19201. private _pointerPressed;
  19202. private _pointerInput;
  19203. private _observer;
  19204. private _onLostFocus;
  19205. /**
  19206. * Attach the input controls to a specific dom element to get the input from.
  19207. * @param element Defines the element the controls should be listened from
  19208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19209. */
  19210. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19211. /**
  19212. * Detach the current controls from the specified dom element.
  19213. * @param element Defines the element to stop listening the inputs from
  19214. */
  19215. detachControl(element: Nullable<HTMLElement>): void;
  19216. /**
  19217. * Update the current camera state depending on the inputs that have been used this frame.
  19218. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19219. */
  19220. checkInputs(): void;
  19221. /**
  19222. * Gets the class name of the current intput.
  19223. * @returns the class name
  19224. */
  19225. getClassName(): string;
  19226. /**
  19227. * Get the friendly name associated with the input class.
  19228. * @returns the input friendly name
  19229. */
  19230. getSimpleName(): string;
  19231. }
  19232. }
  19233. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19234. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19235. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19236. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19237. import { Nullable } from "babylonjs/types";
  19238. /**
  19239. * Default Inputs manager for the FreeCamera.
  19240. * It groups all the default supported inputs for ease of use.
  19241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19242. */
  19243. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19244. /**
  19245. * @hidden
  19246. */
  19247. _mouseInput: Nullable<FreeCameraMouseInput>;
  19248. /**
  19249. * Instantiates a new FreeCameraInputsManager.
  19250. * @param camera Defines the camera the inputs belong to
  19251. */
  19252. constructor(camera: FreeCamera);
  19253. /**
  19254. * Add keyboard input support to the input manager.
  19255. * @returns the current input manager
  19256. */
  19257. addKeyboard(): FreeCameraInputsManager;
  19258. /**
  19259. * Add mouse input support to the input manager.
  19260. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19261. * @returns the current input manager
  19262. */
  19263. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19264. /**
  19265. * Removes the mouse input support from the manager
  19266. * @returns the current input manager
  19267. */
  19268. removeMouse(): FreeCameraInputsManager;
  19269. /**
  19270. * Add touch input support to the input manager.
  19271. * @returns the current input manager
  19272. */
  19273. addTouch(): FreeCameraInputsManager;
  19274. /**
  19275. * Remove all attached input methods from a camera
  19276. */
  19277. clear(): void;
  19278. }
  19279. }
  19280. declare module "babylonjs/Cameras/freeCamera" {
  19281. import { Vector3 } from "babylonjs/Maths/math.vector";
  19282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19283. import { Scene } from "babylonjs/scene";
  19284. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19285. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19286. /**
  19287. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19288. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19289. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19290. */
  19291. export class FreeCamera extends TargetCamera {
  19292. /**
  19293. * Define the collision ellipsoid of the camera.
  19294. * This is helpful to simulate a camera body like the player body around the camera
  19295. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19296. */
  19297. ellipsoid: Vector3;
  19298. /**
  19299. * Define an offset for the position of the ellipsoid around the camera.
  19300. * This can be helpful to determine the center of the body near the gravity center of the body
  19301. * instead of its head.
  19302. */
  19303. ellipsoidOffset: Vector3;
  19304. /**
  19305. * Enable or disable collisions of the camera with the rest of the scene objects.
  19306. */
  19307. checkCollisions: boolean;
  19308. /**
  19309. * Enable or disable gravity on the camera.
  19310. */
  19311. applyGravity: boolean;
  19312. /**
  19313. * Define the input manager associated to the camera.
  19314. */
  19315. inputs: FreeCameraInputsManager;
  19316. /**
  19317. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19318. * Higher values reduce sensitivity.
  19319. */
  19320. get angularSensibility(): number;
  19321. /**
  19322. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19323. * Higher values reduce sensitivity.
  19324. */
  19325. set angularSensibility(value: number);
  19326. /**
  19327. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19328. */
  19329. get keysUp(): number[];
  19330. set keysUp(value: number[]);
  19331. /**
  19332. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19333. */
  19334. get keysUpward(): number[];
  19335. set keysUpward(value: number[]);
  19336. /**
  19337. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19338. */
  19339. get keysDown(): number[];
  19340. set keysDown(value: number[]);
  19341. /**
  19342. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19343. */
  19344. get keysDownward(): number[];
  19345. set keysDownward(value: number[]);
  19346. /**
  19347. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19348. */
  19349. get keysLeft(): number[];
  19350. set keysLeft(value: number[]);
  19351. /**
  19352. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19353. */
  19354. get keysRight(): number[];
  19355. set keysRight(value: number[]);
  19356. /**
  19357. * Event raised when the camera collide with a mesh in the scene.
  19358. */
  19359. onCollide: (collidedMesh: AbstractMesh) => void;
  19360. private _collider;
  19361. private _needMoveForGravity;
  19362. private _oldPosition;
  19363. private _diffPosition;
  19364. private _newPosition;
  19365. /** @hidden */
  19366. _localDirection: Vector3;
  19367. /** @hidden */
  19368. _transformedDirection: Vector3;
  19369. /**
  19370. * Instantiates a Free Camera.
  19371. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19372. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19373. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19374. * @param name Define the name of the camera in the scene
  19375. * @param position Define the start position of the camera in the scene
  19376. * @param scene Define the scene the camera belongs to
  19377. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19378. */
  19379. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19380. /**
  19381. * Attached controls to the current camera.
  19382. * @param element Defines the element the controls should be listened from
  19383. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19384. */
  19385. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19386. /**
  19387. * Detach the current controls from the camera.
  19388. * The camera will stop reacting to inputs.
  19389. * @param element Defines the element to stop listening the inputs from
  19390. */
  19391. detachControl(element: HTMLElement): void;
  19392. private _collisionMask;
  19393. /**
  19394. * Define a collision mask to limit the list of object the camera can collide with
  19395. */
  19396. get collisionMask(): number;
  19397. set collisionMask(mask: number);
  19398. /** @hidden */
  19399. _collideWithWorld(displacement: Vector3): void;
  19400. private _onCollisionPositionChange;
  19401. /** @hidden */
  19402. _checkInputs(): void;
  19403. /** @hidden */
  19404. _decideIfNeedsToMove(): boolean;
  19405. /** @hidden */
  19406. _updatePosition(): void;
  19407. /**
  19408. * Destroy the camera and release the current resources hold by it.
  19409. */
  19410. dispose(): void;
  19411. /**
  19412. * Gets the current object class name.
  19413. * @return the class name
  19414. */
  19415. getClassName(): string;
  19416. }
  19417. }
  19418. declare module "babylonjs/Gamepads/gamepad" {
  19419. import { Observable } from "babylonjs/Misc/observable";
  19420. /**
  19421. * Represents a gamepad control stick position
  19422. */
  19423. export class StickValues {
  19424. /**
  19425. * The x component of the control stick
  19426. */
  19427. x: number;
  19428. /**
  19429. * The y component of the control stick
  19430. */
  19431. y: number;
  19432. /**
  19433. * Initializes the gamepad x and y control stick values
  19434. * @param x The x component of the gamepad control stick value
  19435. * @param y The y component of the gamepad control stick value
  19436. */
  19437. constructor(
  19438. /**
  19439. * The x component of the control stick
  19440. */
  19441. x: number,
  19442. /**
  19443. * The y component of the control stick
  19444. */
  19445. y: number);
  19446. }
  19447. /**
  19448. * An interface which manages callbacks for gamepad button changes
  19449. */
  19450. export interface GamepadButtonChanges {
  19451. /**
  19452. * Called when a gamepad has been changed
  19453. */
  19454. changed: boolean;
  19455. /**
  19456. * Called when a gamepad press event has been triggered
  19457. */
  19458. pressChanged: boolean;
  19459. /**
  19460. * Called when a touch event has been triggered
  19461. */
  19462. touchChanged: boolean;
  19463. /**
  19464. * Called when a value has changed
  19465. */
  19466. valueChanged: boolean;
  19467. }
  19468. /**
  19469. * Represents a gamepad
  19470. */
  19471. export class Gamepad {
  19472. /**
  19473. * The id of the gamepad
  19474. */
  19475. id: string;
  19476. /**
  19477. * The index of the gamepad
  19478. */
  19479. index: number;
  19480. /**
  19481. * The browser gamepad
  19482. */
  19483. browserGamepad: any;
  19484. /**
  19485. * Specifies what type of gamepad this represents
  19486. */
  19487. type: number;
  19488. private _leftStick;
  19489. private _rightStick;
  19490. /** @hidden */
  19491. _isConnected: boolean;
  19492. private _leftStickAxisX;
  19493. private _leftStickAxisY;
  19494. private _rightStickAxisX;
  19495. private _rightStickAxisY;
  19496. /**
  19497. * Triggered when the left control stick has been changed
  19498. */
  19499. private _onleftstickchanged;
  19500. /**
  19501. * Triggered when the right control stick has been changed
  19502. */
  19503. private _onrightstickchanged;
  19504. /**
  19505. * Represents a gamepad controller
  19506. */
  19507. static GAMEPAD: number;
  19508. /**
  19509. * Represents a generic controller
  19510. */
  19511. static GENERIC: number;
  19512. /**
  19513. * Represents an XBox controller
  19514. */
  19515. static XBOX: number;
  19516. /**
  19517. * Represents a pose-enabled controller
  19518. */
  19519. static POSE_ENABLED: number;
  19520. /**
  19521. * Represents an Dual Shock controller
  19522. */
  19523. static DUALSHOCK: number;
  19524. /**
  19525. * Specifies whether the left control stick should be Y-inverted
  19526. */
  19527. protected _invertLeftStickY: boolean;
  19528. /**
  19529. * Specifies if the gamepad has been connected
  19530. */
  19531. get isConnected(): boolean;
  19532. /**
  19533. * Initializes the gamepad
  19534. * @param id The id of the gamepad
  19535. * @param index The index of the gamepad
  19536. * @param browserGamepad The browser gamepad
  19537. * @param leftStickX The x component of the left joystick
  19538. * @param leftStickY The y component of the left joystick
  19539. * @param rightStickX The x component of the right joystick
  19540. * @param rightStickY The y component of the right joystick
  19541. */
  19542. constructor(
  19543. /**
  19544. * The id of the gamepad
  19545. */
  19546. id: string,
  19547. /**
  19548. * The index of the gamepad
  19549. */
  19550. index: number,
  19551. /**
  19552. * The browser gamepad
  19553. */
  19554. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19555. /**
  19556. * Callback triggered when the left joystick has changed
  19557. * @param callback
  19558. */
  19559. onleftstickchanged(callback: (values: StickValues) => void): void;
  19560. /**
  19561. * Callback triggered when the right joystick has changed
  19562. * @param callback
  19563. */
  19564. onrightstickchanged(callback: (values: StickValues) => void): void;
  19565. /**
  19566. * Gets the left joystick
  19567. */
  19568. get leftStick(): StickValues;
  19569. /**
  19570. * Sets the left joystick values
  19571. */
  19572. set leftStick(newValues: StickValues);
  19573. /**
  19574. * Gets the right joystick
  19575. */
  19576. get rightStick(): StickValues;
  19577. /**
  19578. * Sets the right joystick value
  19579. */
  19580. set rightStick(newValues: StickValues);
  19581. /**
  19582. * Updates the gamepad joystick positions
  19583. */
  19584. update(): void;
  19585. /**
  19586. * Disposes the gamepad
  19587. */
  19588. dispose(): void;
  19589. }
  19590. /**
  19591. * Represents a generic gamepad
  19592. */
  19593. export class GenericPad extends Gamepad {
  19594. private _buttons;
  19595. private _onbuttondown;
  19596. private _onbuttonup;
  19597. /**
  19598. * Observable triggered when a button has been pressed
  19599. */
  19600. onButtonDownObservable: Observable<number>;
  19601. /**
  19602. * Observable triggered when a button has been released
  19603. */
  19604. onButtonUpObservable: Observable<number>;
  19605. /**
  19606. * Callback triggered when a button has been pressed
  19607. * @param callback Called when a button has been pressed
  19608. */
  19609. onbuttondown(callback: (buttonPressed: number) => void): void;
  19610. /**
  19611. * Callback triggered when a button has been released
  19612. * @param callback Called when a button has been released
  19613. */
  19614. onbuttonup(callback: (buttonReleased: number) => void): void;
  19615. /**
  19616. * Initializes the generic gamepad
  19617. * @param id The id of the generic gamepad
  19618. * @param index The index of the generic gamepad
  19619. * @param browserGamepad The browser gamepad
  19620. */
  19621. constructor(id: string, index: number, browserGamepad: any);
  19622. private _setButtonValue;
  19623. /**
  19624. * Updates the generic gamepad
  19625. */
  19626. update(): void;
  19627. /**
  19628. * Disposes the generic gamepad
  19629. */
  19630. dispose(): void;
  19631. }
  19632. }
  19633. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19634. import { Observable } from "babylonjs/Misc/observable";
  19635. import { Nullable } from "babylonjs/types";
  19636. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19637. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19639. import { Ray } from "babylonjs/Culling/ray";
  19640. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19641. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19642. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19643. /**
  19644. * Defines the types of pose enabled controllers that are supported
  19645. */
  19646. export enum PoseEnabledControllerType {
  19647. /**
  19648. * HTC Vive
  19649. */
  19650. VIVE = 0,
  19651. /**
  19652. * Oculus Rift
  19653. */
  19654. OCULUS = 1,
  19655. /**
  19656. * Windows mixed reality
  19657. */
  19658. WINDOWS = 2,
  19659. /**
  19660. * Samsung gear VR
  19661. */
  19662. GEAR_VR = 3,
  19663. /**
  19664. * Google Daydream
  19665. */
  19666. DAYDREAM = 4,
  19667. /**
  19668. * Generic
  19669. */
  19670. GENERIC = 5
  19671. }
  19672. /**
  19673. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19674. */
  19675. export interface MutableGamepadButton {
  19676. /**
  19677. * Value of the button/trigger
  19678. */
  19679. value: number;
  19680. /**
  19681. * If the button/trigger is currently touched
  19682. */
  19683. touched: boolean;
  19684. /**
  19685. * If the button/trigger is currently pressed
  19686. */
  19687. pressed: boolean;
  19688. }
  19689. /**
  19690. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19691. * @hidden
  19692. */
  19693. export interface ExtendedGamepadButton extends GamepadButton {
  19694. /**
  19695. * If the button/trigger is currently pressed
  19696. */
  19697. readonly pressed: boolean;
  19698. /**
  19699. * If the button/trigger is currently touched
  19700. */
  19701. readonly touched: boolean;
  19702. /**
  19703. * Value of the button/trigger
  19704. */
  19705. readonly value: number;
  19706. }
  19707. /** @hidden */
  19708. export interface _GamePadFactory {
  19709. /**
  19710. * Returns whether or not the current gamepad can be created for this type of controller.
  19711. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19712. * @returns true if it can be created, otherwise false
  19713. */
  19714. canCreate(gamepadInfo: any): boolean;
  19715. /**
  19716. * Creates a new instance of the Gamepad.
  19717. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19718. * @returns the new gamepad instance
  19719. */
  19720. create(gamepadInfo: any): Gamepad;
  19721. }
  19722. /**
  19723. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19724. */
  19725. export class PoseEnabledControllerHelper {
  19726. /** @hidden */
  19727. static _ControllerFactories: _GamePadFactory[];
  19728. /** @hidden */
  19729. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19730. /**
  19731. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19732. * @param vrGamepad the gamepad to initialized
  19733. * @returns a vr controller of the type the gamepad identified as
  19734. */
  19735. static InitiateController(vrGamepad: any): Gamepad;
  19736. }
  19737. /**
  19738. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19739. */
  19740. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19741. /**
  19742. * If the controller is used in a webXR session
  19743. */
  19744. isXR: boolean;
  19745. private _deviceRoomPosition;
  19746. private _deviceRoomRotationQuaternion;
  19747. /**
  19748. * The device position in babylon space
  19749. */
  19750. devicePosition: Vector3;
  19751. /**
  19752. * The device rotation in babylon space
  19753. */
  19754. deviceRotationQuaternion: Quaternion;
  19755. /**
  19756. * The scale factor of the device in babylon space
  19757. */
  19758. deviceScaleFactor: number;
  19759. /**
  19760. * (Likely devicePosition should be used instead) The device position in its room space
  19761. */
  19762. position: Vector3;
  19763. /**
  19764. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19765. */
  19766. rotationQuaternion: Quaternion;
  19767. /**
  19768. * The type of controller (Eg. Windows mixed reality)
  19769. */
  19770. controllerType: PoseEnabledControllerType;
  19771. protected _calculatedPosition: Vector3;
  19772. private _calculatedRotation;
  19773. /**
  19774. * The raw pose from the device
  19775. */
  19776. rawPose: DevicePose;
  19777. private _trackPosition;
  19778. private _maxRotationDistFromHeadset;
  19779. private _draggedRoomRotation;
  19780. /**
  19781. * @hidden
  19782. */
  19783. _disableTrackPosition(fixedPosition: Vector3): void;
  19784. /**
  19785. * Internal, the mesh attached to the controller
  19786. * @hidden
  19787. */
  19788. _mesh: Nullable<AbstractMesh>;
  19789. private _poseControlledCamera;
  19790. private _leftHandSystemQuaternion;
  19791. /**
  19792. * Internal, matrix used to convert room space to babylon space
  19793. * @hidden
  19794. */
  19795. _deviceToWorld: Matrix;
  19796. /**
  19797. * Node to be used when casting a ray from the controller
  19798. * @hidden
  19799. */
  19800. _pointingPoseNode: Nullable<TransformNode>;
  19801. /**
  19802. * Name of the child mesh that can be used to cast a ray from the controller
  19803. */
  19804. static readonly POINTING_POSE: string;
  19805. /**
  19806. * Creates a new PoseEnabledController from a gamepad
  19807. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19808. */
  19809. constructor(browserGamepad: any);
  19810. private _workingMatrix;
  19811. /**
  19812. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19813. */
  19814. update(): void;
  19815. /**
  19816. * Updates only the pose device and mesh without doing any button event checking
  19817. */
  19818. protected _updatePoseAndMesh(): void;
  19819. /**
  19820. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19821. * @param poseData raw pose fromthe device
  19822. */
  19823. updateFromDevice(poseData: DevicePose): void;
  19824. /**
  19825. * @hidden
  19826. */
  19827. _meshAttachedObservable: Observable<AbstractMesh>;
  19828. /**
  19829. * Attaches a mesh to the controller
  19830. * @param mesh the mesh to be attached
  19831. */
  19832. attachToMesh(mesh: AbstractMesh): void;
  19833. /**
  19834. * Attaches the controllers mesh to a camera
  19835. * @param camera the camera the mesh should be attached to
  19836. */
  19837. attachToPoseControlledCamera(camera: TargetCamera): void;
  19838. /**
  19839. * Disposes of the controller
  19840. */
  19841. dispose(): void;
  19842. /**
  19843. * The mesh that is attached to the controller
  19844. */
  19845. get mesh(): Nullable<AbstractMesh>;
  19846. /**
  19847. * Gets the ray of the controller in the direction the controller is pointing
  19848. * @param length the length the resulting ray should be
  19849. * @returns a ray in the direction the controller is pointing
  19850. */
  19851. getForwardRay(length?: number): Ray;
  19852. }
  19853. }
  19854. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19855. import { Observable } from "babylonjs/Misc/observable";
  19856. import { Scene } from "babylonjs/scene";
  19857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19858. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19859. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19860. import { Nullable } from "babylonjs/types";
  19861. /**
  19862. * Defines the WebVRController object that represents controllers tracked in 3D space
  19863. */
  19864. export abstract class WebVRController extends PoseEnabledController {
  19865. /**
  19866. * Internal, the default controller model for the controller
  19867. */
  19868. protected _defaultModel: Nullable<AbstractMesh>;
  19869. /**
  19870. * Fired when the trigger state has changed
  19871. */
  19872. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19873. /**
  19874. * Fired when the main button state has changed
  19875. */
  19876. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19877. /**
  19878. * Fired when the secondary button state has changed
  19879. */
  19880. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19881. /**
  19882. * Fired when the pad state has changed
  19883. */
  19884. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19885. /**
  19886. * Fired when controllers stick values have changed
  19887. */
  19888. onPadValuesChangedObservable: Observable<StickValues>;
  19889. /**
  19890. * Array of button availible on the controller
  19891. */
  19892. protected _buttons: Array<MutableGamepadButton>;
  19893. private _onButtonStateChange;
  19894. /**
  19895. * Fired when a controller button's state has changed
  19896. * @param callback the callback containing the button that was modified
  19897. */
  19898. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19899. /**
  19900. * X and Y axis corresponding to the controllers joystick
  19901. */
  19902. pad: StickValues;
  19903. /**
  19904. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19905. */
  19906. hand: string;
  19907. /**
  19908. * The default controller model for the controller
  19909. */
  19910. get defaultModel(): Nullable<AbstractMesh>;
  19911. /**
  19912. * Creates a new WebVRController from a gamepad
  19913. * @param vrGamepad the gamepad that the WebVRController should be created from
  19914. */
  19915. constructor(vrGamepad: any);
  19916. /**
  19917. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19918. */
  19919. update(): void;
  19920. /**
  19921. * Function to be called when a button is modified
  19922. */
  19923. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19924. /**
  19925. * Loads a mesh and attaches it to the controller
  19926. * @param scene the scene the mesh should be added to
  19927. * @param meshLoaded callback for when the mesh has been loaded
  19928. */
  19929. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19930. private _setButtonValue;
  19931. private _changes;
  19932. private _checkChanges;
  19933. /**
  19934. * Disposes of th webVRCOntroller
  19935. */
  19936. dispose(): void;
  19937. }
  19938. }
  19939. declare module "babylonjs/Lights/hemisphericLight" {
  19940. import { Nullable } from "babylonjs/types";
  19941. import { Scene } from "babylonjs/scene";
  19942. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19943. import { Color3 } from "babylonjs/Maths/math.color";
  19944. import { Effect } from "babylonjs/Materials/effect";
  19945. import { Light } from "babylonjs/Lights/light";
  19946. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19947. /**
  19948. * The HemisphericLight simulates the ambient environment light,
  19949. * so the passed direction is the light reflection direction, not the incoming direction.
  19950. */
  19951. export class HemisphericLight extends Light {
  19952. /**
  19953. * The groundColor is the light in the opposite direction to the one specified during creation.
  19954. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  19955. */
  19956. groundColor: Color3;
  19957. /**
  19958. * The light reflection direction, not the incoming direction.
  19959. */
  19960. direction: Vector3;
  19961. /**
  19962. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19963. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19964. * The HemisphericLight can't cast shadows.
  19965. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19966. * @param name The friendly name of the light
  19967. * @param direction The direction of the light reflection
  19968. * @param scene The scene the light belongs to
  19969. */
  19970. constructor(name: string, direction: Vector3, scene: Scene);
  19971. protected _buildUniformLayout(): void;
  19972. /**
  19973. * Returns the string "HemisphericLight".
  19974. * @return The class name
  19975. */
  19976. getClassName(): string;
  19977. /**
  19978. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19979. * Returns the updated direction.
  19980. * @param target The target the direction should point to
  19981. * @return The computed direction
  19982. */
  19983. setDirectionToTarget(target: Vector3): Vector3;
  19984. /**
  19985. * Returns the shadow generator associated to the light.
  19986. * @returns Always null for hemispheric lights because it does not support shadows.
  19987. */
  19988. getShadowGenerator(): Nullable<IShadowGenerator>;
  19989. /**
  19990. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19991. * @param effect The effect to update
  19992. * @param lightIndex The index of the light in the effect to update
  19993. * @returns The hemispheric light
  19994. */
  19995. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19996. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19997. /**
  19998. * Computes the world matrix of the node
  19999. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20000. * @param useWasUpdatedFlag defines a reserved property
  20001. * @returns the world matrix
  20002. */
  20003. computeWorldMatrix(): Matrix;
  20004. /**
  20005. * Returns the integer 3.
  20006. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20007. */
  20008. getTypeID(): number;
  20009. /**
  20010. * Prepares the list of defines specific to the light type.
  20011. * @param defines the list of defines
  20012. * @param lightIndex defines the index of the light for the effect
  20013. */
  20014. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20015. }
  20016. }
  20017. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20018. /** @hidden */
  20019. export var vrMultiviewToSingleviewPixelShader: {
  20020. name: string;
  20021. shader: string;
  20022. };
  20023. }
  20024. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20025. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20026. import { Scene } from "babylonjs/scene";
  20027. /**
  20028. * Renders to multiple views with a single draw call
  20029. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20030. */
  20031. export class MultiviewRenderTarget extends RenderTargetTexture {
  20032. /**
  20033. * Creates a multiview render target
  20034. * @param scene scene used with the render target
  20035. * @param size the size of the render target (used for each view)
  20036. */
  20037. constructor(scene: Scene, size?: number | {
  20038. width: number;
  20039. height: number;
  20040. } | {
  20041. ratio: number;
  20042. });
  20043. /**
  20044. * @hidden
  20045. * @param faceIndex the face index, if its a cube texture
  20046. */
  20047. _bindFrameBuffer(faceIndex?: number): void;
  20048. /**
  20049. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20050. * @returns the view count
  20051. */
  20052. getViewCount(): number;
  20053. }
  20054. }
  20055. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20056. import { Camera } from "babylonjs/Cameras/camera";
  20057. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20058. import { Nullable } from "babylonjs/types";
  20059. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20060. import { Matrix } from "babylonjs/Maths/math.vector";
  20061. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20062. module "babylonjs/Engines/engine" {
  20063. interface Engine {
  20064. /**
  20065. * Creates a new multiview render target
  20066. * @param width defines the width of the texture
  20067. * @param height defines the height of the texture
  20068. * @returns the created multiview texture
  20069. */
  20070. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20071. /**
  20072. * Binds a multiview framebuffer to be drawn to
  20073. * @param multiviewTexture texture to bind
  20074. */
  20075. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20076. }
  20077. }
  20078. module "babylonjs/Cameras/camera" {
  20079. interface Camera {
  20080. /**
  20081. * @hidden
  20082. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  20083. */
  20084. _useMultiviewToSingleView: boolean;
  20085. /**
  20086. * @hidden
  20087. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  20088. */
  20089. _multiviewTexture: Nullable<RenderTargetTexture>;
  20090. /**
  20091. * @hidden
  20092. * ensures the multiview texture of the camera exists and has the specified width/height
  20093. * @param width height to set on the multiview texture
  20094. * @param height width to set on the multiview texture
  20095. */
  20096. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20097. }
  20098. }
  20099. module "babylonjs/scene" {
  20100. interface Scene {
  20101. /** @hidden */
  20102. _transformMatrixR: Matrix;
  20103. /** @hidden */
  20104. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20105. /** @hidden */
  20106. _createMultiviewUbo(): void;
  20107. /** @hidden */
  20108. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20109. /** @hidden */
  20110. _renderMultiviewToSingleView(camera: Camera): void;
  20111. }
  20112. }
  20113. }
  20114. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20115. import { Camera } from "babylonjs/Cameras/camera";
  20116. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20117. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20118. import "babylonjs/Engines/Extensions/engine.multiview";
  20119. /**
  20120. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20121. * This will not be used for webXR as it supports displaying texture arrays directly
  20122. */
  20123. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20124. /**
  20125. * Initializes a VRMultiviewToSingleview
  20126. * @param name name of the post process
  20127. * @param camera camera to be applied to
  20128. * @param scaleFactor scaling factor to the size of the output texture
  20129. */
  20130. constructor(name: string, camera: Camera, scaleFactor: number);
  20131. }
  20132. }
  20133. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20134. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20135. import { Nullable } from "babylonjs/types";
  20136. import { Size } from "babylonjs/Maths/math.size";
  20137. import { Observable } from "babylonjs/Misc/observable";
  20138. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20139. /**
  20140. * Interface used to define additional presentation attributes
  20141. */
  20142. export interface IVRPresentationAttributes {
  20143. /**
  20144. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20145. */
  20146. highRefreshRate: boolean;
  20147. /**
  20148. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20149. */
  20150. foveationLevel: number;
  20151. }
  20152. module "babylonjs/Engines/engine" {
  20153. interface Engine {
  20154. /** @hidden */
  20155. _vrDisplay: any;
  20156. /** @hidden */
  20157. _vrSupported: boolean;
  20158. /** @hidden */
  20159. _oldSize: Size;
  20160. /** @hidden */
  20161. _oldHardwareScaleFactor: number;
  20162. /** @hidden */
  20163. _vrExclusivePointerMode: boolean;
  20164. /** @hidden */
  20165. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20166. /** @hidden */
  20167. _onVRDisplayPointerRestricted: () => void;
  20168. /** @hidden */
  20169. _onVRDisplayPointerUnrestricted: () => void;
  20170. /** @hidden */
  20171. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20172. /** @hidden */
  20173. _onVrDisplayDisconnect: Nullable<() => void>;
  20174. /** @hidden */
  20175. _onVrDisplayPresentChange: Nullable<() => void>;
  20176. /**
  20177. * Observable signaled when VR display mode changes
  20178. */
  20179. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20180. /**
  20181. * Observable signaled when VR request present is complete
  20182. */
  20183. onVRRequestPresentComplete: Observable<boolean>;
  20184. /**
  20185. * Observable signaled when VR request present starts
  20186. */
  20187. onVRRequestPresentStart: Observable<Engine>;
  20188. /**
  20189. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20190. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20191. */
  20192. isInVRExclusivePointerMode: boolean;
  20193. /**
  20194. * Gets a boolean indicating if a webVR device was detected
  20195. * @returns true if a webVR device was detected
  20196. */
  20197. isVRDevicePresent(): boolean;
  20198. /**
  20199. * Gets the current webVR device
  20200. * @returns the current webVR device (or null)
  20201. */
  20202. getVRDevice(): any;
  20203. /**
  20204. * Initializes a webVR display and starts listening to display change events
  20205. * The onVRDisplayChangedObservable will be notified upon these changes
  20206. * @returns A promise containing a VRDisplay and if vr is supported
  20207. */
  20208. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20209. /** @hidden */
  20210. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20211. /**
  20212. * Gets or sets the presentation attributes used to configure VR rendering
  20213. */
  20214. vrPresentationAttributes?: IVRPresentationAttributes;
  20215. /**
  20216. * Call this function to switch to webVR mode
  20217. * Will do nothing if webVR is not supported or if there is no webVR device
  20218. * @param options the webvr options provided to the camera. mainly used for multiview
  20219. * @see http://doc.babylonjs.com/how_to/webvr_camera
  20220. */
  20221. enableVR(options: WebVROptions): void;
  20222. /** @hidden */
  20223. _onVRFullScreenTriggered(): void;
  20224. }
  20225. }
  20226. }
  20227. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20228. import { Nullable } from "babylonjs/types";
  20229. import { Observable } from "babylonjs/Misc/observable";
  20230. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20231. import { Scene } from "babylonjs/scene";
  20232. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20233. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20234. import { Node } from "babylonjs/node";
  20235. import { Ray } from "babylonjs/Culling/ray";
  20236. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20237. import "babylonjs/Engines/Extensions/engine.webVR";
  20238. /**
  20239. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20240. * IMPORTANT!! The data is right-hand data.
  20241. * @export
  20242. * @interface DevicePose
  20243. */
  20244. export interface DevicePose {
  20245. /**
  20246. * The position of the device, values in array are [x,y,z].
  20247. */
  20248. readonly position: Nullable<Float32Array>;
  20249. /**
  20250. * The linearVelocity of the device, values in array are [x,y,z].
  20251. */
  20252. readonly linearVelocity: Nullable<Float32Array>;
  20253. /**
  20254. * The linearAcceleration of the device, values in array are [x,y,z].
  20255. */
  20256. readonly linearAcceleration: Nullable<Float32Array>;
  20257. /**
  20258. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20259. */
  20260. readonly orientation: Nullable<Float32Array>;
  20261. /**
  20262. * The angularVelocity of the device, values in array are [x,y,z].
  20263. */
  20264. readonly angularVelocity: Nullable<Float32Array>;
  20265. /**
  20266. * The angularAcceleration of the device, values in array are [x,y,z].
  20267. */
  20268. readonly angularAcceleration: Nullable<Float32Array>;
  20269. }
  20270. /**
  20271. * Interface representing a pose controlled object in Babylon.
  20272. * A pose controlled object has both regular pose values as well as pose values
  20273. * from an external device such as a VR head mounted display
  20274. */
  20275. export interface PoseControlled {
  20276. /**
  20277. * The position of the object in babylon space.
  20278. */
  20279. position: Vector3;
  20280. /**
  20281. * The rotation quaternion of the object in babylon space.
  20282. */
  20283. rotationQuaternion: Quaternion;
  20284. /**
  20285. * The position of the device in babylon space.
  20286. */
  20287. devicePosition?: Vector3;
  20288. /**
  20289. * The rotation quaternion of the device in babylon space.
  20290. */
  20291. deviceRotationQuaternion: Quaternion;
  20292. /**
  20293. * The raw pose coming from the device.
  20294. */
  20295. rawPose: Nullable<DevicePose>;
  20296. /**
  20297. * The scale of the device to be used when translating from device space to babylon space.
  20298. */
  20299. deviceScaleFactor: number;
  20300. /**
  20301. * Updates the poseControlled values based on the input device pose.
  20302. * @param poseData the pose data to update the object with
  20303. */
  20304. updateFromDevice(poseData: DevicePose): void;
  20305. }
  20306. /**
  20307. * Set of options to customize the webVRCamera
  20308. */
  20309. export interface WebVROptions {
  20310. /**
  20311. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20312. */
  20313. trackPosition?: boolean;
  20314. /**
  20315. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20316. */
  20317. positionScale?: number;
  20318. /**
  20319. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20320. */
  20321. displayName?: string;
  20322. /**
  20323. * Should the native controller meshes be initialized. (default: true)
  20324. */
  20325. controllerMeshes?: boolean;
  20326. /**
  20327. * Creating a default HemiLight only on controllers. (default: true)
  20328. */
  20329. defaultLightingOnControllers?: boolean;
  20330. /**
  20331. * If you don't want to use the default VR button of the helper. (default: false)
  20332. */
  20333. useCustomVRButton?: boolean;
  20334. /**
  20335. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20336. */
  20337. customVRButton?: HTMLButtonElement;
  20338. /**
  20339. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20340. */
  20341. rayLength?: number;
  20342. /**
  20343. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20344. */
  20345. defaultHeight?: number;
  20346. /**
  20347. * If multiview should be used if availible (default: false)
  20348. */
  20349. useMultiview?: boolean;
  20350. }
  20351. /**
  20352. * This represents a WebVR camera.
  20353. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20354. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20355. */
  20356. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20357. private webVROptions;
  20358. /**
  20359. * @hidden
  20360. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20361. */
  20362. _vrDevice: any;
  20363. /**
  20364. * The rawPose of the vrDevice.
  20365. */
  20366. rawPose: Nullable<DevicePose>;
  20367. private _onVREnabled;
  20368. private _specsVersion;
  20369. private _attached;
  20370. private _frameData;
  20371. protected _descendants: Array<Node>;
  20372. private _deviceRoomPosition;
  20373. /** @hidden */
  20374. _deviceRoomRotationQuaternion: Quaternion;
  20375. private _standingMatrix;
  20376. /**
  20377. * Represents device position in babylon space.
  20378. */
  20379. devicePosition: Vector3;
  20380. /**
  20381. * Represents device rotation in babylon space.
  20382. */
  20383. deviceRotationQuaternion: Quaternion;
  20384. /**
  20385. * The scale of the device to be used when translating from device space to babylon space.
  20386. */
  20387. deviceScaleFactor: number;
  20388. private _deviceToWorld;
  20389. private _worldToDevice;
  20390. /**
  20391. * References to the webVR controllers for the vrDevice.
  20392. */
  20393. controllers: Array<WebVRController>;
  20394. /**
  20395. * Emits an event when a controller is attached.
  20396. */
  20397. onControllersAttachedObservable: Observable<WebVRController[]>;
  20398. /**
  20399. * Emits an event when a controller's mesh has been loaded;
  20400. */
  20401. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20402. /**
  20403. * Emits an event when the HMD's pose has been updated.
  20404. */
  20405. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20406. private _poseSet;
  20407. /**
  20408. * If the rig cameras be used as parent instead of this camera.
  20409. */
  20410. rigParenting: boolean;
  20411. private _lightOnControllers;
  20412. private _defaultHeight?;
  20413. /**
  20414. * Instantiates a WebVRFreeCamera.
  20415. * @param name The name of the WebVRFreeCamera
  20416. * @param position The starting anchor position for the camera
  20417. * @param scene The scene the camera belongs to
  20418. * @param webVROptions a set of customizable options for the webVRCamera
  20419. */
  20420. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20421. /**
  20422. * Gets the device distance from the ground in meters.
  20423. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  20424. */
  20425. deviceDistanceToRoomGround(): number;
  20426. /**
  20427. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20428. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20429. */
  20430. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20431. /**
  20432. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20433. * @returns A promise with a boolean set to if the standing matrix is supported.
  20434. */
  20435. useStandingMatrixAsync(): Promise<boolean>;
  20436. /**
  20437. * Disposes the camera
  20438. */
  20439. dispose(): void;
  20440. /**
  20441. * Gets a vrController by name.
  20442. * @param name The name of the controller to retreive
  20443. * @returns the controller matching the name specified or null if not found
  20444. */
  20445. getControllerByName(name: string): Nullable<WebVRController>;
  20446. private _leftController;
  20447. /**
  20448. * The controller corresponding to the users left hand.
  20449. */
  20450. get leftController(): Nullable<WebVRController>;
  20451. private _rightController;
  20452. /**
  20453. * The controller corresponding to the users right hand.
  20454. */
  20455. get rightController(): Nullable<WebVRController>;
  20456. /**
  20457. * Casts a ray forward from the vrCamera's gaze.
  20458. * @param length Length of the ray (default: 100)
  20459. * @returns the ray corresponding to the gaze
  20460. */
  20461. getForwardRay(length?: number): Ray;
  20462. /**
  20463. * @hidden
  20464. * Updates the camera based on device's frame data
  20465. */
  20466. _checkInputs(): void;
  20467. /**
  20468. * Updates the poseControlled values based on the input device pose.
  20469. * @param poseData Pose coming from the device
  20470. */
  20471. updateFromDevice(poseData: DevicePose): void;
  20472. private _htmlElementAttached;
  20473. private _detachIfAttached;
  20474. /**
  20475. * WebVR's attach control will start broadcasting frames to the device.
  20476. * Note that in certain browsers (chrome for example) this function must be called
  20477. * within a user-interaction callback. Example:
  20478. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20479. *
  20480. * @param element html element to attach the vrDevice to
  20481. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20482. */
  20483. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20484. /**
  20485. * Detaches the camera from the html element and disables VR
  20486. *
  20487. * @param element html element to detach from
  20488. */
  20489. detachControl(element: HTMLElement): void;
  20490. /**
  20491. * @returns the name of this class
  20492. */
  20493. getClassName(): string;
  20494. /**
  20495. * Calls resetPose on the vrDisplay
  20496. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20497. */
  20498. resetToCurrentRotation(): void;
  20499. /**
  20500. * @hidden
  20501. * Updates the rig cameras (left and right eye)
  20502. */
  20503. _updateRigCameras(): void;
  20504. private _workingVector;
  20505. private _oneVector;
  20506. private _workingMatrix;
  20507. private updateCacheCalled;
  20508. private _correctPositionIfNotTrackPosition;
  20509. /**
  20510. * @hidden
  20511. * Updates the cached values of the camera
  20512. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20513. */
  20514. _updateCache(ignoreParentClass?: boolean): void;
  20515. /**
  20516. * @hidden
  20517. * Get current device position in babylon world
  20518. */
  20519. _computeDevicePosition(): void;
  20520. /**
  20521. * Updates the current device position and rotation in the babylon world
  20522. */
  20523. update(): void;
  20524. /**
  20525. * @hidden
  20526. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20527. * @returns an identity matrix
  20528. */
  20529. _getViewMatrix(): Matrix;
  20530. private _tmpMatrix;
  20531. /**
  20532. * This function is called by the two RIG cameras.
  20533. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20534. * @hidden
  20535. */
  20536. _getWebVRViewMatrix(): Matrix;
  20537. /** @hidden */
  20538. _getWebVRProjectionMatrix(): Matrix;
  20539. private _onGamepadConnectedObserver;
  20540. private _onGamepadDisconnectedObserver;
  20541. private _updateCacheWhenTrackingDisabledObserver;
  20542. /**
  20543. * Initializes the controllers and their meshes
  20544. */
  20545. initControllers(): void;
  20546. }
  20547. }
  20548. declare module "babylonjs/Materials/materialHelper" {
  20549. import { Nullable } from "babylonjs/types";
  20550. import { Scene } from "babylonjs/scene";
  20551. import { Engine } from "babylonjs/Engines/engine";
  20552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20553. import { Light } from "babylonjs/Lights/light";
  20554. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20555. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20556. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20557. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20558. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20559. /**
  20560. * "Static Class" containing the most commonly used helper while dealing with material for
  20561. * rendering purpose.
  20562. *
  20563. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20564. *
  20565. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20566. */
  20567. export class MaterialHelper {
  20568. /**
  20569. * Bind the current view position to an effect.
  20570. * @param effect The effect to be bound
  20571. * @param scene The scene the eyes position is used from
  20572. * @param variableName name of the shader variable that will hold the eye position
  20573. */
  20574. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20575. /**
  20576. * Helps preparing the defines values about the UVs in used in the effect.
  20577. * UVs are shared as much as we can accross channels in the shaders.
  20578. * @param texture The texture we are preparing the UVs for
  20579. * @param defines The defines to update
  20580. * @param key The channel key "diffuse", "specular"... used in the shader
  20581. */
  20582. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20583. /**
  20584. * Binds a texture matrix value to its corrsponding uniform
  20585. * @param texture The texture to bind the matrix for
  20586. * @param uniformBuffer The uniform buffer receivin the data
  20587. * @param key The channel key "diffuse", "specular"... used in the shader
  20588. */
  20589. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20590. /**
  20591. * Gets the current status of the fog (should it be enabled?)
  20592. * @param mesh defines the mesh to evaluate for fog support
  20593. * @param scene defines the hosting scene
  20594. * @returns true if fog must be enabled
  20595. */
  20596. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20597. /**
  20598. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20599. * @param mesh defines the current mesh
  20600. * @param scene defines the current scene
  20601. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20602. * @param pointsCloud defines if point cloud rendering has to be turned on
  20603. * @param fogEnabled defines if fog has to be turned on
  20604. * @param alphaTest defines if alpha testing has to be turned on
  20605. * @param defines defines the current list of defines
  20606. */
  20607. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20608. /**
  20609. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20610. * @param scene defines the current scene
  20611. * @param engine defines the current engine
  20612. * @param defines specifies the list of active defines
  20613. * @param useInstances defines if instances have to be turned on
  20614. * @param useClipPlane defines if clip plane have to be turned on
  20615. * @param useInstances defines if instances have to be turned on
  20616. * @param useThinInstances defines if thin instances have to be turned on
  20617. */
  20618. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20619. /**
  20620. * Prepares the defines for bones
  20621. * @param mesh The mesh containing the geometry data we will draw
  20622. * @param defines The defines to update
  20623. */
  20624. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20625. /**
  20626. * Prepares the defines for morph targets
  20627. * @param mesh The mesh containing the geometry data we will draw
  20628. * @param defines The defines to update
  20629. */
  20630. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20631. /**
  20632. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20633. * @param mesh The mesh containing the geometry data we will draw
  20634. * @param defines The defines to update
  20635. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20636. * @param useBones Precise whether bones should be used or not (override mesh info)
  20637. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20638. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20639. * @returns false if defines are considered not dirty and have not been checked
  20640. */
  20641. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20642. /**
  20643. * Prepares the defines related to multiview
  20644. * @param scene The scene we are intending to draw
  20645. * @param defines The defines to update
  20646. */
  20647. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20648. /**
  20649. * Prepares the defines related to the light information passed in parameter
  20650. * @param scene The scene we are intending to draw
  20651. * @param mesh The mesh the effect is compiling for
  20652. * @param light The light the effect is compiling for
  20653. * @param lightIndex The index of the light
  20654. * @param defines The defines to update
  20655. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20656. * @param state Defines the current state regarding what is needed (normals, etc...)
  20657. */
  20658. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20659. needNormals: boolean;
  20660. needRebuild: boolean;
  20661. shadowEnabled: boolean;
  20662. specularEnabled: boolean;
  20663. lightmapMode: boolean;
  20664. }): void;
  20665. /**
  20666. * Prepares the defines related to the light information passed in parameter
  20667. * @param scene The scene we are intending to draw
  20668. * @param mesh The mesh the effect is compiling for
  20669. * @param defines The defines to update
  20670. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20671. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20672. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20673. * @returns true if normals will be required for the rest of the effect
  20674. */
  20675. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20676. /**
  20677. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20678. * @param lightIndex defines the light index
  20679. * @param uniformsList The uniform list
  20680. * @param samplersList The sampler list
  20681. * @param projectedLightTexture defines if projected texture must be used
  20682. * @param uniformBuffersList defines an optional list of uniform buffers
  20683. */
  20684. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20685. /**
  20686. * Prepares the uniforms and samplers list to be used in the effect
  20687. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20688. * @param samplersList The sampler list
  20689. * @param defines The defines helping in the list generation
  20690. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20691. */
  20692. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20693. /**
  20694. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20695. * @param defines The defines to update while falling back
  20696. * @param fallbacks The authorized effect fallbacks
  20697. * @param maxSimultaneousLights The maximum number of lights allowed
  20698. * @param rank the current rank of the Effect
  20699. * @returns The newly affected rank
  20700. */
  20701. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20702. private static _TmpMorphInfluencers;
  20703. /**
  20704. * Prepares the list of attributes required for morph targets according to the effect defines.
  20705. * @param attribs The current list of supported attribs
  20706. * @param mesh The mesh to prepare the morph targets attributes for
  20707. * @param influencers The number of influencers
  20708. */
  20709. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20710. /**
  20711. * Prepares the list of attributes required for morph targets according to the effect defines.
  20712. * @param attribs The current list of supported attribs
  20713. * @param mesh The mesh to prepare the morph targets attributes for
  20714. * @param defines The current Defines of the effect
  20715. */
  20716. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20717. /**
  20718. * Prepares the list of attributes required for bones according to the effect defines.
  20719. * @param attribs The current list of supported attribs
  20720. * @param mesh The mesh to prepare the bones attributes for
  20721. * @param defines The current Defines of the effect
  20722. * @param fallbacks The current efffect fallback strategy
  20723. */
  20724. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20725. /**
  20726. * Check and prepare the list of attributes required for instances according to the effect defines.
  20727. * @param attribs The current list of supported attribs
  20728. * @param defines The current MaterialDefines of the effect
  20729. */
  20730. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20731. /**
  20732. * Add the list of attributes required for instances to the attribs array.
  20733. * @param attribs The current list of supported attribs
  20734. */
  20735. static PushAttributesForInstances(attribs: string[]): void;
  20736. /**
  20737. * Binds the light information to the effect.
  20738. * @param light The light containing the generator
  20739. * @param effect The effect we are binding the data to
  20740. * @param lightIndex The light index in the effect used to render
  20741. */
  20742. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20743. /**
  20744. * Binds the lights information from the scene to the effect for the given mesh.
  20745. * @param light Light to bind
  20746. * @param lightIndex Light index
  20747. * @param scene The scene where the light belongs to
  20748. * @param effect The effect we are binding the data to
  20749. * @param useSpecular Defines if specular is supported
  20750. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20751. */
  20752. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20753. /**
  20754. * Binds the lights information from the scene to the effect for the given mesh.
  20755. * @param scene The scene the lights belongs to
  20756. * @param mesh The mesh we are binding the information to render
  20757. * @param effect The effect we are binding the data to
  20758. * @param defines The generated defines for the effect
  20759. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20760. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20761. */
  20762. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20763. private static _tempFogColor;
  20764. /**
  20765. * Binds the fog information from the scene to the effect for the given mesh.
  20766. * @param scene The scene the lights belongs to
  20767. * @param mesh The mesh we are binding the information to render
  20768. * @param effect The effect we are binding the data to
  20769. * @param linearSpace Defines if the fog effect is applied in linear space
  20770. */
  20771. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20772. /**
  20773. * Binds the bones information from the mesh to the effect.
  20774. * @param mesh The mesh we are binding the information to render
  20775. * @param effect The effect we are binding the data to
  20776. */
  20777. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20778. /**
  20779. * Binds the morph targets information from the mesh to the effect.
  20780. * @param abstractMesh The mesh we are binding the information to render
  20781. * @param effect The effect we are binding the data to
  20782. */
  20783. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20784. /**
  20785. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20786. * @param defines The generated defines used in the effect
  20787. * @param effect The effect we are binding the data to
  20788. * @param scene The scene we are willing to render with logarithmic scale for
  20789. */
  20790. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20791. /**
  20792. * Binds the clip plane information from the scene to the effect.
  20793. * @param scene The scene the clip plane information are extracted from
  20794. * @param effect The effect we are binding the data to
  20795. */
  20796. static BindClipPlane(effect: Effect, scene: Scene): void;
  20797. }
  20798. }
  20799. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  20800. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20801. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20802. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  20803. import { Nullable } from "babylonjs/types";
  20804. import { Effect } from "babylonjs/Materials/effect";
  20805. import { Matrix } from "babylonjs/Maths/math.vector";
  20806. import { Scene } from "babylonjs/scene";
  20807. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  20808. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  20809. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20810. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  20811. import { Observable } from "babylonjs/Misc/observable";
  20812. /**
  20813. * Block used to expose an input value
  20814. */
  20815. export class InputBlock extends NodeMaterialBlock {
  20816. private _mode;
  20817. private _associatedVariableName;
  20818. private _storedValue;
  20819. private _valueCallback;
  20820. private _type;
  20821. private _animationType;
  20822. /** Gets or set a value used to limit the range of float values */
  20823. min: number;
  20824. /** Gets or set a value used to limit the range of float values */
  20825. max: number;
  20826. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20827. isBoolean: boolean;
  20828. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20829. matrixMode: number;
  20830. /** @hidden */
  20831. _systemValue: Nullable<NodeMaterialSystemValues>;
  20832. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20833. visibleInInspector: boolean;
  20834. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20835. isConstant: boolean;
  20836. /** Gets or sets the group to use to display this block in the Inspector */
  20837. groupInInspector: string;
  20838. /** Gets an observable raised when the value is changed */
  20839. onValueChangedObservable: Observable<InputBlock>;
  20840. /**
  20841. * Gets or sets the connection point type (default is float)
  20842. */
  20843. get type(): NodeMaterialBlockConnectionPointTypes;
  20844. /**
  20845. * Creates a new InputBlock
  20846. * @param name defines the block name
  20847. * @param target defines the target of that block (Vertex by default)
  20848. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20849. */
  20850. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20851. /**
  20852. * Gets the output component
  20853. */
  20854. get output(): NodeMaterialConnectionPoint;
  20855. /**
  20856. * Set the source of this connection point to a vertex attribute
  20857. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20858. * @returns the current connection point
  20859. */
  20860. setAsAttribute(attributeName?: string): InputBlock;
  20861. /**
  20862. * Set the source of this connection point to a system value
  20863. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20864. * @returns the current connection point
  20865. */
  20866. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20867. /**
  20868. * Gets or sets the value of that point.
  20869. * Please note that this value will be ignored if valueCallback is defined
  20870. */
  20871. get value(): any;
  20872. set value(value: any);
  20873. /**
  20874. * Gets or sets a callback used to get the value of that point.
  20875. * Please note that setting this value will force the connection point to ignore the value property
  20876. */
  20877. get valueCallback(): () => any;
  20878. set valueCallback(value: () => any);
  20879. /**
  20880. * Gets or sets the associated variable name in the shader
  20881. */
  20882. get associatedVariableName(): string;
  20883. set associatedVariableName(value: string);
  20884. /** Gets or sets the type of animation applied to the input */
  20885. get animationType(): AnimatedInputBlockTypes;
  20886. set animationType(value: AnimatedInputBlockTypes);
  20887. /**
  20888. * Gets a boolean indicating that this connection point not defined yet
  20889. */
  20890. get isUndefined(): boolean;
  20891. /**
  20892. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20893. * In this case the connection point name must be the name of the uniform to use.
  20894. * Can only be set on inputs
  20895. */
  20896. get isUniform(): boolean;
  20897. set isUniform(value: boolean);
  20898. /**
  20899. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20900. * In this case the connection point name must be the name of the attribute to use
  20901. * Can only be set on inputs
  20902. */
  20903. get isAttribute(): boolean;
  20904. set isAttribute(value: boolean);
  20905. /**
  20906. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20907. * Can only be set on exit points
  20908. */
  20909. get isVarying(): boolean;
  20910. set isVarying(value: boolean);
  20911. /**
  20912. * Gets a boolean indicating that the current connection point is a system value
  20913. */
  20914. get isSystemValue(): boolean;
  20915. /**
  20916. * Gets or sets the current well known value or null if not defined as a system value
  20917. */
  20918. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20919. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20920. /**
  20921. * Gets the current class name
  20922. * @returns the class name
  20923. */
  20924. getClassName(): string;
  20925. /**
  20926. * Animate the input if animationType !== None
  20927. * @param scene defines the rendering scene
  20928. */
  20929. animate(scene: Scene): void;
  20930. private _emitDefine;
  20931. initialize(state: NodeMaterialBuildState): void;
  20932. /**
  20933. * Set the input block to its default value (based on its type)
  20934. */
  20935. setDefaultValue(): void;
  20936. private _emitConstant;
  20937. /** @hidden */
  20938. get _noContextSwitch(): boolean;
  20939. private _emit;
  20940. /** @hidden */
  20941. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20942. /** @hidden */
  20943. _transmit(effect: Effect, scene: Scene): void;
  20944. protected _buildBlock(state: NodeMaterialBuildState): void;
  20945. protected _dumpPropertiesCode(): string;
  20946. dispose(): void;
  20947. serialize(): any;
  20948. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20949. }
  20950. }
  20951. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  20952. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20953. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20954. import { Nullable } from "babylonjs/types";
  20955. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  20956. import { Observable } from "babylonjs/Misc/observable";
  20957. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20958. /**
  20959. * Enum used to define the compatibility state between two connection points
  20960. */
  20961. export enum NodeMaterialConnectionPointCompatibilityStates {
  20962. /** Points are compatibles */
  20963. Compatible = 0,
  20964. /** Points are incompatible because of their types */
  20965. TypeIncompatible = 1,
  20966. /** Points are incompatible because of their targets (vertex vs fragment) */
  20967. TargetIncompatible = 2
  20968. }
  20969. /**
  20970. * Defines the direction of a connection point
  20971. */
  20972. export enum NodeMaterialConnectionPointDirection {
  20973. /** Input */
  20974. Input = 0,
  20975. /** Output */
  20976. Output = 1
  20977. }
  20978. /**
  20979. * Defines a connection point for a block
  20980. */
  20981. export class NodeMaterialConnectionPoint {
  20982. /** @hidden */
  20983. _ownerBlock: NodeMaterialBlock;
  20984. /** @hidden */
  20985. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20986. private _endpoints;
  20987. private _associatedVariableName;
  20988. private _direction;
  20989. /** @hidden */
  20990. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20991. /** @hidden */
  20992. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20993. private _type;
  20994. /** @hidden */
  20995. _enforceAssociatedVariableName: boolean;
  20996. /** Gets the direction of the point */
  20997. get direction(): NodeMaterialConnectionPointDirection;
  20998. /** Indicates that this connection point needs dual validation before being connected to another point */
  20999. needDualDirectionValidation: boolean;
  21000. /**
  21001. * Gets or sets the additional types supported by this connection point
  21002. */
  21003. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21004. /**
  21005. * Gets or sets the additional types excluded by this connection point
  21006. */
  21007. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21008. /**
  21009. * Observable triggered when this point is connected
  21010. */
  21011. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21012. /**
  21013. * Gets or sets the associated variable name in the shader
  21014. */
  21015. get associatedVariableName(): string;
  21016. set associatedVariableName(value: string);
  21017. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21018. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21019. /**
  21020. * Gets or sets the connection point type (default is float)
  21021. */
  21022. get type(): NodeMaterialBlockConnectionPointTypes;
  21023. set type(value: NodeMaterialBlockConnectionPointTypes);
  21024. /**
  21025. * Gets or sets the connection point name
  21026. */
  21027. name: string;
  21028. /**
  21029. * Gets or sets the connection point name
  21030. */
  21031. displayName: string;
  21032. /**
  21033. * Gets or sets a boolean indicating that this connection point can be omitted
  21034. */
  21035. isOptional: boolean;
  21036. /**
  21037. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21038. */
  21039. define: string;
  21040. /** @hidden */
  21041. _prioritizeVertex: boolean;
  21042. private _target;
  21043. /** Gets or sets the target of that connection point */
  21044. get target(): NodeMaterialBlockTargets;
  21045. set target(value: NodeMaterialBlockTargets);
  21046. /**
  21047. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21048. */
  21049. get isConnected(): boolean;
  21050. /**
  21051. * Gets a boolean indicating that the current point is connected to an input block
  21052. */
  21053. get isConnectedToInputBlock(): boolean;
  21054. /**
  21055. * Gets a the connected input block (if any)
  21056. */
  21057. get connectInputBlock(): Nullable<InputBlock>;
  21058. /** Get the other side of the connection (if any) */
  21059. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21060. /** Get the block that owns this connection point */
  21061. get ownerBlock(): NodeMaterialBlock;
  21062. /** Get the block connected on the other side of this connection (if any) */
  21063. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21064. /** Get the block connected on the endpoints of this connection (if any) */
  21065. get connectedBlocks(): Array<NodeMaterialBlock>;
  21066. /** Gets the list of connected endpoints */
  21067. get endpoints(): NodeMaterialConnectionPoint[];
  21068. /** Gets a boolean indicating if that output point is connected to at least one input */
  21069. get hasEndpoints(): boolean;
  21070. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21071. get isConnectedInVertexShader(): boolean;
  21072. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21073. get isConnectedInFragmentShader(): boolean;
  21074. /**
  21075. * Creates a block suitable to be used as an input for this input point.
  21076. * If null is returned, a block based on the point type will be created.
  21077. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  21078. */
  21079. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21080. /**
  21081. * Creates a new connection point
  21082. * @param name defines the connection point name
  21083. * @param ownerBlock defines the block hosting this connection point
  21084. * @param direction defines the direction of the connection point
  21085. */
  21086. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21087. /**
  21088. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21089. * @returns the class name
  21090. */
  21091. getClassName(): string;
  21092. /**
  21093. * Gets a boolean indicating if the current point can be connected to another point
  21094. * @param connectionPoint defines the other connection point
  21095. * @returns a boolean
  21096. */
  21097. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21098. /**
  21099. * Gets a number indicating if the current point can be connected to another point
  21100. * @param connectionPoint defines the other connection point
  21101. * @returns a number defining the compatibility state
  21102. */
  21103. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21104. /**
  21105. * Connect this point to another connection point
  21106. * @param connectionPoint defines the other connection point
  21107. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21108. * @returns the current connection point
  21109. */
  21110. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21111. /**
  21112. * Disconnect this point from one of his endpoint
  21113. * @param endpoint defines the other connection point
  21114. * @returns the current connection point
  21115. */
  21116. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21117. /**
  21118. * Serializes this point in a JSON representation
  21119. * @param isInput defines if the connection point is an input (default is true)
  21120. * @returns the serialized point object
  21121. */
  21122. serialize(isInput?: boolean): any;
  21123. /**
  21124. * Release resources
  21125. */
  21126. dispose(): void;
  21127. }
  21128. }
  21129. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21130. /**
  21131. * Enum used to define the material modes
  21132. */
  21133. export enum NodeMaterialModes {
  21134. /** Regular material */
  21135. Material = 0,
  21136. /** For post process */
  21137. PostProcess = 1,
  21138. /** For particle system */
  21139. Particle = 2
  21140. }
  21141. }
  21142. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21143. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21144. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21145. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21146. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21148. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21149. import { Effect } from "babylonjs/Materials/effect";
  21150. import { Mesh } from "babylonjs/Meshes/mesh";
  21151. import { Nullable } from "babylonjs/types";
  21152. import { Texture } from "babylonjs/Materials/Textures/texture";
  21153. import { Scene } from "babylonjs/scene";
  21154. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21155. /**
  21156. * Block used to read a texture from a sampler
  21157. */
  21158. export class TextureBlock extends NodeMaterialBlock {
  21159. private _defineName;
  21160. private _linearDefineName;
  21161. private _gammaDefineName;
  21162. private _tempTextureRead;
  21163. private _samplerName;
  21164. private _transformedUVName;
  21165. private _textureTransformName;
  21166. private _textureInfoName;
  21167. private _mainUVName;
  21168. private _mainUVDefineName;
  21169. private _fragmentOnly;
  21170. /**
  21171. * Gets or sets the texture associated with the node
  21172. */
  21173. texture: Nullable<Texture>;
  21174. /**
  21175. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21176. */
  21177. convertToGammaSpace: boolean;
  21178. /**
  21179. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21180. */
  21181. convertToLinearSpace: boolean;
  21182. /**
  21183. * Create a new TextureBlock
  21184. * @param name defines the block name
  21185. */
  21186. constructor(name: string, fragmentOnly?: boolean);
  21187. /**
  21188. * Gets the current class name
  21189. * @returns the class name
  21190. */
  21191. getClassName(): string;
  21192. /**
  21193. * Gets the uv input component
  21194. */
  21195. get uv(): NodeMaterialConnectionPoint;
  21196. /**
  21197. * Gets the rgba output component
  21198. */
  21199. get rgba(): NodeMaterialConnectionPoint;
  21200. /**
  21201. * Gets the rgb output component
  21202. */
  21203. get rgb(): NodeMaterialConnectionPoint;
  21204. /**
  21205. * Gets the r output component
  21206. */
  21207. get r(): NodeMaterialConnectionPoint;
  21208. /**
  21209. * Gets the g output component
  21210. */
  21211. get g(): NodeMaterialConnectionPoint;
  21212. /**
  21213. * Gets the b output component
  21214. */
  21215. get b(): NodeMaterialConnectionPoint;
  21216. /**
  21217. * Gets the a output component
  21218. */
  21219. get a(): NodeMaterialConnectionPoint;
  21220. get target(): NodeMaterialBlockTargets;
  21221. autoConfigure(material: NodeMaterial): void;
  21222. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21223. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21224. isReady(): boolean;
  21225. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21226. private get _isMixed();
  21227. private _injectVertexCode;
  21228. private _writeTextureRead;
  21229. private _writeOutput;
  21230. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21231. protected _dumpPropertiesCode(): string;
  21232. serialize(): any;
  21233. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21234. }
  21235. }
  21236. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21237. /** @hidden */
  21238. export var reflectionFunction: {
  21239. name: string;
  21240. shader: string;
  21241. };
  21242. }
  21243. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21244. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21245. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21246. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21247. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21249. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21250. import { Effect } from "babylonjs/Materials/effect";
  21251. import { Mesh } from "babylonjs/Meshes/mesh";
  21252. import { Nullable } from "babylonjs/types";
  21253. import { Scene } from "babylonjs/scene";
  21254. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21255. /**
  21256. * Base block used to read a reflection texture from a sampler
  21257. */
  21258. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21259. /** @hidden */
  21260. _define3DName: string;
  21261. /** @hidden */
  21262. _defineCubicName: string;
  21263. /** @hidden */
  21264. _defineExplicitName: string;
  21265. /** @hidden */
  21266. _defineProjectionName: string;
  21267. /** @hidden */
  21268. _defineLocalCubicName: string;
  21269. /** @hidden */
  21270. _defineSphericalName: string;
  21271. /** @hidden */
  21272. _definePlanarName: string;
  21273. /** @hidden */
  21274. _defineEquirectangularName: string;
  21275. /** @hidden */
  21276. _defineMirroredEquirectangularFixedName: string;
  21277. /** @hidden */
  21278. _defineEquirectangularFixedName: string;
  21279. /** @hidden */
  21280. _defineSkyboxName: string;
  21281. /** @hidden */
  21282. _defineOppositeZ: string;
  21283. /** @hidden */
  21284. _cubeSamplerName: string;
  21285. /** @hidden */
  21286. _2DSamplerName: string;
  21287. protected _positionUVWName: string;
  21288. protected _directionWName: string;
  21289. protected _reflectionVectorName: string;
  21290. /** @hidden */
  21291. _reflectionCoordsName: string;
  21292. /** @hidden */
  21293. _reflectionMatrixName: string;
  21294. protected _reflectionColorName: string;
  21295. /**
  21296. * Gets or sets the texture associated with the node
  21297. */
  21298. texture: Nullable<BaseTexture>;
  21299. /**
  21300. * Create a new ReflectionTextureBaseBlock
  21301. * @param name defines the block name
  21302. */
  21303. constructor(name: string);
  21304. /**
  21305. * Gets the current class name
  21306. * @returns the class name
  21307. */
  21308. getClassName(): string;
  21309. /**
  21310. * Gets the world position input component
  21311. */
  21312. abstract get position(): NodeMaterialConnectionPoint;
  21313. /**
  21314. * Gets the world position input component
  21315. */
  21316. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21317. /**
  21318. * Gets the world normal input component
  21319. */
  21320. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21321. /**
  21322. * Gets the world input component
  21323. */
  21324. abstract get world(): NodeMaterialConnectionPoint;
  21325. /**
  21326. * Gets the camera (or eye) position component
  21327. */
  21328. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21329. /**
  21330. * Gets the view input component
  21331. */
  21332. abstract get view(): NodeMaterialConnectionPoint;
  21333. protected _getTexture(): Nullable<BaseTexture>;
  21334. autoConfigure(material: NodeMaterial): void;
  21335. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21336. isReady(): boolean;
  21337. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21338. /**
  21339. * Gets the code to inject in the vertex shader
  21340. * @param state current state of the node material building
  21341. * @returns the shader code
  21342. */
  21343. handleVertexSide(state: NodeMaterialBuildState): string;
  21344. /**
  21345. * Handles the inits for the fragment code path
  21346. * @param state node material build state
  21347. */
  21348. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21349. /**
  21350. * Generates the reflection coords code for the fragment code path
  21351. * @param worldNormalVarName name of the world normal variable
  21352. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21353. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21354. * @returns the shader code
  21355. */
  21356. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21357. /**
  21358. * Generates the reflection color code for the fragment code path
  21359. * @param lodVarName name of the lod variable
  21360. * @param swizzleLookupTexture swizzle to use for the final color variable
  21361. * @returns the shader code
  21362. */
  21363. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21364. /**
  21365. * Generates the code corresponding to the connected output points
  21366. * @param state node material build state
  21367. * @param varName name of the variable to output
  21368. * @returns the shader code
  21369. */
  21370. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21371. protected _buildBlock(state: NodeMaterialBuildState): this;
  21372. protected _dumpPropertiesCode(): string;
  21373. serialize(): any;
  21374. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21375. }
  21376. }
  21377. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21378. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21379. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21380. import { Nullable } from "babylonjs/types";
  21381. /**
  21382. * Defines a connection point to be used for points with a custom object type
  21383. */
  21384. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21385. private _blockType;
  21386. private _blockName;
  21387. private _nameForCheking?;
  21388. /**
  21389. * Creates a new connection point
  21390. * @param name defines the connection point name
  21391. * @param ownerBlock defines the block hosting this connection point
  21392. * @param direction defines the direction of the connection point
  21393. */
  21394. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21395. /**
  21396. * Gets a number indicating if the current point can be connected to another point
  21397. * @param connectionPoint defines the other connection point
  21398. * @returns a number defining the compatibility state
  21399. */
  21400. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21401. /**
  21402. * Creates a block suitable to be used as an input for this input point.
  21403. * If null is returned, a block based on the point type will be created.
  21404. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  21405. */
  21406. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21407. }
  21408. }
  21409. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21410. /**
  21411. * Enum defining the type of properties that can be edited in the property pages in the NME
  21412. */
  21413. export enum PropertyTypeForEdition {
  21414. /** property is a boolean */
  21415. Boolean = 0,
  21416. /** property is a float */
  21417. Float = 1,
  21418. /** property is a Vector2 */
  21419. Vector2 = 2,
  21420. /** property is a list of values */
  21421. List = 3
  21422. }
  21423. /**
  21424. * Interface that defines an option in a variable of type list
  21425. */
  21426. export interface IEditablePropertyListOption {
  21427. /** label of the option */
  21428. "label": string;
  21429. /** value of the option */
  21430. "value": number;
  21431. }
  21432. /**
  21433. * Interface that defines the options available for an editable property
  21434. */
  21435. export interface IEditablePropertyOption {
  21436. /** min value */
  21437. "min"?: number;
  21438. /** max value */
  21439. "max"?: number;
  21440. /** notifiers: indicates which actions to take when the property is changed */
  21441. "notifiers"?: {
  21442. /** the material should be rebuilt */
  21443. "rebuild"?: boolean;
  21444. /** the preview should be updated */
  21445. "update"?: boolean;
  21446. };
  21447. /** list of the options for a variable of type list */
  21448. "options"?: IEditablePropertyListOption[];
  21449. }
  21450. /**
  21451. * Interface that describes an editable property
  21452. */
  21453. export interface IPropertyDescriptionForEdition {
  21454. /** name of the property */
  21455. "propertyName": string;
  21456. /** display name of the property */
  21457. "displayName": string;
  21458. /** type of the property */
  21459. "type": PropertyTypeForEdition;
  21460. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21461. "groupName": string;
  21462. /** options for the property */
  21463. "options": IEditablePropertyOption;
  21464. }
  21465. /**
  21466. * Decorator that flags a property in a node material block as being editable
  21467. */
  21468. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21469. }
  21470. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21471. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21472. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21473. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21475. import { Nullable } from "babylonjs/types";
  21476. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21477. import { Mesh } from "babylonjs/Meshes/mesh";
  21478. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21479. import { Effect } from "babylonjs/Materials/effect";
  21480. import { Scene } from "babylonjs/scene";
  21481. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21482. /**
  21483. * Block used to implement the refraction part of the sub surface module of the PBR material
  21484. */
  21485. export class RefractionBlock extends NodeMaterialBlock {
  21486. /** @hidden */
  21487. _define3DName: string;
  21488. /** @hidden */
  21489. _refractionMatrixName: string;
  21490. /** @hidden */
  21491. _defineLODRefractionAlpha: string;
  21492. /** @hidden */
  21493. _defineLinearSpecularRefraction: string;
  21494. /** @hidden */
  21495. _defineOppositeZ: string;
  21496. /** @hidden */
  21497. _cubeSamplerName: string;
  21498. /** @hidden */
  21499. _2DSamplerName: string;
  21500. /** @hidden */
  21501. _vRefractionMicrosurfaceInfosName: string;
  21502. /** @hidden */
  21503. _vRefractionInfosName: string;
  21504. private _scene;
  21505. /**
  21506. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21507. * Materials half opaque for instance using refraction could benefit from this control.
  21508. */
  21509. linkRefractionWithTransparency: boolean;
  21510. /**
  21511. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21512. */
  21513. invertRefractionY: boolean;
  21514. /**
  21515. * Gets or sets the texture associated with the node
  21516. */
  21517. texture: Nullable<BaseTexture>;
  21518. /**
  21519. * Create a new RefractionBlock
  21520. * @param name defines the block name
  21521. */
  21522. constructor(name: string);
  21523. /**
  21524. * Gets the current class name
  21525. * @returns the class name
  21526. */
  21527. getClassName(): string;
  21528. /**
  21529. * Gets the intensity input component
  21530. */
  21531. get intensity(): NodeMaterialConnectionPoint;
  21532. /**
  21533. * Gets the index of refraction input component
  21534. */
  21535. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21536. /**
  21537. * Gets the tint at distance input component
  21538. */
  21539. get tintAtDistance(): NodeMaterialConnectionPoint;
  21540. /**
  21541. * Gets the view input component
  21542. */
  21543. get view(): NodeMaterialConnectionPoint;
  21544. /**
  21545. * Gets the refraction object output component
  21546. */
  21547. get refraction(): NodeMaterialConnectionPoint;
  21548. /**
  21549. * Returns true if the block has a texture
  21550. */
  21551. get hasTexture(): boolean;
  21552. protected _getTexture(): Nullable<BaseTexture>;
  21553. autoConfigure(material: NodeMaterial): void;
  21554. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21555. isReady(): boolean;
  21556. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21557. /**
  21558. * Gets the main code of the block (fragment side)
  21559. * @param state current state of the node material building
  21560. * @returns the shader code
  21561. */
  21562. getCode(state: NodeMaterialBuildState): string;
  21563. protected _buildBlock(state: NodeMaterialBuildState): this;
  21564. protected _dumpPropertiesCode(): string;
  21565. serialize(): any;
  21566. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21567. }
  21568. }
  21569. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21570. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21571. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21572. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21573. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21575. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21576. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21577. import { Nullable } from "babylonjs/types";
  21578. import { Scene } from "babylonjs/scene";
  21579. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21580. /**
  21581. * Base block used as input for post process
  21582. */
  21583. export class CurrentScreenBlock extends NodeMaterialBlock {
  21584. private _samplerName;
  21585. private _linearDefineName;
  21586. private _gammaDefineName;
  21587. private _mainUVName;
  21588. private _tempTextureRead;
  21589. /**
  21590. * Gets or sets the texture associated with the node
  21591. */
  21592. texture: Nullable<BaseTexture>;
  21593. /**
  21594. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21595. */
  21596. convertToGammaSpace: boolean;
  21597. /**
  21598. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21599. */
  21600. convertToLinearSpace: boolean;
  21601. /**
  21602. * Create a new CurrentScreenBlock
  21603. * @param name defines the block name
  21604. */
  21605. constructor(name: string);
  21606. /**
  21607. * Gets the current class name
  21608. * @returns the class name
  21609. */
  21610. getClassName(): string;
  21611. /**
  21612. * Gets the uv input component
  21613. */
  21614. get uv(): NodeMaterialConnectionPoint;
  21615. /**
  21616. * Gets the rgba output component
  21617. */
  21618. get rgba(): NodeMaterialConnectionPoint;
  21619. /**
  21620. * Gets the rgb output component
  21621. */
  21622. get rgb(): NodeMaterialConnectionPoint;
  21623. /**
  21624. * Gets the r output component
  21625. */
  21626. get r(): NodeMaterialConnectionPoint;
  21627. /**
  21628. * Gets the g output component
  21629. */
  21630. get g(): NodeMaterialConnectionPoint;
  21631. /**
  21632. * Gets the b output component
  21633. */
  21634. get b(): NodeMaterialConnectionPoint;
  21635. /**
  21636. * Gets the a output component
  21637. */
  21638. get a(): NodeMaterialConnectionPoint;
  21639. /**
  21640. * Initialize the block and prepare the context for build
  21641. * @param state defines the state that will be used for the build
  21642. */
  21643. initialize(state: NodeMaterialBuildState): void;
  21644. get target(): NodeMaterialBlockTargets;
  21645. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21646. isReady(): boolean;
  21647. private _injectVertexCode;
  21648. private _writeTextureRead;
  21649. private _writeOutput;
  21650. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21651. serialize(): any;
  21652. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21653. }
  21654. }
  21655. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21656. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21657. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21658. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21660. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21661. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21662. import { Nullable } from "babylonjs/types";
  21663. import { Scene } from "babylonjs/scene";
  21664. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21665. /**
  21666. * Base block used for the particle texture
  21667. */
  21668. export class ParticleTextureBlock extends NodeMaterialBlock {
  21669. private _samplerName;
  21670. private _linearDefineName;
  21671. private _gammaDefineName;
  21672. private _tempTextureRead;
  21673. /**
  21674. * Gets or sets the texture associated with the node
  21675. */
  21676. texture: Nullable<BaseTexture>;
  21677. /**
  21678. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21679. */
  21680. convertToGammaSpace: boolean;
  21681. /**
  21682. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21683. */
  21684. convertToLinearSpace: boolean;
  21685. /**
  21686. * Create a new ParticleTextureBlock
  21687. * @param name defines the block name
  21688. */
  21689. constructor(name: string);
  21690. /**
  21691. * Gets the current class name
  21692. * @returns the class name
  21693. */
  21694. getClassName(): string;
  21695. /**
  21696. * Gets the uv input component
  21697. */
  21698. get uv(): NodeMaterialConnectionPoint;
  21699. /**
  21700. * Gets the rgba output component
  21701. */
  21702. get rgba(): NodeMaterialConnectionPoint;
  21703. /**
  21704. * Gets the rgb output component
  21705. */
  21706. get rgb(): NodeMaterialConnectionPoint;
  21707. /**
  21708. * Gets the r output component
  21709. */
  21710. get r(): NodeMaterialConnectionPoint;
  21711. /**
  21712. * Gets the g output component
  21713. */
  21714. get g(): NodeMaterialConnectionPoint;
  21715. /**
  21716. * Gets the b output component
  21717. */
  21718. get b(): NodeMaterialConnectionPoint;
  21719. /**
  21720. * Gets the a output component
  21721. */
  21722. get a(): NodeMaterialConnectionPoint;
  21723. /**
  21724. * Initialize the block and prepare the context for build
  21725. * @param state defines the state that will be used for the build
  21726. */
  21727. initialize(state: NodeMaterialBuildState): void;
  21728. autoConfigure(material: NodeMaterial): void;
  21729. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21730. isReady(): boolean;
  21731. private _writeOutput;
  21732. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21733. serialize(): any;
  21734. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21735. }
  21736. }
  21737. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21738. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21739. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21740. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21741. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  21742. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  21743. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  21744. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  21745. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  21746. import { Scene } from "babylonjs/scene";
  21747. /**
  21748. * Class used to store shared data between 2 NodeMaterialBuildState
  21749. */
  21750. export class NodeMaterialBuildStateSharedData {
  21751. /**
  21752. * Gets the list of emitted varyings
  21753. */
  21754. temps: string[];
  21755. /**
  21756. * Gets the list of emitted varyings
  21757. */
  21758. varyings: string[];
  21759. /**
  21760. * Gets the varying declaration string
  21761. */
  21762. varyingDeclaration: string;
  21763. /**
  21764. * Input blocks
  21765. */
  21766. inputBlocks: InputBlock[];
  21767. /**
  21768. * Input blocks
  21769. */
  21770. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21771. /**
  21772. * Bindable blocks (Blocks that need to set data to the effect)
  21773. */
  21774. bindableBlocks: NodeMaterialBlock[];
  21775. /**
  21776. * List of blocks that can provide a compilation fallback
  21777. */
  21778. blocksWithFallbacks: NodeMaterialBlock[];
  21779. /**
  21780. * List of blocks that can provide a define update
  21781. */
  21782. blocksWithDefines: NodeMaterialBlock[];
  21783. /**
  21784. * List of blocks that can provide a repeatable content
  21785. */
  21786. repeatableContentBlocks: NodeMaterialBlock[];
  21787. /**
  21788. * List of blocks that can provide a dynamic list of uniforms
  21789. */
  21790. dynamicUniformBlocks: NodeMaterialBlock[];
  21791. /**
  21792. * List of blocks that can block the isReady function for the material
  21793. */
  21794. blockingBlocks: NodeMaterialBlock[];
  21795. /**
  21796. * Gets the list of animated inputs
  21797. */
  21798. animatedInputs: InputBlock[];
  21799. /**
  21800. * Build Id used to avoid multiple recompilations
  21801. */
  21802. buildId: number;
  21803. /** List of emitted variables */
  21804. variableNames: {
  21805. [key: string]: number;
  21806. };
  21807. /** List of emitted defines */
  21808. defineNames: {
  21809. [key: string]: number;
  21810. };
  21811. /** Should emit comments? */
  21812. emitComments: boolean;
  21813. /** Emit build activity */
  21814. verbose: boolean;
  21815. /** Gets or sets the hosting scene */
  21816. scene: Scene;
  21817. /**
  21818. * Gets the compilation hints emitted at compilation time
  21819. */
  21820. hints: {
  21821. needWorldViewMatrix: boolean;
  21822. needWorldViewProjectionMatrix: boolean;
  21823. needAlphaBlending: boolean;
  21824. needAlphaTesting: boolean;
  21825. };
  21826. /**
  21827. * List of compilation checks
  21828. */
  21829. checks: {
  21830. emitVertex: boolean;
  21831. emitFragment: boolean;
  21832. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21833. };
  21834. /**
  21835. * Is vertex program allowed to be empty?
  21836. */
  21837. allowEmptyVertexProgram: boolean;
  21838. /** Creates a new shared data */
  21839. constructor();
  21840. /**
  21841. * Emits console errors and exceptions if there is a failing check
  21842. */
  21843. emitErrors(): void;
  21844. }
  21845. }
  21846. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  21847. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21848. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21849. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  21850. /**
  21851. * Class used to store node based material build state
  21852. */
  21853. export class NodeMaterialBuildState {
  21854. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21855. supportUniformBuffers: boolean;
  21856. /**
  21857. * Gets the list of emitted attributes
  21858. */
  21859. attributes: string[];
  21860. /**
  21861. * Gets the list of emitted uniforms
  21862. */
  21863. uniforms: string[];
  21864. /**
  21865. * Gets the list of emitted constants
  21866. */
  21867. constants: string[];
  21868. /**
  21869. * Gets the list of emitted samplers
  21870. */
  21871. samplers: string[];
  21872. /**
  21873. * Gets the list of emitted functions
  21874. */
  21875. functions: {
  21876. [key: string]: string;
  21877. };
  21878. /**
  21879. * Gets the list of emitted extensions
  21880. */
  21881. extensions: {
  21882. [key: string]: string;
  21883. };
  21884. /**
  21885. * Gets the target of the compilation state
  21886. */
  21887. target: NodeMaterialBlockTargets;
  21888. /**
  21889. * Gets the list of emitted counters
  21890. */
  21891. counters: {
  21892. [key: string]: number;
  21893. };
  21894. /**
  21895. * Shared data between multiple NodeMaterialBuildState instances
  21896. */
  21897. sharedData: NodeMaterialBuildStateSharedData;
  21898. /** @hidden */
  21899. _vertexState: NodeMaterialBuildState;
  21900. /** @hidden */
  21901. _attributeDeclaration: string;
  21902. /** @hidden */
  21903. _uniformDeclaration: string;
  21904. /** @hidden */
  21905. _constantDeclaration: string;
  21906. /** @hidden */
  21907. _samplerDeclaration: string;
  21908. /** @hidden */
  21909. _varyingTransfer: string;
  21910. /** @hidden */
  21911. _injectAtEnd: string;
  21912. private _repeatableContentAnchorIndex;
  21913. /** @hidden */
  21914. _builtCompilationString: string;
  21915. /**
  21916. * Gets the emitted compilation strings
  21917. */
  21918. compilationString: string;
  21919. /**
  21920. * Finalize the compilation strings
  21921. * @param state defines the current compilation state
  21922. */
  21923. finalize(state: NodeMaterialBuildState): void;
  21924. /** @hidden */
  21925. get _repeatableContentAnchor(): string;
  21926. /** @hidden */
  21927. _getFreeVariableName(prefix: string): string;
  21928. /** @hidden */
  21929. _getFreeDefineName(prefix: string): string;
  21930. /** @hidden */
  21931. _excludeVariableName(name: string): void;
  21932. /** @hidden */
  21933. _emit2DSampler(name: string): void;
  21934. /** @hidden */
  21935. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21936. /** @hidden */
  21937. _emitExtension(name: string, extension: string, define?: string): void;
  21938. /** @hidden */
  21939. _emitFunction(name: string, code: string, comments: string): void;
  21940. /** @hidden */
  21941. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21942. replaceStrings?: {
  21943. search: RegExp;
  21944. replace: string;
  21945. }[];
  21946. repeatKey?: string;
  21947. }): string;
  21948. /** @hidden */
  21949. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21950. repeatKey?: string;
  21951. removeAttributes?: boolean;
  21952. removeUniforms?: boolean;
  21953. removeVaryings?: boolean;
  21954. removeIfDef?: boolean;
  21955. replaceStrings?: {
  21956. search: RegExp;
  21957. replace: string;
  21958. }[];
  21959. }, storeKey?: string): void;
  21960. /** @hidden */
  21961. _registerTempVariable(name: string): boolean;
  21962. /** @hidden */
  21963. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21964. /** @hidden */
  21965. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21966. /** @hidden */
  21967. _emitFloat(value: number): string;
  21968. }
  21969. }
  21970. declare module "babylonjs/Misc/uniqueIdGenerator" {
  21971. /**
  21972. * Helper class used to generate session unique ID
  21973. */
  21974. export class UniqueIdGenerator {
  21975. private static _UniqueIdCounter;
  21976. /**
  21977. * Gets an unique (relatively to the current scene) Id
  21978. */
  21979. static get UniqueId(): number;
  21980. }
  21981. }
  21982. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  21983. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21984. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21985. import { Nullable } from "babylonjs/types";
  21986. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21987. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21988. import { Effect } from "babylonjs/Materials/effect";
  21989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21990. import { Mesh } from "babylonjs/Meshes/mesh";
  21991. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21992. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21993. import { Scene } from "babylonjs/scene";
  21994. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21995. /**
  21996. * Defines a block that can be used inside a node based material
  21997. */
  21998. export class NodeMaterialBlock {
  21999. private _buildId;
  22000. private _buildTarget;
  22001. private _target;
  22002. private _isFinalMerger;
  22003. private _isInput;
  22004. protected _isUnique: boolean;
  22005. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22006. inputsAreExclusive: boolean;
  22007. /** @hidden */
  22008. _codeVariableName: string;
  22009. /** @hidden */
  22010. _inputs: NodeMaterialConnectionPoint[];
  22011. /** @hidden */
  22012. _outputs: NodeMaterialConnectionPoint[];
  22013. /** @hidden */
  22014. _preparationId: number;
  22015. /**
  22016. * Gets or sets the name of the block
  22017. */
  22018. name: string;
  22019. /**
  22020. * Gets or sets the unique id of the node
  22021. */
  22022. uniqueId: number;
  22023. /**
  22024. * Gets or sets the comments associated with this block
  22025. */
  22026. comments: string;
  22027. /**
  22028. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22029. */
  22030. get isUnique(): boolean;
  22031. /**
  22032. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22033. */
  22034. get isFinalMerger(): boolean;
  22035. /**
  22036. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22037. */
  22038. get isInput(): boolean;
  22039. /**
  22040. * Gets or sets the build Id
  22041. */
  22042. get buildId(): number;
  22043. set buildId(value: number);
  22044. /**
  22045. * Gets or sets the target of the block
  22046. */
  22047. get target(): NodeMaterialBlockTargets;
  22048. set target(value: NodeMaterialBlockTargets);
  22049. /**
  22050. * Gets the list of input points
  22051. */
  22052. get inputs(): NodeMaterialConnectionPoint[];
  22053. /** Gets the list of output points */
  22054. get outputs(): NodeMaterialConnectionPoint[];
  22055. /**
  22056. * Find an input by its name
  22057. * @param name defines the name of the input to look for
  22058. * @returns the input or null if not found
  22059. */
  22060. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22061. /**
  22062. * Find an output by its name
  22063. * @param name defines the name of the outputto look for
  22064. * @returns the output or null if not found
  22065. */
  22066. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22067. /**
  22068. * Creates a new NodeMaterialBlock
  22069. * @param name defines the block name
  22070. * @param target defines the target of that block (Vertex by default)
  22071. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22072. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22073. */
  22074. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22075. /**
  22076. * Initialize the block and prepare the context for build
  22077. * @param state defines the state that will be used for the build
  22078. */
  22079. initialize(state: NodeMaterialBuildState): void;
  22080. /**
  22081. * Bind data to effect. Will only be called for blocks with isBindable === true
  22082. * @param effect defines the effect to bind data to
  22083. * @param nodeMaterial defines the hosting NodeMaterial
  22084. * @param mesh defines the mesh that will be rendered
  22085. * @param subMesh defines the submesh that will be rendered
  22086. */
  22087. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22088. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22089. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22090. protected _writeFloat(value: number): string;
  22091. /**
  22092. * Gets the current class name e.g. "NodeMaterialBlock"
  22093. * @returns the class name
  22094. */
  22095. getClassName(): string;
  22096. /**
  22097. * Register a new input. Must be called inside a block constructor
  22098. * @param name defines the connection point name
  22099. * @param type defines the connection point type
  22100. * @param isOptional defines a boolean indicating that this input can be omitted
  22101. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22102. * @param point an already created connection point. If not provided, create a new one
  22103. * @returns the current block
  22104. */
  22105. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22106. /**
  22107. * Register a new output. Must be called inside a block constructor
  22108. * @param name defines the connection point name
  22109. * @param type defines the connection point type
  22110. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22111. * @param point an already created connection point. If not provided, create a new one
  22112. * @returns the current block
  22113. */
  22114. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22115. /**
  22116. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22117. * @param forOutput defines an optional connection point to check compatibility with
  22118. * @returns the first available input or null
  22119. */
  22120. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22121. /**
  22122. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22123. * @param forBlock defines an optional block to check compatibility with
  22124. * @returns the first available input or null
  22125. */
  22126. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22127. /**
  22128. * Gets the sibling of the given output
  22129. * @param current defines the current output
  22130. * @returns the next output in the list or null
  22131. */
  22132. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22133. /**
  22134. * Connect current block with another block
  22135. * @param other defines the block to connect with
  22136. * @param options define the various options to help pick the right connections
  22137. * @returns the current block
  22138. */
  22139. connectTo(other: NodeMaterialBlock, options?: {
  22140. input?: string;
  22141. output?: string;
  22142. outputSwizzle?: string;
  22143. }): this | undefined;
  22144. protected _buildBlock(state: NodeMaterialBuildState): void;
  22145. /**
  22146. * Add uniforms, samplers and uniform buffers at compilation time
  22147. * @param state defines the state to update
  22148. * @param nodeMaterial defines the node material requesting the update
  22149. * @param defines defines the material defines to update
  22150. * @param uniformBuffers defines the list of uniform buffer names
  22151. */
  22152. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22153. /**
  22154. * Add potential fallbacks if shader compilation fails
  22155. * @param mesh defines the mesh to be rendered
  22156. * @param fallbacks defines the current prioritized list of fallbacks
  22157. */
  22158. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22159. /**
  22160. * Initialize defines for shader compilation
  22161. * @param mesh defines the mesh to be rendered
  22162. * @param nodeMaterial defines the node material requesting the update
  22163. * @param defines defines the material defines to update
  22164. * @param useInstances specifies that instances should be used
  22165. */
  22166. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22167. /**
  22168. * Update defines for shader compilation
  22169. * @param mesh defines the mesh to be rendered
  22170. * @param nodeMaterial defines the node material requesting the update
  22171. * @param defines defines the material defines to update
  22172. * @param useInstances specifies that instances should be used
  22173. * @param subMesh defines which submesh to render
  22174. */
  22175. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22176. /**
  22177. * Lets the block try to connect some inputs automatically
  22178. * @param material defines the hosting NodeMaterial
  22179. */
  22180. autoConfigure(material: NodeMaterial): void;
  22181. /**
  22182. * Function called when a block is declared as repeatable content generator
  22183. * @param vertexShaderState defines the current compilation state for the vertex shader
  22184. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22185. * @param mesh defines the mesh to be rendered
  22186. * @param defines defines the material defines to update
  22187. */
  22188. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22189. /**
  22190. * Checks if the block is ready
  22191. * @param mesh defines the mesh to be rendered
  22192. * @param nodeMaterial defines the node material requesting the update
  22193. * @param defines defines the material defines to update
  22194. * @param useInstances specifies that instances should be used
  22195. * @returns true if the block is ready
  22196. */
  22197. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22198. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22199. private _processBuild;
  22200. /**
  22201. * Compile the current node and generate the shader code
  22202. * @param state defines the current compilation state (uniforms, samplers, current string)
  22203. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22204. * @returns true if already built
  22205. */
  22206. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22207. protected _inputRename(name: string): string;
  22208. protected _outputRename(name: string): string;
  22209. protected _dumpPropertiesCode(): string;
  22210. /** @hidden */
  22211. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22212. /** @hidden */
  22213. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22214. /**
  22215. * Clone the current block to a new identical block
  22216. * @param scene defines the hosting scene
  22217. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22218. * @returns a copy of the current block
  22219. */
  22220. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22221. /**
  22222. * Serializes this block in a JSON representation
  22223. * @returns the serialized block object
  22224. */
  22225. serialize(): any;
  22226. /** @hidden */
  22227. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22228. private _deserializePortDisplayNames;
  22229. /**
  22230. * Release resources
  22231. */
  22232. dispose(): void;
  22233. }
  22234. }
  22235. declare module "babylonjs/Materials/pushMaterial" {
  22236. import { Nullable } from "babylonjs/types";
  22237. import { Scene } from "babylonjs/scene";
  22238. import { Matrix } from "babylonjs/Maths/math.vector";
  22239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22240. import { Mesh } from "babylonjs/Meshes/mesh";
  22241. import { Material } from "babylonjs/Materials/material";
  22242. import { Effect } from "babylonjs/Materials/effect";
  22243. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22244. /**
  22245. * Base class of materials working in push mode in babylon JS
  22246. * @hidden
  22247. */
  22248. export class PushMaterial extends Material {
  22249. protected _activeEffect: Effect;
  22250. protected _normalMatrix: Matrix;
  22251. /**
  22252. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  22253. * This means that the material can keep using a previous shader while a new one is being compiled.
  22254. * This is mostly used when shader parallel compilation is supported (true by default)
  22255. */
  22256. allowShaderHotSwapping: boolean;
  22257. constructor(name: string, scene: Scene);
  22258. getEffect(): Effect;
  22259. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22260. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22261. /**
  22262. * Binds the given world matrix to the active effect
  22263. *
  22264. * @param world the matrix to bind
  22265. */
  22266. bindOnlyWorldMatrix(world: Matrix): void;
  22267. /**
  22268. * Binds the given normal matrix to the active effect
  22269. *
  22270. * @param normalMatrix the matrix to bind
  22271. */
  22272. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22273. bind(world: Matrix, mesh?: Mesh): void;
  22274. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22275. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22276. }
  22277. }
  22278. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22279. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22280. /**
  22281. * Root class for all node material optimizers
  22282. */
  22283. export class NodeMaterialOptimizer {
  22284. /**
  22285. * Function used to optimize a NodeMaterial graph
  22286. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22287. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22288. */
  22289. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22290. }
  22291. }
  22292. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22293. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22294. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22295. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22296. import { Scene } from "babylonjs/scene";
  22297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22298. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22299. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22300. /**
  22301. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22302. */
  22303. export class TransformBlock extends NodeMaterialBlock {
  22304. /**
  22305. * Defines the value to use to complement W value to transform it to a Vector4
  22306. */
  22307. complementW: number;
  22308. /**
  22309. * Defines the value to use to complement z value to transform it to a Vector4
  22310. */
  22311. complementZ: number;
  22312. /**
  22313. * Creates a new TransformBlock
  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 vector input
  22324. */
  22325. get vector(): NodeMaterialConnectionPoint;
  22326. /**
  22327. * Gets the output component
  22328. */
  22329. get output(): NodeMaterialConnectionPoint;
  22330. /**
  22331. * Gets the xyz output component
  22332. */
  22333. get xyz(): NodeMaterialConnectionPoint;
  22334. /**
  22335. * Gets the matrix transform input
  22336. */
  22337. get transform(): NodeMaterialConnectionPoint;
  22338. protected _buildBlock(state: NodeMaterialBuildState): this;
  22339. /**
  22340. * Update defines for shader compilation
  22341. * @param mesh defines the mesh to be rendered
  22342. * @param nodeMaterial defines the node material requesting the update
  22343. * @param defines defines the material defines to update
  22344. * @param useInstances specifies that instances should be used
  22345. * @param subMesh defines which submesh to render
  22346. */
  22347. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22348. serialize(): any;
  22349. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22350. protected _dumpPropertiesCode(): string;
  22351. }
  22352. }
  22353. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22354. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22355. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22356. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22357. /**
  22358. * Block used to output the vertex position
  22359. */
  22360. export class VertexOutputBlock extends NodeMaterialBlock {
  22361. /**
  22362. * Creates a new VertexOutputBlock
  22363. * @param name defines the block name
  22364. */
  22365. constructor(name: string);
  22366. /**
  22367. * Gets the current class name
  22368. * @returns the class name
  22369. */
  22370. getClassName(): string;
  22371. /**
  22372. * Gets the vector input component
  22373. */
  22374. get vector(): NodeMaterialConnectionPoint;
  22375. protected _buildBlock(state: NodeMaterialBuildState): this;
  22376. }
  22377. }
  22378. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22379. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22380. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22381. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22382. /**
  22383. * Block used to output the final color
  22384. */
  22385. export class FragmentOutputBlock extends NodeMaterialBlock {
  22386. /**
  22387. * Create a new FragmentOutputBlock
  22388. * @param name defines the block name
  22389. */
  22390. constructor(name: string);
  22391. /**
  22392. * Gets the current class name
  22393. * @returns the class name
  22394. */
  22395. getClassName(): string;
  22396. /**
  22397. * Gets the rgba input component
  22398. */
  22399. get rgba(): NodeMaterialConnectionPoint;
  22400. /**
  22401. * Gets the rgb input component
  22402. */
  22403. get rgb(): NodeMaterialConnectionPoint;
  22404. /**
  22405. * Gets the a input component
  22406. */
  22407. get a(): NodeMaterialConnectionPoint;
  22408. protected _buildBlock(state: NodeMaterialBuildState): this;
  22409. }
  22410. }
  22411. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22412. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22413. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22414. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22415. /**
  22416. * Block used for the particle ramp gradient section
  22417. */
  22418. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22419. /**
  22420. * Create a new ParticleRampGradientBlock
  22421. * @param name defines the block name
  22422. */
  22423. constructor(name: string);
  22424. /**
  22425. * Gets the current class name
  22426. * @returns the class name
  22427. */
  22428. getClassName(): string;
  22429. /**
  22430. * Gets the color input component
  22431. */
  22432. get color(): NodeMaterialConnectionPoint;
  22433. /**
  22434. * Gets the rampColor output component
  22435. */
  22436. get rampColor(): NodeMaterialConnectionPoint;
  22437. /**
  22438. * Initialize the block and prepare the context for build
  22439. * @param state defines the state that will be used for the build
  22440. */
  22441. initialize(state: NodeMaterialBuildState): void;
  22442. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22443. }
  22444. }
  22445. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22446. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22447. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22448. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22449. /**
  22450. * Block used for the particle blend multiply section
  22451. */
  22452. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22453. /**
  22454. * Create a new ParticleBlendMultiplyBlock
  22455. * @param name defines the block name
  22456. */
  22457. constructor(name: string);
  22458. /**
  22459. * Gets the current class name
  22460. * @returns the class name
  22461. */
  22462. getClassName(): string;
  22463. /**
  22464. * Gets the color input component
  22465. */
  22466. get color(): NodeMaterialConnectionPoint;
  22467. /**
  22468. * Gets the alphaTexture input component
  22469. */
  22470. get alphaTexture(): NodeMaterialConnectionPoint;
  22471. /**
  22472. * Gets the alphaColor input component
  22473. */
  22474. get alphaColor(): NodeMaterialConnectionPoint;
  22475. /**
  22476. * Gets the blendColor output component
  22477. */
  22478. get blendColor(): NodeMaterialConnectionPoint;
  22479. /**
  22480. * Initialize the block and prepare the context for build
  22481. * @param state defines the state that will be used for the build
  22482. */
  22483. initialize(state: NodeMaterialBuildState): void;
  22484. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22485. }
  22486. }
  22487. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22488. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22489. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22490. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22491. /**
  22492. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22493. */
  22494. export class VectorMergerBlock extends NodeMaterialBlock {
  22495. /**
  22496. * Create a new VectorMergerBlock
  22497. * @param name defines the block name
  22498. */
  22499. constructor(name: string);
  22500. /**
  22501. * Gets the current class name
  22502. * @returns the class name
  22503. */
  22504. getClassName(): string;
  22505. /**
  22506. * Gets the xyz component (input)
  22507. */
  22508. get xyzIn(): NodeMaterialConnectionPoint;
  22509. /**
  22510. * Gets the xy component (input)
  22511. */
  22512. get xyIn(): NodeMaterialConnectionPoint;
  22513. /**
  22514. * Gets the x component (input)
  22515. */
  22516. get x(): NodeMaterialConnectionPoint;
  22517. /**
  22518. * Gets the y component (input)
  22519. */
  22520. get y(): NodeMaterialConnectionPoint;
  22521. /**
  22522. * Gets the z component (input)
  22523. */
  22524. get z(): NodeMaterialConnectionPoint;
  22525. /**
  22526. * Gets the w component (input)
  22527. */
  22528. get w(): NodeMaterialConnectionPoint;
  22529. /**
  22530. * Gets the xyzw component (output)
  22531. */
  22532. get xyzw(): NodeMaterialConnectionPoint;
  22533. /**
  22534. * Gets the xyz component (output)
  22535. */
  22536. get xyzOut(): NodeMaterialConnectionPoint;
  22537. /**
  22538. * Gets the xy component (output)
  22539. */
  22540. get xyOut(): NodeMaterialConnectionPoint;
  22541. /**
  22542. * Gets the xy component (output)
  22543. * @deprecated Please use xyOut instead.
  22544. */
  22545. get xy(): NodeMaterialConnectionPoint;
  22546. /**
  22547. * Gets the xyz component (output)
  22548. * @deprecated Please use xyzOut instead.
  22549. */
  22550. get xyz(): NodeMaterialConnectionPoint;
  22551. protected _buildBlock(state: NodeMaterialBuildState): this;
  22552. }
  22553. }
  22554. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22555. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22556. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22557. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22558. import { Vector2 } from "babylonjs/Maths/math.vector";
  22559. import { Scene } from "babylonjs/scene";
  22560. /**
  22561. * Block used to remap a float from a range to a new one
  22562. */
  22563. export class RemapBlock extends NodeMaterialBlock {
  22564. /**
  22565. * Gets or sets the source range
  22566. */
  22567. sourceRange: Vector2;
  22568. /**
  22569. * Gets or sets the target range
  22570. */
  22571. targetRange: Vector2;
  22572. /**
  22573. * Creates a new RemapBlock
  22574. * @param name defines the block name
  22575. */
  22576. constructor(name: string);
  22577. /**
  22578. * Gets the current class name
  22579. * @returns the class name
  22580. */
  22581. getClassName(): string;
  22582. /**
  22583. * Gets the input component
  22584. */
  22585. get input(): NodeMaterialConnectionPoint;
  22586. /**
  22587. * Gets the source min input component
  22588. */
  22589. get sourceMin(): NodeMaterialConnectionPoint;
  22590. /**
  22591. * Gets the source max input component
  22592. */
  22593. get sourceMax(): NodeMaterialConnectionPoint;
  22594. /**
  22595. * Gets the target min input component
  22596. */
  22597. get targetMin(): NodeMaterialConnectionPoint;
  22598. /**
  22599. * Gets the target max input component
  22600. */
  22601. get targetMax(): NodeMaterialConnectionPoint;
  22602. /**
  22603. * Gets the output component
  22604. */
  22605. get output(): NodeMaterialConnectionPoint;
  22606. protected _buildBlock(state: NodeMaterialBuildState): this;
  22607. protected _dumpPropertiesCode(): string;
  22608. serialize(): any;
  22609. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22610. }
  22611. }
  22612. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22613. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22614. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22615. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22616. /**
  22617. * Block used to multiply 2 values
  22618. */
  22619. export class MultiplyBlock extends NodeMaterialBlock {
  22620. /**
  22621. * Creates a new MultiplyBlock
  22622. * @param name defines the block name
  22623. */
  22624. constructor(name: string);
  22625. /**
  22626. * Gets the current class name
  22627. * @returns the class name
  22628. */
  22629. getClassName(): string;
  22630. /**
  22631. * Gets the left operand input component
  22632. */
  22633. get left(): NodeMaterialConnectionPoint;
  22634. /**
  22635. * Gets the right operand input component
  22636. */
  22637. get right(): NodeMaterialConnectionPoint;
  22638. /**
  22639. * Gets the output component
  22640. */
  22641. get output(): NodeMaterialConnectionPoint;
  22642. protected _buildBlock(state: NodeMaterialBuildState): this;
  22643. }
  22644. }
  22645. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22646. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22647. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22648. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22649. /**
  22650. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22651. */
  22652. export class ColorSplitterBlock extends NodeMaterialBlock {
  22653. /**
  22654. * Create a new ColorSplitterBlock
  22655. * @param name defines the block name
  22656. */
  22657. constructor(name: string);
  22658. /**
  22659. * Gets the current class name
  22660. * @returns the class name
  22661. */
  22662. getClassName(): string;
  22663. /**
  22664. * Gets the rgba component (input)
  22665. */
  22666. get rgba(): NodeMaterialConnectionPoint;
  22667. /**
  22668. * Gets the rgb component (input)
  22669. */
  22670. get rgbIn(): NodeMaterialConnectionPoint;
  22671. /**
  22672. * Gets the rgb component (output)
  22673. */
  22674. get rgbOut(): NodeMaterialConnectionPoint;
  22675. /**
  22676. * Gets the r component (output)
  22677. */
  22678. get r(): NodeMaterialConnectionPoint;
  22679. /**
  22680. * Gets the g component (output)
  22681. */
  22682. get g(): NodeMaterialConnectionPoint;
  22683. /**
  22684. * Gets the b component (output)
  22685. */
  22686. get b(): NodeMaterialConnectionPoint;
  22687. /**
  22688. * Gets the a component (output)
  22689. */
  22690. get a(): NodeMaterialConnectionPoint;
  22691. protected _inputRename(name: string): string;
  22692. protected _outputRename(name: string): string;
  22693. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22694. }
  22695. }
  22696. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22697. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22698. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22699. import { Scene } from "babylonjs/scene";
  22700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22701. import { Matrix } from "babylonjs/Maths/math.vector";
  22702. import { Mesh } from "babylonjs/Meshes/mesh";
  22703. import { Engine } from "babylonjs/Engines/engine";
  22704. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22705. import { Observable } from "babylonjs/Misc/observable";
  22706. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22707. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22708. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22709. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22710. import { Nullable } from "babylonjs/types";
  22711. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22712. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22713. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22714. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22715. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22716. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22717. import { Effect } from "babylonjs/Materials/effect";
  22718. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22719. import { Camera } from "babylonjs/Cameras/camera";
  22720. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22721. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22722. /**
  22723. * Interface used to configure the node material editor
  22724. */
  22725. export interface INodeMaterialEditorOptions {
  22726. /** Define the URl to load node editor script */
  22727. editorURL?: string;
  22728. }
  22729. /** @hidden */
  22730. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22731. NORMAL: boolean;
  22732. TANGENT: boolean;
  22733. UV1: boolean;
  22734. /** BONES */
  22735. NUM_BONE_INFLUENCERS: number;
  22736. BonesPerMesh: number;
  22737. BONETEXTURE: boolean;
  22738. /** MORPH TARGETS */
  22739. MORPHTARGETS: boolean;
  22740. MORPHTARGETS_NORMAL: boolean;
  22741. MORPHTARGETS_TANGENT: boolean;
  22742. MORPHTARGETS_UV: boolean;
  22743. NUM_MORPH_INFLUENCERS: number;
  22744. /** IMAGE PROCESSING */
  22745. IMAGEPROCESSING: boolean;
  22746. VIGNETTE: boolean;
  22747. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22748. VIGNETTEBLENDMODEOPAQUE: boolean;
  22749. TONEMAPPING: boolean;
  22750. TONEMAPPING_ACES: boolean;
  22751. CONTRAST: boolean;
  22752. EXPOSURE: boolean;
  22753. COLORCURVES: boolean;
  22754. COLORGRADING: boolean;
  22755. COLORGRADING3D: boolean;
  22756. SAMPLER3DGREENDEPTH: boolean;
  22757. SAMPLER3DBGRMAP: boolean;
  22758. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22759. /** MISC. */
  22760. BUMPDIRECTUV: number;
  22761. constructor();
  22762. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22763. }
  22764. /**
  22765. * Class used to configure NodeMaterial
  22766. */
  22767. export interface INodeMaterialOptions {
  22768. /**
  22769. * Defines if blocks should emit comments
  22770. */
  22771. emitComments: boolean;
  22772. }
  22773. /**
  22774. * Class used to create a node based material built by assembling shader blocks
  22775. */
  22776. export class NodeMaterial extends PushMaterial {
  22777. private static _BuildIdGenerator;
  22778. private _options;
  22779. private _vertexCompilationState;
  22780. private _fragmentCompilationState;
  22781. private _sharedData;
  22782. private _buildId;
  22783. private _buildWasSuccessful;
  22784. private _cachedWorldViewMatrix;
  22785. private _cachedWorldViewProjectionMatrix;
  22786. private _optimizers;
  22787. private _animationFrame;
  22788. /** Define the Url to load node editor script */
  22789. static EditorURL: string;
  22790. /** Define the Url to load snippets */
  22791. static SnippetUrl: string;
  22792. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22793. static IgnoreTexturesAtLoadTime: boolean;
  22794. private BJSNODEMATERIALEDITOR;
  22795. /** Get the inspector from bundle or global */
  22796. private _getGlobalNodeMaterialEditor;
  22797. /**
  22798. * Snippet ID if the material was created from the snippet server
  22799. */
  22800. snippetId: string;
  22801. /**
  22802. * Gets or sets data used by visual editor
  22803. * @see https://nme.babylonjs.com
  22804. */
  22805. editorData: any;
  22806. /**
  22807. * 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)
  22808. */
  22809. ignoreAlpha: boolean;
  22810. /**
  22811. * Defines the maximum number of lights that can be used in the material
  22812. */
  22813. maxSimultaneousLights: number;
  22814. /**
  22815. * Observable raised when the material is built
  22816. */
  22817. onBuildObservable: Observable<NodeMaterial>;
  22818. /**
  22819. * Gets or sets the root nodes of the material vertex shader
  22820. */
  22821. _vertexOutputNodes: NodeMaterialBlock[];
  22822. /**
  22823. * Gets or sets the root nodes of the material fragment (pixel) shader
  22824. */
  22825. _fragmentOutputNodes: NodeMaterialBlock[];
  22826. /** Gets or sets options to control the node material overall behavior */
  22827. get options(): INodeMaterialOptions;
  22828. set options(options: INodeMaterialOptions);
  22829. /**
  22830. * Default configuration related to image processing available in the standard Material.
  22831. */
  22832. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22833. /**
  22834. * Gets the image processing configuration used either in this material.
  22835. */
  22836. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22837. /**
  22838. * Sets the Default image processing configuration used either in the this material.
  22839. *
  22840. * If sets to null, the scene one is in use.
  22841. */
  22842. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22843. /**
  22844. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22845. */
  22846. attachedBlocks: NodeMaterialBlock[];
  22847. /**
  22848. * Specifies the mode of the node material
  22849. * @hidden
  22850. */
  22851. _mode: NodeMaterialModes;
  22852. /**
  22853. * Gets the mode property
  22854. */
  22855. get mode(): NodeMaterialModes;
  22856. /**
  22857. * Create a new node based material
  22858. * @param name defines the material name
  22859. * @param scene defines the hosting scene
  22860. * @param options defines creation option
  22861. */
  22862. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22863. /**
  22864. * Gets the current class name of the material e.g. "NodeMaterial"
  22865. * @returns the class name
  22866. */
  22867. getClassName(): string;
  22868. /**
  22869. * Keep track of the image processing observer to allow dispose and replace.
  22870. */
  22871. private _imageProcessingObserver;
  22872. /**
  22873. * Attaches a new image processing configuration to the Standard Material.
  22874. * @param configuration
  22875. */
  22876. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22877. /**
  22878. * Get a block by its name
  22879. * @param name defines the name of the block to retrieve
  22880. * @returns the required block or null if not found
  22881. */
  22882. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22883. /**
  22884. * Get a block by its name
  22885. * @param predicate defines the predicate used to find the good candidate
  22886. * @returns the required block or null if not found
  22887. */
  22888. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22889. /**
  22890. * Get an input block by its name
  22891. * @param predicate defines the predicate used to find the good candidate
  22892. * @returns the required input block or null if not found
  22893. */
  22894. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22895. /**
  22896. * Gets the list of input blocks attached to this material
  22897. * @returns an array of InputBlocks
  22898. */
  22899. getInputBlocks(): InputBlock[];
  22900. /**
  22901. * Adds a new optimizer to the list of optimizers
  22902. * @param optimizer defines the optimizers to add
  22903. * @returns the current material
  22904. */
  22905. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22906. /**
  22907. * Remove an optimizer from the list of optimizers
  22908. * @param optimizer defines the optimizers to remove
  22909. * @returns the current material
  22910. */
  22911. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22912. /**
  22913. * Add a new block to the list of output nodes
  22914. * @param node defines the node to add
  22915. * @returns the current material
  22916. */
  22917. addOutputNode(node: NodeMaterialBlock): this;
  22918. /**
  22919. * Remove a block from the list of root nodes
  22920. * @param node defines the node to remove
  22921. * @returns the current material
  22922. */
  22923. removeOutputNode(node: NodeMaterialBlock): this;
  22924. private _addVertexOutputNode;
  22925. private _removeVertexOutputNode;
  22926. private _addFragmentOutputNode;
  22927. private _removeFragmentOutputNode;
  22928. /**
  22929. * Specifies if the material will require alpha blending
  22930. * @returns a boolean specifying if alpha blending is needed
  22931. */
  22932. needAlphaBlending(): boolean;
  22933. /**
  22934. * Specifies if this material should be rendered in alpha test mode
  22935. * @returns a boolean specifying if an alpha test is needed.
  22936. */
  22937. needAlphaTesting(): boolean;
  22938. private _initializeBlock;
  22939. private _resetDualBlocks;
  22940. /**
  22941. * Remove a block from the current node material
  22942. * @param block defines the block to remove
  22943. */
  22944. removeBlock(block: NodeMaterialBlock): void;
  22945. /**
  22946. * Build the material and generates the inner effect
  22947. * @param verbose defines if the build should log activity
  22948. */
  22949. build(verbose?: boolean): void;
  22950. /**
  22951. * Runs an otpimization phase to try to improve the shader code
  22952. */
  22953. optimize(): void;
  22954. private _prepareDefinesForAttributes;
  22955. /**
  22956. * Create a post process from the material
  22957. * @param camera The camera to apply the render pass to.
  22958. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22959. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22960. * @param engine The engine which the post process will be applied. (default: current engine)
  22961. * @param reusable If the post process can be reused on the same frame. (default: false)
  22962. * @param textureType Type of textures used when performing the post process. (default: 0)
  22963. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22964. * @returns the post process created
  22965. */
  22966. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22967. /**
  22968. * Create the post process effect from the material
  22969. * @param postProcess The post process to create the effect for
  22970. */
  22971. createEffectForPostProcess(postProcess: PostProcess): void;
  22972. private _createEffectOrPostProcess;
  22973. private _createEffectForParticles;
  22974. /**
  22975. * Create the effect to be used as the custom effect for a particle system
  22976. * @param particleSystem Particle system to create the effect for
  22977. * @param onCompiled defines a function to call when the effect creation is successful
  22978. * @param onError defines a function to call when the effect creation has failed
  22979. */
  22980. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22981. private _processDefines;
  22982. /**
  22983. * Get if the submesh is ready to be used and all its information available.
  22984. * Child classes can use it to update shaders
  22985. * @param mesh defines the mesh to check
  22986. * @param subMesh defines which submesh to check
  22987. * @param useInstances specifies that instances should be used
  22988. * @returns a boolean indicating that the submesh is ready or not
  22989. */
  22990. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22991. /**
  22992. * Get a string representing the shaders built by the current node graph
  22993. */
  22994. get compiledShaders(): string;
  22995. /**
  22996. * Binds the world matrix to the material
  22997. * @param world defines the world transformation matrix
  22998. */
  22999. bindOnlyWorldMatrix(world: Matrix): void;
  23000. /**
  23001. * Binds the submesh to this material by preparing the effect and shader to draw
  23002. * @param world defines the world transformation matrix
  23003. * @param mesh defines the mesh containing the submesh
  23004. * @param subMesh defines the submesh to bind the material to
  23005. */
  23006. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23007. /**
  23008. * Gets the active textures from the material
  23009. * @returns an array of textures
  23010. */
  23011. getActiveTextures(): BaseTexture[];
  23012. /**
  23013. * Gets the list of texture blocks
  23014. * @returns an array of texture blocks
  23015. */
  23016. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23017. /**
  23018. * Specifies if the material uses a texture
  23019. * @param texture defines the texture to check against the material
  23020. * @returns a boolean specifying if the material uses the texture
  23021. */
  23022. hasTexture(texture: BaseTexture): boolean;
  23023. /**
  23024. * Disposes the material
  23025. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23026. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23027. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23028. */
  23029. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23030. /** Creates the node editor window. */
  23031. private _createNodeEditor;
  23032. /**
  23033. * Launch the node material editor
  23034. * @param config Define the configuration of the editor
  23035. * @return a promise fulfilled when the node editor is visible
  23036. */
  23037. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23038. /**
  23039. * Clear the current material
  23040. */
  23041. clear(): void;
  23042. /**
  23043. * Clear the current material and set it to a default state
  23044. */
  23045. setToDefault(): void;
  23046. /**
  23047. * Clear the current material and set it to a default state for post process
  23048. */
  23049. setToDefaultPostProcess(): void;
  23050. /**
  23051. * Clear the current material and set it to a default state for particle
  23052. */
  23053. setToDefaultParticle(): void;
  23054. /**
  23055. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23056. * @param url defines the url to load from
  23057. * @returns a promise that will fullfil when the material is fully loaded
  23058. */
  23059. loadAsync(url: string): Promise<void>;
  23060. private _gatherBlocks;
  23061. /**
  23062. * Generate a string containing the code declaration required to create an equivalent of this material
  23063. * @returns a string
  23064. */
  23065. generateCode(): string;
  23066. /**
  23067. * Serializes this material in a JSON representation
  23068. * @returns the serialized material object
  23069. */
  23070. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23071. private _restoreConnections;
  23072. /**
  23073. * Clear the current graph and load a new one from a serialization object
  23074. * @param source defines the JSON representation of the material
  23075. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23076. */
  23077. loadFromSerialization(source: any, rootUrl?: string): void;
  23078. /**
  23079. * Makes a duplicate of the current material.
  23080. * @param name - name to use for the new material.
  23081. */
  23082. clone(name: string): NodeMaterial;
  23083. /**
  23084. * Creates a node material from parsed material data
  23085. * @param source defines the JSON representation of the material
  23086. * @param scene defines the hosting scene
  23087. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23088. * @returns a new node material
  23089. */
  23090. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23091. /**
  23092. * Creates a node material from a snippet saved in a remote file
  23093. * @param name defines the name of the material to create
  23094. * @param url defines the url to load from
  23095. * @param scene defines the hosting scene
  23096. * @returns a promise that will resolve to the new node material
  23097. */
  23098. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23099. /**
  23100. * Creates a node material from a snippet saved by the node material editor
  23101. * @param snippetId defines the snippet to load
  23102. * @param scene defines the hosting scene
  23103. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23104. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23105. * @returns a promise that will resolve to the new node material
  23106. */
  23107. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23108. /**
  23109. * Creates a new node material set to default basic configuration
  23110. * @param name defines the name of the material
  23111. * @param scene defines the hosting scene
  23112. * @returns a new NodeMaterial
  23113. */
  23114. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23115. }
  23116. }
  23117. declare module "babylonjs/PostProcesses/postProcess" {
  23118. import { Nullable } from "babylonjs/types";
  23119. import { SmartArray } from "babylonjs/Misc/smartArray";
  23120. import { Observable } from "babylonjs/Misc/observable";
  23121. import { Vector2 } from "babylonjs/Maths/math.vector";
  23122. import { Camera } from "babylonjs/Cameras/camera";
  23123. import { Effect } from "babylonjs/Materials/effect";
  23124. import "babylonjs/Shaders/postprocess.vertex";
  23125. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23126. import { Engine } from "babylonjs/Engines/engine";
  23127. import { Color4 } from "babylonjs/Maths/math.color";
  23128. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23129. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23130. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23131. /**
  23132. * Size options for a post process
  23133. */
  23134. export type PostProcessOptions = {
  23135. width: number;
  23136. height: number;
  23137. };
  23138. /**
  23139. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23140. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23141. */
  23142. export class PostProcess {
  23143. /** Name of the PostProcess. */
  23144. name: string;
  23145. /**
  23146. * Gets or sets the unique id of the post process
  23147. */
  23148. uniqueId: number;
  23149. /**
  23150. * Width of the texture to apply the post process on
  23151. */
  23152. width: number;
  23153. /**
  23154. * Height of the texture to apply the post process on
  23155. */
  23156. height: number;
  23157. /**
  23158. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23159. */
  23160. nodeMaterialSource: Nullable<NodeMaterial>;
  23161. /**
  23162. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23163. * @hidden
  23164. */
  23165. _outputTexture: Nullable<InternalTexture>;
  23166. /**
  23167. * Sampling mode used by the shader
  23168. * See https://doc.babylonjs.com/classes/3.1/texture
  23169. */
  23170. renderTargetSamplingMode: number;
  23171. /**
  23172. * Clear color to use when screen clearing
  23173. */
  23174. clearColor: Color4;
  23175. /**
  23176. * If the buffer needs to be cleared before applying the post process. (default: true)
  23177. * Should be set to false if shader will overwrite all previous pixels.
  23178. */
  23179. autoClear: boolean;
  23180. /**
  23181. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23182. */
  23183. alphaMode: number;
  23184. /**
  23185. * Sets the setAlphaBlendConstants of the babylon engine
  23186. */
  23187. alphaConstants: Color4;
  23188. /**
  23189. * Animations to be used for the post processing
  23190. */
  23191. animations: import("babylonjs/Animations/animation").Animation[];
  23192. /**
  23193. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23194. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23195. */
  23196. enablePixelPerfectMode: boolean;
  23197. /**
  23198. * Force the postprocess to be applied without taking in account viewport
  23199. */
  23200. forceFullscreenViewport: boolean;
  23201. /**
  23202. * List of inspectable custom properties (used by the Inspector)
  23203. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23204. */
  23205. inspectableCustomProperties: IInspectable[];
  23206. /**
  23207. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23208. *
  23209. * | Value | Type | Description |
  23210. * | ----- | ----------------------------------- | ----------- |
  23211. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23212. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23213. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23214. *
  23215. */
  23216. scaleMode: number;
  23217. /**
  23218. * Force textures to be a power of two (default: false)
  23219. */
  23220. alwaysForcePOT: boolean;
  23221. private _samples;
  23222. /**
  23223. * Number of sample textures (default: 1)
  23224. */
  23225. get samples(): number;
  23226. set samples(n: number);
  23227. /**
  23228. * Modify the scale of the post process to be the same as the viewport (default: false)
  23229. */
  23230. adaptScaleToCurrentViewport: boolean;
  23231. private _camera;
  23232. private _scene;
  23233. private _engine;
  23234. private _options;
  23235. private _reusable;
  23236. private _textureType;
  23237. private _textureFormat;
  23238. /**
  23239. * Smart array of input and output textures for the post process.
  23240. * @hidden
  23241. */
  23242. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23243. /**
  23244. * The index in _textures that corresponds to the output texture.
  23245. * @hidden
  23246. */
  23247. _currentRenderTextureInd: number;
  23248. private _effect;
  23249. private _samplers;
  23250. private _fragmentUrl;
  23251. private _vertexUrl;
  23252. private _parameters;
  23253. private _scaleRatio;
  23254. protected _indexParameters: any;
  23255. private _shareOutputWithPostProcess;
  23256. private _texelSize;
  23257. private _forcedOutputTexture;
  23258. /**
  23259. * Returns the fragment url or shader name used in the post process.
  23260. * @returns the fragment url or name in the shader store.
  23261. */
  23262. getEffectName(): string;
  23263. /**
  23264. * An event triggered when the postprocess is activated.
  23265. */
  23266. onActivateObservable: Observable<Camera>;
  23267. private _onActivateObserver;
  23268. /**
  23269. * A function that is added to the onActivateObservable
  23270. */
  23271. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23272. /**
  23273. * An event triggered when the postprocess changes its size.
  23274. */
  23275. onSizeChangedObservable: Observable<PostProcess>;
  23276. private _onSizeChangedObserver;
  23277. /**
  23278. * A function that is added to the onSizeChangedObservable
  23279. */
  23280. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23281. /**
  23282. * An event triggered when the postprocess applies its effect.
  23283. */
  23284. onApplyObservable: Observable<Effect>;
  23285. private _onApplyObserver;
  23286. /**
  23287. * A function that is added to the onApplyObservable
  23288. */
  23289. set onApply(callback: (effect: Effect) => void);
  23290. /**
  23291. * An event triggered before rendering the postprocess
  23292. */
  23293. onBeforeRenderObservable: Observable<Effect>;
  23294. private _onBeforeRenderObserver;
  23295. /**
  23296. * A function that is added to the onBeforeRenderObservable
  23297. */
  23298. set onBeforeRender(callback: (effect: Effect) => void);
  23299. /**
  23300. * An event triggered after rendering the postprocess
  23301. */
  23302. onAfterRenderObservable: Observable<Effect>;
  23303. private _onAfterRenderObserver;
  23304. /**
  23305. * A function that is added to the onAfterRenderObservable
  23306. */
  23307. set onAfterRender(callback: (efect: Effect) => void);
  23308. /**
  23309. * 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
  23310. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23311. */
  23312. get inputTexture(): InternalTexture;
  23313. set inputTexture(value: InternalTexture);
  23314. /**
  23315. * Gets the camera which post process is applied to.
  23316. * @returns The camera the post process is applied to.
  23317. */
  23318. getCamera(): Camera;
  23319. /**
  23320. * Gets the texel size of the postprocess.
  23321. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23322. */
  23323. get texelSize(): Vector2;
  23324. /**
  23325. * Creates a new instance PostProcess
  23326. * @param name The name of the PostProcess.
  23327. * @param fragmentUrl The url of the fragment shader to be used.
  23328. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23329. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23330. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23331. * @param camera The camera to apply the render pass to.
  23332. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23333. * @param engine The engine which the post process will be applied. (default: current engine)
  23334. * @param reusable If the post process can be reused on the same frame. (default: false)
  23335. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23336. * @param textureType Type of textures used when performing the post process. (default: 0)
  23337. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23338. * @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
  23339. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23340. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23341. */
  23342. constructor(
  23343. /** Name of the PostProcess. */
  23344. 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);
  23345. /**
  23346. * Gets a string idenfifying the name of the class
  23347. * @returns "PostProcess" string
  23348. */
  23349. getClassName(): string;
  23350. /**
  23351. * Gets the engine which this post process belongs to.
  23352. * @returns The engine the post process was enabled with.
  23353. */
  23354. getEngine(): Engine;
  23355. /**
  23356. * The effect that is created when initializing the post process.
  23357. * @returns The created effect corresponding the the postprocess.
  23358. */
  23359. getEffect(): Effect;
  23360. /**
  23361. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23362. * @param postProcess The post process to share the output with.
  23363. * @returns This post process.
  23364. */
  23365. shareOutputWith(postProcess: PostProcess): PostProcess;
  23366. /**
  23367. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23368. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23369. */
  23370. useOwnOutput(): void;
  23371. /**
  23372. * Updates the effect with the current post process compile time values and recompiles the shader.
  23373. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23374. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23375. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23376. * @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
  23377. * @param onCompiled Called when the shader has been compiled.
  23378. * @param onError Called if there is an error when compiling a shader.
  23379. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23380. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23381. */
  23382. 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;
  23383. /**
  23384. * The post process is reusable if it can be used multiple times within one frame.
  23385. * @returns If the post process is reusable
  23386. */
  23387. isReusable(): boolean;
  23388. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23389. markTextureDirty(): void;
  23390. /**
  23391. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23392. * 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.
  23393. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23394. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23395. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23396. * @returns The target texture that was bound to be written to.
  23397. */
  23398. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23399. /**
  23400. * If the post process is supported.
  23401. */
  23402. get isSupported(): boolean;
  23403. /**
  23404. * The aspect ratio of the output texture.
  23405. */
  23406. get aspectRatio(): number;
  23407. /**
  23408. * Get a value indicating if the post-process is ready to be used
  23409. * @returns true if the post-process is ready (shader is compiled)
  23410. */
  23411. isReady(): boolean;
  23412. /**
  23413. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23414. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23415. */
  23416. apply(): Nullable<Effect>;
  23417. private _disposeTextures;
  23418. /**
  23419. * Disposes the post process.
  23420. * @param camera The camera to dispose the post process on.
  23421. */
  23422. dispose(camera?: Camera): void;
  23423. }
  23424. }
  23425. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23426. /** @hidden */
  23427. export var kernelBlurVaryingDeclaration: {
  23428. name: string;
  23429. shader: string;
  23430. };
  23431. }
  23432. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23433. /** @hidden */
  23434. export var kernelBlurFragment: {
  23435. name: string;
  23436. shader: string;
  23437. };
  23438. }
  23439. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23440. /** @hidden */
  23441. export var kernelBlurFragment2: {
  23442. name: string;
  23443. shader: string;
  23444. };
  23445. }
  23446. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23447. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23448. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23449. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23450. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23451. /** @hidden */
  23452. export var kernelBlurPixelShader: {
  23453. name: string;
  23454. shader: string;
  23455. };
  23456. }
  23457. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23458. /** @hidden */
  23459. export var kernelBlurVertex: {
  23460. name: string;
  23461. shader: string;
  23462. };
  23463. }
  23464. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23465. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23466. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23467. /** @hidden */
  23468. export var kernelBlurVertexShader: {
  23469. name: string;
  23470. shader: string;
  23471. };
  23472. }
  23473. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23474. import { Vector2 } from "babylonjs/Maths/math.vector";
  23475. import { Nullable } from "babylonjs/types";
  23476. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23477. import { Camera } from "babylonjs/Cameras/camera";
  23478. import { Effect } from "babylonjs/Materials/effect";
  23479. import { Engine } from "babylonjs/Engines/engine";
  23480. import "babylonjs/Shaders/kernelBlur.fragment";
  23481. import "babylonjs/Shaders/kernelBlur.vertex";
  23482. /**
  23483. * The Blur Post Process which blurs an image based on a kernel and direction.
  23484. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23485. */
  23486. export class BlurPostProcess extends PostProcess {
  23487. /** The direction in which to blur the image. */
  23488. direction: Vector2;
  23489. private blockCompilation;
  23490. protected _kernel: number;
  23491. protected _idealKernel: number;
  23492. protected _packedFloat: boolean;
  23493. private _staticDefines;
  23494. /**
  23495. * Sets the length in pixels of the blur sample region
  23496. */
  23497. set kernel(v: number);
  23498. /**
  23499. * Gets the length in pixels of the blur sample region
  23500. */
  23501. get kernel(): number;
  23502. /**
  23503. * Sets wether or not the blur needs to unpack/repack floats
  23504. */
  23505. set packedFloat(v: boolean);
  23506. /**
  23507. * Gets wether or not the blur is unpacking/repacking floats
  23508. */
  23509. get packedFloat(): boolean;
  23510. /**
  23511. * Creates a new instance BlurPostProcess
  23512. * @param name The name of the effect.
  23513. * @param direction The direction in which to blur the image.
  23514. * @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.
  23515. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23516. * @param camera The camera to apply the render pass to.
  23517. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23518. * @param engine The engine which the post process will be applied. (default: current engine)
  23519. * @param reusable If the post process can be reused on the same frame. (default: false)
  23520. * @param textureType Type of textures used when performing the post process. (default: 0)
  23521. * @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)
  23522. */
  23523. constructor(name: string,
  23524. /** The direction in which to blur the image. */
  23525. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23526. /**
  23527. * Updates the effect with the current post process compile time values and recompiles the shader.
  23528. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23529. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23530. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23531. * @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
  23532. * @param onCompiled Called when the shader has been compiled.
  23533. * @param onError Called if there is an error when compiling a shader.
  23534. */
  23535. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23536. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23537. /**
  23538. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23539. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23540. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23541. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23542. * The gaps between physical kernels are compensated for in the weighting of the samples
  23543. * @param idealKernel Ideal blur kernel.
  23544. * @return Nearest best kernel.
  23545. */
  23546. protected _nearestBestKernel(idealKernel: number): number;
  23547. /**
  23548. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23549. * @param x The point on the Gaussian distribution to sample.
  23550. * @return the value of the Gaussian function at x.
  23551. */
  23552. protected _gaussianWeight(x: number): number;
  23553. /**
  23554. * Generates a string that can be used as a floating point number in GLSL.
  23555. * @param x Value to print.
  23556. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23557. * @return GLSL float string.
  23558. */
  23559. protected _glslFloat(x: number, decimalFigures?: number): string;
  23560. }
  23561. }
  23562. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23563. import { Scene } from "babylonjs/scene";
  23564. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23565. import { Plane } from "babylonjs/Maths/math.plane";
  23566. /**
  23567. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23568. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23569. * You can then easily use it as a reflectionTexture on a flat surface.
  23570. * In case the surface is not a plane, please consider relying on reflection probes.
  23571. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23572. */
  23573. export class MirrorTexture extends RenderTargetTexture {
  23574. private scene;
  23575. /**
  23576. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23577. * 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.
  23578. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23579. */
  23580. mirrorPlane: Plane;
  23581. /**
  23582. * Define the blur ratio used to blur the reflection if needed.
  23583. */
  23584. set blurRatio(value: number);
  23585. get blurRatio(): number;
  23586. /**
  23587. * Define the adaptive blur kernel used to blur the reflection if needed.
  23588. * This will autocompute the closest best match for the `blurKernel`
  23589. */
  23590. set adaptiveBlurKernel(value: number);
  23591. /**
  23592. * Define the blur kernel used to blur the reflection if needed.
  23593. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23594. */
  23595. set blurKernel(value: number);
  23596. /**
  23597. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23598. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23599. */
  23600. set blurKernelX(value: number);
  23601. get blurKernelX(): number;
  23602. /**
  23603. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23604. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23605. */
  23606. set blurKernelY(value: number);
  23607. get blurKernelY(): number;
  23608. private _autoComputeBlurKernel;
  23609. protected _onRatioRescale(): void;
  23610. private _updateGammaSpace;
  23611. private _imageProcessingConfigChangeObserver;
  23612. private _transformMatrix;
  23613. private _mirrorMatrix;
  23614. private _savedViewMatrix;
  23615. private _blurX;
  23616. private _blurY;
  23617. private _adaptiveBlurKernel;
  23618. private _blurKernelX;
  23619. private _blurKernelY;
  23620. private _blurRatio;
  23621. /**
  23622. * Instantiates a Mirror Texture.
  23623. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23624. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23625. * You can then easily use it as a reflectionTexture on a flat surface.
  23626. * In case the surface is not a plane, please consider relying on reflection probes.
  23627. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23628. * @param name
  23629. * @param size
  23630. * @param scene
  23631. * @param generateMipMaps
  23632. * @param type
  23633. * @param samplingMode
  23634. * @param generateDepthBuffer
  23635. */
  23636. constructor(name: string, size: number | {
  23637. width: number;
  23638. height: number;
  23639. } | {
  23640. ratio: number;
  23641. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23642. private _preparePostProcesses;
  23643. /**
  23644. * Clone the mirror texture.
  23645. * @returns the cloned texture
  23646. */
  23647. clone(): MirrorTexture;
  23648. /**
  23649. * Serialize the texture to a JSON representation you could use in Parse later on
  23650. * @returns the serialized JSON representation
  23651. */
  23652. serialize(): any;
  23653. /**
  23654. * Dispose the texture and release its associated resources.
  23655. */
  23656. dispose(): void;
  23657. }
  23658. }
  23659. declare module "babylonjs/Materials/Textures/texture" {
  23660. import { Observable } from "babylonjs/Misc/observable";
  23661. import { Nullable } from "babylonjs/types";
  23662. import { Matrix } from "babylonjs/Maths/math.vector";
  23663. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23664. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23665. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23666. import { Scene } from "babylonjs/scene";
  23667. /**
  23668. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23669. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23670. */
  23671. export class Texture extends BaseTexture {
  23672. /**
  23673. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23674. */
  23675. static SerializeBuffers: boolean;
  23676. /** @hidden */
  23677. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  23678. /** @hidden */
  23679. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  23680. /** @hidden */
  23681. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  23682. /** nearest is mag = nearest and min = nearest and mip = linear */
  23683. static readonly NEAREST_SAMPLINGMODE: number;
  23684. /** nearest is mag = nearest and min = nearest and mip = linear */
  23685. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23686. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23687. static readonly BILINEAR_SAMPLINGMODE: number;
  23688. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23689. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23690. /** Trilinear is mag = linear and min = linear and mip = linear */
  23691. static readonly TRILINEAR_SAMPLINGMODE: number;
  23692. /** Trilinear is mag = linear and min = linear and mip = linear */
  23693. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23694. /** mag = nearest and min = nearest and mip = nearest */
  23695. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23696. /** mag = nearest and min = linear and mip = nearest */
  23697. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23698. /** mag = nearest and min = linear and mip = linear */
  23699. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23700. /** mag = nearest and min = linear and mip = none */
  23701. static readonly NEAREST_LINEAR: number;
  23702. /** mag = nearest and min = nearest and mip = none */
  23703. static readonly NEAREST_NEAREST: number;
  23704. /** mag = linear and min = nearest and mip = nearest */
  23705. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23706. /** mag = linear and min = nearest and mip = linear */
  23707. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23708. /** mag = linear and min = linear and mip = none */
  23709. static readonly LINEAR_LINEAR: number;
  23710. /** mag = linear and min = nearest and mip = none */
  23711. static readonly LINEAR_NEAREST: number;
  23712. /** Explicit coordinates mode */
  23713. static readonly EXPLICIT_MODE: number;
  23714. /** Spherical coordinates mode */
  23715. static readonly SPHERICAL_MODE: number;
  23716. /** Planar coordinates mode */
  23717. static readonly PLANAR_MODE: number;
  23718. /** Cubic coordinates mode */
  23719. static readonly CUBIC_MODE: number;
  23720. /** Projection coordinates mode */
  23721. static readonly PROJECTION_MODE: number;
  23722. /** Inverse Cubic coordinates mode */
  23723. static readonly SKYBOX_MODE: number;
  23724. /** Inverse Cubic coordinates mode */
  23725. static readonly INVCUBIC_MODE: number;
  23726. /** Equirectangular coordinates mode */
  23727. static readonly EQUIRECTANGULAR_MODE: number;
  23728. /** Equirectangular Fixed coordinates mode */
  23729. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23730. /** Equirectangular Fixed Mirrored coordinates mode */
  23731. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23732. /** Texture is not repeating outside of 0..1 UVs */
  23733. static readonly CLAMP_ADDRESSMODE: number;
  23734. /** Texture is repeating outside of 0..1 UVs */
  23735. static readonly WRAP_ADDRESSMODE: number;
  23736. /** Texture is repeating and mirrored */
  23737. static readonly MIRROR_ADDRESSMODE: number;
  23738. /**
  23739. * 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
  23740. */
  23741. static UseSerializedUrlIfAny: boolean;
  23742. /**
  23743. * Define the url of the texture.
  23744. */
  23745. url: Nullable<string>;
  23746. /**
  23747. * Define an offset on the texture to offset the u coordinates of the UVs
  23748. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  23749. */
  23750. uOffset: number;
  23751. /**
  23752. * Define an offset on the texture to offset the v coordinates of the UVs
  23753. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  23754. */
  23755. vOffset: number;
  23756. /**
  23757. * Define an offset on the texture to scale the u coordinates of the UVs
  23758. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23759. */
  23760. uScale: number;
  23761. /**
  23762. * Define an offset on the texture to scale the v coordinates of the UVs
  23763. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23764. */
  23765. vScale: number;
  23766. /**
  23767. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23768. * @see http://doc.babylonjs.com/how_to/more_materials
  23769. */
  23770. uAng: number;
  23771. /**
  23772. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23773. * @see http://doc.babylonjs.com/how_to/more_materials
  23774. */
  23775. vAng: number;
  23776. /**
  23777. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23778. * @see http://doc.babylonjs.com/how_to/more_materials
  23779. */
  23780. wAng: number;
  23781. /**
  23782. * Defines the center of rotation (U)
  23783. */
  23784. uRotationCenter: number;
  23785. /**
  23786. * Defines the center of rotation (V)
  23787. */
  23788. vRotationCenter: number;
  23789. /**
  23790. * Defines the center of rotation (W)
  23791. */
  23792. wRotationCenter: number;
  23793. /**
  23794. * Are mip maps generated for this texture or not.
  23795. */
  23796. get noMipmap(): boolean;
  23797. /**
  23798. * List of inspectable custom properties (used by the Inspector)
  23799. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23800. */
  23801. inspectableCustomProperties: Nullable<IInspectable[]>;
  23802. private _noMipmap;
  23803. /** @hidden */
  23804. _invertY: boolean;
  23805. private _rowGenerationMatrix;
  23806. private _cachedTextureMatrix;
  23807. private _projectionModeMatrix;
  23808. private _t0;
  23809. private _t1;
  23810. private _t2;
  23811. private _cachedUOffset;
  23812. private _cachedVOffset;
  23813. private _cachedUScale;
  23814. private _cachedVScale;
  23815. private _cachedUAng;
  23816. private _cachedVAng;
  23817. private _cachedWAng;
  23818. private _cachedProjectionMatrixId;
  23819. private _cachedCoordinatesMode;
  23820. /** @hidden */
  23821. protected _initialSamplingMode: number;
  23822. /** @hidden */
  23823. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23824. private _deleteBuffer;
  23825. protected _format: Nullable<number>;
  23826. private _delayedOnLoad;
  23827. private _delayedOnError;
  23828. private _mimeType?;
  23829. /**
  23830. * Observable triggered once the texture has been loaded.
  23831. */
  23832. onLoadObservable: Observable<Texture>;
  23833. protected _isBlocking: boolean;
  23834. /**
  23835. * Is the texture preventing material to render while loading.
  23836. * If false, a default texture will be used instead of the loading one during the preparation step.
  23837. */
  23838. set isBlocking(value: boolean);
  23839. get isBlocking(): boolean;
  23840. /**
  23841. * Get the current sampling mode associated with the texture.
  23842. */
  23843. get samplingMode(): number;
  23844. /**
  23845. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23846. */
  23847. get invertY(): boolean;
  23848. /**
  23849. * Instantiates a new texture.
  23850. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23851. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23852. * @param url defines the url of the picture to load as a texture
  23853. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23854. * @param noMipmap defines if the texture will require mip maps or not
  23855. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23856. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23857. * @param onLoad defines a callback triggered when the texture has been loaded
  23858. * @param onError defines a callback triggered when an error occurred during the loading session
  23859. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23860. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23861. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23862. * @param mimeType defines an optional mime type information
  23863. */
  23864. 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);
  23865. /**
  23866. * Update the url (and optional buffer) of this texture if url was null during construction.
  23867. * @param url the url of the texture
  23868. * @param buffer the buffer of the texture (defaults to null)
  23869. * @param onLoad callback called when the texture is loaded (defaults to null)
  23870. */
  23871. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23872. /**
  23873. * Finish the loading sequence of a texture flagged as delayed load.
  23874. * @hidden
  23875. */
  23876. delayLoad(): void;
  23877. private _prepareRowForTextureGeneration;
  23878. /**
  23879. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23880. * @returns the transform matrix of the texture.
  23881. */
  23882. getTextureMatrix(uBase?: number): Matrix;
  23883. /**
  23884. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23885. * @returns The reflection texture transform
  23886. */
  23887. getReflectionTextureMatrix(): Matrix;
  23888. /**
  23889. * Clones the texture.
  23890. * @returns the cloned texture
  23891. */
  23892. clone(): Texture;
  23893. /**
  23894. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23895. * @returns The JSON representation of the texture
  23896. */
  23897. serialize(): any;
  23898. /**
  23899. * Get the current class name of the texture useful for serialization or dynamic coding.
  23900. * @returns "Texture"
  23901. */
  23902. getClassName(): string;
  23903. /**
  23904. * Dispose the texture and release its associated resources.
  23905. */
  23906. dispose(): void;
  23907. /**
  23908. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23909. * @param parsedTexture Define the JSON representation of the texture
  23910. * @param scene Define the scene the parsed texture should be instantiated in
  23911. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23912. * @returns The parsed texture if successful
  23913. */
  23914. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23915. /**
  23916. * Creates a texture from its base 64 representation.
  23917. * @param data Define the base64 payload without the data: prefix
  23918. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23919. * @param scene Define the scene the texture should belong to
  23920. * @param noMipmap Forces the texture to not create mip map information if true
  23921. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23922. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23923. * @param onLoad define a callback triggered when the texture has been loaded
  23924. * @param onError define a callback triggered when an error occurred during the loading session
  23925. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23926. * @returns the created texture
  23927. */
  23928. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23929. /**
  23930. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23931. * @param data Define the base64 payload without the data: prefix
  23932. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23933. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23934. * @param scene Define the scene the texture should belong to
  23935. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23936. * @param noMipmap Forces the texture to not create mip map information if true
  23937. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23938. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23939. * @param onLoad define a callback triggered when the texture has been loaded
  23940. * @param onError define a callback triggered when an error occurred during the loading session
  23941. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23942. * @returns the created texture
  23943. */
  23944. 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;
  23945. }
  23946. }
  23947. declare module "babylonjs/PostProcesses/postProcessManager" {
  23948. import { Nullable } from "babylonjs/types";
  23949. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23950. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  23951. import { Scene } from "babylonjs/scene";
  23952. /**
  23953. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23954. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23955. */
  23956. export class PostProcessManager {
  23957. private _scene;
  23958. private _indexBuffer;
  23959. private _vertexBuffers;
  23960. /**
  23961. * Creates a new instance PostProcess
  23962. * @param scene The scene that the post process is associated with.
  23963. */
  23964. constructor(scene: Scene);
  23965. private _prepareBuffers;
  23966. private _buildIndexBuffer;
  23967. /**
  23968. * Rebuilds the vertex buffers of the manager.
  23969. * @hidden
  23970. */
  23971. _rebuild(): void;
  23972. /**
  23973. * Prepares a frame to be run through a post process.
  23974. * @param sourceTexture The input texture to the post procesess. (default: null)
  23975. * @param postProcesses An array of post processes to be run. (default: null)
  23976. * @returns True if the post processes were able to be run.
  23977. * @hidden
  23978. */
  23979. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23980. /**
  23981. * Manually render a set of post processes to a texture.
  23982. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23983. * @param postProcesses An array of post processes to be run.
  23984. * @param targetTexture The target texture to render to.
  23985. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23986. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23987. * @param lodLevel defines which lod of the texture to render to
  23988. */
  23989. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23990. /**
  23991. * Finalize the result of the output of the postprocesses.
  23992. * @param doNotPresent If true the result will not be displayed to the screen.
  23993. * @param targetTexture The target texture to render to.
  23994. * @param faceIndex The index of the face to bind the target texture to.
  23995. * @param postProcesses The array of post processes to render.
  23996. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23997. * @hidden
  23998. */
  23999. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24000. /**
  24001. * Disposes of the post process manager.
  24002. */
  24003. dispose(): void;
  24004. }
  24005. }
  24006. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24007. import { Observable } from "babylonjs/Misc/observable";
  24008. import { SmartArray } from "babylonjs/Misc/smartArray";
  24009. import { Nullable, Immutable } from "babylonjs/types";
  24010. import { Camera } from "babylonjs/Cameras/camera";
  24011. import { Scene } from "babylonjs/scene";
  24012. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24013. import { Color4 } from "babylonjs/Maths/math.color";
  24014. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24016. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24017. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24018. import { Texture } from "babylonjs/Materials/Textures/texture";
  24019. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24020. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24021. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24022. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24023. import { Engine } from "babylonjs/Engines/engine";
  24024. /**
  24025. * This Helps creating a texture that will be created from a camera in your scene.
  24026. * It is basically a dynamic texture that could be used to create special effects for instance.
  24027. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24028. */
  24029. export class RenderTargetTexture extends Texture {
  24030. isCube: boolean;
  24031. /**
  24032. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24033. */
  24034. static readonly REFRESHRATE_RENDER_ONCE: number;
  24035. /**
  24036. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24037. */
  24038. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24039. /**
  24040. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24041. * the central point of your effect and can save a lot of performances.
  24042. */
  24043. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24044. /**
  24045. * Use this predicate to dynamically define the list of mesh you want to render.
  24046. * If set, the renderList property will be overwritten.
  24047. */
  24048. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24049. private _renderList;
  24050. /**
  24051. * Use this list to define the list of mesh you want to render.
  24052. */
  24053. get renderList(): Nullable<Array<AbstractMesh>>;
  24054. set renderList(value: Nullable<Array<AbstractMesh>>);
  24055. /**
  24056. * Use this function to overload the renderList array at rendering time.
  24057. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24058. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24059. * the cube (if the RTT is a cube, else layerOrFace=0).
  24060. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24061. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24062. * hold dummy elements!
  24063. */
  24064. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24065. private _hookArray;
  24066. /**
  24067. * Define if particles should be rendered in your texture.
  24068. */
  24069. renderParticles: boolean;
  24070. /**
  24071. * Define if sprites should be rendered in your texture.
  24072. */
  24073. renderSprites: boolean;
  24074. /**
  24075. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24076. */
  24077. coordinatesMode: number;
  24078. /**
  24079. * Define the camera used to render the texture.
  24080. */
  24081. activeCamera: Nullable<Camera>;
  24082. /**
  24083. * Override the mesh isReady function with your own one.
  24084. */
  24085. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24086. /**
  24087. * Override the render function of the texture with your own one.
  24088. */
  24089. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24090. /**
  24091. * Define if camera post processes should be use while rendering the texture.
  24092. */
  24093. useCameraPostProcesses: boolean;
  24094. /**
  24095. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24096. */
  24097. ignoreCameraViewport: boolean;
  24098. private _postProcessManager;
  24099. private _postProcesses;
  24100. private _resizeObserver;
  24101. /**
  24102. * An event triggered when the texture is unbind.
  24103. */
  24104. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24105. /**
  24106. * An event triggered when the texture is unbind.
  24107. */
  24108. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24109. private _onAfterUnbindObserver;
  24110. /**
  24111. * Set a after unbind callback in the texture.
  24112. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24113. */
  24114. set onAfterUnbind(callback: () => void);
  24115. /**
  24116. * An event triggered before rendering the texture
  24117. */
  24118. onBeforeRenderObservable: Observable<number>;
  24119. private _onBeforeRenderObserver;
  24120. /**
  24121. * Set a before render callback in the texture.
  24122. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24123. */
  24124. set onBeforeRender(callback: (faceIndex: number) => void);
  24125. /**
  24126. * An event triggered after rendering the texture
  24127. */
  24128. onAfterRenderObservable: Observable<number>;
  24129. private _onAfterRenderObserver;
  24130. /**
  24131. * Set a after render callback in the texture.
  24132. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24133. */
  24134. set onAfterRender(callback: (faceIndex: number) => void);
  24135. /**
  24136. * An event triggered after the texture clear
  24137. */
  24138. onClearObservable: Observable<Engine>;
  24139. private _onClearObserver;
  24140. /**
  24141. * Set a clear callback in the texture.
  24142. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24143. */
  24144. set onClear(callback: (Engine: Engine) => void);
  24145. /**
  24146. * An event triggered when the texture is resized.
  24147. */
  24148. onResizeObservable: Observable<RenderTargetTexture>;
  24149. /**
  24150. * Define the clear color of the Render Target if it should be different from the scene.
  24151. */
  24152. clearColor: Color4;
  24153. protected _size: number | {
  24154. width: number;
  24155. height: number;
  24156. layers?: number;
  24157. };
  24158. protected _initialSizeParameter: number | {
  24159. width: number;
  24160. height: number;
  24161. } | {
  24162. ratio: number;
  24163. };
  24164. protected _sizeRatio: Nullable<number>;
  24165. /** @hidden */
  24166. _generateMipMaps: boolean;
  24167. protected _renderingManager: RenderingManager;
  24168. /** @hidden */
  24169. _waitingRenderList: string[];
  24170. protected _doNotChangeAspectRatio: boolean;
  24171. protected _currentRefreshId: number;
  24172. protected _refreshRate: number;
  24173. protected _textureMatrix: Matrix;
  24174. protected _samples: number;
  24175. protected _renderTargetOptions: RenderTargetCreationOptions;
  24176. /**
  24177. * Gets render target creation options that were used.
  24178. */
  24179. get renderTargetOptions(): RenderTargetCreationOptions;
  24180. protected _onRatioRescale(): void;
  24181. /**
  24182. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24183. * It must define where the camera used to render the texture is set
  24184. */
  24185. boundingBoxPosition: Vector3;
  24186. private _boundingBoxSize;
  24187. /**
  24188. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24189. * When defined, the cubemap will switch to local mode
  24190. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24191. * @example https://www.babylonjs-playground.com/#RNASML
  24192. */
  24193. set boundingBoxSize(value: Vector3);
  24194. get boundingBoxSize(): Vector3;
  24195. /**
  24196. * In case the RTT has been created with a depth texture, get the associated
  24197. * depth texture.
  24198. * Otherwise, return null.
  24199. */
  24200. get depthStencilTexture(): Nullable<InternalTexture>;
  24201. /**
  24202. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24203. * or used a shadow, depth texture...
  24204. * @param name The friendly name of the texture
  24205. * @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)
  24206. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24207. * @param generateMipMaps True if mip maps need to be generated after render.
  24208. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24209. * @param type The type of the buffer in the RTT (int, half float, float...)
  24210. * @param isCube True if a cube texture needs to be created
  24211. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24212. * @param generateDepthBuffer True to generate a depth buffer
  24213. * @param generateStencilBuffer True to generate a stencil buffer
  24214. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24215. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24216. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24217. */
  24218. constructor(name: string, size: number | {
  24219. width: number;
  24220. height: number;
  24221. layers?: number;
  24222. } | {
  24223. ratio: number;
  24224. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24225. /**
  24226. * Creates a depth stencil texture.
  24227. * This is only available in WebGL 2 or with the depth texture extension available.
  24228. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24229. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24230. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24231. */
  24232. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24233. private _processSizeParameter;
  24234. /**
  24235. * Define the number of samples to use in case of MSAA.
  24236. * It defaults to one meaning no MSAA has been enabled.
  24237. */
  24238. get samples(): number;
  24239. set samples(value: number);
  24240. /**
  24241. * Resets the refresh counter of the texture and start bak from scratch.
  24242. * Could be useful to regenerate the texture if it is setup to render only once.
  24243. */
  24244. resetRefreshCounter(): void;
  24245. /**
  24246. * Define the refresh rate of the texture or the rendering frequency.
  24247. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24248. */
  24249. get refreshRate(): number;
  24250. set refreshRate(value: number);
  24251. /**
  24252. * Adds a post process to the render target rendering passes.
  24253. * @param postProcess define the post process to add
  24254. */
  24255. addPostProcess(postProcess: PostProcess): void;
  24256. /**
  24257. * Clear all the post processes attached to the render target
  24258. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24259. */
  24260. clearPostProcesses(dispose?: boolean): void;
  24261. /**
  24262. * Remove one of the post process from the list of attached post processes to the texture
  24263. * @param postProcess define the post process to remove from the list
  24264. */
  24265. removePostProcess(postProcess: PostProcess): void;
  24266. /** @hidden */
  24267. _shouldRender(): boolean;
  24268. /**
  24269. * Gets the actual render size of the texture.
  24270. * @returns the width of the render size
  24271. */
  24272. getRenderSize(): number;
  24273. /**
  24274. * Gets the actual render width of the texture.
  24275. * @returns the width of the render size
  24276. */
  24277. getRenderWidth(): number;
  24278. /**
  24279. * Gets the actual render height of the texture.
  24280. * @returns the height of the render size
  24281. */
  24282. getRenderHeight(): number;
  24283. /**
  24284. * Gets the actual number of layers of the texture.
  24285. * @returns the number of layers
  24286. */
  24287. getRenderLayers(): number;
  24288. /**
  24289. * Get if the texture can be rescaled or not.
  24290. */
  24291. get canRescale(): boolean;
  24292. /**
  24293. * Resize the texture using a ratio.
  24294. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24295. */
  24296. scale(ratio: number): void;
  24297. /**
  24298. * Get the texture reflection matrix used to rotate/transform the reflection.
  24299. * @returns the reflection matrix
  24300. */
  24301. getReflectionTextureMatrix(): Matrix;
  24302. /**
  24303. * Resize the texture to a new desired size.
  24304. * Be carrefull as it will recreate all the data in the new texture.
  24305. * @param size Define the new size. It can be:
  24306. * - a number for squared texture,
  24307. * - an object containing { width: number, height: number }
  24308. * - or an object containing a ratio { ratio: number }
  24309. */
  24310. resize(size: number | {
  24311. width: number;
  24312. height: number;
  24313. } | {
  24314. ratio: number;
  24315. }): void;
  24316. private _defaultRenderListPrepared;
  24317. /**
  24318. * Renders all the objects from the render list into the texture.
  24319. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24320. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24321. */
  24322. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24323. private _bestReflectionRenderTargetDimension;
  24324. private _prepareRenderingManager;
  24325. /**
  24326. * @hidden
  24327. * @param faceIndex face index to bind to if this is a cubetexture
  24328. * @param layer defines the index of the texture to bind in the array
  24329. */
  24330. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24331. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24332. private renderToTarget;
  24333. /**
  24334. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24335. * This allowed control for front to back rendering or reversly depending of the special needs.
  24336. *
  24337. * @param renderingGroupId The rendering group id corresponding to its index
  24338. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24339. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24340. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24341. */
  24342. 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;
  24343. /**
  24344. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24345. *
  24346. * @param renderingGroupId The rendering group id corresponding to its index
  24347. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24348. */
  24349. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24350. /**
  24351. * Clones the texture.
  24352. * @returns the cloned texture
  24353. */
  24354. clone(): RenderTargetTexture;
  24355. /**
  24356. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24357. * @returns The JSON representation of the texture
  24358. */
  24359. serialize(): any;
  24360. /**
  24361. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24362. */
  24363. disposeFramebufferObjects(): void;
  24364. /**
  24365. * Dispose the texture and release its associated resources.
  24366. */
  24367. dispose(): void;
  24368. /** @hidden */
  24369. _rebuild(): void;
  24370. /**
  24371. * Clear the info related to rendering groups preventing retention point in material dispose.
  24372. */
  24373. freeRenderingGroups(): void;
  24374. /**
  24375. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24376. * @returns the view count
  24377. */
  24378. getViewCount(): number;
  24379. }
  24380. }
  24381. declare module "babylonjs/Misc/guid" {
  24382. /**
  24383. * Class used to manipulate GUIDs
  24384. */
  24385. export class GUID {
  24386. /**
  24387. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24388. * Be aware Math.random() could cause collisions, but:
  24389. * "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"
  24390. * @returns a pseudo random id
  24391. */
  24392. static RandomId(): string;
  24393. }
  24394. }
  24395. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24396. import { Nullable } from "babylonjs/types";
  24397. import { Scene } from "babylonjs/scene";
  24398. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24399. import { Material } from "babylonjs/Materials/material";
  24400. import { Effect } from "babylonjs/Materials/effect";
  24401. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24402. /**
  24403. * Options to be used when creating a shadow depth material
  24404. */
  24405. export interface IIOptionShadowDepthMaterial {
  24406. /** Variables in the vertex shader code that need to have their names remapped.
  24407. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24408. * "var_name" should be either: worldPos or vNormalW
  24409. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24410. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24411. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24412. */
  24413. remappedVariables?: string[];
  24414. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24415. standalone?: boolean;
  24416. }
  24417. /**
  24418. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24419. */
  24420. export class ShadowDepthWrapper {
  24421. private _scene;
  24422. private _options?;
  24423. private _baseMaterial;
  24424. private _onEffectCreatedObserver;
  24425. private _subMeshToEffect;
  24426. private _subMeshToDepthEffect;
  24427. private _meshes;
  24428. /** @hidden */
  24429. _matriceNames: any;
  24430. /** Gets the standalone status of the wrapper */
  24431. get standalone(): boolean;
  24432. /** Gets the base material the wrapper is built upon */
  24433. get baseMaterial(): Material;
  24434. /**
  24435. * Instantiate a new shadow depth wrapper.
  24436. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24437. * generate the shadow depth map. For more information, please refer to the documentation:
  24438. * https://doc.babylonjs.com/babylon101/shadows
  24439. * @param baseMaterial Material to wrap
  24440. * @param scene Define the scene the material belongs to
  24441. * @param options Options used to create the wrapper
  24442. */
  24443. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24444. /**
  24445. * Gets the effect to use to generate the depth map
  24446. * @param subMesh subMesh to get the effect for
  24447. * @param shadowGenerator shadow generator to get the effect for
  24448. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24449. */
  24450. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24451. /**
  24452. * Specifies that the submesh is ready to be used for depth rendering
  24453. * @param subMesh submesh to check
  24454. * @param defines the list of defines to take into account when checking the effect
  24455. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24456. * @param useInstances specifies that instances should be used
  24457. * @returns a boolean indicating that the submesh is ready or not
  24458. */
  24459. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24460. /**
  24461. * Disposes the resources
  24462. */
  24463. dispose(): void;
  24464. private _makeEffect;
  24465. }
  24466. }
  24467. declare module "babylonjs/Materials/material" {
  24468. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24469. import { SmartArray } from "babylonjs/Misc/smartArray";
  24470. import { Observable } from "babylonjs/Misc/observable";
  24471. import { Nullable } from "babylonjs/types";
  24472. import { Scene } from "babylonjs/scene";
  24473. import { Matrix } from "babylonjs/Maths/math.vector";
  24474. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24476. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24477. import { Effect } from "babylonjs/Materials/effect";
  24478. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24479. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24480. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24481. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24482. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  24483. import { Mesh } from "babylonjs/Meshes/mesh";
  24484. import { Animation } from "babylonjs/Animations/animation";
  24485. /**
  24486. * Options for compiling materials.
  24487. */
  24488. export interface IMaterialCompilationOptions {
  24489. /**
  24490. * Defines whether clip planes are enabled.
  24491. */
  24492. clipPlane: boolean;
  24493. /**
  24494. * Defines whether instances are enabled.
  24495. */
  24496. useInstances: boolean;
  24497. }
  24498. /**
  24499. * Options passed when calling customShaderNameResolve
  24500. */
  24501. export interface ICustomShaderNameResolveOptions {
  24502. /**
  24503. * 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
  24504. */
  24505. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24506. }
  24507. /**
  24508. * Base class for the main features of a material in Babylon.js
  24509. */
  24510. export class Material implements IAnimatable {
  24511. /**
  24512. * Returns the triangle fill mode
  24513. */
  24514. static readonly TriangleFillMode: number;
  24515. /**
  24516. * Returns the wireframe mode
  24517. */
  24518. static readonly WireFrameFillMode: number;
  24519. /**
  24520. * Returns the point fill mode
  24521. */
  24522. static readonly PointFillMode: number;
  24523. /**
  24524. * Returns the point list draw mode
  24525. */
  24526. static readonly PointListDrawMode: number;
  24527. /**
  24528. * Returns the line list draw mode
  24529. */
  24530. static readonly LineListDrawMode: number;
  24531. /**
  24532. * Returns the line loop draw mode
  24533. */
  24534. static readonly LineLoopDrawMode: number;
  24535. /**
  24536. * Returns the line strip draw mode
  24537. */
  24538. static readonly LineStripDrawMode: number;
  24539. /**
  24540. * Returns the triangle strip draw mode
  24541. */
  24542. static readonly TriangleStripDrawMode: number;
  24543. /**
  24544. * Returns the triangle fan draw mode
  24545. */
  24546. static readonly TriangleFanDrawMode: number;
  24547. /**
  24548. * Stores the clock-wise side orientation
  24549. */
  24550. static readonly ClockWiseSideOrientation: number;
  24551. /**
  24552. * Stores the counter clock-wise side orientation
  24553. */
  24554. static readonly CounterClockWiseSideOrientation: number;
  24555. /**
  24556. * The dirty texture flag value
  24557. */
  24558. static readonly TextureDirtyFlag: number;
  24559. /**
  24560. * The dirty light flag value
  24561. */
  24562. static readonly LightDirtyFlag: number;
  24563. /**
  24564. * The dirty fresnel flag value
  24565. */
  24566. static readonly FresnelDirtyFlag: number;
  24567. /**
  24568. * The dirty attribute flag value
  24569. */
  24570. static readonly AttributesDirtyFlag: number;
  24571. /**
  24572. * The dirty misc flag value
  24573. */
  24574. static readonly MiscDirtyFlag: number;
  24575. /**
  24576. * The all dirty flag value
  24577. */
  24578. static readonly AllDirtyFlag: number;
  24579. /**
  24580. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24581. */
  24582. static readonly MATERIAL_OPAQUE: number;
  24583. /**
  24584. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24585. */
  24586. static readonly MATERIAL_ALPHATEST: number;
  24587. /**
  24588. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24589. */
  24590. static readonly MATERIAL_ALPHABLEND: number;
  24591. /**
  24592. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24593. * They are also discarded below the alpha cutoff threshold to improve performances.
  24594. */
  24595. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24596. /**
  24597. * Custom callback helping to override the default shader used in the material.
  24598. */
  24599. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24600. /**
  24601. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24602. */
  24603. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24604. /**
  24605. * The ID of the material
  24606. */
  24607. id: string;
  24608. /**
  24609. * Gets or sets the unique id of the material
  24610. */
  24611. uniqueId: number;
  24612. /**
  24613. * The name of the material
  24614. */
  24615. name: string;
  24616. /**
  24617. * Gets or sets user defined metadata
  24618. */
  24619. metadata: any;
  24620. /**
  24621. * For internal use only. Please do not use.
  24622. */
  24623. reservedDataStore: any;
  24624. /**
  24625. * Specifies if the ready state should be checked on each call
  24626. */
  24627. checkReadyOnEveryCall: boolean;
  24628. /**
  24629. * Specifies if the ready state should be checked once
  24630. */
  24631. checkReadyOnlyOnce: boolean;
  24632. /**
  24633. * The state of the material
  24634. */
  24635. state: string;
  24636. /**
  24637. * The alpha value of the material
  24638. */
  24639. protected _alpha: number;
  24640. /**
  24641. * List of inspectable custom properties (used by the Inspector)
  24642. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24643. */
  24644. inspectableCustomProperties: IInspectable[];
  24645. /**
  24646. * Sets the alpha value of the material
  24647. */
  24648. set alpha(value: number);
  24649. /**
  24650. * Gets the alpha value of the material
  24651. */
  24652. get alpha(): number;
  24653. /**
  24654. * Specifies if back face culling is enabled
  24655. */
  24656. protected _backFaceCulling: boolean;
  24657. /**
  24658. * Sets the back-face culling state
  24659. */
  24660. set backFaceCulling(value: boolean);
  24661. /**
  24662. * Gets the back-face culling state
  24663. */
  24664. get backFaceCulling(): boolean;
  24665. /**
  24666. * Stores the value for side orientation
  24667. */
  24668. sideOrientation: number;
  24669. /**
  24670. * Callback triggered when the material is compiled
  24671. */
  24672. onCompiled: Nullable<(effect: Effect) => void>;
  24673. /**
  24674. * Callback triggered when an error occurs
  24675. */
  24676. onError: Nullable<(effect: Effect, errors: string) => void>;
  24677. /**
  24678. * Callback triggered to get the render target textures
  24679. */
  24680. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24681. /**
  24682. * Gets a boolean indicating that current material needs to register RTT
  24683. */
  24684. get hasRenderTargetTextures(): boolean;
  24685. /**
  24686. * Specifies if the material should be serialized
  24687. */
  24688. doNotSerialize: boolean;
  24689. /**
  24690. * @hidden
  24691. */
  24692. _storeEffectOnSubMeshes: boolean;
  24693. /**
  24694. * Stores the animations for the material
  24695. */
  24696. animations: Nullable<Array<Animation>>;
  24697. /**
  24698. * An event triggered when the material is disposed
  24699. */
  24700. onDisposeObservable: Observable<Material>;
  24701. /**
  24702. * An observer which watches for dispose events
  24703. */
  24704. private _onDisposeObserver;
  24705. private _onUnBindObservable;
  24706. /**
  24707. * Called during a dispose event
  24708. */
  24709. set onDispose(callback: () => void);
  24710. private _onBindObservable;
  24711. /**
  24712. * An event triggered when the material is bound
  24713. */
  24714. get onBindObservable(): Observable<AbstractMesh>;
  24715. /**
  24716. * An observer which watches for bind events
  24717. */
  24718. private _onBindObserver;
  24719. /**
  24720. * Called during a bind event
  24721. */
  24722. set onBind(callback: (Mesh: AbstractMesh) => void);
  24723. /**
  24724. * An event triggered when the material is unbound
  24725. */
  24726. get onUnBindObservable(): Observable<Material>;
  24727. protected _onEffectCreatedObservable: Nullable<Observable<{
  24728. effect: Effect;
  24729. subMesh: Nullable<SubMesh>;
  24730. }>>;
  24731. /**
  24732. * An event triggered when the effect is (re)created
  24733. */
  24734. get onEffectCreatedObservable(): Observable<{
  24735. effect: Effect;
  24736. subMesh: Nullable<SubMesh>;
  24737. }>;
  24738. /**
  24739. * Stores the value of the alpha mode
  24740. */
  24741. private _alphaMode;
  24742. /**
  24743. * Sets the value of the alpha mode.
  24744. *
  24745. * | Value | Type | Description |
  24746. * | --- | --- | --- |
  24747. * | 0 | ALPHA_DISABLE | |
  24748. * | 1 | ALPHA_ADD | |
  24749. * | 2 | ALPHA_COMBINE | |
  24750. * | 3 | ALPHA_SUBTRACT | |
  24751. * | 4 | ALPHA_MULTIPLY | |
  24752. * | 5 | ALPHA_MAXIMIZED | |
  24753. * | 6 | ALPHA_ONEONE | |
  24754. * | 7 | ALPHA_PREMULTIPLIED | |
  24755. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24756. * | 9 | ALPHA_INTERPOLATE | |
  24757. * | 10 | ALPHA_SCREENMODE | |
  24758. *
  24759. */
  24760. set alphaMode(value: number);
  24761. /**
  24762. * Gets the value of the alpha mode
  24763. */
  24764. get alphaMode(): number;
  24765. /**
  24766. * Stores the state of the need depth pre-pass value
  24767. */
  24768. private _needDepthPrePass;
  24769. /**
  24770. * Sets the need depth pre-pass value
  24771. */
  24772. set needDepthPrePass(value: boolean);
  24773. /**
  24774. * Gets the depth pre-pass value
  24775. */
  24776. get needDepthPrePass(): boolean;
  24777. /**
  24778. * Specifies if depth writing should be disabled
  24779. */
  24780. disableDepthWrite: boolean;
  24781. /**
  24782. * Specifies if color writing should be disabled
  24783. */
  24784. disableColorWrite: boolean;
  24785. /**
  24786. * Specifies if depth writing should be forced
  24787. */
  24788. forceDepthWrite: boolean;
  24789. /**
  24790. * Specifies the depth function that should be used. 0 means the default engine function
  24791. */
  24792. depthFunction: number;
  24793. /**
  24794. * Specifies if there should be a separate pass for culling
  24795. */
  24796. separateCullingPass: boolean;
  24797. /**
  24798. * Stores the state specifing if fog should be enabled
  24799. */
  24800. private _fogEnabled;
  24801. /**
  24802. * Sets the state for enabling fog
  24803. */
  24804. set fogEnabled(value: boolean);
  24805. /**
  24806. * Gets the value of the fog enabled state
  24807. */
  24808. get fogEnabled(): boolean;
  24809. /**
  24810. * Stores the size of points
  24811. */
  24812. pointSize: number;
  24813. /**
  24814. * Stores the z offset value
  24815. */
  24816. zOffset: number;
  24817. get wireframe(): boolean;
  24818. /**
  24819. * Sets the state of wireframe mode
  24820. */
  24821. set wireframe(value: boolean);
  24822. /**
  24823. * Gets the value specifying if point clouds are enabled
  24824. */
  24825. get pointsCloud(): boolean;
  24826. /**
  24827. * Sets the state of point cloud mode
  24828. */
  24829. set pointsCloud(value: boolean);
  24830. /**
  24831. * Gets the material fill mode
  24832. */
  24833. get fillMode(): number;
  24834. /**
  24835. * Sets the material fill mode
  24836. */
  24837. set fillMode(value: number);
  24838. /**
  24839. * @hidden
  24840. * Stores the effects for the material
  24841. */
  24842. _effect: Nullable<Effect>;
  24843. /**
  24844. * Specifies if uniform buffers should be used
  24845. */
  24846. private _useUBO;
  24847. /**
  24848. * Stores a reference to the scene
  24849. */
  24850. private _scene;
  24851. /**
  24852. * Stores the fill mode state
  24853. */
  24854. private _fillMode;
  24855. /**
  24856. * Specifies if the depth write state should be cached
  24857. */
  24858. private _cachedDepthWriteState;
  24859. /**
  24860. * Specifies if the color write state should be cached
  24861. */
  24862. private _cachedColorWriteState;
  24863. /**
  24864. * Specifies if the depth function state should be cached
  24865. */
  24866. private _cachedDepthFunctionState;
  24867. /**
  24868. * Stores the uniform buffer
  24869. */
  24870. protected _uniformBuffer: UniformBuffer;
  24871. /** @hidden */
  24872. _indexInSceneMaterialArray: number;
  24873. /** @hidden */
  24874. meshMap: Nullable<{
  24875. [id: string]: AbstractMesh | undefined;
  24876. }>;
  24877. /**
  24878. * Creates a material instance
  24879. * @param name defines the name of the material
  24880. * @param scene defines the scene to reference
  24881. * @param doNotAdd specifies if the material should be added to the scene
  24882. */
  24883. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24884. /**
  24885. * Returns a string representation of the current material
  24886. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24887. * @returns a string with material information
  24888. */
  24889. toString(fullDetails?: boolean): string;
  24890. /**
  24891. * Gets the class name of the material
  24892. * @returns a string with the class name of the material
  24893. */
  24894. getClassName(): string;
  24895. /**
  24896. * Specifies if updates for the material been locked
  24897. */
  24898. get isFrozen(): boolean;
  24899. /**
  24900. * Locks updates for the material
  24901. */
  24902. freeze(): void;
  24903. /**
  24904. * Unlocks updates for the material
  24905. */
  24906. unfreeze(): void;
  24907. /**
  24908. * Specifies if the material is ready to be used
  24909. * @param mesh defines the mesh to check
  24910. * @param useInstances specifies if instances should be used
  24911. * @returns a boolean indicating if the material is ready to be used
  24912. */
  24913. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24914. /**
  24915. * Specifies that the submesh is ready to be used
  24916. * @param mesh defines the mesh to check
  24917. * @param subMesh defines which submesh to check
  24918. * @param useInstances specifies that instances should be used
  24919. * @returns a boolean indicating that the submesh is ready or not
  24920. */
  24921. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24922. /**
  24923. * Returns the material effect
  24924. * @returns the effect associated with the material
  24925. */
  24926. getEffect(): Nullable<Effect>;
  24927. /**
  24928. * Returns the current scene
  24929. * @returns a Scene
  24930. */
  24931. getScene(): Scene;
  24932. /**
  24933. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24934. */
  24935. protected _forceAlphaTest: boolean;
  24936. /**
  24937. * The transparency mode of the material.
  24938. */
  24939. protected _transparencyMode: Nullable<number>;
  24940. /**
  24941. * Gets the current transparency mode.
  24942. */
  24943. get transparencyMode(): Nullable<number>;
  24944. /**
  24945. * Sets the transparency mode of the material.
  24946. *
  24947. * | Value | Type | Description |
  24948. * | ----- | ----------------------------------- | ----------- |
  24949. * | 0 | OPAQUE | |
  24950. * | 1 | ALPHATEST | |
  24951. * | 2 | ALPHABLEND | |
  24952. * | 3 | ALPHATESTANDBLEND | |
  24953. *
  24954. */
  24955. set transparencyMode(value: Nullable<number>);
  24956. /**
  24957. * Returns true if alpha blending should be disabled.
  24958. */
  24959. protected get _disableAlphaBlending(): boolean;
  24960. /**
  24961. * Specifies whether or not this material should be rendered in alpha blend mode.
  24962. * @returns a boolean specifying if alpha blending is needed
  24963. */
  24964. needAlphaBlending(): boolean;
  24965. /**
  24966. * Specifies if the mesh will require alpha blending
  24967. * @param mesh defines the mesh to check
  24968. * @returns a boolean specifying if alpha blending is needed for the mesh
  24969. */
  24970. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24971. /**
  24972. * Specifies whether or not this material should be rendered in alpha test mode.
  24973. * @returns a boolean specifying if an alpha test is needed.
  24974. */
  24975. needAlphaTesting(): boolean;
  24976. /**
  24977. * Specifies if material alpha testing should be turned on for the mesh
  24978. * @param mesh defines the mesh to check
  24979. */
  24980. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24981. /**
  24982. * Gets the texture used for the alpha test
  24983. * @returns the texture to use for alpha testing
  24984. */
  24985. getAlphaTestTexture(): Nullable<BaseTexture>;
  24986. /**
  24987. * Marks the material to indicate that it needs to be re-calculated
  24988. */
  24989. markDirty(): void;
  24990. /** @hidden */
  24991. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24992. /**
  24993. * Binds the material to the mesh
  24994. * @param world defines the world transformation matrix
  24995. * @param mesh defines the mesh to bind the material to
  24996. */
  24997. bind(world: Matrix, mesh?: Mesh): void;
  24998. /**
  24999. * Binds the submesh to the material
  25000. * @param world defines the world transformation matrix
  25001. * @param mesh defines the mesh containing the submesh
  25002. * @param subMesh defines the submesh to bind the material to
  25003. */
  25004. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25005. /**
  25006. * Binds the world matrix to the material
  25007. * @param world defines the world transformation matrix
  25008. */
  25009. bindOnlyWorldMatrix(world: Matrix): void;
  25010. /**
  25011. * Binds the scene's uniform buffer to the effect.
  25012. * @param effect defines the effect to bind to the scene uniform buffer
  25013. * @param sceneUbo defines the uniform buffer storing scene data
  25014. */
  25015. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25016. /**
  25017. * Binds the view matrix to the effect
  25018. * @param effect defines the effect to bind the view matrix to
  25019. */
  25020. bindView(effect: Effect): void;
  25021. /**
  25022. * Binds the view projection matrix to the effect
  25023. * @param effect defines the effect to bind the view projection matrix to
  25024. */
  25025. bindViewProjection(effect: Effect): void;
  25026. /**
  25027. * Processes to execute after binding the material to a mesh
  25028. * @param mesh defines the rendered mesh
  25029. */
  25030. protected _afterBind(mesh?: Mesh): void;
  25031. /**
  25032. * Unbinds the material from the mesh
  25033. */
  25034. unbind(): void;
  25035. /**
  25036. * Gets the active textures from the material
  25037. * @returns an array of textures
  25038. */
  25039. getActiveTextures(): BaseTexture[];
  25040. /**
  25041. * Specifies if the material uses a texture
  25042. * @param texture defines the texture to check against the material
  25043. * @returns a boolean specifying if the material uses the texture
  25044. */
  25045. hasTexture(texture: BaseTexture): boolean;
  25046. /**
  25047. * Makes a duplicate of the material, and gives it a new name
  25048. * @param name defines the new name for the duplicated material
  25049. * @returns the cloned material
  25050. */
  25051. clone(name: string): Nullable<Material>;
  25052. /**
  25053. * Gets the meshes bound to the material
  25054. * @returns an array of meshes bound to the material
  25055. */
  25056. getBindedMeshes(): AbstractMesh[];
  25057. /**
  25058. * Force shader compilation
  25059. * @param mesh defines the mesh associated with this material
  25060. * @param onCompiled defines a function to execute once the material is compiled
  25061. * @param options defines the options to configure the compilation
  25062. * @param onError defines a function to execute if the material fails compiling
  25063. */
  25064. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25065. /**
  25066. * Force shader compilation
  25067. * @param mesh defines the mesh that will use this material
  25068. * @param options defines additional options for compiling the shaders
  25069. * @returns a promise that resolves when the compilation completes
  25070. */
  25071. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25072. private static readonly _AllDirtyCallBack;
  25073. private static readonly _ImageProcessingDirtyCallBack;
  25074. private static readonly _TextureDirtyCallBack;
  25075. private static readonly _FresnelDirtyCallBack;
  25076. private static readonly _MiscDirtyCallBack;
  25077. private static readonly _LightsDirtyCallBack;
  25078. private static readonly _AttributeDirtyCallBack;
  25079. private static _FresnelAndMiscDirtyCallBack;
  25080. private static _TextureAndMiscDirtyCallBack;
  25081. private static readonly _DirtyCallbackArray;
  25082. private static readonly _RunDirtyCallBacks;
  25083. /**
  25084. * Marks a define in the material to indicate that it needs to be re-computed
  25085. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25086. */
  25087. markAsDirty(flag: number): void;
  25088. /**
  25089. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25090. * @param func defines a function which checks material defines against the submeshes
  25091. */
  25092. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25093. /**
  25094. * Indicates that we need to re-calculated for all submeshes
  25095. */
  25096. protected _markAllSubMeshesAsAllDirty(): void;
  25097. /**
  25098. * Indicates that image processing needs to be re-calculated for all submeshes
  25099. */
  25100. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25101. /**
  25102. * Indicates that textures need to be re-calculated for all submeshes
  25103. */
  25104. protected _markAllSubMeshesAsTexturesDirty(): void;
  25105. /**
  25106. * Indicates that fresnel needs to be re-calculated for all submeshes
  25107. */
  25108. protected _markAllSubMeshesAsFresnelDirty(): void;
  25109. /**
  25110. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25111. */
  25112. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25113. /**
  25114. * Indicates that lights need to be re-calculated for all submeshes
  25115. */
  25116. protected _markAllSubMeshesAsLightsDirty(): void;
  25117. /**
  25118. * Indicates that attributes need to be re-calculated for all submeshes
  25119. */
  25120. protected _markAllSubMeshesAsAttributesDirty(): void;
  25121. /**
  25122. * Indicates that misc needs to be re-calculated for all submeshes
  25123. */
  25124. protected _markAllSubMeshesAsMiscDirty(): void;
  25125. /**
  25126. * Indicates that textures and misc need to be re-calculated for all submeshes
  25127. */
  25128. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25129. /**
  25130. * Disposes the material
  25131. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25132. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25133. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25134. */
  25135. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25136. /** @hidden */
  25137. private releaseVertexArrayObject;
  25138. /**
  25139. * Serializes this material
  25140. * @returns the serialized material object
  25141. */
  25142. serialize(): any;
  25143. /**
  25144. * Creates a material from parsed material data
  25145. * @param parsedMaterial defines parsed material data
  25146. * @param scene defines the hosting scene
  25147. * @param rootUrl defines the root URL to use to load textures
  25148. * @returns a new material
  25149. */
  25150. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25151. }
  25152. }
  25153. declare module "babylonjs/Materials/multiMaterial" {
  25154. import { Nullable } from "babylonjs/types";
  25155. import { Scene } from "babylonjs/scene";
  25156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25157. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25158. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25159. import { Material } from "babylonjs/Materials/material";
  25160. /**
  25161. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25162. * separate meshes. This can be use to improve performances.
  25163. * @see http://doc.babylonjs.com/how_to/multi_materials
  25164. */
  25165. export class MultiMaterial extends Material {
  25166. private _subMaterials;
  25167. /**
  25168. * Gets or Sets the list of Materials used within the multi material.
  25169. * They need to be ordered according to the submeshes order in the associated mesh
  25170. */
  25171. get subMaterials(): Nullable<Material>[];
  25172. set subMaterials(value: Nullable<Material>[]);
  25173. /**
  25174. * Function used to align with Node.getChildren()
  25175. * @returns the list of Materials used within the multi material
  25176. */
  25177. getChildren(): Nullable<Material>[];
  25178. /**
  25179. * Instantiates a new Multi Material
  25180. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25181. * separate meshes. This can be use to improve performances.
  25182. * @see http://doc.babylonjs.com/how_to/multi_materials
  25183. * @param name Define the name in the scene
  25184. * @param scene Define the scene the material belongs to
  25185. */
  25186. constructor(name: string, scene: Scene);
  25187. private _hookArray;
  25188. /**
  25189. * Get one of the submaterial by its index in the submaterials array
  25190. * @param index The index to look the sub material at
  25191. * @returns The Material if the index has been defined
  25192. */
  25193. getSubMaterial(index: number): Nullable<Material>;
  25194. /**
  25195. * Get the list of active textures for the whole sub materials list.
  25196. * @returns All the textures that will be used during the rendering
  25197. */
  25198. getActiveTextures(): BaseTexture[];
  25199. /**
  25200. * Gets the current class name of the material e.g. "MultiMaterial"
  25201. * Mainly use in serialization.
  25202. * @returns the class name
  25203. */
  25204. getClassName(): string;
  25205. /**
  25206. * Checks if the material is ready to render the requested sub mesh
  25207. * @param mesh Define the mesh the submesh belongs to
  25208. * @param subMesh Define the sub mesh to look readyness for
  25209. * @param useInstances Define whether or not the material is used with instances
  25210. * @returns true if ready, otherwise false
  25211. */
  25212. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25213. /**
  25214. * Clones the current material and its related sub materials
  25215. * @param name Define the name of the newly cloned material
  25216. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25217. * @returns the cloned material
  25218. */
  25219. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25220. /**
  25221. * Serializes the materials into a JSON representation.
  25222. * @returns the JSON representation
  25223. */
  25224. serialize(): any;
  25225. /**
  25226. * Dispose the material and release its associated resources
  25227. * @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)
  25228. * @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)
  25229. * @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)
  25230. */
  25231. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25232. /**
  25233. * Creates a MultiMaterial from parsed MultiMaterial data.
  25234. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25235. * @param scene defines the hosting scene
  25236. * @returns a new MultiMaterial
  25237. */
  25238. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25239. }
  25240. }
  25241. declare module "babylonjs/Meshes/subMesh" {
  25242. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  25243. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25244. import { Engine } from "babylonjs/Engines/engine";
  25245. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  25246. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25247. import { Effect } from "babylonjs/Materials/effect";
  25248. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25249. import { Plane } from "babylonjs/Maths/math.plane";
  25250. import { Collider } from "babylonjs/Collisions/collider";
  25251. import { Material } from "babylonjs/Materials/material";
  25252. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25253. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25254. import { Mesh } from "babylonjs/Meshes/mesh";
  25255. import { Ray } from "babylonjs/Culling/ray";
  25256. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25257. /**
  25258. * Defines a subdivision inside a mesh
  25259. */
  25260. export class SubMesh implements ICullable {
  25261. /** the material index to use */
  25262. materialIndex: number;
  25263. /** vertex index start */
  25264. verticesStart: number;
  25265. /** vertices count */
  25266. verticesCount: number;
  25267. /** index start */
  25268. indexStart: number;
  25269. /** indices count */
  25270. indexCount: number;
  25271. /** @hidden */
  25272. _materialDefines: Nullable<MaterialDefines>;
  25273. /** @hidden */
  25274. _materialEffect: Nullable<Effect>;
  25275. /** @hidden */
  25276. _effectOverride: Nullable<Effect>;
  25277. /**
  25278. * Gets material defines used by the effect associated to the sub mesh
  25279. */
  25280. get materialDefines(): Nullable<MaterialDefines>;
  25281. /**
  25282. * Sets material defines used by the effect associated to the sub mesh
  25283. */
  25284. set materialDefines(defines: Nullable<MaterialDefines>);
  25285. /**
  25286. * Gets associated effect
  25287. */
  25288. get effect(): Nullable<Effect>;
  25289. /**
  25290. * Sets associated effect (effect used to render this submesh)
  25291. * @param effect defines the effect to associate with
  25292. * @param defines defines the set of defines used to compile this effect
  25293. */
  25294. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25295. /** @hidden */
  25296. _linesIndexCount: number;
  25297. private _mesh;
  25298. private _renderingMesh;
  25299. private _boundingInfo;
  25300. private _linesIndexBuffer;
  25301. /** @hidden */
  25302. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25303. /** @hidden */
  25304. _trianglePlanes: Plane[];
  25305. /** @hidden */
  25306. _lastColliderTransformMatrix: Nullable<Matrix>;
  25307. /** @hidden */
  25308. _renderId: number;
  25309. /** @hidden */
  25310. _alphaIndex: number;
  25311. /** @hidden */
  25312. _distanceToCamera: number;
  25313. /** @hidden */
  25314. _id: number;
  25315. private _currentMaterial;
  25316. /**
  25317. * Add a new submesh to a mesh
  25318. * @param materialIndex defines the material index to use
  25319. * @param verticesStart defines vertex index start
  25320. * @param verticesCount defines vertices count
  25321. * @param indexStart defines index start
  25322. * @param indexCount defines indices count
  25323. * @param mesh defines the parent mesh
  25324. * @param renderingMesh defines an optional rendering mesh
  25325. * @param createBoundingBox defines if bounding box should be created for this submesh
  25326. * @returns the new submesh
  25327. */
  25328. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25329. /**
  25330. * Creates a new submesh
  25331. * @param materialIndex defines the material index to use
  25332. * @param verticesStart defines vertex index start
  25333. * @param verticesCount defines vertices count
  25334. * @param indexStart defines index start
  25335. * @param indexCount defines indices count
  25336. * @param mesh defines the parent mesh
  25337. * @param renderingMesh defines an optional rendering mesh
  25338. * @param createBoundingBox defines if bounding box should be created for this submesh
  25339. */
  25340. constructor(
  25341. /** the material index to use */
  25342. materialIndex: number,
  25343. /** vertex index start */
  25344. verticesStart: number,
  25345. /** vertices count */
  25346. verticesCount: number,
  25347. /** index start */
  25348. indexStart: number,
  25349. /** indices count */
  25350. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  25351. /**
  25352. * Returns true if this submesh covers the entire parent mesh
  25353. * @ignorenaming
  25354. */
  25355. get IsGlobal(): boolean;
  25356. /**
  25357. * Returns the submesh BoudingInfo object
  25358. * @returns current bounding info (or mesh's one if the submesh is global)
  25359. */
  25360. getBoundingInfo(): BoundingInfo;
  25361. /**
  25362. * Sets the submesh BoundingInfo
  25363. * @param boundingInfo defines the new bounding info to use
  25364. * @returns the SubMesh
  25365. */
  25366. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25367. /**
  25368. * Returns the mesh of the current submesh
  25369. * @return the parent mesh
  25370. */
  25371. getMesh(): AbstractMesh;
  25372. /**
  25373. * Returns the rendering mesh of the submesh
  25374. * @returns the rendering mesh (could be different from parent mesh)
  25375. */
  25376. getRenderingMesh(): Mesh;
  25377. /**
  25378. * Returns the replacement mesh of the submesh
  25379. * @returns the replacement mesh (could be different from parent mesh)
  25380. */
  25381. getReplacementMesh(): Nullable<AbstractMesh>;
  25382. /**
  25383. * Returns the effective mesh of the submesh
  25384. * @returns the effective mesh (could be different from parent mesh)
  25385. */
  25386. getEffectiveMesh(): AbstractMesh;
  25387. /**
  25388. * Returns the submesh material
  25389. * @returns null or the current material
  25390. */
  25391. getMaterial(): Nullable<Material>;
  25392. /**
  25393. * Sets a new updated BoundingInfo object to the submesh
  25394. * @param data defines an optional position array to use to determine the bounding info
  25395. * @returns the SubMesh
  25396. */
  25397. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25398. /** @hidden */
  25399. _checkCollision(collider: Collider): boolean;
  25400. /**
  25401. * Updates the submesh BoundingInfo
  25402. * @param world defines the world matrix to use to update the bounding info
  25403. * @returns the submesh
  25404. */
  25405. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25406. /**
  25407. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25408. * @param frustumPlanes defines the frustum planes
  25409. * @returns true if the submesh is intersecting with the frustum
  25410. */
  25411. isInFrustum(frustumPlanes: Plane[]): boolean;
  25412. /**
  25413. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25414. * @param frustumPlanes defines the frustum planes
  25415. * @returns true if the submesh is inside the frustum
  25416. */
  25417. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25418. /**
  25419. * Renders the submesh
  25420. * @param enableAlphaMode defines if alpha needs to be used
  25421. * @returns the submesh
  25422. */
  25423. render(enableAlphaMode: boolean): SubMesh;
  25424. /**
  25425. * @hidden
  25426. */
  25427. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25428. /**
  25429. * Checks if the submesh intersects with a ray
  25430. * @param ray defines the ray to test
  25431. * @returns true is the passed ray intersects the submesh bounding box
  25432. */
  25433. canIntersects(ray: Ray): boolean;
  25434. /**
  25435. * Intersects current submesh with a ray
  25436. * @param ray defines the ray to test
  25437. * @param positions defines mesh's positions array
  25438. * @param indices defines mesh's indices array
  25439. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25440. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25441. * @returns intersection info or null if no intersection
  25442. */
  25443. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25444. /** @hidden */
  25445. private _intersectLines;
  25446. /** @hidden */
  25447. private _intersectUnIndexedLines;
  25448. /** @hidden */
  25449. private _intersectTriangles;
  25450. /** @hidden */
  25451. private _intersectUnIndexedTriangles;
  25452. /** @hidden */
  25453. _rebuild(): void;
  25454. /**
  25455. * Creates a new submesh from the passed mesh
  25456. * @param newMesh defines the new hosting mesh
  25457. * @param newRenderingMesh defines an optional rendering mesh
  25458. * @returns the new submesh
  25459. */
  25460. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25461. /**
  25462. * Release associated resources
  25463. */
  25464. dispose(): void;
  25465. /**
  25466. * Gets the class name
  25467. * @returns the string "SubMesh".
  25468. */
  25469. getClassName(): string;
  25470. /**
  25471. * Creates a new submesh from indices data
  25472. * @param materialIndex the index of the main mesh material
  25473. * @param startIndex the index where to start the copy in the mesh indices array
  25474. * @param indexCount the number of indices to copy then from the startIndex
  25475. * @param mesh the main mesh to create the submesh from
  25476. * @param renderingMesh the optional rendering mesh
  25477. * @returns a new submesh
  25478. */
  25479. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25480. }
  25481. }
  25482. declare module "babylonjs/Loading/sceneLoaderFlags" {
  25483. /**
  25484. * Class used to represent data loading progression
  25485. */
  25486. export class SceneLoaderFlags {
  25487. private static _ForceFullSceneLoadingForIncremental;
  25488. private static _ShowLoadingScreen;
  25489. private static _CleanBoneMatrixWeights;
  25490. private static _loggingLevel;
  25491. /**
  25492. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25493. */
  25494. static get ForceFullSceneLoadingForIncremental(): boolean;
  25495. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25496. /**
  25497. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25498. */
  25499. static get ShowLoadingScreen(): boolean;
  25500. static set ShowLoadingScreen(value: boolean);
  25501. /**
  25502. * Defines the current logging level (while loading the scene)
  25503. * @ignorenaming
  25504. */
  25505. static get loggingLevel(): number;
  25506. static set loggingLevel(value: number);
  25507. /**
  25508. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25509. */
  25510. static get CleanBoneMatrixWeights(): boolean;
  25511. static set CleanBoneMatrixWeights(value: boolean);
  25512. }
  25513. }
  25514. declare module "babylonjs/Meshes/geometry" {
  25515. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  25516. import { Scene } from "babylonjs/scene";
  25517. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  25518. import { Engine } from "babylonjs/Engines/engine";
  25519. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  25520. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25521. import { Effect } from "babylonjs/Materials/effect";
  25522. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25523. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25524. import { Mesh } from "babylonjs/Meshes/mesh";
  25525. /**
  25526. * Class used to store geometry data (vertex buffers + index buffer)
  25527. */
  25528. export class Geometry implements IGetSetVerticesData {
  25529. /**
  25530. * Gets or sets the ID of the geometry
  25531. */
  25532. id: string;
  25533. /**
  25534. * Gets or sets the unique ID of the geometry
  25535. */
  25536. uniqueId: number;
  25537. /**
  25538. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25539. */
  25540. delayLoadState: number;
  25541. /**
  25542. * Gets the file containing the data to load when running in delay load state
  25543. */
  25544. delayLoadingFile: Nullable<string>;
  25545. /**
  25546. * Callback called when the geometry is updated
  25547. */
  25548. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25549. private _scene;
  25550. private _engine;
  25551. private _meshes;
  25552. private _totalVertices;
  25553. /** @hidden */
  25554. _indices: IndicesArray;
  25555. /** @hidden */
  25556. _vertexBuffers: {
  25557. [key: string]: VertexBuffer;
  25558. };
  25559. private _isDisposed;
  25560. private _extend;
  25561. private _boundingBias;
  25562. /** @hidden */
  25563. _delayInfo: Array<string>;
  25564. private _indexBuffer;
  25565. private _indexBufferIsUpdatable;
  25566. /** @hidden */
  25567. _boundingInfo: Nullable<BoundingInfo>;
  25568. /** @hidden */
  25569. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25570. /** @hidden */
  25571. _softwareSkinningFrameId: number;
  25572. private _vertexArrayObjects;
  25573. private _updatable;
  25574. /** @hidden */
  25575. _positions: Nullable<Vector3[]>;
  25576. /**
  25577. * 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
  25578. */
  25579. get boundingBias(): Vector2;
  25580. /**
  25581. * 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
  25582. */
  25583. set boundingBias(value: Vector2);
  25584. /**
  25585. * Static function used to attach a new empty geometry to a mesh
  25586. * @param mesh defines the mesh to attach the geometry to
  25587. * @returns the new Geometry
  25588. */
  25589. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25590. /** Get the list of meshes using this geometry */
  25591. get meshes(): Mesh[];
  25592. /**
  25593. * Creates a new geometry
  25594. * @param id defines the unique ID
  25595. * @param scene defines the hosting scene
  25596. * @param vertexData defines the VertexData used to get geometry data
  25597. * @param updatable defines if geometry must be updatable (false by default)
  25598. * @param mesh defines the mesh that will be associated with the geometry
  25599. */
  25600. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25601. /**
  25602. * Gets the current extend of the geometry
  25603. */
  25604. get extend(): {
  25605. minimum: Vector3;
  25606. maximum: Vector3;
  25607. };
  25608. /**
  25609. * Gets the hosting scene
  25610. * @returns the hosting Scene
  25611. */
  25612. getScene(): Scene;
  25613. /**
  25614. * Gets the hosting engine
  25615. * @returns the hosting Engine
  25616. */
  25617. getEngine(): Engine;
  25618. /**
  25619. * Defines if the geometry is ready to use
  25620. * @returns true if the geometry is ready to be used
  25621. */
  25622. isReady(): boolean;
  25623. /**
  25624. * Gets a value indicating that the geometry should not be serialized
  25625. */
  25626. get doNotSerialize(): boolean;
  25627. /** @hidden */
  25628. _rebuild(): void;
  25629. /**
  25630. * Affects all geometry data in one call
  25631. * @param vertexData defines the geometry data
  25632. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25633. */
  25634. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25635. /**
  25636. * Set specific vertex data
  25637. * @param kind defines the data kind (Position, normal, etc...)
  25638. * @param data defines the vertex data to use
  25639. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25640. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25641. */
  25642. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25643. /**
  25644. * Removes a specific vertex data
  25645. * @param kind defines the data kind (Position, normal, etc...)
  25646. */
  25647. removeVerticesData(kind: string): void;
  25648. /**
  25649. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25650. * @param buffer defines the vertex buffer to use
  25651. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25652. */
  25653. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25654. /**
  25655. * Update a specific vertex buffer
  25656. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25657. * It will do nothing if the buffer is not updatable
  25658. * @param kind defines the data kind (Position, normal, etc...)
  25659. * @param data defines the data to use
  25660. * @param offset defines the offset in the target buffer where to store the data
  25661. * @param useBytes set to true if the offset is in bytes
  25662. */
  25663. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25664. /**
  25665. * Update a specific vertex buffer
  25666. * This function will create a new buffer if the current one is not updatable
  25667. * @param kind defines the data kind (Position, normal, etc...)
  25668. * @param data defines the data to use
  25669. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25670. */
  25671. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25672. private _updateBoundingInfo;
  25673. /** @hidden */
  25674. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25675. /**
  25676. * Gets total number of vertices
  25677. * @returns the total number of vertices
  25678. */
  25679. getTotalVertices(): number;
  25680. /**
  25681. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25682. * @param kind defines the data kind (Position, normal, etc...)
  25683. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25684. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25685. * @returns a float array containing vertex data
  25686. */
  25687. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25688. /**
  25689. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25690. * @param kind defines the data kind (Position, normal, etc...)
  25691. * @returns true if the vertex buffer with the specified kind is updatable
  25692. */
  25693. isVertexBufferUpdatable(kind: string): boolean;
  25694. /**
  25695. * Gets a specific vertex buffer
  25696. * @param kind defines the data kind (Position, normal, etc...)
  25697. * @returns a VertexBuffer
  25698. */
  25699. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25700. /**
  25701. * Returns all vertex buffers
  25702. * @return an object holding all vertex buffers indexed by kind
  25703. */
  25704. getVertexBuffers(): Nullable<{
  25705. [key: string]: VertexBuffer;
  25706. }>;
  25707. /**
  25708. * Gets a boolean indicating if specific vertex buffer is present
  25709. * @param kind defines the data kind (Position, normal, etc...)
  25710. * @returns true if data is present
  25711. */
  25712. isVerticesDataPresent(kind: string): boolean;
  25713. /**
  25714. * Gets a list of all attached data kinds (Position, normal, etc...)
  25715. * @returns a list of string containing all kinds
  25716. */
  25717. getVerticesDataKinds(): string[];
  25718. /**
  25719. * Update index buffer
  25720. * @param indices defines the indices to store in the index buffer
  25721. * @param offset defines the offset in the target buffer where to store the data
  25722. * @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)
  25723. */
  25724. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25725. /**
  25726. * Creates a new index buffer
  25727. * @param indices defines the indices to store in the index buffer
  25728. * @param totalVertices defines the total number of vertices (could be null)
  25729. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25730. */
  25731. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25732. /**
  25733. * Return the total number of indices
  25734. * @returns the total number of indices
  25735. */
  25736. getTotalIndices(): number;
  25737. /**
  25738. * Gets the index buffer array
  25739. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25740. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25741. * @returns the index buffer array
  25742. */
  25743. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25744. /**
  25745. * Gets the index buffer
  25746. * @return the index buffer
  25747. */
  25748. getIndexBuffer(): Nullable<DataBuffer>;
  25749. /** @hidden */
  25750. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25751. /**
  25752. * Release the associated resources for a specific mesh
  25753. * @param mesh defines the source mesh
  25754. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25755. */
  25756. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25757. /**
  25758. * Apply current geometry to a given mesh
  25759. * @param mesh defines the mesh to apply geometry to
  25760. */
  25761. applyToMesh(mesh: Mesh): void;
  25762. private _updateExtend;
  25763. private _applyToMesh;
  25764. private notifyUpdate;
  25765. /**
  25766. * Load the geometry if it was flagged as delay loaded
  25767. * @param scene defines the hosting scene
  25768. * @param onLoaded defines a callback called when the geometry is loaded
  25769. */
  25770. load(scene: Scene, onLoaded?: () => void): void;
  25771. private _queueLoad;
  25772. /**
  25773. * Invert the geometry to move from a right handed system to a left handed one.
  25774. */
  25775. toLeftHanded(): void;
  25776. /** @hidden */
  25777. _resetPointsArrayCache(): void;
  25778. /** @hidden */
  25779. _generatePointsArray(): boolean;
  25780. /**
  25781. * Gets a value indicating if the geometry is disposed
  25782. * @returns true if the geometry was disposed
  25783. */
  25784. isDisposed(): boolean;
  25785. private _disposeVertexArrayObjects;
  25786. /**
  25787. * Free all associated resources
  25788. */
  25789. dispose(): void;
  25790. /**
  25791. * Clone the current geometry into a new geometry
  25792. * @param id defines the unique ID of the new geometry
  25793. * @returns a new geometry object
  25794. */
  25795. copy(id: string): Geometry;
  25796. /**
  25797. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25798. * @return a JSON representation of the current geometry data (without the vertices data)
  25799. */
  25800. serialize(): any;
  25801. private toNumberArray;
  25802. /**
  25803. * Serialize all vertices data into a JSON oject
  25804. * @returns a JSON representation of the current geometry data
  25805. */
  25806. serializeVerticeData(): any;
  25807. /**
  25808. * Extracts a clone of a mesh geometry
  25809. * @param mesh defines the source mesh
  25810. * @param id defines the unique ID of the new geometry object
  25811. * @returns the new geometry object
  25812. */
  25813. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25814. /**
  25815. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25816. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25817. * Be aware Math.random() could cause collisions, but:
  25818. * "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"
  25819. * @returns a string containing a new GUID
  25820. */
  25821. static RandomId(): string;
  25822. /** @hidden */
  25823. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25824. private static _CleanMatricesWeights;
  25825. /**
  25826. * Create a new geometry from persisted data (Using .babylon file format)
  25827. * @param parsedVertexData defines the persisted data
  25828. * @param scene defines the hosting scene
  25829. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25830. * @returns the new geometry object
  25831. */
  25832. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25833. }
  25834. }
  25835. declare module "babylonjs/Meshes/mesh.vertexData" {
  25836. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25837. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25838. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  25839. import { Geometry } from "babylonjs/Meshes/geometry";
  25840. import { Mesh } from "babylonjs/Meshes/mesh";
  25841. /**
  25842. * Define an interface for all classes that will get and set the data on vertices
  25843. */
  25844. export interface IGetSetVerticesData {
  25845. /**
  25846. * Gets a boolean indicating if specific vertex data is present
  25847. * @param kind defines the vertex data kind to use
  25848. * @returns true is data kind is present
  25849. */
  25850. isVerticesDataPresent(kind: string): boolean;
  25851. /**
  25852. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25853. * @param kind defines the data kind (Position, normal, etc...)
  25854. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25855. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25856. * @returns a float array containing vertex data
  25857. */
  25858. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25859. /**
  25860. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25861. * @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.
  25862. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25863. * @returns the indices array or an empty array if the mesh has no geometry
  25864. */
  25865. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25866. /**
  25867. * Set specific vertex data
  25868. * @param kind defines the data kind (Position, normal, etc...)
  25869. * @param data defines the vertex data to use
  25870. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25871. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25872. */
  25873. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25874. /**
  25875. * Update a specific associated vertex buffer
  25876. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25877. * - VertexBuffer.PositionKind
  25878. * - VertexBuffer.UVKind
  25879. * - VertexBuffer.UV2Kind
  25880. * - VertexBuffer.UV3Kind
  25881. * - VertexBuffer.UV4Kind
  25882. * - VertexBuffer.UV5Kind
  25883. * - VertexBuffer.UV6Kind
  25884. * - VertexBuffer.ColorKind
  25885. * - VertexBuffer.MatricesIndicesKind
  25886. * - VertexBuffer.MatricesIndicesExtraKind
  25887. * - VertexBuffer.MatricesWeightsKind
  25888. * - VertexBuffer.MatricesWeightsExtraKind
  25889. * @param data defines the data source
  25890. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25891. * @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)
  25892. */
  25893. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25894. /**
  25895. * Creates a new index buffer
  25896. * @param indices defines the indices to store in the index buffer
  25897. * @param totalVertices defines the total number of vertices (could be null)
  25898. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25899. */
  25900. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25901. }
  25902. /**
  25903. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25904. */
  25905. export class VertexData {
  25906. /**
  25907. * Mesh side orientation : usually the external or front surface
  25908. */
  25909. static readonly FRONTSIDE: number;
  25910. /**
  25911. * Mesh side orientation : usually the internal or back surface
  25912. */
  25913. static readonly BACKSIDE: number;
  25914. /**
  25915. * Mesh side orientation : both internal and external or front and back surfaces
  25916. */
  25917. static readonly DOUBLESIDE: number;
  25918. /**
  25919. * Mesh side orientation : by default, `FRONTSIDE`
  25920. */
  25921. static readonly DEFAULTSIDE: number;
  25922. /**
  25923. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25924. */
  25925. positions: Nullable<FloatArray>;
  25926. /**
  25927. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25928. */
  25929. normals: Nullable<FloatArray>;
  25930. /**
  25931. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25932. */
  25933. tangents: Nullable<FloatArray>;
  25934. /**
  25935. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25936. */
  25937. uvs: Nullable<FloatArray>;
  25938. /**
  25939. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25940. */
  25941. uvs2: Nullable<FloatArray>;
  25942. /**
  25943. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25944. */
  25945. uvs3: Nullable<FloatArray>;
  25946. /**
  25947. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25948. */
  25949. uvs4: Nullable<FloatArray>;
  25950. /**
  25951. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25952. */
  25953. uvs5: Nullable<FloatArray>;
  25954. /**
  25955. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25956. */
  25957. uvs6: Nullable<FloatArray>;
  25958. /**
  25959. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25960. */
  25961. colors: Nullable<FloatArray>;
  25962. /**
  25963. * 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).
  25964. */
  25965. matricesIndices: Nullable<FloatArray>;
  25966. /**
  25967. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25968. */
  25969. matricesWeights: Nullable<FloatArray>;
  25970. /**
  25971. * An array extending the number of possible indices
  25972. */
  25973. matricesIndicesExtra: Nullable<FloatArray>;
  25974. /**
  25975. * An array extending the number of possible weights when the number of indices is extended
  25976. */
  25977. matricesWeightsExtra: Nullable<FloatArray>;
  25978. /**
  25979. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25980. */
  25981. indices: Nullable<IndicesArray>;
  25982. /**
  25983. * Uses the passed data array to set the set the values for the specified kind of data
  25984. * @param data a linear array of floating numbers
  25985. * @param kind the type of data that is being set, eg positions, colors etc
  25986. */
  25987. set(data: FloatArray, kind: string): void;
  25988. /**
  25989. * Associates the vertexData to the passed Mesh.
  25990. * Sets it as updatable or not (default `false`)
  25991. * @param mesh the mesh the vertexData is applied to
  25992. * @param updatable when used and having the value true allows new data to update the vertexData
  25993. * @returns the VertexData
  25994. */
  25995. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25996. /**
  25997. * Associates the vertexData to the passed Geometry.
  25998. * Sets it as updatable or not (default `false`)
  25999. * @param geometry the geometry the vertexData is applied to
  26000. * @param updatable when used and having the value true allows new data to update the vertexData
  26001. * @returns VertexData
  26002. */
  26003. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26004. /**
  26005. * Updates the associated mesh
  26006. * @param mesh the mesh to be updated
  26007. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26008. * @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
  26009. * @returns VertexData
  26010. */
  26011. updateMesh(mesh: Mesh): VertexData;
  26012. /**
  26013. * Updates the associated geometry
  26014. * @param geometry the geometry to be updated
  26015. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26016. * @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
  26017. * @returns VertexData.
  26018. */
  26019. updateGeometry(geometry: Geometry): VertexData;
  26020. private _applyTo;
  26021. private _update;
  26022. /**
  26023. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26024. * @param matrix the transforming matrix
  26025. * @returns the VertexData
  26026. */
  26027. transform(matrix: Matrix): VertexData;
  26028. /**
  26029. * Merges the passed VertexData into the current one
  26030. * @param other the VertexData to be merged into the current one
  26031. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26032. * @returns the modified VertexData
  26033. */
  26034. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26035. private _mergeElement;
  26036. private _validate;
  26037. /**
  26038. * Serializes the VertexData
  26039. * @returns a serialized object
  26040. */
  26041. serialize(): any;
  26042. /**
  26043. * Extracts the vertexData from a mesh
  26044. * @param mesh the mesh from which to extract the VertexData
  26045. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26046. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26047. * @returns the object VertexData associated to the passed mesh
  26048. */
  26049. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26050. /**
  26051. * Extracts the vertexData from the geometry
  26052. * @param geometry the geometry from which to extract the VertexData
  26053. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26054. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26055. * @returns the object VertexData associated to the passed mesh
  26056. */
  26057. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26058. private static _ExtractFrom;
  26059. /**
  26060. * Creates the VertexData for a Ribbon
  26061. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26062. * * pathArray array of paths, each of which an array of successive Vector3
  26063. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26064. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26065. * * 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
  26066. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26067. * * 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)
  26068. * * 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)
  26069. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26070. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26071. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26072. * @returns the VertexData of the ribbon
  26073. */
  26074. static CreateRibbon(options: {
  26075. pathArray: Vector3[][];
  26076. closeArray?: boolean;
  26077. closePath?: boolean;
  26078. offset?: number;
  26079. sideOrientation?: number;
  26080. frontUVs?: Vector4;
  26081. backUVs?: Vector4;
  26082. invertUV?: boolean;
  26083. uvs?: Vector2[];
  26084. colors?: Color4[];
  26085. }): VertexData;
  26086. /**
  26087. * Creates the VertexData for a box
  26088. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26089. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26090. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26091. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26092. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26093. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26094. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26095. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26096. * * 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)
  26097. * * 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)
  26098. * @returns the VertexData of the box
  26099. */
  26100. static CreateBox(options: {
  26101. size?: number;
  26102. width?: number;
  26103. height?: number;
  26104. depth?: number;
  26105. faceUV?: Vector4[];
  26106. faceColors?: Color4[];
  26107. sideOrientation?: number;
  26108. frontUVs?: Vector4;
  26109. backUVs?: Vector4;
  26110. }): VertexData;
  26111. /**
  26112. * Creates the VertexData for a tiled box
  26113. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26114. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26115. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26116. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26117. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26118. * @returns the VertexData of the box
  26119. */
  26120. static CreateTiledBox(options: {
  26121. pattern?: number;
  26122. width?: number;
  26123. height?: number;
  26124. depth?: number;
  26125. tileSize?: number;
  26126. tileWidth?: number;
  26127. tileHeight?: number;
  26128. alignHorizontal?: number;
  26129. alignVertical?: number;
  26130. faceUV?: Vector4[];
  26131. faceColors?: Color4[];
  26132. sideOrientation?: number;
  26133. }): VertexData;
  26134. /**
  26135. * Creates the VertexData for a tiled plane
  26136. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26137. * * pattern a limited pattern arrangement depending on the number
  26138. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26139. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26140. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26141. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26142. * * 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)
  26143. * * 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)
  26144. * @returns the VertexData of the tiled plane
  26145. */
  26146. static CreateTiledPlane(options: {
  26147. pattern?: number;
  26148. tileSize?: number;
  26149. tileWidth?: number;
  26150. tileHeight?: number;
  26151. size?: number;
  26152. width?: number;
  26153. height?: number;
  26154. alignHorizontal?: number;
  26155. alignVertical?: number;
  26156. sideOrientation?: number;
  26157. frontUVs?: Vector4;
  26158. backUVs?: Vector4;
  26159. }): VertexData;
  26160. /**
  26161. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26162. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26163. * * segments sets the number of horizontal strips optional, default 32
  26164. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26165. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26166. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26167. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26168. * * 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
  26169. * * 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
  26170. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26171. * * 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)
  26172. * * 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)
  26173. * @returns the VertexData of the ellipsoid
  26174. */
  26175. static CreateSphere(options: {
  26176. segments?: number;
  26177. diameter?: number;
  26178. diameterX?: number;
  26179. diameterY?: number;
  26180. diameterZ?: number;
  26181. arc?: number;
  26182. slice?: number;
  26183. sideOrientation?: number;
  26184. frontUVs?: Vector4;
  26185. backUVs?: Vector4;
  26186. }): VertexData;
  26187. /**
  26188. * Creates the VertexData for a cylinder, cone or prism
  26189. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26190. * * height sets the height (y direction) of the cylinder, optional, default 2
  26191. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26192. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26193. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26194. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26195. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26196. * * 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
  26197. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26198. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26199. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26200. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26201. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26202. * * 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)
  26203. * * 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)
  26204. * @returns the VertexData of the cylinder, cone or prism
  26205. */
  26206. static CreateCylinder(options: {
  26207. height?: number;
  26208. diameterTop?: number;
  26209. diameterBottom?: number;
  26210. diameter?: number;
  26211. tessellation?: number;
  26212. subdivisions?: number;
  26213. arc?: number;
  26214. faceColors?: Color4[];
  26215. faceUV?: Vector4[];
  26216. hasRings?: boolean;
  26217. enclose?: boolean;
  26218. sideOrientation?: number;
  26219. frontUVs?: Vector4;
  26220. backUVs?: Vector4;
  26221. }): VertexData;
  26222. /**
  26223. * Creates the VertexData for a torus
  26224. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26225. * * diameter the diameter of the torus, optional default 1
  26226. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26227. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26228. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26229. * * 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)
  26230. * * 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)
  26231. * @returns the VertexData of the torus
  26232. */
  26233. static CreateTorus(options: {
  26234. diameter?: number;
  26235. thickness?: number;
  26236. tessellation?: number;
  26237. sideOrientation?: number;
  26238. frontUVs?: Vector4;
  26239. backUVs?: Vector4;
  26240. }): VertexData;
  26241. /**
  26242. * Creates the VertexData of the LineSystem
  26243. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26244. * - lines an array of lines, each line being an array of successive Vector3
  26245. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26246. * @returns the VertexData of the LineSystem
  26247. */
  26248. static CreateLineSystem(options: {
  26249. lines: Vector3[][];
  26250. colors?: Nullable<Color4[][]>;
  26251. }): VertexData;
  26252. /**
  26253. * Create the VertexData for a DashedLines
  26254. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26255. * - points an array successive Vector3
  26256. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26257. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26258. * - dashNb the intended total number of dashes, optional, default 200
  26259. * @returns the VertexData for the DashedLines
  26260. */
  26261. static CreateDashedLines(options: {
  26262. points: Vector3[];
  26263. dashSize?: number;
  26264. gapSize?: number;
  26265. dashNb?: number;
  26266. }): VertexData;
  26267. /**
  26268. * Creates the VertexData for a Ground
  26269. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26270. * - width the width (x direction) of the ground, optional, default 1
  26271. * - height the height (z direction) of the ground, optional, default 1
  26272. * - subdivisions the number of subdivisions per side, optional, default 1
  26273. * @returns the VertexData of the Ground
  26274. */
  26275. static CreateGround(options: {
  26276. width?: number;
  26277. height?: number;
  26278. subdivisions?: number;
  26279. subdivisionsX?: number;
  26280. subdivisionsY?: number;
  26281. }): VertexData;
  26282. /**
  26283. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26284. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26285. * * xmin the ground minimum X coordinate, optional, default -1
  26286. * * zmin the ground minimum Z coordinate, optional, default -1
  26287. * * xmax the ground maximum X coordinate, optional, default 1
  26288. * * zmax the ground maximum Z coordinate, optional, default 1
  26289. * * 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}
  26290. * * 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}
  26291. * @returns the VertexData of the TiledGround
  26292. */
  26293. static CreateTiledGround(options: {
  26294. xmin: number;
  26295. zmin: number;
  26296. xmax: number;
  26297. zmax: number;
  26298. subdivisions?: {
  26299. w: number;
  26300. h: number;
  26301. };
  26302. precision?: {
  26303. w: number;
  26304. h: number;
  26305. };
  26306. }): VertexData;
  26307. /**
  26308. * Creates the VertexData of the Ground designed from a heightmap
  26309. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26310. * * width the width (x direction) of the ground
  26311. * * height the height (z direction) of the ground
  26312. * * subdivisions the number of subdivisions per side
  26313. * * minHeight the minimum altitude on the ground, optional, default 0
  26314. * * maxHeight the maximum altitude on the ground, optional default 1
  26315. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26316. * * buffer the array holding the image color data
  26317. * * bufferWidth the width of image
  26318. * * bufferHeight the height of image
  26319. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26320. * @returns the VertexData of the Ground designed from a heightmap
  26321. */
  26322. static CreateGroundFromHeightMap(options: {
  26323. width: number;
  26324. height: number;
  26325. subdivisions: number;
  26326. minHeight: number;
  26327. maxHeight: number;
  26328. colorFilter: Color3;
  26329. buffer: Uint8Array;
  26330. bufferWidth: number;
  26331. bufferHeight: number;
  26332. alphaFilter: number;
  26333. }): VertexData;
  26334. /**
  26335. * Creates the VertexData for a Plane
  26336. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26337. * * size sets the width and height of the plane to the value of size, optional default 1
  26338. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26339. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26340. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26341. * * 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)
  26342. * * 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)
  26343. * @returns the VertexData of the box
  26344. */
  26345. static CreatePlane(options: {
  26346. size?: number;
  26347. width?: number;
  26348. height?: number;
  26349. sideOrientation?: number;
  26350. frontUVs?: Vector4;
  26351. backUVs?: Vector4;
  26352. }): VertexData;
  26353. /**
  26354. * Creates the VertexData of the Disc or regular Polygon
  26355. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26356. * * radius the radius of the disc, optional default 0.5
  26357. * * tessellation the number of polygon sides, optional, default 64
  26358. * * 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
  26359. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26360. * * 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)
  26361. * * 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)
  26362. * @returns the VertexData of the box
  26363. */
  26364. static CreateDisc(options: {
  26365. radius?: number;
  26366. tessellation?: number;
  26367. arc?: number;
  26368. sideOrientation?: number;
  26369. frontUVs?: Vector4;
  26370. backUVs?: Vector4;
  26371. }): VertexData;
  26372. /**
  26373. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26374. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26375. * @param polygon a mesh built from polygonTriangulation.build()
  26376. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26377. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26378. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26379. * @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)
  26380. * @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)
  26381. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26382. * @returns the VertexData of the Polygon
  26383. */
  26384. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26385. /**
  26386. * Creates the VertexData of the IcoSphere
  26387. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26388. * * radius the radius of the IcoSphere, optional default 1
  26389. * * radiusX allows stretching in the x direction, optional, default radius
  26390. * * radiusY allows stretching in the y direction, optional, default radius
  26391. * * radiusZ allows stretching in the z direction, optional, default radius
  26392. * * flat when true creates a flat shaded mesh, optional, default true
  26393. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26394. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26395. * * 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)
  26396. * * 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)
  26397. * @returns the VertexData of the IcoSphere
  26398. */
  26399. static CreateIcoSphere(options: {
  26400. radius?: number;
  26401. radiusX?: number;
  26402. radiusY?: number;
  26403. radiusZ?: number;
  26404. flat?: boolean;
  26405. subdivisions?: number;
  26406. sideOrientation?: number;
  26407. frontUVs?: Vector4;
  26408. backUVs?: Vector4;
  26409. }): VertexData;
  26410. /**
  26411. * Creates the VertexData for a Polyhedron
  26412. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26413. * * type provided types are:
  26414. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26415. * * 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)
  26416. * * size the size of the IcoSphere, optional default 1
  26417. * * sizeX allows stretching in the x direction, optional, default size
  26418. * * sizeY allows stretching in the y direction, optional, default size
  26419. * * sizeZ allows stretching in the z direction, optional, default size
  26420. * * 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
  26421. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26422. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26423. * * flat when true creates a flat shaded mesh, optional, default true
  26424. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26425. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26426. * * 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)
  26427. * * 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)
  26428. * @returns the VertexData of the Polyhedron
  26429. */
  26430. static CreatePolyhedron(options: {
  26431. type?: number;
  26432. size?: number;
  26433. sizeX?: number;
  26434. sizeY?: number;
  26435. sizeZ?: number;
  26436. custom?: any;
  26437. faceUV?: Vector4[];
  26438. faceColors?: Color4[];
  26439. flat?: boolean;
  26440. sideOrientation?: number;
  26441. frontUVs?: Vector4;
  26442. backUVs?: Vector4;
  26443. }): VertexData;
  26444. /**
  26445. * Creates the VertexData for a TorusKnot
  26446. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26447. * * radius the radius of the torus knot, optional, default 2
  26448. * * tube the thickness of the tube, optional, default 0.5
  26449. * * radialSegments the number of sides on each tube segments, optional, default 32
  26450. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26451. * * p the number of windings around the z axis, optional, default 2
  26452. * * q the number of windings around the x axis, optional, default 3
  26453. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26454. * * 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)
  26455. * * 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)
  26456. * @returns the VertexData of the Torus Knot
  26457. */
  26458. static CreateTorusKnot(options: {
  26459. radius?: number;
  26460. tube?: number;
  26461. radialSegments?: number;
  26462. tubularSegments?: number;
  26463. p?: number;
  26464. q?: number;
  26465. sideOrientation?: number;
  26466. frontUVs?: Vector4;
  26467. backUVs?: Vector4;
  26468. }): VertexData;
  26469. /**
  26470. * Compute normals for given positions and indices
  26471. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26472. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26473. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26474. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26475. * * facetNormals : optional array of facet normals (vector3)
  26476. * * facetPositions : optional array of facet positions (vector3)
  26477. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26478. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26479. * * bInfo : optional bounding info, required for facetPartitioning computation
  26480. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26481. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26482. * * useRightHandedSystem: optional boolean to for right handed system computation
  26483. * * depthSort : optional boolean to enable the facet depth sort computation
  26484. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26485. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26486. */
  26487. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26488. facetNormals?: any;
  26489. facetPositions?: any;
  26490. facetPartitioning?: any;
  26491. ratio?: number;
  26492. bInfo?: any;
  26493. bbSize?: Vector3;
  26494. subDiv?: any;
  26495. useRightHandedSystem?: boolean;
  26496. depthSort?: boolean;
  26497. distanceTo?: Vector3;
  26498. depthSortedFacets?: any;
  26499. }): void;
  26500. /** @hidden */
  26501. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26502. /**
  26503. * Applies VertexData created from the imported parameters to the geometry
  26504. * @param parsedVertexData the parsed data from an imported file
  26505. * @param geometry the geometry to apply the VertexData to
  26506. */
  26507. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26508. }
  26509. }
  26510. declare module "babylonjs/Morph/morphTarget" {
  26511. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26512. import { Observable } from "babylonjs/Misc/observable";
  26513. import { Nullable, FloatArray } from "babylonjs/types";
  26514. import { Scene } from "babylonjs/scene";
  26515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26516. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26517. /**
  26518. * Defines a target to use with MorphTargetManager
  26519. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26520. */
  26521. export class MorphTarget implements IAnimatable {
  26522. /** defines the name of the target */
  26523. name: string;
  26524. /**
  26525. * Gets or sets the list of animations
  26526. */
  26527. animations: import("babylonjs/Animations/animation").Animation[];
  26528. private _scene;
  26529. private _positions;
  26530. private _normals;
  26531. private _tangents;
  26532. private _uvs;
  26533. private _influence;
  26534. private _uniqueId;
  26535. /**
  26536. * Observable raised when the influence changes
  26537. */
  26538. onInfluenceChanged: Observable<boolean>;
  26539. /** @hidden */
  26540. _onDataLayoutChanged: Observable<void>;
  26541. /**
  26542. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26543. */
  26544. get influence(): number;
  26545. set influence(influence: number);
  26546. /**
  26547. * Gets or sets the id of the morph Target
  26548. */
  26549. id: string;
  26550. private _animationPropertiesOverride;
  26551. /**
  26552. * Gets or sets the animation properties override
  26553. */
  26554. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26555. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26556. /**
  26557. * Creates a new MorphTarget
  26558. * @param name defines the name of the target
  26559. * @param influence defines the influence to use
  26560. * @param scene defines the scene the morphtarget belongs to
  26561. */
  26562. constructor(
  26563. /** defines the name of the target */
  26564. name: string, influence?: number, scene?: Nullable<Scene>);
  26565. /**
  26566. * Gets the unique ID of this manager
  26567. */
  26568. get uniqueId(): number;
  26569. /**
  26570. * Gets a boolean defining if the target contains position data
  26571. */
  26572. get hasPositions(): boolean;
  26573. /**
  26574. * Gets a boolean defining if the target contains normal data
  26575. */
  26576. get hasNormals(): boolean;
  26577. /**
  26578. * Gets a boolean defining if the target contains tangent data
  26579. */
  26580. get hasTangents(): boolean;
  26581. /**
  26582. * Gets a boolean defining if the target contains texture coordinates data
  26583. */
  26584. get hasUVs(): boolean;
  26585. /**
  26586. * Affects position data to this target
  26587. * @param data defines the position data to use
  26588. */
  26589. setPositions(data: Nullable<FloatArray>): void;
  26590. /**
  26591. * Gets the position data stored in this target
  26592. * @returns a FloatArray containing the position data (or null if not present)
  26593. */
  26594. getPositions(): Nullable<FloatArray>;
  26595. /**
  26596. * Affects normal data to this target
  26597. * @param data defines the normal data to use
  26598. */
  26599. setNormals(data: Nullable<FloatArray>): void;
  26600. /**
  26601. * Gets the normal data stored in this target
  26602. * @returns a FloatArray containing the normal data (or null if not present)
  26603. */
  26604. getNormals(): Nullable<FloatArray>;
  26605. /**
  26606. * Affects tangent data to this target
  26607. * @param data defines the tangent data to use
  26608. */
  26609. setTangents(data: Nullable<FloatArray>): void;
  26610. /**
  26611. * Gets the tangent data stored in this target
  26612. * @returns a FloatArray containing the tangent data (or null if not present)
  26613. */
  26614. getTangents(): Nullable<FloatArray>;
  26615. /**
  26616. * Affects texture coordinates data to this target
  26617. * @param data defines the texture coordinates data to use
  26618. */
  26619. setUVs(data: Nullable<FloatArray>): void;
  26620. /**
  26621. * Gets the texture coordinates data stored in this target
  26622. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26623. */
  26624. getUVs(): Nullable<FloatArray>;
  26625. /**
  26626. * Clone the current target
  26627. * @returns a new MorphTarget
  26628. */
  26629. clone(): MorphTarget;
  26630. /**
  26631. * Serializes the current target into a Serialization object
  26632. * @returns the serialized object
  26633. */
  26634. serialize(): any;
  26635. /**
  26636. * Returns the string "MorphTarget"
  26637. * @returns "MorphTarget"
  26638. */
  26639. getClassName(): string;
  26640. /**
  26641. * Creates a new target from serialized data
  26642. * @param serializationObject defines the serialized data to use
  26643. * @returns a new MorphTarget
  26644. */
  26645. static Parse(serializationObject: any): MorphTarget;
  26646. /**
  26647. * Creates a MorphTarget from mesh data
  26648. * @param mesh defines the source mesh
  26649. * @param name defines the name to use for the new target
  26650. * @param influence defines the influence to attach to the target
  26651. * @returns a new MorphTarget
  26652. */
  26653. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26654. }
  26655. }
  26656. declare module "babylonjs/Morph/morphTargetManager" {
  26657. import { Nullable } from "babylonjs/types";
  26658. import { Scene } from "babylonjs/scene";
  26659. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  26660. /**
  26661. * This class is used to deform meshes using morphing between different targets
  26662. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26663. */
  26664. export class MorphTargetManager {
  26665. private _targets;
  26666. private _targetInfluenceChangedObservers;
  26667. private _targetDataLayoutChangedObservers;
  26668. private _activeTargets;
  26669. private _scene;
  26670. private _influences;
  26671. private _supportsNormals;
  26672. private _supportsTangents;
  26673. private _supportsUVs;
  26674. private _vertexCount;
  26675. private _uniqueId;
  26676. private _tempInfluences;
  26677. /**
  26678. * Gets or sets a boolean indicating if normals must be morphed
  26679. */
  26680. enableNormalMorphing: boolean;
  26681. /**
  26682. * Gets or sets a boolean indicating if tangents must be morphed
  26683. */
  26684. enableTangentMorphing: boolean;
  26685. /**
  26686. * Gets or sets a boolean indicating if UV must be morphed
  26687. */
  26688. enableUVMorphing: boolean;
  26689. /**
  26690. * Creates a new MorphTargetManager
  26691. * @param scene defines the current scene
  26692. */
  26693. constructor(scene?: Nullable<Scene>);
  26694. /**
  26695. * Gets the unique ID of this manager
  26696. */
  26697. get uniqueId(): number;
  26698. /**
  26699. * Gets the number of vertices handled by this manager
  26700. */
  26701. get vertexCount(): number;
  26702. /**
  26703. * Gets a boolean indicating if this manager supports morphing of normals
  26704. */
  26705. get supportsNormals(): boolean;
  26706. /**
  26707. * Gets a boolean indicating if this manager supports morphing of tangents
  26708. */
  26709. get supportsTangents(): boolean;
  26710. /**
  26711. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26712. */
  26713. get supportsUVs(): boolean;
  26714. /**
  26715. * Gets the number of targets stored in this manager
  26716. */
  26717. get numTargets(): number;
  26718. /**
  26719. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26720. */
  26721. get numInfluencers(): number;
  26722. /**
  26723. * Gets the list of influences (one per target)
  26724. */
  26725. get influences(): Float32Array;
  26726. /**
  26727. * Gets the active target at specified index. An active target is a target with an influence > 0
  26728. * @param index defines the index to check
  26729. * @returns the requested target
  26730. */
  26731. getActiveTarget(index: number): MorphTarget;
  26732. /**
  26733. * Gets the target at specified index
  26734. * @param index defines the index to check
  26735. * @returns the requested target
  26736. */
  26737. getTarget(index: number): MorphTarget;
  26738. /**
  26739. * Add a new target to this manager
  26740. * @param target defines the target to add
  26741. */
  26742. addTarget(target: MorphTarget): void;
  26743. /**
  26744. * Removes a target from the manager
  26745. * @param target defines the target to remove
  26746. */
  26747. removeTarget(target: MorphTarget): void;
  26748. /**
  26749. * Clone the current manager
  26750. * @returns a new MorphTargetManager
  26751. */
  26752. clone(): MorphTargetManager;
  26753. /**
  26754. * Serializes the current manager into a Serialization object
  26755. * @returns the serialized object
  26756. */
  26757. serialize(): any;
  26758. private _syncActiveTargets;
  26759. /**
  26760. * Syncrhonize the targets with all the meshes using this morph target manager
  26761. */
  26762. synchronize(): void;
  26763. /**
  26764. * Creates a new MorphTargetManager from serialized data
  26765. * @param serializationObject defines the serialized data
  26766. * @param scene defines the hosting scene
  26767. * @returns the new MorphTargetManager
  26768. */
  26769. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26770. }
  26771. }
  26772. declare module "babylonjs/Meshes/meshLODLevel" {
  26773. import { Mesh } from "babylonjs/Meshes/mesh";
  26774. import { Nullable } from "babylonjs/types";
  26775. /**
  26776. * Class used to represent a specific level of detail of a mesh
  26777. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26778. */
  26779. export class MeshLODLevel {
  26780. /** Defines the distance where this level should start being displayed */
  26781. distance: number;
  26782. /** Defines the mesh to use to render this level */
  26783. mesh: Nullable<Mesh>;
  26784. /**
  26785. * Creates a new LOD level
  26786. * @param distance defines the distance where this level should star being displayed
  26787. * @param mesh defines the mesh to use to render this level
  26788. */
  26789. constructor(
  26790. /** Defines the distance where this level should start being displayed */
  26791. distance: number,
  26792. /** Defines the mesh to use to render this level */
  26793. mesh: Nullable<Mesh>);
  26794. }
  26795. }
  26796. declare module "babylonjs/Meshes/groundMesh" {
  26797. import { Scene } from "babylonjs/scene";
  26798. import { Vector3 } from "babylonjs/Maths/math.vector";
  26799. import { Mesh } from "babylonjs/Meshes/mesh";
  26800. /**
  26801. * Mesh representing the gorund
  26802. */
  26803. export class GroundMesh extends Mesh {
  26804. /** If octree should be generated */
  26805. generateOctree: boolean;
  26806. private _heightQuads;
  26807. /** @hidden */
  26808. _subdivisionsX: number;
  26809. /** @hidden */
  26810. _subdivisionsY: number;
  26811. /** @hidden */
  26812. _width: number;
  26813. /** @hidden */
  26814. _height: number;
  26815. /** @hidden */
  26816. _minX: number;
  26817. /** @hidden */
  26818. _maxX: number;
  26819. /** @hidden */
  26820. _minZ: number;
  26821. /** @hidden */
  26822. _maxZ: number;
  26823. constructor(name: string, scene: Scene);
  26824. /**
  26825. * "GroundMesh"
  26826. * @returns "GroundMesh"
  26827. */
  26828. getClassName(): string;
  26829. /**
  26830. * The minimum of x and y subdivisions
  26831. */
  26832. get subdivisions(): number;
  26833. /**
  26834. * X subdivisions
  26835. */
  26836. get subdivisionsX(): number;
  26837. /**
  26838. * Y subdivisions
  26839. */
  26840. get subdivisionsY(): number;
  26841. /**
  26842. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26843. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26844. * @param chunksCount the number of subdivisions for x and y
  26845. * @param octreeBlocksSize (Default: 32)
  26846. */
  26847. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26848. /**
  26849. * Returns a height (y) value in the Worl system :
  26850. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26851. * @param x x coordinate
  26852. * @param z z coordinate
  26853. * @returns the ground y position if (x, z) are outside the ground surface.
  26854. */
  26855. getHeightAtCoordinates(x: number, z: number): number;
  26856. /**
  26857. * Returns a normalized vector (Vector3) orthogonal to the ground
  26858. * at the ground coordinates (x, z) expressed in the World system.
  26859. * @param x x coordinate
  26860. * @param z z coordinate
  26861. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26862. */
  26863. getNormalAtCoordinates(x: number, z: number): Vector3;
  26864. /**
  26865. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26866. * at the ground coordinates (x, z) expressed in the World system.
  26867. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26868. * @param x x coordinate
  26869. * @param z z coordinate
  26870. * @param ref vector to store the result
  26871. * @returns the GroundMesh.
  26872. */
  26873. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26874. /**
  26875. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26876. * if the ground has been updated.
  26877. * This can be used in the render loop.
  26878. * @returns the GroundMesh.
  26879. */
  26880. updateCoordinateHeights(): GroundMesh;
  26881. private _getFacetAt;
  26882. private _initHeightQuads;
  26883. private _computeHeightQuads;
  26884. /**
  26885. * Serializes this ground mesh
  26886. * @param serializationObject object to write serialization to
  26887. */
  26888. serialize(serializationObject: any): void;
  26889. /**
  26890. * Parses a serialized ground mesh
  26891. * @param parsedMesh the serialized mesh
  26892. * @param scene the scene to create the ground mesh in
  26893. * @returns the created ground mesh
  26894. */
  26895. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26896. }
  26897. }
  26898. declare module "babylonjs/Physics/physicsJoint" {
  26899. import { Vector3 } from "babylonjs/Maths/math.vector";
  26900. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  26901. /**
  26902. * Interface for Physics-Joint data
  26903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26904. */
  26905. export interface PhysicsJointData {
  26906. /**
  26907. * The main pivot of the joint
  26908. */
  26909. mainPivot?: Vector3;
  26910. /**
  26911. * The connected pivot of the joint
  26912. */
  26913. connectedPivot?: Vector3;
  26914. /**
  26915. * The main axis of the joint
  26916. */
  26917. mainAxis?: Vector3;
  26918. /**
  26919. * The connected axis of the joint
  26920. */
  26921. connectedAxis?: Vector3;
  26922. /**
  26923. * The collision of the joint
  26924. */
  26925. collision?: boolean;
  26926. /**
  26927. * Native Oimo/Cannon/Energy data
  26928. */
  26929. nativeParams?: any;
  26930. }
  26931. /**
  26932. * This is a holder class for the physics joint created by the physics plugin
  26933. * It holds a set of functions to control the underlying joint
  26934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26935. */
  26936. export class PhysicsJoint {
  26937. /**
  26938. * The type of the physics joint
  26939. */
  26940. type: number;
  26941. /**
  26942. * The data for the physics joint
  26943. */
  26944. jointData: PhysicsJointData;
  26945. private _physicsJoint;
  26946. protected _physicsPlugin: IPhysicsEnginePlugin;
  26947. /**
  26948. * Initializes the physics joint
  26949. * @param type The type of the physics joint
  26950. * @param jointData The data for the physics joint
  26951. */
  26952. constructor(
  26953. /**
  26954. * The type of the physics joint
  26955. */
  26956. type: number,
  26957. /**
  26958. * The data for the physics joint
  26959. */
  26960. jointData: PhysicsJointData);
  26961. /**
  26962. * Gets the physics joint
  26963. */
  26964. get physicsJoint(): any;
  26965. /**
  26966. * Sets the physics joint
  26967. */
  26968. set physicsJoint(newJoint: any);
  26969. /**
  26970. * Sets the physics plugin
  26971. */
  26972. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26973. /**
  26974. * Execute a function that is physics-plugin specific.
  26975. * @param {Function} func the function that will be executed.
  26976. * It accepts two parameters: the physics world and the physics joint
  26977. */
  26978. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26979. /**
  26980. * Distance-Joint type
  26981. */
  26982. static DistanceJoint: number;
  26983. /**
  26984. * Hinge-Joint type
  26985. */
  26986. static HingeJoint: number;
  26987. /**
  26988. * Ball-and-Socket joint type
  26989. */
  26990. static BallAndSocketJoint: number;
  26991. /**
  26992. * Wheel-Joint type
  26993. */
  26994. static WheelJoint: number;
  26995. /**
  26996. * Slider-Joint type
  26997. */
  26998. static SliderJoint: number;
  26999. /**
  27000. * Prismatic-Joint type
  27001. */
  27002. static PrismaticJoint: number;
  27003. /**
  27004. * Universal-Joint type
  27005. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27006. */
  27007. static UniversalJoint: number;
  27008. /**
  27009. * Hinge-Joint 2 type
  27010. */
  27011. static Hinge2Joint: number;
  27012. /**
  27013. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27014. */
  27015. static PointToPointJoint: number;
  27016. /**
  27017. * Spring-Joint type
  27018. */
  27019. static SpringJoint: number;
  27020. /**
  27021. * Lock-Joint type
  27022. */
  27023. static LockJoint: number;
  27024. }
  27025. /**
  27026. * A class representing a physics distance joint
  27027. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27028. */
  27029. export class DistanceJoint extends PhysicsJoint {
  27030. /**
  27031. *
  27032. * @param jointData The data for the Distance-Joint
  27033. */
  27034. constructor(jointData: DistanceJointData);
  27035. /**
  27036. * Update the predefined distance.
  27037. * @param maxDistance The maximum preferred distance
  27038. * @param minDistance The minimum preferred distance
  27039. */
  27040. updateDistance(maxDistance: number, minDistance?: number): void;
  27041. }
  27042. /**
  27043. * Represents a Motor-Enabled Joint
  27044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27045. */
  27046. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27047. /**
  27048. * Initializes the Motor-Enabled Joint
  27049. * @param type The type of the joint
  27050. * @param jointData The physica joint data for the joint
  27051. */
  27052. constructor(type: number, jointData: PhysicsJointData);
  27053. /**
  27054. * Set the motor values.
  27055. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27056. * @param force the force to apply
  27057. * @param maxForce max force for this motor.
  27058. */
  27059. setMotor(force?: number, maxForce?: number): void;
  27060. /**
  27061. * Set the motor's limits.
  27062. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27063. * @param upperLimit The upper limit of the motor
  27064. * @param lowerLimit The lower limit of the motor
  27065. */
  27066. setLimit(upperLimit: number, lowerLimit?: number): void;
  27067. }
  27068. /**
  27069. * This class represents a single physics Hinge-Joint
  27070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27071. */
  27072. export class HingeJoint extends MotorEnabledJoint {
  27073. /**
  27074. * Initializes the Hinge-Joint
  27075. * @param jointData The joint data for the Hinge-Joint
  27076. */
  27077. constructor(jointData: PhysicsJointData);
  27078. /**
  27079. * Set the motor values.
  27080. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27081. * @param {number} force the force to apply
  27082. * @param {number} maxForce max force for this motor.
  27083. */
  27084. setMotor(force?: number, maxForce?: number): void;
  27085. /**
  27086. * Set the motor's limits.
  27087. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27088. * @param upperLimit The upper limit of the motor
  27089. * @param lowerLimit The lower limit of the motor
  27090. */
  27091. setLimit(upperLimit: number, lowerLimit?: number): void;
  27092. }
  27093. /**
  27094. * This class represents a dual hinge physics joint (same as wheel joint)
  27095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27096. */
  27097. export class Hinge2Joint extends MotorEnabledJoint {
  27098. /**
  27099. * Initializes the Hinge2-Joint
  27100. * @param jointData The joint data for the Hinge2-Joint
  27101. */
  27102. constructor(jointData: PhysicsJointData);
  27103. /**
  27104. * Set the motor values.
  27105. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27106. * @param {number} targetSpeed the speed the motor is to reach
  27107. * @param {number} maxForce max force for this motor.
  27108. * @param {motorIndex} the motor's index, 0 or 1.
  27109. */
  27110. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27111. /**
  27112. * Set the motor limits.
  27113. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27114. * @param {number} upperLimit the upper limit
  27115. * @param {number} lowerLimit lower limit
  27116. * @param {motorIndex} the motor's index, 0 or 1.
  27117. */
  27118. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27119. }
  27120. /**
  27121. * Interface for a motor enabled joint
  27122. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27123. */
  27124. export interface IMotorEnabledJoint {
  27125. /**
  27126. * Physics joint
  27127. */
  27128. physicsJoint: any;
  27129. /**
  27130. * Sets the motor of the motor-enabled joint
  27131. * @param force The force of the motor
  27132. * @param maxForce The maximum force of the motor
  27133. * @param motorIndex The index of the motor
  27134. */
  27135. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27136. /**
  27137. * Sets the limit of the motor
  27138. * @param upperLimit The upper limit of the motor
  27139. * @param lowerLimit The lower limit of the motor
  27140. * @param motorIndex The index of the motor
  27141. */
  27142. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27143. }
  27144. /**
  27145. * Joint data for a Distance-Joint
  27146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27147. */
  27148. export interface DistanceJointData extends PhysicsJointData {
  27149. /**
  27150. * Max distance the 2 joint objects can be apart
  27151. */
  27152. maxDistance: number;
  27153. }
  27154. /**
  27155. * Joint data from a spring joint
  27156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27157. */
  27158. export interface SpringJointData extends PhysicsJointData {
  27159. /**
  27160. * Length of the spring
  27161. */
  27162. length: number;
  27163. /**
  27164. * Stiffness of the spring
  27165. */
  27166. stiffness: number;
  27167. /**
  27168. * Damping of the spring
  27169. */
  27170. damping: number;
  27171. /** this callback will be called when applying the force to the impostors. */
  27172. forceApplicationCallback: () => void;
  27173. }
  27174. }
  27175. declare module "babylonjs/Physics/physicsRaycastResult" {
  27176. import { Vector3 } from "babylonjs/Maths/math.vector";
  27177. /**
  27178. * Holds the data for the raycast result
  27179. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27180. */
  27181. export class PhysicsRaycastResult {
  27182. private _hasHit;
  27183. private _hitDistance;
  27184. private _hitNormalWorld;
  27185. private _hitPointWorld;
  27186. private _rayFromWorld;
  27187. private _rayToWorld;
  27188. /**
  27189. * Gets if there was a hit
  27190. */
  27191. get hasHit(): boolean;
  27192. /**
  27193. * Gets the distance from the hit
  27194. */
  27195. get hitDistance(): number;
  27196. /**
  27197. * Gets the hit normal/direction in the world
  27198. */
  27199. get hitNormalWorld(): Vector3;
  27200. /**
  27201. * Gets the hit point in the world
  27202. */
  27203. get hitPointWorld(): Vector3;
  27204. /**
  27205. * Gets the ray "start point" of the ray in the world
  27206. */
  27207. get rayFromWorld(): Vector3;
  27208. /**
  27209. * Gets the ray "end point" of the ray in the world
  27210. */
  27211. get rayToWorld(): Vector3;
  27212. /**
  27213. * Sets the hit data (normal & point in world space)
  27214. * @param hitNormalWorld defines the normal in world space
  27215. * @param hitPointWorld defines the point in world space
  27216. */
  27217. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27218. /**
  27219. * Sets the distance from the start point to the hit point
  27220. * @param distance
  27221. */
  27222. setHitDistance(distance: number): void;
  27223. /**
  27224. * Calculates the distance manually
  27225. */
  27226. calculateHitDistance(): void;
  27227. /**
  27228. * Resets all the values to default
  27229. * @param from The from point on world space
  27230. * @param to The to point on world space
  27231. */
  27232. reset(from?: Vector3, to?: Vector3): void;
  27233. }
  27234. /**
  27235. * Interface for the size containing width and height
  27236. */
  27237. interface IXYZ {
  27238. /**
  27239. * X
  27240. */
  27241. x: number;
  27242. /**
  27243. * Y
  27244. */
  27245. y: number;
  27246. /**
  27247. * Z
  27248. */
  27249. z: number;
  27250. }
  27251. }
  27252. declare module "babylonjs/Physics/IPhysicsEngine" {
  27253. import { Nullable } from "babylonjs/types";
  27254. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  27255. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27256. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  27257. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  27258. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  27259. /**
  27260. * Interface used to describe a physics joint
  27261. */
  27262. export interface PhysicsImpostorJoint {
  27263. /** Defines the main impostor to which the joint is linked */
  27264. mainImpostor: PhysicsImpostor;
  27265. /** Defines the impostor that is connected to the main impostor using this joint */
  27266. connectedImpostor: PhysicsImpostor;
  27267. /** Defines the joint itself */
  27268. joint: PhysicsJoint;
  27269. }
  27270. /** @hidden */
  27271. export interface IPhysicsEnginePlugin {
  27272. world: any;
  27273. name: string;
  27274. setGravity(gravity: Vector3): void;
  27275. setTimeStep(timeStep: number): void;
  27276. getTimeStep(): number;
  27277. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27278. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27279. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27280. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27281. removePhysicsBody(impostor: PhysicsImpostor): void;
  27282. generateJoint(joint: PhysicsImpostorJoint): void;
  27283. removeJoint(joint: PhysicsImpostorJoint): void;
  27284. isSupported(): boolean;
  27285. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27286. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27287. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27288. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27289. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27290. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27291. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27292. getBodyMass(impostor: PhysicsImpostor): number;
  27293. getBodyFriction(impostor: PhysicsImpostor): number;
  27294. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27295. getBodyRestitution(impostor: PhysicsImpostor): number;
  27296. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27297. getBodyPressure?(impostor: PhysicsImpostor): number;
  27298. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27299. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27300. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27301. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27302. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27303. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27304. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27305. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27306. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27307. sleepBody(impostor: PhysicsImpostor): void;
  27308. wakeUpBody(impostor: PhysicsImpostor): void;
  27309. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27310. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27311. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27312. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27313. getRadius(impostor: PhysicsImpostor): number;
  27314. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27315. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27316. dispose(): void;
  27317. }
  27318. /**
  27319. * Interface used to define a physics engine
  27320. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  27321. */
  27322. export interface IPhysicsEngine {
  27323. /**
  27324. * Gets the gravity vector used by the simulation
  27325. */
  27326. gravity: Vector3;
  27327. /**
  27328. * Sets the gravity vector used by the simulation
  27329. * @param gravity defines the gravity vector to use
  27330. */
  27331. setGravity(gravity: Vector3): void;
  27332. /**
  27333. * Set the time step of the physics engine.
  27334. * Default is 1/60.
  27335. * To slow it down, enter 1/600 for example.
  27336. * To speed it up, 1/30
  27337. * @param newTimeStep the new timestep to apply to this world.
  27338. */
  27339. setTimeStep(newTimeStep: number): void;
  27340. /**
  27341. * Get the time step of the physics engine.
  27342. * @returns the current time step
  27343. */
  27344. getTimeStep(): number;
  27345. /**
  27346. * Set the sub time step of the physics engine.
  27347. * Default is 0 meaning there is no sub steps
  27348. * To increase physics resolution precision, set a small value (like 1 ms)
  27349. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27350. */
  27351. setSubTimeStep(subTimeStep: number): void;
  27352. /**
  27353. * Get the sub time step of the physics engine.
  27354. * @returns the current sub time step
  27355. */
  27356. getSubTimeStep(): number;
  27357. /**
  27358. * Release all resources
  27359. */
  27360. dispose(): void;
  27361. /**
  27362. * Gets the name of the current physics plugin
  27363. * @returns the name of the plugin
  27364. */
  27365. getPhysicsPluginName(): string;
  27366. /**
  27367. * Adding a new impostor for the impostor tracking.
  27368. * This will be done by the impostor itself.
  27369. * @param impostor the impostor to add
  27370. */
  27371. addImpostor(impostor: PhysicsImpostor): void;
  27372. /**
  27373. * Remove an impostor from the engine.
  27374. * This impostor and its mesh will not longer be updated by the physics engine.
  27375. * @param impostor the impostor to remove
  27376. */
  27377. removeImpostor(impostor: PhysicsImpostor): void;
  27378. /**
  27379. * Add a joint to the physics engine
  27380. * @param mainImpostor defines the main impostor to which the joint is added.
  27381. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27382. * @param joint defines the joint that will connect both impostors.
  27383. */
  27384. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27385. /**
  27386. * Removes a joint from the simulation
  27387. * @param mainImpostor defines the impostor used with the joint
  27388. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27389. * @param joint defines the joint to remove
  27390. */
  27391. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27392. /**
  27393. * Gets the current plugin used to run the simulation
  27394. * @returns current plugin
  27395. */
  27396. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27397. /**
  27398. * Gets the list of physic impostors
  27399. * @returns an array of PhysicsImpostor
  27400. */
  27401. getImpostors(): Array<PhysicsImpostor>;
  27402. /**
  27403. * Gets the impostor for a physics enabled object
  27404. * @param object defines the object impersonated by the impostor
  27405. * @returns the PhysicsImpostor or null if not found
  27406. */
  27407. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27408. /**
  27409. * Gets the impostor for a physics body object
  27410. * @param body defines physics body used by the impostor
  27411. * @returns the PhysicsImpostor or null if not found
  27412. */
  27413. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27414. /**
  27415. * Does a raycast in the physics world
  27416. * @param from when should the ray start?
  27417. * @param to when should the ray end?
  27418. * @returns PhysicsRaycastResult
  27419. */
  27420. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27421. /**
  27422. * Called by the scene. No need to call it.
  27423. * @param delta defines the timespam between frames
  27424. */
  27425. _step(delta: number): void;
  27426. }
  27427. }
  27428. declare module "babylonjs/Physics/physicsImpostor" {
  27429. import { Nullable, IndicesArray } from "babylonjs/types";
  27430. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  27431. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27433. import { Scene } from "babylonjs/scene";
  27434. import { Bone } from "babylonjs/Bones/bone";
  27435. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27436. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  27437. import { Space } from "babylonjs/Maths/math.axis";
  27438. /**
  27439. * The interface for the physics imposter parameters
  27440. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27441. */
  27442. export interface PhysicsImpostorParameters {
  27443. /**
  27444. * The mass of the physics imposter
  27445. */
  27446. mass: number;
  27447. /**
  27448. * The friction of the physics imposter
  27449. */
  27450. friction?: number;
  27451. /**
  27452. * The coefficient of restitution of the physics imposter
  27453. */
  27454. restitution?: number;
  27455. /**
  27456. * The native options of the physics imposter
  27457. */
  27458. nativeOptions?: any;
  27459. /**
  27460. * Specifies if the parent should be ignored
  27461. */
  27462. ignoreParent?: boolean;
  27463. /**
  27464. * Specifies if bi-directional transformations should be disabled
  27465. */
  27466. disableBidirectionalTransformation?: boolean;
  27467. /**
  27468. * The pressure inside the physics imposter, soft object only
  27469. */
  27470. pressure?: number;
  27471. /**
  27472. * The stiffness the physics imposter, soft object only
  27473. */
  27474. stiffness?: number;
  27475. /**
  27476. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27477. */
  27478. velocityIterations?: number;
  27479. /**
  27480. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27481. */
  27482. positionIterations?: number;
  27483. /**
  27484. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27485. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27486. * Add to fix multiple points
  27487. */
  27488. fixedPoints?: number;
  27489. /**
  27490. * The collision margin around a soft object
  27491. */
  27492. margin?: number;
  27493. /**
  27494. * The collision margin around a soft object
  27495. */
  27496. damping?: number;
  27497. /**
  27498. * The path for a rope based on an extrusion
  27499. */
  27500. path?: any;
  27501. /**
  27502. * The shape of an extrusion used for a rope based on an extrusion
  27503. */
  27504. shape?: any;
  27505. }
  27506. /**
  27507. * Interface for a physics-enabled object
  27508. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27509. */
  27510. export interface IPhysicsEnabledObject {
  27511. /**
  27512. * The position of the physics-enabled object
  27513. */
  27514. position: Vector3;
  27515. /**
  27516. * The rotation of the physics-enabled object
  27517. */
  27518. rotationQuaternion: Nullable<Quaternion>;
  27519. /**
  27520. * The scale of the physics-enabled object
  27521. */
  27522. scaling: Vector3;
  27523. /**
  27524. * The rotation of the physics-enabled object
  27525. */
  27526. rotation?: Vector3;
  27527. /**
  27528. * The parent of the physics-enabled object
  27529. */
  27530. parent?: any;
  27531. /**
  27532. * The bounding info of the physics-enabled object
  27533. * @returns The bounding info of the physics-enabled object
  27534. */
  27535. getBoundingInfo(): BoundingInfo;
  27536. /**
  27537. * Computes the world matrix
  27538. * @param force Specifies if the world matrix should be computed by force
  27539. * @returns A world matrix
  27540. */
  27541. computeWorldMatrix(force: boolean): Matrix;
  27542. /**
  27543. * Gets the world matrix
  27544. * @returns A world matrix
  27545. */
  27546. getWorldMatrix?(): Matrix;
  27547. /**
  27548. * Gets the child meshes
  27549. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27550. * @returns An array of abstract meshes
  27551. */
  27552. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27553. /**
  27554. * Gets the vertex data
  27555. * @param kind The type of vertex data
  27556. * @returns A nullable array of numbers, or a float32 array
  27557. */
  27558. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27559. /**
  27560. * Gets the indices from the mesh
  27561. * @returns A nullable array of index arrays
  27562. */
  27563. getIndices?(): Nullable<IndicesArray>;
  27564. /**
  27565. * Gets the scene from the mesh
  27566. * @returns the indices array or null
  27567. */
  27568. getScene?(): Scene;
  27569. /**
  27570. * Gets the absolute position from the mesh
  27571. * @returns the absolute position
  27572. */
  27573. getAbsolutePosition(): Vector3;
  27574. /**
  27575. * Gets the absolute pivot point from the mesh
  27576. * @returns the absolute pivot point
  27577. */
  27578. getAbsolutePivotPoint(): Vector3;
  27579. /**
  27580. * Rotates the mesh
  27581. * @param axis The axis of rotation
  27582. * @param amount The amount of rotation
  27583. * @param space The space of the rotation
  27584. * @returns The rotation transform node
  27585. */
  27586. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27587. /**
  27588. * Translates the mesh
  27589. * @param axis The axis of translation
  27590. * @param distance The distance of translation
  27591. * @param space The space of the translation
  27592. * @returns The transform node
  27593. */
  27594. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27595. /**
  27596. * Sets the absolute position of the mesh
  27597. * @param absolutePosition The absolute position of the mesh
  27598. * @returns The transform node
  27599. */
  27600. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27601. /**
  27602. * Gets the class name of the mesh
  27603. * @returns The class name
  27604. */
  27605. getClassName(): string;
  27606. }
  27607. /**
  27608. * Represents a physics imposter
  27609. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27610. */
  27611. export class PhysicsImpostor {
  27612. /**
  27613. * The physics-enabled object used as the physics imposter
  27614. */
  27615. object: IPhysicsEnabledObject;
  27616. /**
  27617. * The type of the physics imposter
  27618. */
  27619. type: number;
  27620. private _options;
  27621. private _scene?;
  27622. /**
  27623. * The default object size of the imposter
  27624. */
  27625. static DEFAULT_OBJECT_SIZE: Vector3;
  27626. /**
  27627. * The identity quaternion of the imposter
  27628. */
  27629. static IDENTITY_QUATERNION: Quaternion;
  27630. /** @hidden */
  27631. _pluginData: any;
  27632. private _physicsEngine;
  27633. private _physicsBody;
  27634. private _bodyUpdateRequired;
  27635. private _onBeforePhysicsStepCallbacks;
  27636. private _onAfterPhysicsStepCallbacks;
  27637. /** @hidden */
  27638. _onPhysicsCollideCallbacks: Array<{
  27639. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27640. otherImpostors: Array<PhysicsImpostor>;
  27641. }>;
  27642. private _deltaPosition;
  27643. private _deltaRotation;
  27644. private _deltaRotationConjugated;
  27645. /** @hidden */
  27646. _isFromLine: boolean;
  27647. private _parent;
  27648. private _isDisposed;
  27649. private static _tmpVecs;
  27650. private static _tmpQuat;
  27651. /**
  27652. * Specifies if the physics imposter is disposed
  27653. */
  27654. get isDisposed(): boolean;
  27655. /**
  27656. * Gets the mass of the physics imposter
  27657. */
  27658. get mass(): number;
  27659. set mass(value: number);
  27660. /**
  27661. * Gets the coefficient of friction
  27662. */
  27663. get friction(): number;
  27664. /**
  27665. * Sets the coefficient of friction
  27666. */
  27667. set friction(value: number);
  27668. /**
  27669. * Gets the coefficient of restitution
  27670. */
  27671. get restitution(): number;
  27672. /**
  27673. * Sets the coefficient of restitution
  27674. */
  27675. set restitution(value: number);
  27676. /**
  27677. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27678. */
  27679. get pressure(): number;
  27680. /**
  27681. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27682. */
  27683. set pressure(value: number);
  27684. /**
  27685. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27686. */
  27687. get stiffness(): number;
  27688. /**
  27689. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27690. */
  27691. set stiffness(value: number);
  27692. /**
  27693. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27694. */
  27695. get velocityIterations(): number;
  27696. /**
  27697. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27698. */
  27699. set velocityIterations(value: number);
  27700. /**
  27701. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27702. */
  27703. get positionIterations(): number;
  27704. /**
  27705. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27706. */
  27707. set positionIterations(value: number);
  27708. /**
  27709. * The unique id of the physics imposter
  27710. * set by the physics engine when adding this impostor to the array
  27711. */
  27712. uniqueId: number;
  27713. /**
  27714. * @hidden
  27715. */
  27716. soft: boolean;
  27717. /**
  27718. * @hidden
  27719. */
  27720. segments: number;
  27721. private _joints;
  27722. /**
  27723. * Initializes the physics imposter
  27724. * @param object The physics-enabled object used as the physics imposter
  27725. * @param type The type of the physics imposter
  27726. * @param _options The options for the physics imposter
  27727. * @param _scene The Babylon scene
  27728. */
  27729. constructor(
  27730. /**
  27731. * The physics-enabled object used as the physics imposter
  27732. */
  27733. object: IPhysicsEnabledObject,
  27734. /**
  27735. * The type of the physics imposter
  27736. */
  27737. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27738. /**
  27739. * This function will completly initialize this impostor.
  27740. * It will create a new body - but only if this mesh has no parent.
  27741. * If it has, this impostor will not be used other than to define the impostor
  27742. * of the child mesh.
  27743. * @hidden
  27744. */
  27745. _init(): void;
  27746. private _getPhysicsParent;
  27747. /**
  27748. * Should a new body be generated.
  27749. * @returns boolean specifying if body initialization is required
  27750. */
  27751. isBodyInitRequired(): boolean;
  27752. /**
  27753. * Sets the updated scaling
  27754. * @param updated Specifies if the scaling is updated
  27755. */
  27756. setScalingUpdated(): void;
  27757. /**
  27758. * Force a regeneration of this or the parent's impostor's body.
  27759. * Use under cautious - This will remove all joints already implemented.
  27760. */
  27761. forceUpdate(): void;
  27762. /**
  27763. * Gets the body that holds this impostor. Either its own, or its parent.
  27764. */
  27765. get physicsBody(): any;
  27766. /**
  27767. * Get the parent of the physics imposter
  27768. * @returns Physics imposter or null
  27769. */
  27770. get parent(): Nullable<PhysicsImpostor>;
  27771. /**
  27772. * Sets the parent of the physics imposter
  27773. */
  27774. set parent(value: Nullable<PhysicsImpostor>);
  27775. /**
  27776. * Set the physics body. Used mainly by the physics engine/plugin
  27777. */
  27778. set physicsBody(physicsBody: any);
  27779. /**
  27780. * Resets the update flags
  27781. */
  27782. resetUpdateFlags(): void;
  27783. /**
  27784. * Gets the object extend size
  27785. * @returns the object extend size
  27786. */
  27787. getObjectExtendSize(): Vector3;
  27788. /**
  27789. * Gets the object center
  27790. * @returns The object center
  27791. */
  27792. getObjectCenter(): Vector3;
  27793. /**
  27794. * Get a specific parameter from the options parameters
  27795. * @param paramName The object parameter name
  27796. * @returns The object parameter
  27797. */
  27798. getParam(paramName: string): any;
  27799. /**
  27800. * Sets a specific parameter in the options given to the physics plugin
  27801. * @param paramName The parameter name
  27802. * @param value The value of the parameter
  27803. */
  27804. setParam(paramName: string, value: number): void;
  27805. /**
  27806. * Specifically change the body's mass option. Won't recreate the physics body object
  27807. * @param mass The mass of the physics imposter
  27808. */
  27809. setMass(mass: number): void;
  27810. /**
  27811. * Gets the linear velocity
  27812. * @returns linear velocity or null
  27813. */
  27814. getLinearVelocity(): Nullable<Vector3>;
  27815. /**
  27816. * Sets the linear velocity
  27817. * @param velocity linear velocity or null
  27818. */
  27819. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27820. /**
  27821. * Gets the angular velocity
  27822. * @returns angular velocity or null
  27823. */
  27824. getAngularVelocity(): Nullable<Vector3>;
  27825. /**
  27826. * Sets the angular velocity
  27827. * @param velocity The velocity or null
  27828. */
  27829. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27830. /**
  27831. * Execute a function with the physics plugin native code
  27832. * Provide a function the will have two variables - the world object and the physics body object
  27833. * @param func The function to execute with the physics plugin native code
  27834. */
  27835. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27836. /**
  27837. * Register a function that will be executed before the physics world is stepping forward
  27838. * @param func The function to execute before the physics world is stepped forward
  27839. */
  27840. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27841. /**
  27842. * Unregister a function that will be executed before the physics world is stepping forward
  27843. * @param func The function to execute before the physics world is stepped forward
  27844. */
  27845. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27846. /**
  27847. * Register a function that will be executed after the physics step
  27848. * @param func The function to execute after physics step
  27849. */
  27850. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27851. /**
  27852. * Unregisters a function that will be executed after the physics step
  27853. * @param func The function to execute after physics step
  27854. */
  27855. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27856. /**
  27857. * register a function that will be executed when this impostor collides against a different body
  27858. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27859. * @param func Callback that is executed on collision
  27860. */
  27861. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27862. /**
  27863. * Unregisters the physics imposter on contact
  27864. * @param collideAgainst The physics object to collide against
  27865. * @param func Callback to execute on collision
  27866. */
  27867. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27868. private _tmpQuat;
  27869. private _tmpQuat2;
  27870. /**
  27871. * Get the parent rotation
  27872. * @returns The parent rotation
  27873. */
  27874. getParentsRotation(): Quaternion;
  27875. /**
  27876. * this function is executed by the physics engine.
  27877. */
  27878. beforeStep: () => void;
  27879. /**
  27880. * this function is executed by the physics engine
  27881. */
  27882. afterStep: () => void;
  27883. /**
  27884. * Legacy collision detection event support
  27885. */
  27886. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27887. /**
  27888. * event and body object due to cannon's event-based architecture.
  27889. */
  27890. onCollide: (e: {
  27891. body: any;
  27892. }) => void;
  27893. /**
  27894. * Apply a force
  27895. * @param force The force to apply
  27896. * @param contactPoint The contact point for the force
  27897. * @returns The physics imposter
  27898. */
  27899. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27900. /**
  27901. * Apply an impulse
  27902. * @param force The impulse force
  27903. * @param contactPoint The contact point for the impulse force
  27904. * @returns The physics imposter
  27905. */
  27906. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27907. /**
  27908. * A help function to create a joint
  27909. * @param otherImpostor A physics imposter used to create a joint
  27910. * @param jointType The type of joint
  27911. * @param jointData The data for the joint
  27912. * @returns The physics imposter
  27913. */
  27914. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27915. /**
  27916. * Add a joint to this impostor with a different impostor
  27917. * @param otherImpostor A physics imposter used to add a joint
  27918. * @param joint The joint to add
  27919. * @returns The physics imposter
  27920. */
  27921. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27922. /**
  27923. * Add an anchor to a cloth impostor
  27924. * @param otherImpostor rigid impostor to anchor to
  27925. * @param width ratio across width from 0 to 1
  27926. * @param height ratio up height from 0 to 1
  27927. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27928. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27929. * @returns impostor the soft imposter
  27930. */
  27931. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27932. /**
  27933. * Add a hook to a rope impostor
  27934. * @param otherImpostor rigid impostor to anchor to
  27935. * @param length ratio across rope from 0 to 1
  27936. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27937. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27938. * @returns impostor the rope imposter
  27939. */
  27940. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27941. /**
  27942. * Will keep this body still, in a sleep mode.
  27943. * @returns the physics imposter
  27944. */
  27945. sleep(): PhysicsImpostor;
  27946. /**
  27947. * Wake the body up.
  27948. * @returns The physics imposter
  27949. */
  27950. wakeUp(): PhysicsImpostor;
  27951. /**
  27952. * Clones the physics imposter
  27953. * @param newObject The physics imposter clones to this physics-enabled object
  27954. * @returns A nullable physics imposter
  27955. */
  27956. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27957. /**
  27958. * Disposes the physics imposter
  27959. */
  27960. dispose(): void;
  27961. /**
  27962. * Sets the delta position
  27963. * @param position The delta position amount
  27964. */
  27965. setDeltaPosition(position: Vector3): void;
  27966. /**
  27967. * Sets the delta rotation
  27968. * @param rotation The delta rotation amount
  27969. */
  27970. setDeltaRotation(rotation: Quaternion): void;
  27971. /**
  27972. * Gets the box size of the physics imposter and stores the result in the input parameter
  27973. * @param result Stores the box size
  27974. * @returns The physics imposter
  27975. */
  27976. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27977. /**
  27978. * Gets the radius of the physics imposter
  27979. * @returns Radius of the physics imposter
  27980. */
  27981. getRadius(): number;
  27982. /**
  27983. * Sync a bone with this impostor
  27984. * @param bone The bone to sync to the impostor.
  27985. * @param boneMesh The mesh that the bone is influencing.
  27986. * @param jointPivot The pivot of the joint / bone in local space.
  27987. * @param distToJoint Optional distance from the impostor to the joint.
  27988. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27989. */
  27990. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27991. /**
  27992. * Sync impostor to a bone
  27993. * @param bone The bone that the impostor will be synced to.
  27994. * @param boneMesh The mesh that the bone is influencing.
  27995. * @param jointPivot The pivot of the joint / bone in local space.
  27996. * @param distToJoint Optional distance from the impostor to the joint.
  27997. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27998. * @param boneAxis Optional vector3 axis the bone is aligned with
  27999. */
  28000. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28001. /**
  28002. * No-Imposter type
  28003. */
  28004. static NoImpostor: number;
  28005. /**
  28006. * Sphere-Imposter type
  28007. */
  28008. static SphereImpostor: number;
  28009. /**
  28010. * Box-Imposter type
  28011. */
  28012. static BoxImpostor: number;
  28013. /**
  28014. * Plane-Imposter type
  28015. */
  28016. static PlaneImpostor: number;
  28017. /**
  28018. * Mesh-imposter type
  28019. */
  28020. static MeshImpostor: number;
  28021. /**
  28022. * Capsule-Impostor type (Ammo.js plugin only)
  28023. */
  28024. static CapsuleImpostor: number;
  28025. /**
  28026. * Cylinder-Imposter type
  28027. */
  28028. static CylinderImpostor: number;
  28029. /**
  28030. * Particle-Imposter type
  28031. */
  28032. static ParticleImpostor: number;
  28033. /**
  28034. * Heightmap-Imposter type
  28035. */
  28036. static HeightmapImpostor: number;
  28037. /**
  28038. * ConvexHull-Impostor type (Ammo.js plugin only)
  28039. */
  28040. static ConvexHullImpostor: number;
  28041. /**
  28042. * Custom-Imposter type (Ammo.js plugin only)
  28043. */
  28044. static CustomImpostor: number;
  28045. /**
  28046. * Rope-Imposter type
  28047. */
  28048. static RopeImpostor: number;
  28049. /**
  28050. * Cloth-Imposter type
  28051. */
  28052. static ClothImpostor: number;
  28053. /**
  28054. * Softbody-Imposter type
  28055. */
  28056. static SoftbodyImpostor: number;
  28057. }
  28058. }
  28059. declare module "babylonjs/Meshes/mesh" {
  28060. import { Observable } from "babylonjs/Misc/observable";
  28061. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28062. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28063. import { Camera } from "babylonjs/Cameras/camera";
  28064. import { Scene } from "babylonjs/scene";
  28065. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28066. import { Color4 } from "babylonjs/Maths/math.color";
  28067. import { Engine } from "babylonjs/Engines/engine";
  28068. import { Node } from "babylonjs/node";
  28069. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28070. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28071. import { Buffer } from "babylonjs/Meshes/buffer";
  28072. import { Geometry } from "babylonjs/Meshes/geometry";
  28073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28074. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28075. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  28076. import { Effect } from "babylonjs/Materials/effect";
  28077. import { Material } from "babylonjs/Materials/material";
  28078. import { Skeleton } from "babylonjs/Bones/skeleton";
  28079. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  28080. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  28081. import { Path3D } from "babylonjs/Maths/math.path";
  28082. import { Plane } from "babylonjs/Maths/math.plane";
  28083. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28084. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  28085. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  28086. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  28087. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28088. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  28089. /**
  28090. * @hidden
  28091. **/
  28092. export class _CreationDataStorage {
  28093. closePath?: boolean;
  28094. closeArray?: boolean;
  28095. idx: number[];
  28096. dashSize: number;
  28097. gapSize: number;
  28098. path3D: Path3D;
  28099. pathArray: Vector3[][];
  28100. arc: number;
  28101. radius: number;
  28102. cap: number;
  28103. tessellation: number;
  28104. }
  28105. /**
  28106. * @hidden
  28107. **/
  28108. class _InstanceDataStorage {
  28109. visibleInstances: any;
  28110. batchCache: _InstancesBatch;
  28111. instancesBufferSize: number;
  28112. instancesBuffer: Nullable<Buffer>;
  28113. instancesData: Float32Array;
  28114. overridenInstanceCount: number;
  28115. isFrozen: boolean;
  28116. previousBatch: Nullable<_InstancesBatch>;
  28117. hardwareInstancedRendering: boolean;
  28118. sideOrientation: number;
  28119. manualUpdate: boolean;
  28120. }
  28121. /**
  28122. * @hidden
  28123. **/
  28124. export class _InstancesBatch {
  28125. mustReturn: boolean;
  28126. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  28127. renderSelf: boolean[];
  28128. hardwareInstancedRendering: boolean[];
  28129. }
  28130. /**
  28131. * @hidden
  28132. **/
  28133. class _ThinInstanceDataStorage {
  28134. instancesCount: number;
  28135. matrixBuffer: Nullable<Buffer>;
  28136. matrixBufferSize: number;
  28137. matrixData: Nullable<Float32Array>;
  28138. boundingVectors: Array<Vector3>;
  28139. }
  28140. /**
  28141. * Class used to represent renderable models
  28142. */
  28143. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28144. /**
  28145. * Mesh side orientation : usually the external or front surface
  28146. */
  28147. static readonly FRONTSIDE: number;
  28148. /**
  28149. * Mesh side orientation : usually the internal or back surface
  28150. */
  28151. static readonly BACKSIDE: number;
  28152. /**
  28153. * Mesh side orientation : both internal and external or front and back surfaces
  28154. */
  28155. static readonly DOUBLESIDE: number;
  28156. /**
  28157. * Mesh side orientation : by default, `FRONTSIDE`
  28158. */
  28159. static readonly DEFAULTSIDE: number;
  28160. /**
  28161. * Mesh cap setting : no cap
  28162. */
  28163. static readonly NO_CAP: number;
  28164. /**
  28165. * Mesh cap setting : one cap at the beginning of the mesh
  28166. */
  28167. static readonly CAP_START: number;
  28168. /**
  28169. * Mesh cap setting : one cap at the end of the mesh
  28170. */
  28171. static readonly CAP_END: number;
  28172. /**
  28173. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28174. */
  28175. static readonly CAP_ALL: number;
  28176. /**
  28177. * Mesh pattern setting : no flip or rotate
  28178. */
  28179. static readonly NO_FLIP: number;
  28180. /**
  28181. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28182. */
  28183. static readonly FLIP_TILE: number;
  28184. /**
  28185. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28186. */
  28187. static readonly ROTATE_TILE: number;
  28188. /**
  28189. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28190. */
  28191. static readonly FLIP_ROW: number;
  28192. /**
  28193. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28194. */
  28195. static readonly ROTATE_ROW: number;
  28196. /**
  28197. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28198. */
  28199. static readonly FLIP_N_ROTATE_TILE: number;
  28200. /**
  28201. * Mesh pattern setting : rotate pattern and rotate
  28202. */
  28203. static readonly FLIP_N_ROTATE_ROW: number;
  28204. /**
  28205. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28206. */
  28207. static readonly CENTER: number;
  28208. /**
  28209. * Mesh tile positioning : part tiles on left
  28210. */
  28211. static readonly LEFT: number;
  28212. /**
  28213. * Mesh tile positioning : part tiles on right
  28214. */
  28215. static readonly RIGHT: number;
  28216. /**
  28217. * Mesh tile positioning : part tiles on top
  28218. */
  28219. static readonly TOP: number;
  28220. /**
  28221. * Mesh tile positioning : part tiles on bottom
  28222. */
  28223. static readonly BOTTOM: number;
  28224. /**
  28225. * Gets the default side orientation.
  28226. * @param orientation the orientation to value to attempt to get
  28227. * @returns the default orientation
  28228. * @hidden
  28229. */
  28230. static _GetDefaultSideOrientation(orientation?: number): number;
  28231. private _internalMeshDataInfo;
  28232. /**
  28233. * An event triggered before rendering the mesh
  28234. */
  28235. get onBeforeRenderObservable(): Observable<Mesh>;
  28236. /**
  28237. * An event triggered before binding the mesh
  28238. */
  28239. get onBeforeBindObservable(): Observable<Mesh>;
  28240. /**
  28241. * An event triggered after rendering the mesh
  28242. */
  28243. get onAfterRenderObservable(): Observable<Mesh>;
  28244. /**
  28245. * An event triggered before drawing the mesh
  28246. */
  28247. get onBeforeDrawObservable(): Observable<Mesh>;
  28248. private _onBeforeDrawObserver;
  28249. /**
  28250. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28251. */
  28252. set onBeforeDraw(callback: () => void);
  28253. get hasInstances(): boolean;
  28254. get hasThinInstances(): boolean;
  28255. /**
  28256. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28257. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28258. */
  28259. delayLoadState: number;
  28260. /**
  28261. * Gets the list of instances created from this mesh
  28262. * it is not supposed to be modified manually.
  28263. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28264. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  28265. */
  28266. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  28267. /**
  28268. * Gets the file containing delay loading data for this mesh
  28269. */
  28270. delayLoadingFile: string;
  28271. /** @hidden */
  28272. _binaryInfo: any;
  28273. /**
  28274. * User defined function used to change how LOD level selection is done
  28275. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28276. */
  28277. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28278. /**
  28279. * Gets or sets the morph target manager
  28280. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28281. */
  28282. get morphTargetManager(): Nullable<MorphTargetManager>;
  28283. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28284. /** @hidden */
  28285. _creationDataStorage: Nullable<_CreationDataStorage>;
  28286. /** @hidden */
  28287. _geometry: Nullable<Geometry>;
  28288. /** @hidden */
  28289. _delayInfo: Array<string>;
  28290. /** @hidden */
  28291. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28292. /** @hidden */
  28293. _instanceDataStorage: _InstanceDataStorage;
  28294. /** @hidden */
  28295. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28296. private _effectiveMaterial;
  28297. /** @hidden */
  28298. _shouldGenerateFlatShading: boolean;
  28299. /** @hidden */
  28300. _originalBuilderSideOrientation: number;
  28301. /**
  28302. * Use this property to change the original side orientation defined at construction time
  28303. */
  28304. overrideMaterialSideOrientation: Nullable<number>;
  28305. /**
  28306. * Gets the source mesh (the one used to clone this one from)
  28307. */
  28308. get source(): Nullable<Mesh>;
  28309. /**
  28310. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28311. */
  28312. get isUnIndexed(): boolean;
  28313. set isUnIndexed(value: boolean);
  28314. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28315. get worldMatrixInstancedBuffer(): Float32Array;
  28316. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28317. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28318. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28319. /**
  28320. * @constructor
  28321. * @param name The value used by scene.getMeshByName() to do a lookup.
  28322. * @param scene The scene to add this mesh to.
  28323. * @param parent The parent of this mesh, if it has one
  28324. * @param source An optional Mesh from which geometry is shared, cloned.
  28325. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28326. * When false, achieved by calling a clone(), also passing False.
  28327. * This will make creation of children, recursive.
  28328. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28329. */
  28330. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28331. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28332. doNotInstantiate: boolean;
  28333. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28334. /**
  28335. * Gets the class name
  28336. * @returns the string "Mesh".
  28337. */
  28338. getClassName(): string;
  28339. /** @hidden */
  28340. get _isMesh(): boolean;
  28341. /**
  28342. * Returns a description of this mesh
  28343. * @param fullDetails define if full details about this mesh must be used
  28344. * @returns a descriptive string representing this mesh
  28345. */
  28346. toString(fullDetails?: boolean): string;
  28347. /** @hidden */
  28348. _unBindEffect(): void;
  28349. /**
  28350. * Gets a boolean indicating if this mesh has LOD
  28351. */
  28352. get hasLODLevels(): boolean;
  28353. /**
  28354. * Gets the list of MeshLODLevel associated with the current mesh
  28355. * @returns an array of MeshLODLevel
  28356. */
  28357. getLODLevels(): MeshLODLevel[];
  28358. private _sortLODLevels;
  28359. /**
  28360. * Add a mesh as LOD level triggered at the given distance.
  28361. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28362. * @param distance The distance from the center of the object to show this level
  28363. * @param mesh The mesh to be added as LOD level (can be null)
  28364. * @return This mesh (for chaining)
  28365. */
  28366. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28367. /**
  28368. * Returns the LOD level mesh at the passed distance or null if not found.
  28369. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28370. * @param distance The distance from the center of the object to show this level
  28371. * @returns a Mesh or `null`
  28372. */
  28373. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28374. /**
  28375. * Remove a mesh from the LOD array
  28376. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28377. * @param mesh defines the mesh to be removed
  28378. * @return This mesh (for chaining)
  28379. */
  28380. removeLODLevel(mesh: Mesh): Mesh;
  28381. /**
  28382. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28383. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28384. * @param camera defines the camera to use to compute distance
  28385. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28386. * @return This mesh (for chaining)
  28387. */
  28388. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28389. /**
  28390. * Gets the mesh internal Geometry object
  28391. */
  28392. get geometry(): Nullable<Geometry>;
  28393. /**
  28394. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28395. * @returns the total number of vertices
  28396. */
  28397. getTotalVertices(): number;
  28398. /**
  28399. * Returns the content of an associated vertex buffer
  28400. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28401. * - VertexBuffer.PositionKind
  28402. * - VertexBuffer.UVKind
  28403. * - VertexBuffer.UV2Kind
  28404. * - VertexBuffer.UV3Kind
  28405. * - VertexBuffer.UV4Kind
  28406. * - VertexBuffer.UV5Kind
  28407. * - VertexBuffer.UV6Kind
  28408. * - VertexBuffer.ColorKind
  28409. * - VertexBuffer.MatricesIndicesKind
  28410. * - VertexBuffer.MatricesIndicesExtraKind
  28411. * - VertexBuffer.MatricesWeightsKind
  28412. * - VertexBuffer.MatricesWeightsExtraKind
  28413. * @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
  28414. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28415. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28416. */
  28417. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28418. /**
  28419. * Returns the mesh VertexBuffer object from the requested `kind`
  28420. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28421. * - VertexBuffer.PositionKind
  28422. * - VertexBuffer.NormalKind
  28423. * - VertexBuffer.UVKind
  28424. * - VertexBuffer.UV2Kind
  28425. * - VertexBuffer.UV3Kind
  28426. * - VertexBuffer.UV4Kind
  28427. * - VertexBuffer.UV5Kind
  28428. * - VertexBuffer.UV6Kind
  28429. * - VertexBuffer.ColorKind
  28430. * - VertexBuffer.MatricesIndicesKind
  28431. * - VertexBuffer.MatricesIndicesExtraKind
  28432. * - VertexBuffer.MatricesWeightsKind
  28433. * - VertexBuffer.MatricesWeightsExtraKind
  28434. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28435. */
  28436. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28437. /**
  28438. * Tests if a specific vertex buffer is associated with this mesh
  28439. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28440. * - VertexBuffer.PositionKind
  28441. * - VertexBuffer.NormalKind
  28442. * - VertexBuffer.UVKind
  28443. * - VertexBuffer.UV2Kind
  28444. * - VertexBuffer.UV3Kind
  28445. * - VertexBuffer.UV4Kind
  28446. * - VertexBuffer.UV5Kind
  28447. * - VertexBuffer.UV6Kind
  28448. * - VertexBuffer.ColorKind
  28449. * - VertexBuffer.MatricesIndicesKind
  28450. * - VertexBuffer.MatricesIndicesExtraKind
  28451. * - VertexBuffer.MatricesWeightsKind
  28452. * - VertexBuffer.MatricesWeightsExtraKind
  28453. * @returns a boolean
  28454. */
  28455. isVerticesDataPresent(kind: string): boolean;
  28456. /**
  28457. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28458. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28459. * - VertexBuffer.PositionKind
  28460. * - VertexBuffer.UVKind
  28461. * - VertexBuffer.UV2Kind
  28462. * - VertexBuffer.UV3Kind
  28463. * - VertexBuffer.UV4Kind
  28464. * - VertexBuffer.UV5Kind
  28465. * - VertexBuffer.UV6Kind
  28466. * - VertexBuffer.ColorKind
  28467. * - VertexBuffer.MatricesIndicesKind
  28468. * - VertexBuffer.MatricesIndicesExtraKind
  28469. * - VertexBuffer.MatricesWeightsKind
  28470. * - VertexBuffer.MatricesWeightsExtraKind
  28471. * @returns a boolean
  28472. */
  28473. isVertexBufferUpdatable(kind: string): boolean;
  28474. /**
  28475. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28476. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28477. * - VertexBuffer.PositionKind
  28478. * - VertexBuffer.NormalKind
  28479. * - VertexBuffer.UVKind
  28480. * - VertexBuffer.UV2Kind
  28481. * - VertexBuffer.UV3Kind
  28482. * - VertexBuffer.UV4Kind
  28483. * - VertexBuffer.UV5Kind
  28484. * - VertexBuffer.UV6Kind
  28485. * - VertexBuffer.ColorKind
  28486. * - VertexBuffer.MatricesIndicesKind
  28487. * - VertexBuffer.MatricesIndicesExtraKind
  28488. * - VertexBuffer.MatricesWeightsKind
  28489. * - VertexBuffer.MatricesWeightsExtraKind
  28490. * @returns an array of strings
  28491. */
  28492. getVerticesDataKinds(): string[];
  28493. /**
  28494. * Returns a positive integer : the total number of indices in this mesh geometry.
  28495. * @returns the numner of indices or zero if the mesh has no geometry.
  28496. */
  28497. getTotalIndices(): number;
  28498. /**
  28499. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28500. * @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.
  28501. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28502. * @returns the indices array or an empty array if the mesh has no geometry
  28503. */
  28504. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28505. get isBlocked(): boolean;
  28506. /**
  28507. * Determine if the current mesh is ready to be rendered
  28508. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28509. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28510. * @returns true if all associated assets are ready (material, textures, shaders)
  28511. */
  28512. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28513. /**
  28514. * 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.
  28515. */
  28516. get areNormalsFrozen(): boolean;
  28517. /**
  28518. * 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.
  28519. * @returns the current mesh
  28520. */
  28521. freezeNormals(): Mesh;
  28522. /**
  28523. * 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
  28524. * @returns the current mesh
  28525. */
  28526. unfreezeNormals(): Mesh;
  28527. /**
  28528. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28529. */
  28530. set overridenInstanceCount(count: number);
  28531. /** @hidden */
  28532. _preActivate(): Mesh;
  28533. /** @hidden */
  28534. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28535. /** @hidden */
  28536. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28537. protected _afterComputeWorldMatrix(): void;
  28538. /**
  28539. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28540. * This means the mesh underlying bounding box and sphere are recomputed.
  28541. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28542. * @returns the current mesh
  28543. */
  28544. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28545. /** @hidden */
  28546. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28547. /**
  28548. * This function will subdivide the mesh into multiple submeshes
  28549. * @param count defines the expected number of submeshes
  28550. */
  28551. subdivide(count: number): void;
  28552. /**
  28553. * Copy a FloatArray into a specific associated vertex buffer
  28554. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28555. * - VertexBuffer.PositionKind
  28556. * - VertexBuffer.UVKind
  28557. * - VertexBuffer.UV2Kind
  28558. * - VertexBuffer.UV3Kind
  28559. * - VertexBuffer.UV4Kind
  28560. * - VertexBuffer.UV5Kind
  28561. * - VertexBuffer.UV6Kind
  28562. * - VertexBuffer.ColorKind
  28563. * - VertexBuffer.MatricesIndicesKind
  28564. * - VertexBuffer.MatricesIndicesExtraKind
  28565. * - VertexBuffer.MatricesWeightsKind
  28566. * - VertexBuffer.MatricesWeightsExtraKind
  28567. * @param data defines the data source
  28568. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28569. * @param stride defines the data stride size (can be null)
  28570. * @returns the current mesh
  28571. */
  28572. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28573. /**
  28574. * Delete a vertex buffer associated with this mesh
  28575. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28576. * - VertexBuffer.PositionKind
  28577. * - VertexBuffer.UVKind
  28578. * - VertexBuffer.UV2Kind
  28579. * - VertexBuffer.UV3Kind
  28580. * - VertexBuffer.UV4Kind
  28581. * - VertexBuffer.UV5Kind
  28582. * - VertexBuffer.UV6Kind
  28583. * - VertexBuffer.ColorKind
  28584. * - VertexBuffer.MatricesIndicesKind
  28585. * - VertexBuffer.MatricesIndicesExtraKind
  28586. * - VertexBuffer.MatricesWeightsKind
  28587. * - VertexBuffer.MatricesWeightsExtraKind
  28588. */
  28589. removeVerticesData(kind: string): void;
  28590. /**
  28591. * Flags an associated vertex buffer as updatable
  28592. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28593. * - VertexBuffer.PositionKind
  28594. * - VertexBuffer.UVKind
  28595. * - VertexBuffer.UV2Kind
  28596. * - VertexBuffer.UV3Kind
  28597. * - VertexBuffer.UV4Kind
  28598. * - VertexBuffer.UV5Kind
  28599. * - VertexBuffer.UV6Kind
  28600. * - VertexBuffer.ColorKind
  28601. * - VertexBuffer.MatricesIndicesKind
  28602. * - VertexBuffer.MatricesIndicesExtraKind
  28603. * - VertexBuffer.MatricesWeightsKind
  28604. * - VertexBuffer.MatricesWeightsExtraKind
  28605. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28606. */
  28607. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28608. /**
  28609. * Sets the mesh global Vertex Buffer
  28610. * @param buffer defines the buffer to use
  28611. * @returns the current mesh
  28612. */
  28613. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28614. /**
  28615. * Update a specific associated vertex buffer
  28616. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28617. * - VertexBuffer.PositionKind
  28618. * - VertexBuffer.UVKind
  28619. * - VertexBuffer.UV2Kind
  28620. * - VertexBuffer.UV3Kind
  28621. * - VertexBuffer.UV4Kind
  28622. * - VertexBuffer.UV5Kind
  28623. * - VertexBuffer.UV6Kind
  28624. * - VertexBuffer.ColorKind
  28625. * - VertexBuffer.MatricesIndicesKind
  28626. * - VertexBuffer.MatricesIndicesExtraKind
  28627. * - VertexBuffer.MatricesWeightsKind
  28628. * - VertexBuffer.MatricesWeightsExtraKind
  28629. * @param data defines the data source
  28630. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28631. * @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)
  28632. * @returns the current mesh
  28633. */
  28634. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28635. /**
  28636. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28637. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28638. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28639. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28640. * @returns the current mesh
  28641. */
  28642. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28643. /**
  28644. * Creates a un-shared specific occurence of the geometry for the mesh.
  28645. * @returns the current mesh
  28646. */
  28647. makeGeometryUnique(): Mesh;
  28648. /**
  28649. * Set the index buffer of this mesh
  28650. * @param indices defines the source data
  28651. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28652. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28653. * @returns the current mesh
  28654. */
  28655. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28656. /**
  28657. * Update the current index buffer
  28658. * @param indices defines the source data
  28659. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28660. * @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)
  28661. * @returns the current mesh
  28662. */
  28663. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28664. /**
  28665. * Invert the geometry to move from a right handed system to a left handed one.
  28666. * @returns the current mesh
  28667. */
  28668. toLeftHanded(): Mesh;
  28669. /** @hidden */
  28670. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28671. /** @hidden */
  28672. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28673. /**
  28674. * Registers for this mesh a javascript function called just before the rendering process
  28675. * @param func defines the function to call before rendering this mesh
  28676. * @returns the current mesh
  28677. */
  28678. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28679. /**
  28680. * Disposes a previously registered javascript function called before the rendering
  28681. * @param func defines the function to remove
  28682. * @returns the current mesh
  28683. */
  28684. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28685. /**
  28686. * Registers for this mesh a javascript function called just after the rendering is complete
  28687. * @param func defines the function to call after rendering this mesh
  28688. * @returns the current mesh
  28689. */
  28690. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28691. /**
  28692. * Disposes a previously registered javascript function called after the rendering.
  28693. * @param func defines the function to remove
  28694. * @returns the current mesh
  28695. */
  28696. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28697. /** @hidden */
  28698. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28699. /** @hidden */
  28700. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28701. /** @hidden */
  28702. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28703. /** @hidden */
  28704. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28705. /** @hidden */
  28706. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28707. /** @hidden */
  28708. _rebuild(): void;
  28709. /** @hidden */
  28710. _freeze(): void;
  28711. /** @hidden */
  28712. _unFreeze(): void;
  28713. /**
  28714. * 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
  28715. * @param subMesh defines the subMesh to render
  28716. * @param enableAlphaMode defines if alpha mode can be changed
  28717. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28718. * @returns the current mesh
  28719. */
  28720. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28721. private _onBeforeDraw;
  28722. /**
  28723. * Renormalize the mesh and patch it up if there are no weights
  28724. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28725. * However in the case of zero weights then we set just a single influence to 1.
  28726. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28727. */
  28728. cleanMatrixWeights(): void;
  28729. private normalizeSkinFourWeights;
  28730. private normalizeSkinWeightsAndExtra;
  28731. /**
  28732. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28733. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28734. * the user know there was an issue with importing the mesh
  28735. * @returns a validation object with skinned, valid and report string
  28736. */
  28737. validateSkinning(): {
  28738. skinned: boolean;
  28739. valid: boolean;
  28740. report: string;
  28741. };
  28742. /** @hidden */
  28743. _checkDelayState(): Mesh;
  28744. private _queueLoad;
  28745. /**
  28746. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28747. * A mesh is in the frustum if its bounding box intersects the frustum
  28748. * @param frustumPlanes defines the frustum to test
  28749. * @returns true if the mesh is in the frustum planes
  28750. */
  28751. isInFrustum(frustumPlanes: Plane[]): boolean;
  28752. /**
  28753. * Sets the mesh material by the material or multiMaterial `id` property
  28754. * @param id is a string identifying the material or the multiMaterial
  28755. * @returns the current mesh
  28756. */
  28757. setMaterialByID(id: string): Mesh;
  28758. /**
  28759. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28760. * @returns an array of IAnimatable
  28761. */
  28762. getAnimatables(): IAnimatable[];
  28763. /**
  28764. * Modifies the mesh geometry according to the passed transformation matrix.
  28765. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28766. * The mesh normals are modified using the same transformation.
  28767. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28768. * @param transform defines the transform matrix to use
  28769. * @see http://doc.babylonjs.com/resources/baking_transformations
  28770. * @returns the current mesh
  28771. */
  28772. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28773. /**
  28774. * Modifies the mesh geometry according to its own current World Matrix.
  28775. * The mesh World Matrix is then reset.
  28776. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28777. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28778. * @see http://doc.babylonjs.com/resources/baking_transformations
  28779. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28780. * @returns the current mesh
  28781. */
  28782. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28783. /** @hidden */
  28784. get _positions(): Nullable<Vector3[]>;
  28785. /** @hidden */
  28786. _resetPointsArrayCache(): Mesh;
  28787. /** @hidden */
  28788. _generatePointsArray(): boolean;
  28789. /**
  28790. * Returns a new Mesh object generated from the current mesh properties.
  28791. * This method must not get confused with createInstance()
  28792. * @param name is a string, the name given to the new mesh
  28793. * @param newParent can be any Node object (default `null`)
  28794. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28795. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28796. * @returns a new mesh
  28797. */
  28798. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28799. /**
  28800. * Releases resources associated with this mesh.
  28801. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28802. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28803. */
  28804. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28805. /** @hidden */
  28806. _disposeInstanceSpecificData(): void;
  28807. /** @hidden */
  28808. _disposeThinInstanceSpecificData(): void;
  28809. /**
  28810. * Modifies the mesh geometry according to a displacement map.
  28811. * 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.
  28812. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28813. * @param url is a string, the URL from the image file is to be downloaded.
  28814. * @param minHeight is the lower limit of the displacement.
  28815. * @param maxHeight is the upper limit of the displacement.
  28816. * @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.
  28817. * @param uvOffset is an optional vector2 used to offset UV.
  28818. * @param uvScale is an optional vector2 used to scale UV.
  28819. * @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.
  28820. * @returns the Mesh.
  28821. */
  28822. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28823. /**
  28824. * Modifies the mesh geometry according to a displacementMap buffer.
  28825. * 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.
  28826. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28827. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28828. * @param heightMapWidth is the width of the buffer image.
  28829. * @param heightMapHeight is the height of the buffer image.
  28830. * @param minHeight is the lower limit of the displacement.
  28831. * @param maxHeight is the upper limit of the displacement.
  28832. * @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.
  28833. * @param uvOffset is an optional vector2 used to offset UV.
  28834. * @param uvScale is an optional vector2 used to scale UV.
  28835. * @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.
  28836. * @returns the Mesh.
  28837. */
  28838. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28839. /**
  28840. * Modify the mesh to get a flat shading rendering.
  28841. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28842. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28843. * @returns current mesh
  28844. */
  28845. convertToFlatShadedMesh(): Mesh;
  28846. /**
  28847. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28848. * In other words, more vertices, no more indices and a single bigger VBO.
  28849. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28850. * @returns current mesh
  28851. */
  28852. convertToUnIndexedMesh(): Mesh;
  28853. /**
  28854. * Inverses facet orientations.
  28855. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28856. * @param flipNormals will also inverts the normals
  28857. * @returns current mesh
  28858. */
  28859. flipFaces(flipNormals?: boolean): Mesh;
  28860. /**
  28861. * Increase the number of facets and hence vertices in a mesh
  28862. * Vertex normals are interpolated from existing vertex normals
  28863. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28864. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28865. */
  28866. increaseVertices(numberPerEdge: number): void;
  28867. /**
  28868. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28869. * This will undo any application of covertToFlatShadedMesh
  28870. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28871. */
  28872. forceSharedVertices(): void;
  28873. /** @hidden */
  28874. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28875. /** @hidden */
  28876. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28877. /**
  28878. * Creates a new InstancedMesh object from the mesh model.
  28879. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  28880. * @param name defines the name of the new instance
  28881. * @returns a new InstancedMesh
  28882. */
  28883. createInstance(name: string): InstancedMesh;
  28884. /**
  28885. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28886. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28887. * @returns the current mesh
  28888. */
  28889. synchronizeInstances(): Mesh;
  28890. /**
  28891. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28892. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28893. * This should be used together with the simplification to avoid disappearing triangles.
  28894. * @param successCallback an optional success callback to be called after the optimization finished.
  28895. * @returns the current mesh
  28896. */
  28897. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28898. /**
  28899. * Serialize current mesh
  28900. * @param serializationObject defines the object which will receive the serialization data
  28901. */
  28902. serialize(serializationObject: any): void;
  28903. /** @hidden */
  28904. _syncGeometryWithMorphTargetManager(): void;
  28905. /** @hidden */
  28906. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28907. /**
  28908. * Returns a new Mesh object parsed from the source provided.
  28909. * @param parsedMesh is the source
  28910. * @param scene defines the hosting scene
  28911. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28912. * @returns a new Mesh
  28913. */
  28914. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28915. /**
  28916. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28917. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28918. * @param name defines the name of the mesh to create
  28919. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28920. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28921. * @param closePath creates a seam between the first and the last points of each path of the path array
  28922. * @param offset is taken in account only if the `pathArray` is containing a single path
  28923. * @param scene defines the hosting scene
  28924. * @param updatable defines if the mesh must be flagged as updatable
  28925. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28926. * @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)
  28927. * @returns a new Mesh
  28928. */
  28929. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28930. /**
  28931. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28932. * @param name defines the name of the mesh to create
  28933. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28934. * @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
  28935. * @param scene defines the hosting scene
  28936. * @param updatable defines if the mesh must be flagged as updatable
  28937. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28938. * @returns a new Mesh
  28939. */
  28940. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28941. /**
  28942. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28943. * @param name defines the name of the mesh to create
  28944. * @param size sets the size (float) of each box side (default 1)
  28945. * @param scene defines the hosting scene
  28946. * @param updatable defines if the mesh must be flagged as updatable
  28947. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28948. * @returns a new Mesh
  28949. */
  28950. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28951. /**
  28952. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28953. * @param name defines the name of the mesh to create
  28954. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28955. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28956. * @param scene defines the hosting scene
  28957. * @param updatable defines if the mesh must be flagged as updatable
  28958. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28959. * @returns a new Mesh
  28960. */
  28961. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28962. /**
  28963. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28964. * @param name defines the name of the mesh to create
  28965. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28966. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28967. * @param scene defines the hosting scene
  28968. * @returns a new Mesh
  28969. */
  28970. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28971. /**
  28972. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28973. * @param name defines the name of the mesh to create
  28974. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28975. * @param diameterTop set the top cap diameter (floats, default 1)
  28976. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28977. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28978. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28979. * @param scene defines the hosting scene
  28980. * @param updatable defines if the mesh must be flagged as updatable
  28981. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28982. * @returns a new Mesh
  28983. */
  28984. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28985. /**
  28986. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28987. * @param name defines the name of the mesh to create
  28988. * @param diameter sets the diameter size (float) of the torus (default 1)
  28989. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28990. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28991. * @param scene defines the hosting scene
  28992. * @param updatable defines if the mesh must be flagged as updatable
  28993. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28994. * @returns a new Mesh
  28995. */
  28996. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28997. /**
  28998. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28999. * @param name defines the name of the mesh to create
  29000. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29001. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29002. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29003. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29004. * @param p the number of windings on X axis (positive integers, default 2)
  29005. * @param q the number of windings on Y axis (positive integers, default 3)
  29006. * @param scene defines the hosting scene
  29007. * @param updatable defines if the mesh must be flagged as updatable
  29008. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29009. * @returns a new Mesh
  29010. */
  29011. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29012. /**
  29013. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29014. * @param name defines the name of the mesh to create
  29015. * @param points is an array successive Vector3
  29016. * @param scene defines the hosting scene
  29017. * @param updatable defines if the mesh must be flagged as updatable
  29018. * @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).
  29019. * @returns a new Mesh
  29020. */
  29021. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29022. /**
  29023. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29024. * @param name defines the name of the mesh to create
  29025. * @param points is an array successive Vector3
  29026. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29027. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29028. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29029. * @param scene defines the hosting scene
  29030. * @param updatable defines if the mesh must be flagged as updatable
  29031. * @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)
  29032. * @returns a new Mesh
  29033. */
  29034. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29035. /**
  29036. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29037. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29038. * 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.
  29039. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29040. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29041. * Remember you can only change the shape positions, not their number when updating a polygon.
  29042. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29043. * @param name defines the name of the mesh to create
  29044. * @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
  29045. * @param scene defines the hosting scene
  29046. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29047. * @param updatable defines if the mesh must be flagged as updatable
  29048. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29049. * @param earcutInjection can be used to inject your own earcut reference
  29050. * @returns a new Mesh
  29051. */
  29052. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29053. /**
  29054. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29055. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29056. * @param name defines the name of the mesh to create
  29057. * @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
  29058. * @param depth defines the height of extrusion
  29059. * @param scene defines the hosting scene
  29060. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  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 earcutInjection can be used to inject your own earcut reference
  29064. * @returns a new Mesh
  29065. */
  29066. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29067. /**
  29068. * Creates an extruded shape mesh.
  29069. * 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
  29070. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  29071. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29072. * @param name defines the name of the mesh to create
  29073. * @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
  29074. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29075. * @param scale is the value to scale the shape
  29076. * @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
  29077. * @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
  29078. * @param scene defines the hosting scene
  29079. * @param updatable defines if the mesh must be flagged as updatable
  29080. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29081. * @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)
  29082. * @returns a new Mesh
  29083. */
  29084. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29085. /**
  29086. * Creates an custom extruded shape mesh.
  29087. * The custom extrusion is a parametric shape.
  29088. * It has no predefined shape. Its final shape will depend on the input parameters.
  29089. * Please consider using the same method from the MeshBuilder class instead
  29090. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29091. * @param name defines the name of the mesh to create
  29092. * @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
  29093. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29094. * @param scaleFunction is a custom Javascript function called on each path point
  29095. * @param rotationFunction is a custom Javascript function called on each path point
  29096. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29097. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29098. * @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
  29099. * @param scene defines the hosting scene
  29100. * @param updatable defines if the mesh must be flagged as updatable
  29101. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29102. * @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)
  29103. * @returns a new Mesh
  29104. */
  29105. 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;
  29106. /**
  29107. * Creates lathe mesh.
  29108. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29109. * Please consider using the same method from the MeshBuilder class instead
  29110. * @param name defines the name of the mesh to create
  29111. * @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
  29112. * @param radius is the radius value of the lathe
  29113. * @param tessellation is the side number of the lathe.
  29114. * @param scene defines the hosting scene
  29115. * @param updatable defines if the mesh must be flagged as updatable
  29116. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29117. * @returns a new Mesh
  29118. */
  29119. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29120. /**
  29121. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29122. * @param name defines the name of the mesh to create
  29123. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29124. * @param scene defines the hosting scene
  29125. * @param updatable defines if the mesh must be flagged as updatable
  29126. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29127. * @returns a new Mesh
  29128. */
  29129. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29130. /**
  29131. * Creates a ground mesh.
  29132. * Please consider using the same method from the MeshBuilder class instead
  29133. * @param name defines the name of the mesh to create
  29134. * @param width set the width of the ground
  29135. * @param height set the height of the ground
  29136. * @param subdivisions sets the number of subdivisions per side
  29137. * @param scene defines the hosting scene
  29138. * @param updatable defines if the mesh must be flagged as updatable
  29139. * @returns a new Mesh
  29140. */
  29141. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29142. /**
  29143. * Creates a tiled ground mesh.
  29144. * Please consider using the same method from the MeshBuilder class instead
  29145. * @param name defines the name of the mesh to create
  29146. * @param xmin set the ground minimum X coordinate
  29147. * @param zmin set the ground minimum Y coordinate
  29148. * @param xmax set the ground maximum X coordinate
  29149. * @param zmax set the ground maximum Z coordinate
  29150. * @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
  29151. * @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
  29152. * @param scene defines the hosting scene
  29153. * @param updatable defines if the mesh must be flagged as updatable
  29154. * @returns a new Mesh
  29155. */
  29156. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29157. w: number;
  29158. h: number;
  29159. }, precision: {
  29160. w: number;
  29161. h: number;
  29162. }, scene: Scene, updatable?: boolean): Mesh;
  29163. /**
  29164. * Creates a ground mesh from a height map.
  29165. * Please consider using the same method from the MeshBuilder class instead
  29166. * @see http://doc.babylonjs.com/babylon101/height_map
  29167. * @param name defines the name of the mesh to create
  29168. * @param url sets the URL of the height map image resource
  29169. * @param width set the ground width size
  29170. * @param height set the ground height size
  29171. * @param subdivisions sets the number of subdivision per side
  29172. * @param minHeight is the minimum altitude on the ground
  29173. * @param maxHeight is the maximum altitude on the ground
  29174. * @param scene defines the hosting scene
  29175. * @param updatable defines if the mesh must be flagged as updatable
  29176. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29177. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29178. * @returns a new Mesh
  29179. */
  29180. 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;
  29181. /**
  29182. * Creates a tube mesh.
  29183. * The tube is a parametric shape.
  29184. * It has no predefined shape. Its final shape will depend on the input parameters.
  29185. * Please consider using the same method from the MeshBuilder class instead
  29186. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  29187. * @param name defines the name of the mesh to create
  29188. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29189. * @param radius sets the tube radius size
  29190. * @param tessellation is the number of sides on the tubular surface
  29191. * @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
  29192. * @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
  29193. * @param scene defines the hosting scene
  29194. * @param updatable defines if the mesh must be flagged as updatable
  29195. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29196. * @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)
  29197. * @returns a new Mesh
  29198. */
  29199. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29200. (i: number, distance: number): number;
  29201. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29202. /**
  29203. * Creates a polyhedron mesh.
  29204. * Please consider using the same method from the MeshBuilder class instead.
  29205. * * 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
  29206. * * The parameter `size` (positive float, default 1) sets the polygon size
  29207. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29208. * * 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`
  29209. * * 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
  29210. * * 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)`)
  29211. * * 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
  29212. * * 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
  29213. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29214. * * If you create a double-sided mesh, you can choose what parts of 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
  29215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29216. * @param name defines the name of the mesh to create
  29217. * @param options defines the options used to create the mesh
  29218. * @param scene defines the hosting scene
  29219. * @returns a new Mesh
  29220. */
  29221. static CreatePolyhedron(name: string, options: {
  29222. type?: number;
  29223. size?: number;
  29224. sizeX?: number;
  29225. sizeY?: number;
  29226. sizeZ?: number;
  29227. custom?: any;
  29228. faceUV?: Vector4[];
  29229. faceColors?: Color4[];
  29230. updatable?: boolean;
  29231. sideOrientation?: number;
  29232. }, scene: Scene): Mesh;
  29233. /**
  29234. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29235. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29236. * * 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`)
  29237. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29238. * * 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
  29239. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29240. * * If you create a double-sided mesh, you can choose what parts of 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
  29241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29242. * @param name defines the name of the mesh
  29243. * @param options defines the options used to create the mesh
  29244. * @param scene defines the hosting scene
  29245. * @returns a new Mesh
  29246. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29247. */
  29248. static CreateIcoSphere(name: string, options: {
  29249. radius?: number;
  29250. flat?: boolean;
  29251. subdivisions?: number;
  29252. sideOrientation?: number;
  29253. updatable?: boolean;
  29254. }, scene: Scene): Mesh;
  29255. /**
  29256. * Creates a decal mesh.
  29257. * Please consider using the same method from the MeshBuilder class instead.
  29258. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29259. * @param name defines the name of the mesh
  29260. * @param sourceMesh defines the mesh receiving the decal
  29261. * @param position sets the position of the decal in world coordinates
  29262. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29263. * @param size sets the decal scaling
  29264. * @param angle sets the angle to rotate the decal
  29265. * @returns a new Mesh
  29266. */
  29267. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29268. /**
  29269. * Prepare internal position array for software CPU skinning
  29270. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29271. */
  29272. setPositionsForCPUSkinning(): Float32Array;
  29273. /**
  29274. * Prepare internal normal array for software CPU skinning
  29275. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29276. */
  29277. setNormalsForCPUSkinning(): Float32Array;
  29278. /**
  29279. * Updates the vertex buffer by applying transformation from the bones
  29280. * @param skeleton defines the skeleton to apply to current mesh
  29281. * @returns the current mesh
  29282. */
  29283. applySkeleton(skeleton: Skeleton): Mesh;
  29284. /**
  29285. * 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
  29286. * @param meshes defines the list of meshes to scan
  29287. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29288. */
  29289. static MinMax(meshes: AbstractMesh[]): {
  29290. min: Vector3;
  29291. max: Vector3;
  29292. };
  29293. /**
  29294. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29295. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29296. * @returns a vector3
  29297. */
  29298. static Center(meshesOrMinMaxVector: {
  29299. min: Vector3;
  29300. max: Vector3;
  29301. } | AbstractMesh[]): Vector3;
  29302. /**
  29303. * Merge the array of meshes into a single mesh for performance reasons.
  29304. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29305. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29306. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29307. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29308. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29309. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29310. * @returns a new mesh
  29311. */
  29312. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29313. /** @hidden */
  29314. addInstance(instance: InstancedMesh): void;
  29315. /** @hidden */
  29316. removeInstance(instance: InstancedMesh): void;
  29317. }
  29318. }
  29319. declare module "babylonjs/Cameras/camera" {
  29320. import { SmartArray } from "babylonjs/Misc/smartArray";
  29321. import { Observable } from "babylonjs/Misc/observable";
  29322. import { Nullable } from "babylonjs/types";
  29323. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  29324. import { Scene } from "babylonjs/scene";
  29325. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  29326. import { Node } from "babylonjs/node";
  29327. import { Mesh } from "babylonjs/Meshes/mesh";
  29328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29329. import { ICullable } from "babylonjs/Culling/boundingInfo";
  29330. import { Viewport } from "babylonjs/Maths/math.viewport";
  29331. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29332. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29333. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  29334. import { Ray } from "babylonjs/Culling/ray";
  29335. /**
  29336. * This is the base class of all the camera used in the application.
  29337. * @see http://doc.babylonjs.com/features/cameras
  29338. */
  29339. export class Camera extends Node {
  29340. /** @hidden */
  29341. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29342. /**
  29343. * This is the default projection mode used by the cameras.
  29344. * It helps recreating a feeling of perspective and better appreciate depth.
  29345. * This is the best way to simulate real life cameras.
  29346. */
  29347. static readonly PERSPECTIVE_CAMERA: number;
  29348. /**
  29349. * This helps creating camera with an orthographic mode.
  29350. * 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.
  29351. */
  29352. static readonly ORTHOGRAPHIC_CAMERA: number;
  29353. /**
  29354. * This is the default FOV mode for perspective cameras.
  29355. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29356. */
  29357. static readonly FOVMODE_VERTICAL_FIXED: number;
  29358. /**
  29359. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29360. */
  29361. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29362. /**
  29363. * This specifies ther is no need for a camera rig.
  29364. * Basically only one eye is rendered corresponding to the camera.
  29365. */
  29366. static readonly RIG_MODE_NONE: number;
  29367. /**
  29368. * Simulates a camera Rig with one blue eye and one red eye.
  29369. * This can be use with 3d blue and red glasses.
  29370. */
  29371. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29372. /**
  29373. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29374. */
  29375. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29376. /**
  29377. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29378. */
  29379. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29380. /**
  29381. * Defines that both eyes of the camera will be rendered over under each other.
  29382. */
  29383. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29384. /**
  29385. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29386. */
  29387. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29388. /**
  29389. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29390. */
  29391. static readonly RIG_MODE_VR: number;
  29392. /**
  29393. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29394. */
  29395. static readonly RIG_MODE_WEBVR: number;
  29396. /**
  29397. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29398. */
  29399. static readonly RIG_MODE_CUSTOM: number;
  29400. /**
  29401. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29402. */
  29403. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29404. /**
  29405. * Define the input manager associated with the camera.
  29406. */
  29407. inputs: CameraInputsManager<Camera>;
  29408. /** @hidden */
  29409. _position: Vector3;
  29410. /**
  29411. * Define the current local position of the camera in the scene
  29412. */
  29413. get position(): Vector3;
  29414. set position(newPosition: Vector3);
  29415. /**
  29416. * The vector the camera should consider as up.
  29417. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29418. */
  29419. upVector: Vector3;
  29420. /**
  29421. * Define the current limit on the left side for an orthographic camera
  29422. * In scene unit
  29423. */
  29424. orthoLeft: Nullable<number>;
  29425. /**
  29426. * Define the current limit on the right side for an orthographic camera
  29427. * In scene unit
  29428. */
  29429. orthoRight: Nullable<number>;
  29430. /**
  29431. * Define the current limit on the bottom side for an orthographic camera
  29432. * In scene unit
  29433. */
  29434. orthoBottom: Nullable<number>;
  29435. /**
  29436. * Define the current limit on the top side for an orthographic camera
  29437. * In scene unit
  29438. */
  29439. orthoTop: Nullable<number>;
  29440. /**
  29441. * Field Of View is set in Radians. (default is 0.8)
  29442. */
  29443. fov: number;
  29444. /**
  29445. * Define the minimum distance the camera can see from.
  29446. * This is important to note that the depth buffer are not infinite and the closer it starts
  29447. * the more your scene might encounter depth fighting issue.
  29448. */
  29449. minZ: number;
  29450. /**
  29451. * Define the maximum distance the camera can see to.
  29452. * This is important to note that the depth buffer are not infinite and the further it end
  29453. * the more your scene might encounter depth fighting issue.
  29454. */
  29455. maxZ: number;
  29456. /**
  29457. * Define the default inertia of the camera.
  29458. * This helps giving a smooth feeling to the camera movement.
  29459. */
  29460. inertia: number;
  29461. /**
  29462. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29463. */
  29464. mode: number;
  29465. /**
  29466. * Define whether the camera is intermediate.
  29467. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29468. */
  29469. isIntermediate: boolean;
  29470. /**
  29471. * Define the viewport of the camera.
  29472. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29473. */
  29474. viewport: Viewport;
  29475. /**
  29476. * Restricts the camera to viewing objects with the same layerMask.
  29477. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29478. */
  29479. layerMask: number;
  29480. /**
  29481. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29482. */
  29483. fovMode: number;
  29484. /**
  29485. * Rig mode of the camera.
  29486. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29487. * This is normally controlled byt the camera themselves as internal use.
  29488. */
  29489. cameraRigMode: number;
  29490. /**
  29491. * Defines the distance between both "eyes" in case of a RIG
  29492. */
  29493. interaxialDistance: number;
  29494. /**
  29495. * Defines if stereoscopic rendering is done side by side or over under.
  29496. */
  29497. isStereoscopicSideBySide: boolean;
  29498. /**
  29499. * 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
  29500. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29501. * else in the scene. (Eg. security camera)
  29502. *
  29503. * 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)
  29504. */
  29505. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  29506. /**
  29507. * When set, the camera will render to this render target instead of the default canvas
  29508. *
  29509. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29510. */
  29511. outputRenderTarget: Nullable<RenderTargetTexture>;
  29512. /**
  29513. * Observable triggered when the camera view matrix has changed.
  29514. */
  29515. onViewMatrixChangedObservable: Observable<Camera>;
  29516. /**
  29517. * Observable triggered when the camera Projection matrix has changed.
  29518. */
  29519. onProjectionMatrixChangedObservable: Observable<Camera>;
  29520. /**
  29521. * Observable triggered when the inputs have been processed.
  29522. */
  29523. onAfterCheckInputsObservable: Observable<Camera>;
  29524. /**
  29525. * Observable triggered when reset has been called and applied to the camera.
  29526. */
  29527. onRestoreStateObservable: Observable<Camera>;
  29528. /**
  29529. * Is this camera a part of a rig system?
  29530. */
  29531. isRigCamera: boolean;
  29532. /**
  29533. * If isRigCamera set to true this will be set with the parent camera.
  29534. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29535. */
  29536. rigParent?: Camera;
  29537. /** @hidden */
  29538. _cameraRigParams: any;
  29539. /** @hidden */
  29540. _rigCameras: Camera[];
  29541. /** @hidden */
  29542. _rigPostProcess: Nullable<PostProcess>;
  29543. protected _webvrViewMatrix: Matrix;
  29544. /** @hidden */
  29545. _skipRendering: boolean;
  29546. /** @hidden */
  29547. _projectionMatrix: Matrix;
  29548. /** @hidden */
  29549. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  29550. /** @hidden */
  29551. _activeMeshes: SmartArray<AbstractMesh>;
  29552. protected _globalPosition: Vector3;
  29553. /** @hidden */
  29554. _computedViewMatrix: Matrix;
  29555. private _doNotComputeProjectionMatrix;
  29556. private _transformMatrix;
  29557. private _frustumPlanes;
  29558. private _refreshFrustumPlanes;
  29559. private _storedFov;
  29560. private _stateStored;
  29561. /**
  29562. * Instantiates a new camera object.
  29563. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29564. * @see http://doc.babylonjs.com/features/cameras
  29565. * @param name Defines the name of the camera in the scene
  29566. * @param position Defines the position of the camera
  29567. * @param scene Defines the scene the camera belongs too
  29568. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29569. */
  29570. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29571. /**
  29572. * Store current camera state (fov, position, etc..)
  29573. * @returns the camera
  29574. */
  29575. storeState(): Camera;
  29576. /**
  29577. * Restores the camera state values if it has been stored. You must call storeState() first
  29578. */
  29579. protected _restoreStateValues(): boolean;
  29580. /**
  29581. * Restored camera state. You must call storeState() first.
  29582. * @returns true if restored and false otherwise
  29583. */
  29584. restoreState(): boolean;
  29585. /**
  29586. * Gets the class name of the camera.
  29587. * @returns the class name
  29588. */
  29589. getClassName(): string;
  29590. /** @hidden */
  29591. readonly _isCamera: boolean;
  29592. /**
  29593. * Gets a string representation of the camera useful for debug purpose.
  29594. * @param fullDetails Defines that a more verboe level of logging is required
  29595. * @returns the string representation
  29596. */
  29597. toString(fullDetails?: boolean): string;
  29598. /**
  29599. * Gets the current world space position of the camera.
  29600. */
  29601. get globalPosition(): Vector3;
  29602. /**
  29603. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29604. * @returns the active meshe list
  29605. */
  29606. getActiveMeshes(): SmartArray<AbstractMesh>;
  29607. /**
  29608. * Check whether a mesh is part of the current active mesh list of the camera
  29609. * @param mesh Defines the mesh to check
  29610. * @returns true if active, false otherwise
  29611. */
  29612. isActiveMesh(mesh: Mesh): boolean;
  29613. /**
  29614. * Is this camera ready to be used/rendered
  29615. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29616. * @return true if the camera is ready
  29617. */
  29618. isReady(completeCheck?: boolean): boolean;
  29619. /** @hidden */
  29620. _initCache(): void;
  29621. /** @hidden */
  29622. _updateCache(ignoreParentClass?: boolean): void;
  29623. /** @hidden */
  29624. _isSynchronized(): boolean;
  29625. /** @hidden */
  29626. _isSynchronizedViewMatrix(): boolean;
  29627. /** @hidden */
  29628. _isSynchronizedProjectionMatrix(): boolean;
  29629. /**
  29630. * Attach the input controls to a specific dom element to get the input from.
  29631. * @param element Defines the element the controls should be listened from
  29632. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29633. */
  29634. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29635. /**
  29636. * Detach the current controls from the specified dom element.
  29637. * @param element Defines the element to stop listening the inputs from
  29638. */
  29639. detachControl(element: HTMLElement): void;
  29640. /**
  29641. * Update the camera state according to the different inputs gathered during the frame.
  29642. */
  29643. update(): void;
  29644. /** @hidden */
  29645. _checkInputs(): void;
  29646. /** @hidden */
  29647. get rigCameras(): Camera[];
  29648. /**
  29649. * Gets the post process used by the rig cameras
  29650. */
  29651. get rigPostProcess(): Nullable<PostProcess>;
  29652. /**
  29653. * Internal, gets the first post proces.
  29654. * @returns the first post process to be run on this camera.
  29655. */
  29656. _getFirstPostProcess(): Nullable<PostProcess>;
  29657. private _cascadePostProcessesToRigCams;
  29658. /**
  29659. * Attach a post process to the camera.
  29660. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29661. * @param postProcess The post process to attach to the camera
  29662. * @param insertAt The position of the post process in case several of them are in use in the scene
  29663. * @returns the position the post process has been inserted at
  29664. */
  29665. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29666. /**
  29667. * Detach a post process to the camera.
  29668. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29669. * @param postProcess The post process to detach from the camera
  29670. */
  29671. detachPostProcess(postProcess: PostProcess): void;
  29672. /**
  29673. * Gets the current world matrix of the camera
  29674. */
  29675. getWorldMatrix(): Matrix;
  29676. /** @hidden */
  29677. _getViewMatrix(): Matrix;
  29678. /**
  29679. * Gets the current view matrix of the camera.
  29680. * @param force forces the camera to recompute the matrix without looking at the cached state
  29681. * @returns the view matrix
  29682. */
  29683. getViewMatrix(force?: boolean): Matrix;
  29684. /**
  29685. * Freeze the projection matrix.
  29686. * It will prevent the cache check of the camera projection compute and can speed up perf
  29687. * if no parameter of the camera are meant to change
  29688. * @param projection Defines manually a projection if necessary
  29689. */
  29690. freezeProjectionMatrix(projection?: Matrix): void;
  29691. /**
  29692. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29693. */
  29694. unfreezeProjectionMatrix(): void;
  29695. /**
  29696. * Gets the current projection matrix of the camera.
  29697. * @param force forces the camera to recompute the matrix without looking at the cached state
  29698. * @returns the projection matrix
  29699. */
  29700. getProjectionMatrix(force?: boolean): Matrix;
  29701. /**
  29702. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29703. * @returns a Matrix
  29704. */
  29705. getTransformationMatrix(): Matrix;
  29706. private _updateFrustumPlanes;
  29707. /**
  29708. * Checks if a cullable object (mesh...) is in the camera frustum
  29709. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29710. * @param target The object to check
  29711. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29712. * @returns true if the object is in frustum otherwise false
  29713. */
  29714. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29715. /**
  29716. * Checks if a cullable object (mesh...) is in the camera frustum
  29717. * Unlike isInFrustum this cheks the full bounding box
  29718. * @param target The object to check
  29719. * @returns true if the object is in frustum otherwise false
  29720. */
  29721. isCompletelyInFrustum(target: ICullable): boolean;
  29722. /**
  29723. * Gets a ray in the forward direction from the camera.
  29724. * @param length Defines the length of the ray to create
  29725. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29726. * @param origin Defines the start point of the ray which defaults to the camera position
  29727. * @returns the forward ray
  29728. */
  29729. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29730. /**
  29731. * Releases resources associated with this node.
  29732. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29733. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29734. */
  29735. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29736. /** @hidden */
  29737. _isLeftCamera: boolean;
  29738. /**
  29739. * Gets the left camera of a rig setup in case of Rigged Camera
  29740. */
  29741. get isLeftCamera(): boolean;
  29742. /** @hidden */
  29743. _isRightCamera: boolean;
  29744. /**
  29745. * Gets the right camera of a rig setup in case of Rigged Camera
  29746. */
  29747. get isRightCamera(): boolean;
  29748. /**
  29749. * Gets the left camera of a rig setup in case of Rigged Camera
  29750. */
  29751. get leftCamera(): Nullable<FreeCamera>;
  29752. /**
  29753. * Gets the right camera of a rig setup in case of Rigged Camera
  29754. */
  29755. get rightCamera(): Nullable<FreeCamera>;
  29756. /**
  29757. * Gets the left camera target of a rig setup in case of Rigged Camera
  29758. * @returns the target position
  29759. */
  29760. getLeftTarget(): Nullable<Vector3>;
  29761. /**
  29762. * Gets the right camera target of a rig setup in case of Rigged Camera
  29763. * @returns the target position
  29764. */
  29765. getRightTarget(): Nullable<Vector3>;
  29766. /**
  29767. * @hidden
  29768. */
  29769. setCameraRigMode(mode: number, rigParams: any): void;
  29770. /** @hidden */
  29771. static _setStereoscopicRigMode(camera: Camera): void;
  29772. /** @hidden */
  29773. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29774. /** @hidden */
  29775. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29776. /** @hidden */
  29777. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29778. /** @hidden */
  29779. _getVRProjectionMatrix(): Matrix;
  29780. protected _updateCameraRotationMatrix(): void;
  29781. protected _updateWebVRCameraRotationMatrix(): void;
  29782. /**
  29783. * This function MUST be overwritten by the different WebVR cameras available.
  29784. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29785. * @hidden
  29786. */
  29787. _getWebVRProjectionMatrix(): Matrix;
  29788. /**
  29789. * This function MUST be overwritten by the different WebVR cameras available.
  29790. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29791. * @hidden
  29792. */
  29793. _getWebVRViewMatrix(): Matrix;
  29794. /** @hidden */
  29795. setCameraRigParameter(name: string, value: any): void;
  29796. /**
  29797. * needs to be overridden by children so sub has required properties to be copied
  29798. * @hidden
  29799. */
  29800. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29801. /**
  29802. * May need to be overridden by children
  29803. * @hidden
  29804. */
  29805. _updateRigCameras(): void;
  29806. /** @hidden */
  29807. _setupInputs(): void;
  29808. /**
  29809. * Serialiaze the camera setup to a json represention
  29810. * @returns the JSON representation
  29811. */
  29812. serialize(): any;
  29813. /**
  29814. * Clones the current camera.
  29815. * @param name The cloned camera name
  29816. * @returns the cloned camera
  29817. */
  29818. clone(name: string): Camera;
  29819. /**
  29820. * Gets the direction of the camera relative to a given local axis.
  29821. * @param localAxis Defines the reference axis to provide a relative direction.
  29822. * @return the direction
  29823. */
  29824. getDirection(localAxis: Vector3): Vector3;
  29825. /**
  29826. * Returns the current camera absolute rotation
  29827. */
  29828. get absoluteRotation(): Quaternion;
  29829. /**
  29830. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29831. * @param localAxis Defines the reference axis to provide a relative direction.
  29832. * @param result Defines the vector to store the result in
  29833. */
  29834. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29835. /**
  29836. * Gets a camera constructor for a given camera type
  29837. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29838. * @param name The name of the camera the result will be able to instantiate
  29839. * @param scene The scene the result will construct the camera in
  29840. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29841. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29842. * @returns a factory method to construc the camera
  29843. */
  29844. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29845. /**
  29846. * Compute the world matrix of the camera.
  29847. * @returns the camera world matrix
  29848. */
  29849. computeWorldMatrix(): Matrix;
  29850. /**
  29851. * Parse a JSON and creates the camera from the parsed information
  29852. * @param parsedCamera The JSON to parse
  29853. * @param scene The scene to instantiate the camera in
  29854. * @returns the newly constructed camera
  29855. */
  29856. static Parse(parsedCamera: any, scene: Scene): Camera;
  29857. }
  29858. }
  29859. declare module "babylonjs/Meshes/Builders/discBuilder" {
  29860. import { Nullable } from "babylonjs/types";
  29861. import { Scene } from "babylonjs/scene";
  29862. import { Vector4 } from "babylonjs/Maths/math.vector";
  29863. import { Mesh } from "babylonjs/Meshes/mesh";
  29864. /**
  29865. * Class containing static functions to help procedurally build meshes
  29866. */
  29867. export class DiscBuilder {
  29868. /**
  29869. * Creates a plane polygonal mesh. By default, this is a disc
  29870. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29871. * * 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
  29872. * * 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
  29873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29874. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29876. * @param name defines the name of the mesh
  29877. * @param options defines the options used to create the mesh
  29878. * @param scene defines the hosting scene
  29879. * @returns the plane polygonal mesh
  29880. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29881. */
  29882. static CreateDisc(name: string, options: {
  29883. radius?: number;
  29884. tessellation?: number;
  29885. arc?: number;
  29886. updatable?: boolean;
  29887. sideOrientation?: number;
  29888. frontUVs?: Vector4;
  29889. backUVs?: Vector4;
  29890. }, scene?: Nullable<Scene>): Mesh;
  29891. }
  29892. }
  29893. declare module "babylonjs/Materials/fresnelParameters" {
  29894. import { DeepImmutable } from "babylonjs/types";
  29895. import { Color3 } from "babylonjs/Maths/math.color";
  29896. /**
  29897. * Options to be used when creating a FresnelParameters.
  29898. */
  29899. export type IFresnelParametersCreationOptions = {
  29900. /**
  29901. * Define the color used on edges (grazing angle)
  29902. */
  29903. leftColor?: Color3;
  29904. /**
  29905. * Define the color used on center
  29906. */
  29907. rightColor?: Color3;
  29908. /**
  29909. * Define bias applied to computed fresnel term
  29910. */
  29911. bias?: number;
  29912. /**
  29913. * Defined the power exponent applied to fresnel term
  29914. */
  29915. power?: number;
  29916. /**
  29917. * Define if the fresnel effect is enable or not.
  29918. */
  29919. isEnabled?: boolean;
  29920. };
  29921. /**
  29922. * Serialized format for FresnelParameters.
  29923. */
  29924. export type IFresnelParametersSerialized = {
  29925. /**
  29926. * Define the color used on edges (grazing angle) [as an array]
  29927. */
  29928. leftColor: number[];
  29929. /**
  29930. * Define the color used on center [as an array]
  29931. */
  29932. rightColor: number[];
  29933. /**
  29934. * Define bias applied to computed fresnel term
  29935. */
  29936. bias: number;
  29937. /**
  29938. * Defined the power exponent applied to fresnel term
  29939. */
  29940. power?: number;
  29941. /**
  29942. * Define if the fresnel effect is enable or not.
  29943. */
  29944. isEnabled: boolean;
  29945. };
  29946. /**
  29947. * This represents all the required information to add a fresnel effect on a material:
  29948. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29949. */
  29950. export class FresnelParameters {
  29951. private _isEnabled;
  29952. /**
  29953. * Define if the fresnel effect is enable or not.
  29954. */
  29955. get isEnabled(): boolean;
  29956. set isEnabled(value: boolean);
  29957. /**
  29958. * Define the color used on edges (grazing angle)
  29959. */
  29960. leftColor: Color3;
  29961. /**
  29962. * Define the color used on center
  29963. */
  29964. rightColor: Color3;
  29965. /**
  29966. * Define bias applied to computed fresnel term
  29967. */
  29968. bias: number;
  29969. /**
  29970. * Defined the power exponent applied to fresnel term
  29971. */
  29972. power: number;
  29973. /**
  29974. * Creates a new FresnelParameters object.
  29975. *
  29976. * @param options provide your own settings to optionally to override defaults
  29977. */
  29978. constructor(options?: IFresnelParametersCreationOptions);
  29979. /**
  29980. * Clones the current fresnel and its valuues
  29981. * @returns a clone fresnel configuration
  29982. */
  29983. clone(): FresnelParameters;
  29984. /**
  29985. * Determines equality between FresnelParameters objects
  29986. * @param otherFresnelParameters defines the second operand
  29987. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29988. */
  29989. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29990. /**
  29991. * Serializes the current fresnel parameters to a JSON representation.
  29992. * @return the JSON serialization
  29993. */
  29994. serialize(): IFresnelParametersSerialized;
  29995. /**
  29996. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29997. * @param parsedFresnelParameters Define the JSON representation
  29998. * @returns the parsed parameters
  29999. */
  30000. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  30001. }
  30002. }
  30003. declare module "babylonjs/Materials/materialFlags" {
  30004. /**
  30005. * This groups all the flags used to control the materials channel.
  30006. */
  30007. export class MaterialFlags {
  30008. private static _DiffuseTextureEnabled;
  30009. /**
  30010. * Are diffuse textures enabled in the application.
  30011. */
  30012. static get DiffuseTextureEnabled(): boolean;
  30013. static set DiffuseTextureEnabled(value: boolean);
  30014. private static _AmbientTextureEnabled;
  30015. /**
  30016. * Are ambient textures enabled in the application.
  30017. */
  30018. static get AmbientTextureEnabled(): boolean;
  30019. static set AmbientTextureEnabled(value: boolean);
  30020. private static _OpacityTextureEnabled;
  30021. /**
  30022. * Are opacity textures enabled in the application.
  30023. */
  30024. static get OpacityTextureEnabled(): boolean;
  30025. static set OpacityTextureEnabled(value: boolean);
  30026. private static _ReflectionTextureEnabled;
  30027. /**
  30028. * Are reflection textures enabled in the application.
  30029. */
  30030. static get ReflectionTextureEnabled(): boolean;
  30031. static set ReflectionTextureEnabled(value: boolean);
  30032. private static _EmissiveTextureEnabled;
  30033. /**
  30034. * Are emissive textures enabled in the application.
  30035. */
  30036. static get EmissiveTextureEnabled(): boolean;
  30037. static set EmissiveTextureEnabled(value: boolean);
  30038. private static _SpecularTextureEnabled;
  30039. /**
  30040. * Are specular textures enabled in the application.
  30041. */
  30042. static get SpecularTextureEnabled(): boolean;
  30043. static set SpecularTextureEnabled(value: boolean);
  30044. private static _BumpTextureEnabled;
  30045. /**
  30046. * Are bump textures enabled in the application.
  30047. */
  30048. static get BumpTextureEnabled(): boolean;
  30049. static set BumpTextureEnabled(value: boolean);
  30050. private static _LightmapTextureEnabled;
  30051. /**
  30052. * Are lightmap textures enabled in the application.
  30053. */
  30054. static get LightmapTextureEnabled(): boolean;
  30055. static set LightmapTextureEnabled(value: boolean);
  30056. private static _RefractionTextureEnabled;
  30057. /**
  30058. * Are refraction textures enabled in the application.
  30059. */
  30060. static get RefractionTextureEnabled(): boolean;
  30061. static set RefractionTextureEnabled(value: boolean);
  30062. private static _ColorGradingTextureEnabled;
  30063. /**
  30064. * Are color grading textures enabled in the application.
  30065. */
  30066. static get ColorGradingTextureEnabled(): boolean;
  30067. static set ColorGradingTextureEnabled(value: boolean);
  30068. private static _FresnelEnabled;
  30069. /**
  30070. * Are fresnels enabled in the application.
  30071. */
  30072. static get FresnelEnabled(): boolean;
  30073. static set FresnelEnabled(value: boolean);
  30074. private static _ClearCoatTextureEnabled;
  30075. /**
  30076. * Are clear coat textures enabled in the application.
  30077. */
  30078. static get ClearCoatTextureEnabled(): boolean;
  30079. static set ClearCoatTextureEnabled(value: boolean);
  30080. private static _ClearCoatBumpTextureEnabled;
  30081. /**
  30082. * Are clear coat bump textures enabled in the application.
  30083. */
  30084. static get ClearCoatBumpTextureEnabled(): boolean;
  30085. static set ClearCoatBumpTextureEnabled(value: boolean);
  30086. private static _ClearCoatTintTextureEnabled;
  30087. /**
  30088. * Are clear coat tint textures enabled in the application.
  30089. */
  30090. static get ClearCoatTintTextureEnabled(): boolean;
  30091. static set ClearCoatTintTextureEnabled(value: boolean);
  30092. private static _SheenTextureEnabled;
  30093. /**
  30094. * Are sheen textures enabled in the application.
  30095. */
  30096. static get SheenTextureEnabled(): boolean;
  30097. static set SheenTextureEnabled(value: boolean);
  30098. private static _AnisotropicTextureEnabled;
  30099. /**
  30100. * Are anisotropic textures enabled in the application.
  30101. */
  30102. static get AnisotropicTextureEnabled(): boolean;
  30103. static set AnisotropicTextureEnabled(value: boolean);
  30104. private static _ThicknessTextureEnabled;
  30105. /**
  30106. * Are thickness textures enabled in the application.
  30107. */
  30108. static get ThicknessTextureEnabled(): boolean;
  30109. static set ThicknessTextureEnabled(value: boolean);
  30110. }
  30111. }
  30112. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  30113. /** @hidden */
  30114. export var defaultFragmentDeclaration: {
  30115. name: string;
  30116. shader: string;
  30117. };
  30118. }
  30119. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  30120. /** @hidden */
  30121. export var defaultUboDeclaration: {
  30122. name: string;
  30123. shader: string;
  30124. };
  30125. }
  30126. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  30127. /** @hidden */
  30128. export var lightFragmentDeclaration: {
  30129. name: string;
  30130. shader: string;
  30131. };
  30132. }
  30133. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  30134. /** @hidden */
  30135. export var lightUboDeclaration: {
  30136. name: string;
  30137. shader: string;
  30138. };
  30139. }
  30140. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  30141. /** @hidden */
  30142. export var lightsFragmentFunctions: {
  30143. name: string;
  30144. shader: string;
  30145. };
  30146. }
  30147. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  30148. /** @hidden */
  30149. export var shadowsFragmentFunctions: {
  30150. name: string;
  30151. shader: string;
  30152. };
  30153. }
  30154. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  30155. /** @hidden */
  30156. export var fresnelFunction: {
  30157. name: string;
  30158. shader: string;
  30159. };
  30160. }
  30161. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  30162. /** @hidden */
  30163. export var bumpFragmentMainFunctions: {
  30164. name: string;
  30165. shader: string;
  30166. };
  30167. }
  30168. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  30169. /** @hidden */
  30170. export var bumpFragmentFunctions: {
  30171. name: string;
  30172. shader: string;
  30173. };
  30174. }
  30175. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  30176. /** @hidden */
  30177. export var logDepthDeclaration: {
  30178. name: string;
  30179. shader: string;
  30180. };
  30181. }
  30182. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  30183. /** @hidden */
  30184. export var bumpFragment: {
  30185. name: string;
  30186. shader: string;
  30187. };
  30188. }
  30189. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  30190. /** @hidden */
  30191. export var depthPrePass: {
  30192. name: string;
  30193. shader: string;
  30194. };
  30195. }
  30196. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  30197. /** @hidden */
  30198. export var lightFragment: {
  30199. name: string;
  30200. shader: string;
  30201. };
  30202. }
  30203. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  30204. /** @hidden */
  30205. export var logDepthFragment: {
  30206. name: string;
  30207. shader: string;
  30208. };
  30209. }
  30210. declare module "babylonjs/Shaders/default.fragment" {
  30211. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  30212. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30213. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30214. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30215. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30216. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  30217. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  30218. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  30219. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  30220. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  30221. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  30222. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  30223. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  30224. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  30225. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30226. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  30227. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  30228. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  30229. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  30230. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  30231. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  30232. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  30233. /** @hidden */
  30234. export var defaultPixelShader: {
  30235. name: string;
  30236. shader: string;
  30237. };
  30238. }
  30239. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  30240. /** @hidden */
  30241. export var defaultVertexDeclaration: {
  30242. name: string;
  30243. shader: string;
  30244. };
  30245. }
  30246. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  30247. /** @hidden */
  30248. export var bumpVertexDeclaration: {
  30249. name: string;
  30250. shader: string;
  30251. };
  30252. }
  30253. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  30254. /** @hidden */
  30255. export var bumpVertex: {
  30256. name: string;
  30257. shader: string;
  30258. };
  30259. }
  30260. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  30261. /** @hidden */
  30262. export var fogVertex: {
  30263. name: string;
  30264. shader: string;
  30265. };
  30266. }
  30267. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  30268. /** @hidden */
  30269. export var shadowsVertex: {
  30270. name: string;
  30271. shader: string;
  30272. };
  30273. }
  30274. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  30275. /** @hidden */
  30276. export var pointCloudVertex: {
  30277. name: string;
  30278. shader: string;
  30279. };
  30280. }
  30281. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  30282. /** @hidden */
  30283. export var logDepthVertex: {
  30284. name: string;
  30285. shader: string;
  30286. };
  30287. }
  30288. declare module "babylonjs/Shaders/default.vertex" {
  30289. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  30290. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30291. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30292. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  30293. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  30294. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  30295. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  30296. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  30297. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30298. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30299. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  30300. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  30301. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30302. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  30303. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  30304. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  30305. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  30306. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  30307. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  30308. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  30309. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  30310. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  30311. /** @hidden */
  30312. export var defaultVertexShader: {
  30313. name: string;
  30314. shader: string;
  30315. };
  30316. }
  30317. declare module "babylonjs/Materials/standardMaterial" {
  30318. import { SmartArray } from "babylonjs/Misc/smartArray";
  30319. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30320. import { Nullable } from "babylonjs/types";
  30321. import { Scene } from "babylonjs/scene";
  30322. import { Matrix } from "babylonjs/Maths/math.vector";
  30323. import { Color3 } from "babylonjs/Maths/math.color";
  30324. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30326. import { Mesh } from "babylonjs/Meshes/mesh";
  30327. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  30328. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30329. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  30330. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30331. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  30332. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30333. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30334. import "babylonjs/Shaders/default.fragment";
  30335. import "babylonjs/Shaders/default.vertex";
  30336. /** @hidden */
  30337. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30338. MAINUV1: boolean;
  30339. MAINUV2: boolean;
  30340. DIFFUSE: boolean;
  30341. DIFFUSEDIRECTUV: number;
  30342. AMBIENT: boolean;
  30343. AMBIENTDIRECTUV: number;
  30344. OPACITY: boolean;
  30345. OPACITYDIRECTUV: number;
  30346. OPACITYRGB: boolean;
  30347. REFLECTION: boolean;
  30348. EMISSIVE: boolean;
  30349. EMISSIVEDIRECTUV: number;
  30350. SPECULAR: boolean;
  30351. SPECULARDIRECTUV: number;
  30352. BUMP: boolean;
  30353. BUMPDIRECTUV: number;
  30354. PARALLAX: boolean;
  30355. PARALLAXOCCLUSION: boolean;
  30356. SPECULAROVERALPHA: boolean;
  30357. CLIPPLANE: boolean;
  30358. CLIPPLANE2: boolean;
  30359. CLIPPLANE3: boolean;
  30360. CLIPPLANE4: boolean;
  30361. CLIPPLANE5: boolean;
  30362. CLIPPLANE6: boolean;
  30363. ALPHATEST: boolean;
  30364. DEPTHPREPASS: boolean;
  30365. ALPHAFROMDIFFUSE: boolean;
  30366. POINTSIZE: boolean;
  30367. FOG: boolean;
  30368. SPECULARTERM: boolean;
  30369. DIFFUSEFRESNEL: boolean;
  30370. OPACITYFRESNEL: boolean;
  30371. REFLECTIONFRESNEL: boolean;
  30372. REFRACTIONFRESNEL: boolean;
  30373. EMISSIVEFRESNEL: boolean;
  30374. FRESNEL: boolean;
  30375. NORMAL: boolean;
  30376. UV1: boolean;
  30377. UV2: boolean;
  30378. VERTEXCOLOR: boolean;
  30379. VERTEXALPHA: boolean;
  30380. NUM_BONE_INFLUENCERS: number;
  30381. BonesPerMesh: number;
  30382. BONETEXTURE: boolean;
  30383. INSTANCES: boolean;
  30384. THIN_INSTANCES: boolean;
  30385. GLOSSINESS: boolean;
  30386. ROUGHNESS: boolean;
  30387. EMISSIVEASILLUMINATION: boolean;
  30388. LINKEMISSIVEWITHDIFFUSE: boolean;
  30389. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30390. LIGHTMAP: boolean;
  30391. LIGHTMAPDIRECTUV: number;
  30392. OBJECTSPACE_NORMALMAP: boolean;
  30393. USELIGHTMAPASSHADOWMAP: boolean;
  30394. REFLECTIONMAP_3D: boolean;
  30395. REFLECTIONMAP_SPHERICAL: boolean;
  30396. REFLECTIONMAP_PLANAR: boolean;
  30397. REFLECTIONMAP_CUBIC: boolean;
  30398. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30399. REFLECTIONMAP_PROJECTION: boolean;
  30400. REFLECTIONMAP_SKYBOX: boolean;
  30401. REFLECTIONMAP_EXPLICIT: boolean;
  30402. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30403. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30404. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30405. INVERTCUBICMAP: boolean;
  30406. LOGARITHMICDEPTH: boolean;
  30407. REFRACTION: boolean;
  30408. REFRACTIONMAP_3D: boolean;
  30409. REFLECTIONOVERALPHA: boolean;
  30410. TWOSIDEDLIGHTING: boolean;
  30411. SHADOWFLOAT: boolean;
  30412. MORPHTARGETS: boolean;
  30413. MORPHTARGETS_NORMAL: boolean;
  30414. MORPHTARGETS_TANGENT: boolean;
  30415. MORPHTARGETS_UV: boolean;
  30416. NUM_MORPH_INFLUENCERS: number;
  30417. NONUNIFORMSCALING: boolean;
  30418. PREMULTIPLYALPHA: boolean;
  30419. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30420. ALPHABLEND: boolean;
  30421. RGBDLIGHTMAP: boolean;
  30422. RGBDREFLECTION: boolean;
  30423. RGBDREFRACTION: boolean;
  30424. IMAGEPROCESSING: boolean;
  30425. VIGNETTE: boolean;
  30426. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30427. VIGNETTEBLENDMODEOPAQUE: boolean;
  30428. TONEMAPPING: boolean;
  30429. TONEMAPPING_ACES: boolean;
  30430. CONTRAST: boolean;
  30431. COLORCURVES: boolean;
  30432. COLORGRADING: boolean;
  30433. COLORGRADING3D: boolean;
  30434. SAMPLER3DGREENDEPTH: boolean;
  30435. SAMPLER3DBGRMAP: boolean;
  30436. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30437. MULTIVIEW: boolean;
  30438. /**
  30439. * If the reflection texture on this material is in linear color space
  30440. * @hidden
  30441. */
  30442. IS_REFLECTION_LINEAR: boolean;
  30443. /**
  30444. * If the refraction texture on this material is in linear color space
  30445. * @hidden
  30446. */
  30447. IS_REFRACTION_LINEAR: boolean;
  30448. EXPOSURE: boolean;
  30449. constructor();
  30450. setReflectionMode(modeToEnable: string): void;
  30451. }
  30452. /**
  30453. * This is the default material used in Babylon. It is the best trade off between quality
  30454. * and performances.
  30455. * @see http://doc.babylonjs.com/babylon101/materials
  30456. */
  30457. export class StandardMaterial extends PushMaterial {
  30458. private _diffuseTexture;
  30459. /**
  30460. * The basic texture of the material as viewed under a light.
  30461. */
  30462. diffuseTexture: Nullable<BaseTexture>;
  30463. private _ambientTexture;
  30464. /**
  30465. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30466. */
  30467. ambientTexture: Nullable<BaseTexture>;
  30468. private _opacityTexture;
  30469. /**
  30470. * Define the transparency of the material from a texture.
  30471. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30472. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30473. */
  30474. opacityTexture: Nullable<BaseTexture>;
  30475. private _reflectionTexture;
  30476. /**
  30477. * Define the texture used to display the reflection.
  30478. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30479. */
  30480. reflectionTexture: Nullable<BaseTexture>;
  30481. private _emissiveTexture;
  30482. /**
  30483. * Define texture of the material as if self lit.
  30484. * This will be mixed in the final result even in the absence of light.
  30485. */
  30486. emissiveTexture: Nullable<BaseTexture>;
  30487. private _specularTexture;
  30488. /**
  30489. * Define how the color and intensity of the highlight given by the light in the material.
  30490. */
  30491. specularTexture: Nullable<BaseTexture>;
  30492. private _bumpTexture;
  30493. /**
  30494. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30495. * 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.
  30496. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  30497. */
  30498. bumpTexture: Nullable<BaseTexture>;
  30499. private _lightmapTexture;
  30500. /**
  30501. * Complex lighting can be computationally expensive to compute at runtime.
  30502. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30503. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  30504. */
  30505. lightmapTexture: Nullable<BaseTexture>;
  30506. private _refractionTexture;
  30507. /**
  30508. * Define the texture used to display the refraction.
  30509. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30510. */
  30511. refractionTexture: Nullable<BaseTexture>;
  30512. /**
  30513. * The color of the material lit by the environmental background lighting.
  30514. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30515. */
  30516. ambientColor: Color3;
  30517. /**
  30518. * The basic color of the material as viewed under a light.
  30519. */
  30520. diffuseColor: Color3;
  30521. /**
  30522. * Define how the color and intensity of the highlight given by the light in the material.
  30523. */
  30524. specularColor: Color3;
  30525. /**
  30526. * Define the color of the material as if self lit.
  30527. * This will be mixed in the final result even in the absence of light.
  30528. */
  30529. emissiveColor: Color3;
  30530. /**
  30531. * Defines how sharp are the highlights in the material.
  30532. * The bigger the value the sharper giving a more glossy feeling to the result.
  30533. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30534. */
  30535. specularPower: number;
  30536. private _useAlphaFromDiffuseTexture;
  30537. /**
  30538. * Does the transparency come from the diffuse texture alpha channel.
  30539. */
  30540. useAlphaFromDiffuseTexture: boolean;
  30541. private _useEmissiveAsIllumination;
  30542. /**
  30543. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30544. */
  30545. useEmissiveAsIllumination: boolean;
  30546. private _linkEmissiveWithDiffuse;
  30547. /**
  30548. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30549. * the emissive level when the final color is close to one.
  30550. */
  30551. linkEmissiveWithDiffuse: boolean;
  30552. private _useSpecularOverAlpha;
  30553. /**
  30554. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30555. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30556. */
  30557. useSpecularOverAlpha: boolean;
  30558. private _useReflectionOverAlpha;
  30559. /**
  30560. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30561. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30562. */
  30563. useReflectionOverAlpha: boolean;
  30564. private _disableLighting;
  30565. /**
  30566. * Does lights from the scene impacts this material.
  30567. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30568. */
  30569. disableLighting: boolean;
  30570. private _useObjectSpaceNormalMap;
  30571. /**
  30572. * Allows using an object space normal map (instead of tangent space).
  30573. */
  30574. useObjectSpaceNormalMap: boolean;
  30575. private _useParallax;
  30576. /**
  30577. * Is parallax enabled or not.
  30578. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  30579. */
  30580. useParallax: boolean;
  30581. private _useParallaxOcclusion;
  30582. /**
  30583. * Is parallax occlusion enabled or not.
  30584. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30585. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  30586. */
  30587. useParallaxOcclusion: boolean;
  30588. /**
  30589. * 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.
  30590. */
  30591. parallaxScaleBias: number;
  30592. private _roughness;
  30593. /**
  30594. * Helps to define how blurry the reflections should appears in the material.
  30595. */
  30596. roughness: number;
  30597. /**
  30598. * In case of refraction, define the value of the index of refraction.
  30599. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30600. */
  30601. indexOfRefraction: number;
  30602. /**
  30603. * Invert the refraction texture alongside the y axis.
  30604. * It can be useful with procedural textures or probe for instance.
  30605. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30606. */
  30607. invertRefractionY: boolean;
  30608. /**
  30609. * Defines the alpha limits in alpha test mode.
  30610. */
  30611. alphaCutOff: number;
  30612. private _useLightmapAsShadowmap;
  30613. /**
  30614. * In case of light mapping, define whether the map contains light or shadow informations.
  30615. */
  30616. useLightmapAsShadowmap: boolean;
  30617. private _diffuseFresnelParameters;
  30618. /**
  30619. * Define the diffuse fresnel parameters of the material.
  30620. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30621. */
  30622. diffuseFresnelParameters: FresnelParameters;
  30623. private _opacityFresnelParameters;
  30624. /**
  30625. * Define the opacity fresnel parameters of the material.
  30626. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30627. */
  30628. opacityFresnelParameters: FresnelParameters;
  30629. private _reflectionFresnelParameters;
  30630. /**
  30631. * Define the reflection fresnel parameters of the material.
  30632. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30633. */
  30634. reflectionFresnelParameters: FresnelParameters;
  30635. private _refractionFresnelParameters;
  30636. /**
  30637. * Define the refraction fresnel parameters of the material.
  30638. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30639. */
  30640. refractionFresnelParameters: FresnelParameters;
  30641. private _emissiveFresnelParameters;
  30642. /**
  30643. * Define the emissive fresnel parameters of the material.
  30644. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30645. */
  30646. emissiveFresnelParameters: FresnelParameters;
  30647. private _useReflectionFresnelFromSpecular;
  30648. /**
  30649. * If true automatically deducts the fresnels values from the material specularity.
  30650. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30651. */
  30652. useReflectionFresnelFromSpecular: boolean;
  30653. private _useGlossinessFromSpecularMapAlpha;
  30654. /**
  30655. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30656. */
  30657. useGlossinessFromSpecularMapAlpha: boolean;
  30658. private _maxSimultaneousLights;
  30659. /**
  30660. * Defines the maximum number of lights that can be used in the material
  30661. */
  30662. maxSimultaneousLights: number;
  30663. private _invertNormalMapX;
  30664. /**
  30665. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30666. */
  30667. invertNormalMapX: boolean;
  30668. private _invertNormalMapY;
  30669. /**
  30670. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30671. */
  30672. invertNormalMapY: boolean;
  30673. private _twoSidedLighting;
  30674. /**
  30675. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30676. */
  30677. twoSidedLighting: boolean;
  30678. /**
  30679. * Default configuration related to image processing available in the standard Material.
  30680. */
  30681. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30682. /**
  30683. * Gets the image processing configuration used either in this material.
  30684. */
  30685. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30686. /**
  30687. * Sets the Default image processing configuration used either in the this material.
  30688. *
  30689. * If sets to null, the scene one is in use.
  30690. */
  30691. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30692. /**
  30693. * Keep track of the image processing observer to allow dispose and replace.
  30694. */
  30695. private _imageProcessingObserver;
  30696. /**
  30697. * Attaches a new image processing configuration to the Standard Material.
  30698. * @param configuration
  30699. */
  30700. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30701. /**
  30702. * Gets wether the color curves effect is enabled.
  30703. */
  30704. get cameraColorCurvesEnabled(): boolean;
  30705. /**
  30706. * Sets wether the color curves effect is enabled.
  30707. */
  30708. set cameraColorCurvesEnabled(value: boolean);
  30709. /**
  30710. * Gets wether the color grading effect is enabled.
  30711. */
  30712. get cameraColorGradingEnabled(): boolean;
  30713. /**
  30714. * Gets wether the color grading effect is enabled.
  30715. */
  30716. set cameraColorGradingEnabled(value: boolean);
  30717. /**
  30718. * Gets wether tonemapping is enabled or not.
  30719. */
  30720. get cameraToneMappingEnabled(): boolean;
  30721. /**
  30722. * Sets wether tonemapping is enabled or not
  30723. */
  30724. set cameraToneMappingEnabled(value: boolean);
  30725. /**
  30726. * The camera exposure used on this material.
  30727. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30728. * This corresponds to a photographic exposure.
  30729. */
  30730. get cameraExposure(): number;
  30731. /**
  30732. * The camera exposure used on this material.
  30733. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30734. * This corresponds to a photographic exposure.
  30735. */
  30736. set cameraExposure(value: number);
  30737. /**
  30738. * Gets The camera contrast used on this material.
  30739. */
  30740. get cameraContrast(): number;
  30741. /**
  30742. * Sets The camera contrast used on this material.
  30743. */
  30744. set cameraContrast(value: number);
  30745. /**
  30746. * Gets the Color Grading 2D Lookup Texture.
  30747. */
  30748. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30749. /**
  30750. * Sets the Color Grading 2D Lookup Texture.
  30751. */
  30752. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30753. /**
  30754. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30755. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30756. * 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;
  30757. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30758. */
  30759. get cameraColorCurves(): Nullable<ColorCurves>;
  30760. /**
  30761. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30762. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30763. * 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;
  30764. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30765. */
  30766. set cameraColorCurves(value: Nullable<ColorCurves>);
  30767. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30768. protected _worldViewProjectionMatrix: Matrix;
  30769. protected _globalAmbientColor: Color3;
  30770. protected _useLogarithmicDepth: boolean;
  30771. protected _rebuildInParallel: boolean;
  30772. /**
  30773. * Instantiates a new standard material.
  30774. * This is the default material used in Babylon. It is the best trade off between quality
  30775. * and performances.
  30776. * @see http://doc.babylonjs.com/babylon101/materials
  30777. * @param name Define the name of the material in the scene
  30778. * @param scene Define the scene the material belong to
  30779. */
  30780. constructor(name: string, scene: Scene);
  30781. /**
  30782. * Gets a boolean indicating that current material needs to register RTT
  30783. */
  30784. get hasRenderTargetTextures(): boolean;
  30785. /**
  30786. * Gets the current class name of the material e.g. "StandardMaterial"
  30787. * Mainly use in serialization.
  30788. * @returns the class name
  30789. */
  30790. getClassName(): string;
  30791. /**
  30792. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30793. * You can try switching to logarithmic depth.
  30794. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30795. */
  30796. get useLogarithmicDepth(): boolean;
  30797. set useLogarithmicDepth(value: boolean);
  30798. /**
  30799. * Specifies if the material will require alpha blending
  30800. * @returns a boolean specifying if alpha blending is needed
  30801. */
  30802. needAlphaBlending(): boolean;
  30803. /**
  30804. * Specifies if this material should be rendered in alpha test mode
  30805. * @returns a boolean specifying if an alpha test is needed.
  30806. */
  30807. needAlphaTesting(): boolean;
  30808. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30809. /**
  30810. * Get the texture used for alpha test purpose.
  30811. * @returns the diffuse texture in case of the standard material.
  30812. */
  30813. getAlphaTestTexture(): Nullable<BaseTexture>;
  30814. /**
  30815. * Get if the submesh is ready to be used and all its information available.
  30816. * Child classes can use it to update shaders
  30817. * @param mesh defines the mesh to check
  30818. * @param subMesh defines which submesh to check
  30819. * @param useInstances specifies that instances should be used
  30820. * @returns a boolean indicating that the submesh is ready or not
  30821. */
  30822. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30823. /**
  30824. * Builds the material UBO layouts.
  30825. * Used internally during the effect preparation.
  30826. */
  30827. buildUniformLayout(): void;
  30828. /**
  30829. * Unbinds the material from the mesh
  30830. */
  30831. unbind(): void;
  30832. /**
  30833. * Binds the submesh to this material by preparing the effect and shader to draw
  30834. * @param world defines the world transformation matrix
  30835. * @param mesh defines the mesh containing the submesh
  30836. * @param subMesh defines the submesh to bind the material to
  30837. */
  30838. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30839. /**
  30840. * Get the list of animatables in the material.
  30841. * @returns the list of animatables object used in the material
  30842. */
  30843. getAnimatables(): IAnimatable[];
  30844. /**
  30845. * Gets the active textures from the material
  30846. * @returns an array of textures
  30847. */
  30848. getActiveTextures(): BaseTexture[];
  30849. /**
  30850. * Specifies if the material uses a texture
  30851. * @param texture defines the texture to check against the material
  30852. * @returns a boolean specifying if the material uses the texture
  30853. */
  30854. hasTexture(texture: BaseTexture): boolean;
  30855. /**
  30856. * Disposes the material
  30857. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30858. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30859. */
  30860. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30861. /**
  30862. * Makes a duplicate of the material, and gives it a new name
  30863. * @param name defines the new name for the duplicated material
  30864. * @returns the cloned material
  30865. */
  30866. clone(name: string): StandardMaterial;
  30867. /**
  30868. * Serializes this material in a JSON representation
  30869. * @returns the serialized material object
  30870. */
  30871. serialize(): any;
  30872. /**
  30873. * Creates a standard material from parsed material data
  30874. * @param source defines the JSON representation of the material
  30875. * @param scene defines the hosting scene
  30876. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30877. * @returns a new standard material
  30878. */
  30879. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30880. /**
  30881. * Are diffuse textures enabled in the application.
  30882. */
  30883. static get DiffuseTextureEnabled(): boolean;
  30884. static set DiffuseTextureEnabled(value: boolean);
  30885. /**
  30886. * Are ambient textures enabled in the application.
  30887. */
  30888. static get AmbientTextureEnabled(): boolean;
  30889. static set AmbientTextureEnabled(value: boolean);
  30890. /**
  30891. * Are opacity textures enabled in the application.
  30892. */
  30893. static get OpacityTextureEnabled(): boolean;
  30894. static set OpacityTextureEnabled(value: boolean);
  30895. /**
  30896. * Are reflection textures enabled in the application.
  30897. */
  30898. static get ReflectionTextureEnabled(): boolean;
  30899. static set ReflectionTextureEnabled(value: boolean);
  30900. /**
  30901. * Are emissive textures enabled in the application.
  30902. */
  30903. static get EmissiveTextureEnabled(): boolean;
  30904. static set EmissiveTextureEnabled(value: boolean);
  30905. /**
  30906. * Are specular textures enabled in the application.
  30907. */
  30908. static get SpecularTextureEnabled(): boolean;
  30909. static set SpecularTextureEnabled(value: boolean);
  30910. /**
  30911. * Are bump textures enabled in the application.
  30912. */
  30913. static get BumpTextureEnabled(): boolean;
  30914. static set BumpTextureEnabled(value: boolean);
  30915. /**
  30916. * Are lightmap textures enabled in the application.
  30917. */
  30918. static get LightmapTextureEnabled(): boolean;
  30919. static set LightmapTextureEnabled(value: boolean);
  30920. /**
  30921. * Are refraction textures enabled in the application.
  30922. */
  30923. static get RefractionTextureEnabled(): boolean;
  30924. static set RefractionTextureEnabled(value: boolean);
  30925. /**
  30926. * Are color grading textures enabled in the application.
  30927. */
  30928. static get ColorGradingTextureEnabled(): boolean;
  30929. static set ColorGradingTextureEnabled(value: boolean);
  30930. /**
  30931. * Are fresnels enabled in the application.
  30932. */
  30933. static get FresnelEnabled(): boolean;
  30934. static set FresnelEnabled(value: boolean);
  30935. }
  30936. }
  30937. declare module "babylonjs/Particles/solidParticleSystem" {
  30938. import { Nullable } from "babylonjs/types";
  30939. import { Mesh } from "babylonjs/Meshes/mesh";
  30940. import { Scene, IDisposable } from "babylonjs/scene";
  30941. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  30942. import { Material } from "babylonjs/Materials/material";
  30943. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  30944. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  30945. /**
  30946. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30947. *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.
  30948. * The SPS is also a particle system. It provides some methods to manage the particles.
  30949. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  30950. *
  30951. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  30952. */
  30953. export class SolidParticleSystem implements IDisposable {
  30954. /**
  30955. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  30956. * Example : var p = SPS.particles[i];
  30957. */
  30958. particles: SolidParticle[];
  30959. /**
  30960. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  30961. */
  30962. nbParticles: number;
  30963. /**
  30964. * If the particles must ever face the camera (default false). Useful for planar particles.
  30965. */
  30966. billboard: boolean;
  30967. /**
  30968. * Recompute normals when adding a shape
  30969. */
  30970. recomputeNormals: boolean;
  30971. /**
  30972. * This a counter ofr your own usage. It's not set by any SPS functions.
  30973. */
  30974. counter: number;
  30975. /**
  30976. * The SPS name. This name is also given to the underlying mesh.
  30977. */
  30978. name: string;
  30979. /**
  30980. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  30981. */
  30982. mesh: Mesh;
  30983. /**
  30984. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  30985. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  30986. */
  30987. vars: any;
  30988. /**
  30989. * This array is populated when the SPS is set as 'pickable'.
  30990. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30991. * Each element of this array is an object `{idx: int, faceId: int}`.
  30992. * `idx` is the picked particle index in the `SPS.particles` array
  30993. * `faceId` is the picked face index counted within this particle.
  30994. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30995. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30996. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30997. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30998. */
  30999. pickedParticles: {
  31000. idx: number;
  31001. faceId: number;
  31002. }[];
  31003. /**
  31004. * This array is populated when the SPS is set as 'pickable'
  31005. * Each key of this array is a submesh index.
  31006. * Each element of this array is a second array defined like this :
  31007. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31008. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31009. * `idx` is the picked particle index in the `SPS.particles` array
  31010. * `faceId` is the picked face index counted within this particle.
  31011. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31012. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31013. */
  31014. pickedBySubMesh: {
  31015. idx: number;
  31016. faceId: number;
  31017. }[][];
  31018. /**
  31019. * This array is populated when `enableDepthSort` is set to true.
  31020. * Each element of this array is an instance of the class DepthSortedParticle.
  31021. */
  31022. depthSortedParticles: DepthSortedParticle[];
  31023. /**
  31024. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31025. * @hidden
  31026. */
  31027. _bSphereOnly: boolean;
  31028. /**
  31029. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31030. * @hidden
  31031. */
  31032. _bSphereRadiusFactor: number;
  31033. private _scene;
  31034. private _positions;
  31035. private _indices;
  31036. private _normals;
  31037. private _colors;
  31038. private _uvs;
  31039. private _indices32;
  31040. private _positions32;
  31041. private _normals32;
  31042. private _fixedNormal32;
  31043. private _colors32;
  31044. private _uvs32;
  31045. private _index;
  31046. private _updatable;
  31047. private _pickable;
  31048. private _isVisibilityBoxLocked;
  31049. private _alwaysVisible;
  31050. private _depthSort;
  31051. private _expandable;
  31052. private _shapeCounter;
  31053. private _copy;
  31054. private _color;
  31055. private _computeParticleColor;
  31056. private _computeParticleTexture;
  31057. private _computeParticleRotation;
  31058. private _computeParticleVertex;
  31059. private _computeBoundingBox;
  31060. private _depthSortParticles;
  31061. private _camera;
  31062. private _mustUnrotateFixedNormals;
  31063. private _particlesIntersect;
  31064. private _needs32Bits;
  31065. private _isNotBuilt;
  31066. private _lastParticleId;
  31067. private _idxOfId;
  31068. private _multimaterialEnabled;
  31069. private _useModelMaterial;
  31070. private _indicesByMaterial;
  31071. private _materialIndexes;
  31072. private _depthSortFunction;
  31073. private _materialSortFunction;
  31074. private _materials;
  31075. private _multimaterial;
  31076. private _materialIndexesById;
  31077. private _defaultMaterial;
  31078. private _autoUpdateSubMeshes;
  31079. private _tmpVertex;
  31080. /**
  31081. * Creates a SPS (Solid Particle System) object.
  31082. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31083. * @param scene (Scene) is the scene in which the SPS is added.
  31084. * @param options defines the options of the sps e.g.
  31085. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31086. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31087. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31088. * * 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.
  31089. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31090. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31091. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31092. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31093. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31094. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31095. */
  31096. constructor(name: string, scene: Scene, options?: {
  31097. updatable?: boolean;
  31098. isPickable?: boolean;
  31099. enableDepthSort?: boolean;
  31100. particleIntersection?: boolean;
  31101. boundingSphereOnly?: boolean;
  31102. bSphereRadiusFactor?: number;
  31103. expandable?: boolean;
  31104. useModelMaterial?: boolean;
  31105. enableMultiMaterial?: boolean;
  31106. });
  31107. /**
  31108. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31109. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31110. * @returns the created mesh
  31111. */
  31112. buildMesh(): Mesh;
  31113. /**
  31114. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31115. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31116. * Thus the particles generated from `digest()` have their property `position` set yet.
  31117. * @param mesh ( Mesh ) is the mesh to be digested
  31118. * @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
  31119. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31120. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31121. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31122. * @returns the current SPS
  31123. */
  31124. digest(mesh: Mesh, options?: {
  31125. facetNb?: number;
  31126. number?: number;
  31127. delta?: number;
  31128. storage?: [];
  31129. }): SolidParticleSystem;
  31130. /**
  31131. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31132. * @hidden
  31133. */
  31134. private _unrotateFixedNormals;
  31135. /**
  31136. * Resets the temporary working copy particle
  31137. * @hidden
  31138. */
  31139. private _resetCopy;
  31140. /**
  31141. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31142. * @param p the current index in the positions array to be updated
  31143. * @param ind the current index in the indices array
  31144. * @param shape a Vector3 array, the shape geometry
  31145. * @param positions the positions array to be updated
  31146. * @param meshInd the shape indices array
  31147. * @param indices the indices array to be updated
  31148. * @param meshUV the shape uv array
  31149. * @param uvs the uv array to be updated
  31150. * @param meshCol the shape color array
  31151. * @param colors the color array to be updated
  31152. * @param meshNor the shape normals array
  31153. * @param normals the normals array to be updated
  31154. * @param idx the particle index
  31155. * @param idxInShape the particle index in its shape
  31156. * @param options the addShape() method passed options
  31157. * @model the particle model
  31158. * @hidden
  31159. */
  31160. private _meshBuilder;
  31161. /**
  31162. * Returns a shape Vector3 array from positions float array
  31163. * @param positions float array
  31164. * @returns a vector3 array
  31165. * @hidden
  31166. */
  31167. private _posToShape;
  31168. /**
  31169. * Returns a shapeUV array from a float uvs (array deep copy)
  31170. * @param uvs as a float array
  31171. * @returns a shapeUV array
  31172. * @hidden
  31173. */
  31174. private _uvsToShapeUV;
  31175. /**
  31176. * Adds a new particle object in the particles array
  31177. * @param idx particle index in particles array
  31178. * @param id particle id
  31179. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31180. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31181. * @param model particle ModelShape object
  31182. * @param shapeId model shape identifier
  31183. * @param idxInShape index of the particle in the current model
  31184. * @param bInfo model bounding info object
  31185. * @param storage target storage array, if any
  31186. * @hidden
  31187. */
  31188. private _addParticle;
  31189. /**
  31190. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31191. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31192. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31193. * @param nb (positive integer) the number of particles to be created from this model
  31194. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31195. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31196. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31197. * @returns the number of shapes in the system
  31198. */
  31199. addShape(mesh: Mesh, nb: number, options?: {
  31200. positionFunction?: any;
  31201. vertexFunction?: any;
  31202. storage?: [];
  31203. }): number;
  31204. /**
  31205. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31206. * @hidden
  31207. */
  31208. private _rebuildParticle;
  31209. /**
  31210. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31211. * @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.
  31212. * @returns the SPS.
  31213. */
  31214. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31215. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31216. * Returns an array with the removed particles.
  31217. * 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.
  31218. * The SPS can't be empty so at least one particle needs to remain in place.
  31219. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31220. * @param start index of the first particle to remove
  31221. * @param end index of the last particle to remove (included)
  31222. * @returns an array populated with the removed particles
  31223. */
  31224. removeParticles(start: number, end: number): SolidParticle[];
  31225. /**
  31226. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31227. * @param solidParticleArray an array populated with Solid Particles objects
  31228. * @returns the SPS
  31229. */
  31230. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31231. /**
  31232. * Creates a new particle and modifies the SPS mesh geometry :
  31233. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31234. * - calls _addParticle() to populate the particle array
  31235. * factorized code from addShape() and insertParticlesFromArray()
  31236. * @param idx particle index in the particles array
  31237. * @param i particle index in its shape
  31238. * @param modelShape particle ModelShape object
  31239. * @param shape shape vertex array
  31240. * @param meshInd shape indices array
  31241. * @param meshUV shape uv array
  31242. * @param meshCol shape color array
  31243. * @param meshNor shape normals array
  31244. * @param bbInfo shape bounding info
  31245. * @param storage target particle storage
  31246. * @options addShape() passed options
  31247. * @hidden
  31248. */
  31249. private _insertNewParticle;
  31250. /**
  31251. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31252. * This method calls `updateParticle()` for each particle of the SPS.
  31253. * For an animated SPS, it is usually called within the render loop.
  31254. * 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.
  31255. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31256. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31257. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31258. * @returns the SPS.
  31259. */
  31260. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31261. /**
  31262. * Disposes the SPS.
  31263. */
  31264. dispose(): void;
  31265. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31266. * idx is the particle index in the SPS
  31267. * faceId is the picked face index counted within this particle.
  31268. * Returns null if the pickInfo can't identify a picked particle.
  31269. * @param pickingInfo (PickingInfo object)
  31270. * @returns {idx: number, faceId: number} or null
  31271. */
  31272. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31273. idx: number;
  31274. faceId: number;
  31275. }>;
  31276. /**
  31277. * Returns a SolidParticle object from its identifier : particle.id
  31278. * @param id (integer) the particle Id
  31279. * @returns the searched particle or null if not found in the SPS.
  31280. */
  31281. getParticleById(id: number): Nullable<SolidParticle>;
  31282. /**
  31283. * Returns a new array populated with the particles having the passed shapeId.
  31284. * @param shapeId (integer) the shape identifier
  31285. * @returns a new solid particle array
  31286. */
  31287. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31288. /**
  31289. * Populates the passed array "ref" with the particles having the passed shapeId.
  31290. * @param shapeId the shape identifier
  31291. * @returns the SPS
  31292. * @param ref
  31293. */
  31294. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31295. /**
  31296. * Computes the required SubMeshes according the materials assigned to the particles.
  31297. * @returns the solid particle system.
  31298. * Does nothing if called before the SPS mesh is built.
  31299. */
  31300. computeSubMeshes(): SolidParticleSystem;
  31301. /**
  31302. * Sorts the solid particles by material when MultiMaterial is enabled.
  31303. * Updates the indices32 array.
  31304. * Updates the indicesByMaterial array.
  31305. * Updates the mesh indices array.
  31306. * @returns the SPS
  31307. * @hidden
  31308. */
  31309. private _sortParticlesByMaterial;
  31310. /**
  31311. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31312. * @hidden
  31313. */
  31314. private _setMaterialIndexesById;
  31315. /**
  31316. * Returns an array with unique values of Materials from the passed array
  31317. * @param array the material array to be checked and filtered
  31318. * @hidden
  31319. */
  31320. private _filterUniqueMaterialId;
  31321. /**
  31322. * Sets a new Standard Material as _defaultMaterial if not already set.
  31323. * @hidden
  31324. */
  31325. private _setDefaultMaterial;
  31326. /**
  31327. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31328. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31329. * @returns the SPS.
  31330. */
  31331. refreshVisibleSize(): SolidParticleSystem;
  31332. /**
  31333. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31334. * @param size the size (float) of the visibility box
  31335. * note : this doesn't lock the SPS mesh bounding box.
  31336. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31337. */
  31338. setVisibilityBox(size: number): void;
  31339. /**
  31340. * Gets whether the SPS as always visible or not
  31341. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31342. */
  31343. get isAlwaysVisible(): boolean;
  31344. /**
  31345. * Sets the SPS as always visible or not
  31346. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31347. */
  31348. set isAlwaysVisible(val: boolean);
  31349. /**
  31350. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31351. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31352. */
  31353. set isVisibilityBoxLocked(val: boolean);
  31354. /**
  31355. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31356. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31357. */
  31358. get isVisibilityBoxLocked(): boolean;
  31359. /**
  31360. * Tells to `setParticles()` to compute the particle rotations or not.
  31361. * Default value : true. The SPS is faster when it's set to false.
  31362. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31363. */
  31364. set computeParticleRotation(val: boolean);
  31365. /**
  31366. * Tells to `setParticles()` to compute the particle colors or not.
  31367. * Default value : true. The SPS is faster when it's set to false.
  31368. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31369. */
  31370. set computeParticleColor(val: boolean);
  31371. set computeParticleTexture(val: boolean);
  31372. /**
  31373. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31374. * Default value : false. The SPS is faster when it's set to false.
  31375. * Note : the particle custom vertex positions aren't stored values.
  31376. */
  31377. set computeParticleVertex(val: boolean);
  31378. /**
  31379. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31380. */
  31381. set computeBoundingBox(val: boolean);
  31382. /**
  31383. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31384. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31385. * Default : `true`
  31386. */
  31387. set depthSortParticles(val: boolean);
  31388. /**
  31389. * Gets if `setParticles()` computes the particle rotations or not.
  31390. * Default value : true. The SPS is faster when it's set to false.
  31391. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31392. */
  31393. get computeParticleRotation(): boolean;
  31394. /**
  31395. * Gets if `setParticles()` computes the particle colors or not.
  31396. * Default value : true. The SPS is faster when it's set to false.
  31397. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31398. */
  31399. get computeParticleColor(): boolean;
  31400. /**
  31401. * Gets if `setParticles()` computes the particle textures or not.
  31402. * Default value : true. The SPS is faster when it's set to false.
  31403. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31404. */
  31405. get computeParticleTexture(): boolean;
  31406. /**
  31407. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31408. * Default value : false. The SPS is faster when it's set to false.
  31409. * Note : the particle custom vertex positions aren't stored values.
  31410. */
  31411. get computeParticleVertex(): boolean;
  31412. /**
  31413. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31414. */
  31415. get computeBoundingBox(): boolean;
  31416. /**
  31417. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31418. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31419. * Default : `true`
  31420. */
  31421. get depthSortParticles(): boolean;
  31422. /**
  31423. * Gets if the SPS is created as expandable at construction time.
  31424. * Default : `false`
  31425. */
  31426. get expandable(): boolean;
  31427. /**
  31428. * Gets if the SPS supports the Multi Materials
  31429. */
  31430. get multimaterialEnabled(): boolean;
  31431. /**
  31432. * Gets if the SPS uses the model materials for its own multimaterial.
  31433. */
  31434. get useModelMaterial(): boolean;
  31435. /**
  31436. * The SPS used material array.
  31437. */
  31438. get materials(): Material[];
  31439. /**
  31440. * Sets the SPS MultiMaterial from the passed materials.
  31441. * Note : the passed array is internally copied and not used then by reference.
  31442. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31443. */
  31444. setMultiMaterial(materials: Material[]): void;
  31445. /**
  31446. * The SPS computed multimaterial object
  31447. */
  31448. get multimaterial(): MultiMaterial;
  31449. set multimaterial(mm: MultiMaterial);
  31450. /**
  31451. * If the subMeshes must be updated on the next call to setParticles()
  31452. */
  31453. get autoUpdateSubMeshes(): boolean;
  31454. set autoUpdateSubMeshes(val: boolean);
  31455. /**
  31456. * This function does nothing. It may be overwritten to set all the particle first values.
  31457. * The SPS doesn't call this function, you may have to call it by your own.
  31458. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31459. */
  31460. initParticles(): void;
  31461. /**
  31462. * This function does nothing. It may be overwritten to recycle a particle.
  31463. * The SPS doesn't call this function, you may have to call it by your own.
  31464. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31465. * @param particle The particle to recycle
  31466. * @returns the recycled particle
  31467. */
  31468. recycleParticle(particle: SolidParticle): SolidParticle;
  31469. /**
  31470. * Updates a particle : this function should be overwritten by the user.
  31471. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31472. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31473. * @example : just set a particle position or velocity and recycle conditions
  31474. * @param particle The particle to update
  31475. * @returns the updated particle
  31476. */
  31477. updateParticle(particle: SolidParticle): SolidParticle;
  31478. /**
  31479. * Updates a vertex of a particle : it can be overwritten by the user.
  31480. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31481. * @param particle the current particle
  31482. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31483. * @param pt the index of the current vertex in the particle shape
  31484. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31485. * @example : just set a vertex particle position or color
  31486. * @returns the sps
  31487. */
  31488. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31489. /**
  31490. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31491. * This does nothing and may be overwritten by the user.
  31492. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31493. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31494. * @param update the boolean update value actually passed to setParticles()
  31495. */
  31496. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31497. /**
  31498. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31499. * This will be passed three parameters.
  31500. * This does nothing and may be overwritten by the user.
  31501. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31502. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31503. * @param update the boolean update value actually passed to setParticles()
  31504. */
  31505. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31506. }
  31507. }
  31508. declare module "babylonjs/Particles/solidParticle" {
  31509. import { Nullable } from "babylonjs/types";
  31510. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  31511. import { Color4 } from "babylonjs/Maths/math.color";
  31512. import { Mesh } from "babylonjs/Meshes/mesh";
  31513. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31514. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  31515. import { Plane } from "babylonjs/Maths/math.plane";
  31516. import { Material } from "babylonjs/Materials/material";
  31517. /**
  31518. * Represents one particle of a solid particle system.
  31519. */
  31520. export class SolidParticle {
  31521. /**
  31522. * particle global index
  31523. */
  31524. idx: number;
  31525. /**
  31526. * particle identifier
  31527. */
  31528. id: number;
  31529. /**
  31530. * The color of the particle
  31531. */
  31532. color: Nullable<Color4>;
  31533. /**
  31534. * The world space position of the particle.
  31535. */
  31536. position: Vector3;
  31537. /**
  31538. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31539. */
  31540. rotation: Vector3;
  31541. /**
  31542. * The world space rotation quaternion of the particle.
  31543. */
  31544. rotationQuaternion: Nullable<Quaternion>;
  31545. /**
  31546. * The scaling of the particle.
  31547. */
  31548. scaling: Vector3;
  31549. /**
  31550. * The uvs of the particle.
  31551. */
  31552. uvs: Vector4;
  31553. /**
  31554. * The current speed of the particle.
  31555. */
  31556. velocity: Vector3;
  31557. /**
  31558. * The pivot point in the particle local space.
  31559. */
  31560. pivot: Vector3;
  31561. /**
  31562. * Must the particle be translated from its pivot point in its local space ?
  31563. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31564. * Default : false
  31565. */
  31566. translateFromPivot: boolean;
  31567. /**
  31568. * Is the particle active or not ?
  31569. */
  31570. alive: boolean;
  31571. /**
  31572. * Is the particle visible or not ?
  31573. */
  31574. isVisible: boolean;
  31575. /**
  31576. * Index of this particle in the global "positions" array (Internal use)
  31577. * @hidden
  31578. */
  31579. _pos: number;
  31580. /**
  31581. * @hidden Index of this particle in the global "indices" array (Internal use)
  31582. */
  31583. _ind: number;
  31584. /**
  31585. * @hidden ModelShape of this particle (Internal use)
  31586. */
  31587. _model: ModelShape;
  31588. /**
  31589. * ModelShape id of this particle
  31590. */
  31591. shapeId: number;
  31592. /**
  31593. * Index of the particle in its shape id
  31594. */
  31595. idxInShape: number;
  31596. /**
  31597. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31598. */
  31599. _modelBoundingInfo: BoundingInfo;
  31600. /**
  31601. * @hidden Particle BoundingInfo object (Internal use)
  31602. */
  31603. _boundingInfo: BoundingInfo;
  31604. /**
  31605. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31606. */
  31607. _sps: SolidParticleSystem;
  31608. /**
  31609. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31610. */
  31611. _stillInvisible: boolean;
  31612. /**
  31613. * @hidden Last computed particle rotation matrix
  31614. */
  31615. _rotationMatrix: number[];
  31616. /**
  31617. * Parent particle Id, if any.
  31618. * Default null.
  31619. */
  31620. parentId: Nullable<number>;
  31621. /**
  31622. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31623. */
  31624. materialIndex: Nullable<number>;
  31625. /**
  31626. * Custom object or properties.
  31627. */
  31628. props: Nullable<any>;
  31629. /**
  31630. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31631. * The possible values are :
  31632. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31633. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31634. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31635. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31636. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31637. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31638. * */
  31639. cullingStrategy: number;
  31640. /**
  31641. * @hidden Internal global position in the SPS.
  31642. */
  31643. _globalPosition: Vector3;
  31644. /**
  31645. * Creates a Solid Particle object.
  31646. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31647. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31648. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31649. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31650. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31651. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31652. * @param shapeId (integer) is the model shape identifier in the SPS.
  31653. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31654. * @param sps defines the sps it is associated to
  31655. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31656. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31657. */
  31658. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31659. /**
  31660. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31661. * @param target the particle target
  31662. * @returns the current particle
  31663. */
  31664. copyToRef(target: SolidParticle): SolidParticle;
  31665. /**
  31666. * Legacy support, changed scale to scaling
  31667. */
  31668. get scale(): Vector3;
  31669. /**
  31670. * Legacy support, changed scale to scaling
  31671. */
  31672. set scale(scale: Vector3);
  31673. /**
  31674. * Legacy support, changed quaternion to rotationQuaternion
  31675. */
  31676. get quaternion(): Nullable<Quaternion>;
  31677. /**
  31678. * Legacy support, changed quaternion to rotationQuaternion
  31679. */
  31680. set quaternion(q: Nullable<Quaternion>);
  31681. /**
  31682. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31683. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31684. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31685. * @returns true if it intersects
  31686. */
  31687. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31688. /**
  31689. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31690. * A particle is in the frustum if its bounding box intersects the frustum
  31691. * @param frustumPlanes defines the frustum to test
  31692. * @returns true if the particle is in the frustum planes
  31693. */
  31694. isInFrustum(frustumPlanes: Plane[]): boolean;
  31695. /**
  31696. * get the rotation matrix of the particle
  31697. * @hidden
  31698. */
  31699. getRotationMatrix(m: Matrix): void;
  31700. }
  31701. /**
  31702. * Represents the shape of the model used by one particle of a solid particle system.
  31703. * SPS internal tool, don't use it manually.
  31704. */
  31705. export class ModelShape {
  31706. /**
  31707. * The shape id
  31708. * @hidden
  31709. */
  31710. shapeID: number;
  31711. /**
  31712. * flat array of model positions (internal use)
  31713. * @hidden
  31714. */
  31715. _shape: Vector3[];
  31716. /**
  31717. * flat array of model UVs (internal use)
  31718. * @hidden
  31719. */
  31720. _shapeUV: number[];
  31721. /**
  31722. * color array of the model
  31723. * @hidden
  31724. */
  31725. _shapeColors: number[];
  31726. /**
  31727. * indices array of the model
  31728. * @hidden
  31729. */
  31730. _indices: number[];
  31731. /**
  31732. * normals array of the model
  31733. * @hidden
  31734. */
  31735. _normals: number[];
  31736. /**
  31737. * length of the shape in the model indices array (internal use)
  31738. * @hidden
  31739. */
  31740. _indicesLength: number;
  31741. /**
  31742. * Custom position function (internal use)
  31743. * @hidden
  31744. */
  31745. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31746. /**
  31747. * Custom vertex function (internal use)
  31748. * @hidden
  31749. */
  31750. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31751. /**
  31752. * Model material (internal use)
  31753. * @hidden
  31754. */
  31755. _material: Nullable<Material>;
  31756. /**
  31757. * 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.
  31758. * SPS internal tool, don't use it manually.
  31759. * @hidden
  31760. */
  31761. 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>);
  31762. }
  31763. /**
  31764. * Represents a Depth Sorted Particle in the solid particle system.
  31765. * @hidden
  31766. */
  31767. export class DepthSortedParticle {
  31768. /**
  31769. * Particle index
  31770. */
  31771. idx: number;
  31772. /**
  31773. * Index of the particle in the "indices" array
  31774. */
  31775. ind: number;
  31776. /**
  31777. * Length of the particle shape in the "indices" array
  31778. */
  31779. indicesLength: number;
  31780. /**
  31781. * Squared distance from the particle to the camera
  31782. */
  31783. sqDistance: number;
  31784. /**
  31785. * Material index when used with MultiMaterials
  31786. */
  31787. materialIndex: number;
  31788. /**
  31789. * Creates a new sorted particle
  31790. * @param materialIndex
  31791. */
  31792. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31793. }
  31794. /**
  31795. * Represents a solid particle vertex
  31796. */
  31797. export class SolidParticleVertex {
  31798. /**
  31799. * Vertex position
  31800. */
  31801. position: Vector3;
  31802. /**
  31803. * Vertex color
  31804. */
  31805. color: Color4;
  31806. /**
  31807. * Vertex UV
  31808. */
  31809. uv: Vector2;
  31810. /**
  31811. * Creates a new solid particle vertex
  31812. */
  31813. constructor();
  31814. /** Vertex x coordinate */
  31815. get x(): number;
  31816. set x(val: number);
  31817. /** Vertex y coordinate */
  31818. get y(): number;
  31819. set y(val: number);
  31820. /** Vertex z coordinate */
  31821. get z(): number;
  31822. set z(val: number);
  31823. }
  31824. }
  31825. declare module "babylonjs/Collisions/meshCollisionData" {
  31826. import { Collider } from "babylonjs/Collisions/collider";
  31827. import { Vector3 } from "babylonjs/Maths/math.vector";
  31828. import { Nullable } from "babylonjs/types";
  31829. import { Observer } from "babylonjs/Misc/observable";
  31830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31831. /**
  31832. * @hidden
  31833. */
  31834. export class _MeshCollisionData {
  31835. _checkCollisions: boolean;
  31836. _collisionMask: number;
  31837. _collisionGroup: number;
  31838. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31839. _collider: Nullable<Collider>;
  31840. _oldPositionForCollisions: Vector3;
  31841. _diffPositionForCollisions: Vector3;
  31842. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31843. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31844. }
  31845. }
  31846. declare module "babylonjs/Meshes/abstractMesh" {
  31847. import { Observable } from "babylonjs/Misc/observable";
  31848. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  31849. import { Camera } from "babylonjs/Cameras/camera";
  31850. import { Scene, IDisposable } from "babylonjs/scene";
  31851. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  31852. import { Node } from "babylonjs/node";
  31853. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  31854. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31855. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31856. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31857. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31858. import { Material } from "babylonjs/Materials/material";
  31859. import { Light } from "babylonjs/Lights/light";
  31860. import { Skeleton } from "babylonjs/Bones/skeleton";
  31861. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  31862. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  31863. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31864. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  31865. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  31866. import { Plane } from "babylonjs/Maths/math.plane";
  31867. import { Ray } from "babylonjs/Culling/ray";
  31868. import { Collider } from "babylonjs/Collisions/collider";
  31869. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31870. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  31871. /** @hidden */
  31872. class _FacetDataStorage {
  31873. facetPositions: Vector3[];
  31874. facetNormals: Vector3[];
  31875. facetPartitioning: number[][];
  31876. facetNb: number;
  31877. partitioningSubdivisions: number;
  31878. partitioningBBoxRatio: number;
  31879. facetDataEnabled: boolean;
  31880. facetParameters: any;
  31881. bbSize: Vector3;
  31882. subDiv: {
  31883. max: number;
  31884. X: number;
  31885. Y: number;
  31886. Z: number;
  31887. };
  31888. facetDepthSort: boolean;
  31889. facetDepthSortEnabled: boolean;
  31890. depthSortedIndices: IndicesArray;
  31891. depthSortedFacets: {
  31892. ind: number;
  31893. sqDistance: number;
  31894. }[];
  31895. facetDepthSortFunction: (f1: {
  31896. ind: number;
  31897. sqDistance: number;
  31898. }, f2: {
  31899. ind: number;
  31900. sqDistance: number;
  31901. }) => number;
  31902. facetDepthSortFrom: Vector3;
  31903. facetDepthSortOrigin: Vector3;
  31904. invertedMatrix: Matrix;
  31905. }
  31906. /**
  31907. * @hidden
  31908. **/
  31909. class _InternalAbstractMeshDataInfo {
  31910. _hasVertexAlpha: boolean;
  31911. _useVertexColors: boolean;
  31912. _numBoneInfluencers: number;
  31913. _applyFog: boolean;
  31914. _receiveShadows: boolean;
  31915. _facetData: _FacetDataStorage;
  31916. _visibility: number;
  31917. _skeleton: Nullable<Skeleton>;
  31918. _layerMask: number;
  31919. _computeBonesUsingShaders: boolean;
  31920. _isActive: boolean;
  31921. _onlyForInstances: boolean;
  31922. _isActiveIntermediate: boolean;
  31923. _onlyForInstancesIntermediate: boolean;
  31924. _actAsRegularMesh: boolean;
  31925. }
  31926. /**
  31927. * Class used to store all common mesh properties
  31928. */
  31929. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31930. /** No occlusion */
  31931. static OCCLUSION_TYPE_NONE: number;
  31932. /** Occlusion set to optimisitic */
  31933. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31934. /** Occlusion set to strict */
  31935. static OCCLUSION_TYPE_STRICT: number;
  31936. /** Use an accurante occlusion algorithm */
  31937. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31938. /** Use a conservative occlusion algorithm */
  31939. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31940. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31941. * Test order :
  31942. * Is the bounding sphere outside the frustum ?
  31943. * If not, are the bounding box vertices outside the frustum ?
  31944. * It not, then the cullable object is in the frustum.
  31945. */
  31946. static readonly CULLINGSTRATEGY_STANDARD: number;
  31947. /** Culling strategy : Bounding Sphere Only.
  31948. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31949. * It's also less accurate than the standard because some not visible objects can still be selected.
  31950. * Test : is the bounding sphere outside the frustum ?
  31951. * If not, then the cullable object is in the frustum.
  31952. */
  31953. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31954. /** Culling strategy : Optimistic Inclusion.
  31955. * This in an inclusion test first, then the standard exclusion test.
  31956. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31957. * 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.
  31958. * Anyway, it's as accurate as the standard strategy.
  31959. * Test :
  31960. * Is the cullable object bounding sphere center in the frustum ?
  31961. * If not, apply the default culling strategy.
  31962. */
  31963. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31964. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31965. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31966. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31967. * 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.
  31968. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31969. * Test :
  31970. * Is the cullable object bounding sphere center in the frustum ?
  31971. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31972. */
  31973. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31974. /**
  31975. * No billboard
  31976. */
  31977. static get BILLBOARDMODE_NONE(): number;
  31978. /** Billboard on X axis */
  31979. static get BILLBOARDMODE_X(): number;
  31980. /** Billboard on Y axis */
  31981. static get BILLBOARDMODE_Y(): number;
  31982. /** Billboard on Z axis */
  31983. static get BILLBOARDMODE_Z(): number;
  31984. /** Billboard on all axes */
  31985. static get BILLBOARDMODE_ALL(): number;
  31986. /** Billboard on using position instead of orientation */
  31987. static get BILLBOARDMODE_USE_POSITION(): number;
  31988. /** @hidden */
  31989. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  31990. /**
  31991. * The culling strategy to use to check whether the mesh must be rendered or not.
  31992. * This value can be changed at any time and will be used on the next render mesh selection.
  31993. * The possible values are :
  31994. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31995. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31996. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31997. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31998. * Please read each static variable documentation to get details about the culling process.
  31999. * */
  32000. cullingStrategy: number;
  32001. /**
  32002. * Gets the number of facets in the mesh
  32003. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32004. */
  32005. get facetNb(): number;
  32006. /**
  32007. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32008. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32009. */
  32010. get partitioningSubdivisions(): number;
  32011. set partitioningSubdivisions(nb: number);
  32012. /**
  32013. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32014. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32015. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32016. */
  32017. get partitioningBBoxRatio(): number;
  32018. set partitioningBBoxRatio(ratio: number);
  32019. /**
  32020. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32021. * Works only for updatable meshes.
  32022. * Doesn't work with multi-materials
  32023. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32024. */
  32025. get mustDepthSortFacets(): boolean;
  32026. set mustDepthSortFacets(sort: boolean);
  32027. /**
  32028. * The location (Vector3) where the facet depth sort must be computed from.
  32029. * By default, the active camera position.
  32030. * Used only when facet depth sort is enabled
  32031. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32032. */
  32033. get facetDepthSortFrom(): Vector3;
  32034. set facetDepthSortFrom(location: Vector3);
  32035. /**
  32036. * gets a boolean indicating if facetData is enabled
  32037. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32038. */
  32039. get isFacetDataEnabled(): boolean;
  32040. /** @hidden */
  32041. _updateNonUniformScalingState(value: boolean): boolean;
  32042. /**
  32043. * An event triggered when this mesh collides with another one
  32044. */
  32045. onCollideObservable: Observable<AbstractMesh>;
  32046. /** Set a function to call when this mesh collides with another one */
  32047. set onCollide(callback: () => void);
  32048. /**
  32049. * An event triggered when the collision's position changes
  32050. */
  32051. onCollisionPositionChangeObservable: Observable<Vector3>;
  32052. /** Set a function to call when the collision's position changes */
  32053. set onCollisionPositionChange(callback: () => void);
  32054. /**
  32055. * An event triggered when material is changed
  32056. */
  32057. onMaterialChangedObservable: Observable<AbstractMesh>;
  32058. /**
  32059. * Gets or sets the orientation for POV movement & rotation
  32060. */
  32061. definedFacingForward: boolean;
  32062. /** @hidden */
  32063. _occlusionQuery: Nullable<WebGLQuery>;
  32064. /** @hidden */
  32065. _renderingGroup: Nullable<RenderingGroup>;
  32066. /**
  32067. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32068. */
  32069. get visibility(): number;
  32070. /**
  32071. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32072. */
  32073. set visibility(value: number);
  32074. /** Gets or sets the alpha index used to sort transparent meshes
  32075. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32076. */
  32077. alphaIndex: number;
  32078. /**
  32079. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32080. */
  32081. isVisible: boolean;
  32082. /**
  32083. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32084. */
  32085. isPickable: boolean;
  32086. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32087. showSubMeshesBoundingBox: boolean;
  32088. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32089. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32090. */
  32091. isBlocker: boolean;
  32092. /**
  32093. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32094. */
  32095. enablePointerMoveEvents: boolean;
  32096. /**
  32097. * Specifies the rendering group id for this mesh (0 by default)
  32098. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32099. */
  32100. renderingGroupId: number;
  32101. private _material;
  32102. /** Gets or sets current material */
  32103. get material(): Nullable<Material>;
  32104. set material(value: Nullable<Material>);
  32105. /**
  32106. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32107. * @see http://doc.babylonjs.com/babylon101/shadows
  32108. */
  32109. get receiveShadows(): boolean;
  32110. set receiveShadows(value: boolean);
  32111. /** Defines color to use when rendering outline */
  32112. outlineColor: Color3;
  32113. /** Define width to use when rendering outline */
  32114. outlineWidth: number;
  32115. /** Defines color to use when rendering overlay */
  32116. overlayColor: Color3;
  32117. /** Defines alpha to use when rendering overlay */
  32118. overlayAlpha: number;
  32119. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32120. get hasVertexAlpha(): boolean;
  32121. set hasVertexAlpha(value: boolean);
  32122. /** 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) */
  32123. get useVertexColors(): boolean;
  32124. set useVertexColors(value: boolean);
  32125. /**
  32126. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32127. */
  32128. get computeBonesUsingShaders(): boolean;
  32129. set computeBonesUsingShaders(value: boolean);
  32130. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32131. get numBoneInfluencers(): number;
  32132. set numBoneInfluencers(value: number);
  32133. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32134. get applyFog(): boolean;
  32135. set applyFog(value: boolean);
  32136. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32137. useOctreeForRenderingSelection: boolean;
  32138. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32139. useOctreeForPicking: boolean;
  32140. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32141. useOctreeForCollisions: boolean;
  32142. /**
  32143. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32144. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32145. */
  32146. get layerMask(): number;
  32147. set layerMask(value: number);
  32148. /**
  32149. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32150. */
  32151. alwaysSelectAsActiveMesh: boolean;
  32152. /**
  32153. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32154. */
  32155. doNotSyncBoundingInfo: boolean;
  32156. /**
  32157. * Gets or sets the current action manager
  32158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32159. */
  32160. actionManager: Nullable<AbstractActionManager>;
  32161. private _meshCollisionData;
  32162. /**
  32163. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32164. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32165. */
  32166. ellipsoid: Vector3;
  32167. /**
  32168. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32169. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32170. */
  32171. ellipsoidOffset: Vector3;
  32172. /**
  32173. * Gets or sets a collision mask used to mask collisions (default is -1).
  32174. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32175. */
  32176. get collisionMask(): number;
  32177. set collisionMask(mask: number);
  32178. /**
  32179. * Gets or sets the current collision group mask (-1 by default).
  32180. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32181. */
  32182. get collisionGroup(): number;
  32183. set collisionGroup(mask: number);
  32184. /**
  32185. * Gets or sets current surrounding meshes (null by default).
  32186. *
  32187. * By default collision detection is tested against every mesh in the scene.
  32188. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32189. * meshes will be tested for the collision.
  32190. *
  32191. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32192. */
  32193. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32194. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32195. /**
  32196. * Defines edge width used when edgesRenderer is enabled
  32197. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32198. */
  32199. edgesWidth: number;
  32200. /**
  32201. * Defines edge color used when edgesRenderer is enabled
  32202. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32203. */
  32204. edgesColor: Color4;
  32205. /** @hidden */
  32206. _edgesRenderer: Nullable<IEdgesRenderer>;
  32207. /** @hidden */
  32208. _masterMesh: Nullable<AbstractMesh>;
  32209. /** @hidden */
  32210. _boundingInfo: Nullable<BoundingInfo>;
  32211. /** @hidden */
  32212. _renderId: number;
  32213. /**
  32214. * Gets or sets the list of subMeshes
  32215. * @see http://doc.babylonjs.com/how_to/multi_materials
  32216. */
  32217. subMeshes: SubMesh[];
  32218. /** @hidden */
  32219. _intersectionsInProgress: AbstractMesh[];
  32220. /** @hidden */
  32221. _unIndexed: boolean;
  32222. /** @hidden */
  32223. _lightSources: Light[];
  32224. /** Gets the list of lights affecting that mesh */
  32225. get lightSources(): Light[];
  32226. /** @hidden */
  32227. get _positions(): Nullable<Vector3[]>;
  32228. /** @hidden */
  32229. _waitingData: {
  32230. lods: Nullable<any>;
  32231. actions: Nullable<any>;
  32232. freezeWorldMatrix: Nullable<boolean>;
  32233. };
  32234. /** @hidden */
  32235. _bonesTransformMatrices: Nullable<Float32Array>;
  32236. /** @hidden */
  32237. _transformMatrixTexture: Nullable<RawTexture>;
  32238. /**
  32239. * Gets or sets a skeleton to apply skining transformations
  32240. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32241. */
  32242. set skeleton(value: Nullable<Skeleton>);
  32243. get skeleton(): Nullable<Skeleton>;
  32244. /**
  32245. * An event triggered when the mesh is rebuilt.
  32246. */
  32247. onRebuildObservable: Observable<AbstractMesh>;
  32248. /**
  32249. * Creates a new AbstractMesh
  32250. * @param name defines the name of the mesh
  32251. * @param scene defines the hosting scene
  32252. */
  32253. constructor(name: string, scene?: Nullable<Scene>);
  32254. /**
  32255. * Returns the string "AbstractMesh"
  32256. * @returns "AbstractMesh"
  32257. */
  32258. getClassName(): string;
  32259. /**
  32260. * Gets a string representation of the current mesh
  32261. * @param fullDetails defines a boolean indicating if full details must be included
  32262. * @returns a string representation of the current mesh
  32263. */
  32264. toString(fullDetails?: boolean): string;
  32265. /**
  32266. * @hidden
  32267. */
  32268. protected _getEffectiveParent(): Nullable<Node>;
  32269. /** @hidden */
  32270. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32271. /** @hidden */
  32272. _rebuild(): void;
  32273. /** @hidden */
  32274. _resyncLightSources(): void;
  32275. /** @hidden */
  32276. _resyncLightSource(light: Light): void;
  32277. /** @hidden */
  32278. _unBindEffect(): void;
  32279. /** @hidden */
  32280. _removeLightSource(light: Light, dispose: boolean): void;
  32281. private _markSubMeshesAsDirty;
  32282. /** @hidden */
  32283. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32284. /** @hidden */
  32285. _markSubMeshesAsAttributesDirty(): void;
  32286. /** @hidden */
  32287. _markSubMeshesAsMiscDirty(): void;
  32288. /**
  32289. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32290. */
  32291. get scaling(): Vector3;
  32292. set scaling(newScaling: Vector3);
  32293. /**
  32294. * Returns true if the mesh is blocked. Implemented by child classes
  32295. */
  32296. get isBlocked(): boolean;
  32297. /**
  32298. * Returns the mesh itself by default. Implemented by child classes
  32299. * @param camera defines the camera to use to pick the right LOD level
  32300. * @returns the currentAbstractMesh
  32301. */
  32302. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32303. /**
  32304. * Returns 0 by default. Implemented by child classes
  32305. * @returns an integer
  32306. */
  32307. getTotalVertices(): number;
  32308. /**
  32309. * Returns a positive integer : the total number of indices in this mesh geometry.
  32310. * @returns the numner of indices or zero if the mesh has no geometry.
  32311. */
  32312. getTotalIndices(): number;
  32313. /**
  32314. * Returns null by default. Implemented by child classes
  32315. * @returns null
  32316. */
  32317. getIndices(): Nullable<IndicesArray>;
  32318. /**
  32319. * Returns the array of the requested vertex data kind. Implemented by child classes
  32320. * @param kind defines the vertex data kind to use
  32321. * @returns null
  32322. */
  32323. getVerticesData(kind: string): Nullable<FloatArray>;
  32324. /**
  32325. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32326. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32327. * Note that a new underlying VertexBuffer object is created each call.
  32328. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32329. * @param kind defines vertex data kind:
  32330. * * VertexBuffer.PositionKind
  32331. * * VertexBuffer.UVKind
  32332. * * VertexBuffer.UV2Kind
  32333. * * VertexBuffer.UV3Kind
  32334. * * VertexBuffer.UV4Kind
  32335. * * VertexBuffer.UV5Kind
  32336. * * VertexBuffer.UV6Kind
  32337. * * VertexBuffer.ColorKind
  32338. * * VertexBuffer.MatricesIndicesKind
  32339. * * VertexBuffer.MatricesIndicesExtraKind
  32340. * * VertexBuffer.MatricesWeightsKind
  32341. * * VertexBuffer.MatricesWeightsExtraKind
  32342. * @param data defines the data source
  32343. * @param updatable defines if the data must be flagged as updatable (or static)
  32344. * @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
  32345. * @returns the current mesh
  32346. */
  32347. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32348. /**
  32349. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32350. * If the mesh has no geometry, it is simply returned as it is.
  32351. * @param kind defines vertex data kind:
  32352. * * VertexBuffer.PositionKind
  32353. * * VertexBuffer.UVKind
  32354. * * VertexBuffer.UV2Kind
  32355. * * VertexBuffer.UV3Kind
  32356. * * VertexBuffer.UV4Kind
  32357. * * VertexBuffer.UV5Kind
  32358. * * VertexBuffer.UV6Kind
  32359. * * VertexBuffer.ColorKind
  32360. * * VertexBuffer.MatricesIndicesKind
  32361. * * VertexBuffer.MatricesIndicesExtraKind
  32362. * * VertexBuffer.MatricesWeightsKind
  32363. * * VertexBuffer.MatricesWeightsExtraKind
  32364. * @param data defines the data source
  32365. * @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
  32366. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32367. * @returns the current mesh
  32368. */
  32369. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32370. /**
  32371. * Sets the mesh indices,
  32372. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32373. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32374. * @param totalVertices Defines the total number of vertices
  32375. * @returns the current mesh
  32376. */
  32377. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32378. /**
  32379. * Gets a boolean indicating if specific vertex data is present
  32380. * @param kind defines the vertex data kind to use
  32381. * @returns true is data kind is present
  32382. */
  32383. isVerticesDataPresent(kind: string): boolean;
  32384. /**
  32385. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32386. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32387. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32388. * @returns a BoundingInfo
  32389. */
  32390. getBoundingInfo(): BoundingInfo;
  32391. /**
  32392. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32393. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32394. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32395. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32396. * @returns the current mesh
  32397. */
  32398. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32399. /**
  32400. * Overwrite the current bounding info
  32401. * @param boundingInfo defines the new bounding info
  32402. * @returns the current mesh
  32403. */
  32404. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32405. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32406. get useBones(): boolean;
  32407. /** @hidden */
  32408. _preActivate(): void;
  32409. /** @hidden */
  32410. _preActivateForIntermediateRendering(renderId: number): void;
  32411. /** @hidden */
  32412. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32413. /** @hidden */
  32414. _postActivate(): void;
  32415. /** @hidden */
  32416. _freeze(): void;
  32417. /** @hidden */
  32418. _unFreeze(): void;
  32419. /**
  32420. * Gets the current world matrix
  32421. * @returns a Matrix
  32422. */
  32423. getWorldMatrix(): Matrix;
  32424. /** @hidden */
  32425. _getWorldMatrixDeterminant(): number;
  32426. /**
  32427. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32428. */
  32429. get isAnInstance(): boolean;
  32430. /**
  32431. * Gets a boolean indicating if this mesh has instances
  32432. */
  32433. get hasInstances(): boolean;
  32434. /**
  32435. * Gets a boolean indicating if this mesh has thin instances
  32436. */
  32437. get hasThinInstances(): boolean;
  32438. /**
  32439. * Perform relative position change from the point of view of behind the front of the mesh.
  32440. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32441. * Supports definition of mesh facing forward or backward
  32442. * @param amountRight defines the distance on the right axis
  32443. * @param amountUp defines the distance on the up axis
  32444. * @param amountForward defines the distance on the forward axis
  32445. * @returns the current mesh
  32446. */
  32447. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32448. /**
  32449. * Calculate relative position change from the point of view of behind the front of the mesh.
  32450. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32451. * Supports definition of mesh facing forward or backward
  32452. * @param amountRight defines the distance on the right axis
  32453. * @param amountUp defines the distance on the up axis
  32454. * @param amountForward defines the distance on the forward axis
  32455. * @returns the new displacement vector
  32456. */
  32457. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32458. /**
  32459. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32460. * Supports definition of mesh facing forward or backward
  32461. * @param flipBack defines the flip
  32462. * @param twirlClockwise defines the twirl
  32463. * @param tiltRight defines the tilt
  32464. * @returns the current mesh
  32465. */
  32466. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32467. /**
  32468. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32469. * Supports definition of mesh facing forward or backward.
  32470. * @param flipBack defines the flip
  32471. * @param twirlClockwise defines the twirl
  32472. * @param tiltRight defines the tilt
  32473. * @returns the new rotation vector
  32474. */
  32475. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32476. /**
  32477. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32478. * This means the mesh underlying bounding box and sphere are recomputed.
  32479. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32480. * @returns the current mesh
  32481. */
  32482. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32483. /** @hidden */
  32484. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32485. /** @hidden */
  32486. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32487. /** @hidden */
  32488. _updateBoundingInfo(): AbstractMesh;
  32489. /** @hidden */
  32490. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32491. /** @hidden */
  32492. protected _afterComputeWorldMatrix(): void;
  32493. /** @hidden */
  32494. get _effectiveMesh(): AbstractMesh;
  32495. /**
  32496. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32497. * A mesh is in the frustum if its bounding box intersects the frustum
  32498. * @param frustumPlanes defines the frustum to test
  32499. * @returns true if the mesh is in the frustum planes
  32500. */
  32501. isInFrustum(frustumPlanes: Plane[]): boolean;
  32502. /**
  32503. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32504. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32505. * @param frustumPlanes defines the frustum to test
  32506. * @returns true if the mesh is completely in the frustum planes
  32507. */
  32508. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32509. /**
  32510. * True if the mesh intersects another mesh or a SolidParticle object
  32511. * @param mesh defines a target mesh or SolidParticle to test
  32512. * @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)
  32513. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32514. * @returns true if there is an intersection
  32515. */
  32516. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32517. /**
  32518. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32519. * @param point defines the point to test
  32520. * @returns true if there is an intersection
  32521. */
  32522. intersectsPoint(point: Vector3): boolean;
  32523. /**
  32524. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32525. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32526. */
  32527. get checkCollisions(): boolean;
  32528. set checkCollisions(collisionEnabled: boolean);
  32529. /**
  32530. * Gets Collider object used to compute collisions (not physics)
  32531. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32532. */
  32533. get collider(): Nullable<Collider>;
  32534. /**
  32535. * Move the mesh using collision engine
  32536. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32537. * @param displacement defines the requested displacement vector
  32538. * @returns the current mesh
  32539. */
  32540. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32541. private _onCollisionPositionChange;
  32542. /** @hidden */
  32543. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32544. /** @hidden */
  32545. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32546. /** @hidden */
  32547. _checkCollision(collider: Collider): AbstractMesh;
  32548. /** @hidden */
  32549. _generatePointsArray(): boolean;
  32550. /**
  32551. * Checks if the passed Ray intersects with the mesh
  32552. * @param ray defines the ray to use
  32553. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32554. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32555. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32556. * @returns the picking info
  32557. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32558. */
  32559. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  32560. /**
  32561. * Clones the current mesh
  32562. * @param name defines the mesh name
  32563. * @param newParent defines the new mesh parent
  32564. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32565. * @returns the new mesh
  32566. */
  32567. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32568. /**
  32569. * Disposes all the submeshes of the current meshnp
  32570. * @returns the current mesh
  32571. */
  32572. releaseSubMeshes(): AbstractMesh;
  32573. /**
  32574. * Releases resources associated with this abstract mesh.
  32575. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32576. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32577. */
  32578. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32579. /**
  32580. * Adds the passed mesh as a child to the current mesh
  32581. * @param mesh defines the child mesh
  32582. * @returns the current mesh
  32583. */
  32584. addChild(mesh: AbstractMesh): AbstractMesh;
  32585. /**
  32586. * Removes the passed mesh from the current mesh children list
  32587. * @param mesh defines the child mesh
  32588. * @returns the current mesh
  32589. */
  32590. removeChild(mesh: AbstractMesh): AbstractMesh;
  32591. /** @hidden */
  32592. private _initFacetData;
  32593. /**
  32594. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32595. * This method can be called within the render loop.
  32596. * 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
  32597. * @returns the current mesh
  32598. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32599. */
  32600. updateFacetData(): AbstractMesh;
  32601. /**
  32602. * Returns the facetLocalNormals array.
  32603. * The normals are expressed in the mesh local spac
  32604. * @returns an array of Vector3
  32605. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32606. */
  32607. getFacetLocalNormals(): Vector3[];
  32608. /**
  32609. * Returns the facetLocalPositions array.
  32610. * The facet positions are expressed in the mesh local space
  32611. * @returns an array of Vector3
  32612. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32613. */
  32614. getFacetLocalPositions(): Vector3[];
  32615. /**
  32616. * Returns the facetLocalPartioning array
  32617. * @returns an array of array of numbers
  32618. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32619. */
  32620. getFacetLocalPartitioning(): number[][];
  32621. /**
  32622. * Returns the i-th facet position in the world system.
  32623. * This method allocates a new Vector3 per call
  32624. * @param i defines the facet index
  32625. * @returns a new Vector3
  32626. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32627. */
  32628. getFacetPosition(i: number): Vector3;
  32629. /**
  32630. * Sets the reference Vector3 with the i-th facet position in the world system
  32631. * @param i defines the facet index
  32632. * @param ref defines the target vector
  32633. * @returns the current mesh
  32634. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32635. */
  32636. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32637. /**
  32638. * Returns the i-th facet normal in the world system.
  32639. * This method allocates a new Vector3 per call
  32640. * @param i defines the facet index
  32641. * @returns a new Vector3
  32642. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32643. */
  32644. getFacetNormal(i: number): Vector3;
  32645. /**
  32646. * Sets the reference Vector3 with the i-th facet normal in the world system
  32647. * @param i defines the facet index
  32648. * @param ref defines the target vector
  32649. * @returns the current mesh
  32650. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32651. */
  32652. getFacetNormalToRef(i: number, ref: Vector3): this;
  32653. /**
  32654. * 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)
  32655. * @param x defines x coordinate
  32656. * @param y defines y coordinate
  32657. * @param z defines z coordinate
  32658. * @returns the array of facet indexes
  32659. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32660. */
  32661. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32662. /**
  32663. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32664. * @param projected sets as the (x,y,z) world projection on the facet
  32665. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  32666. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  32667. * @param x defines x coordinate
  32668. * @param y defines y coordinate
  32669. * @param z defines z coordinate
  32670. * @returns the face index if found (or null instead)
  32671. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32672. */
  32673. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32674. /**
  32675. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32676. * @param projected sets as the (x,y,z) local projection on the facet
  32677. * @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
  32678. * @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
  32679. * @param x defines x coordinate
  32680. * @param y defines y coordinate
  32681. * @param z defines z coordinate
  32682. * @returns the face index if found (or null instead)
  32683. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32684. */
  32685. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32686. /**
  32687. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32688. * @returns the parameters
  32689. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32690. */
  32691. getFacetDataParameters(): any;
  32692. /**
  32693. * Disables the feature FacetData and frees the related memory
  32694. * @returns the current mesh
  32695. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32696. */
  32697. disableFacetData(): AbstractMesh;
  32698. /**
  32699. * Updates the AbstractMesh indices array
  32700. * @param indices defines the data source
  32701. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32702. * @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)
  32703. * @returns the current mesh
  32704. */
  32705. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32706. /**
  32707. * Creates new normals data for the mesh
  32708. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32709. * @returns the current mesh
  32710. */
  32711. createNormals(updatable: boolean): AbstractMesh;
  32712. /**
  32713. * Align the mesh with a normal
  32714. * @param normal defines the normal to use
  32715. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32716. * @returns the current mesh
  32717. */
  32718. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32719. /** @hidden */
  32720. _checkOcclusionQuery(): boolean;
  32721. /**
  32722. * Disables the mesh edge rendering mode
  32723. * @returns the currentAbstractMesh
  32724. */
  32725. disableEdgesRendering(): AbstractMesh;
  32726. /**
  32727. * Enables the edge rendering mode on the mesh.
  32728. * This mode makes the mesh edges visible
  32729. * @param epsilon defines the maximal distance between two angles to detect a face
  32730. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32731. * @returns the currentAbstractMesh
  32732. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32733. */
  32734. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32735. }
  32736. }
  32737. declare module "babylonjs/Actions/actionEvent" {
  32738. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32739. import { Nullable } from "babylonjs/types";
  32740. import { Sprite } from "babylonjs/Sprites/sprite";
  32741. import { Scene } from "babylonjs/scene";
  32742. import { Vector2 } from "babylonjs/Maths/math.vector";
  32743. /**
  32744. * Interface used to define ActionEvent
  32745. */
  32746. export interface IActionEvent {
  32747. /** The mesh or sprite that triggered the action */
  32748. source: any;
  32749. /** The X mouse cursor position at the time of the event */
  32750. pointerX: number;
  32751. /** The Y mouse cursor position at the time of the event */
  32752. pointerY: number;
  32753. /** The mesh that is currently pointed at (can be null) */
  32754. meshUnderPointer: Nullable<AbstractMesh>;
  32755. /** the original (browser) event that triggered the ActionEvent */
  32756. sourceEvent?: any;
  32757. /** additional data for the event */
  32758. additionalData?: any;
  32759. }
  32760. /**
  32761. * ActionEvent is the event being sent when an action is triggered.
  32762. */
  32763. export class ActionEvent implements IActionEvent {
  32764. /** The mesh or sprite that triggered the action */
  32765. source: any;
  32766. /** The X mouse cursor position at the time of the event */
  32767. pointerX: number;
  32768. /** The Y mouse cursor position at the time of the event */
  32769. pointerY: number;
  32770. /** The mesh that is currently pointed at (can be null) */
  32771. meshUnderPointer: Nullable<AbstractMesh>;
  32772. /** the original (browser) event that triggered the ActionEvent */
  32773. sourceEvent?: any;
  32774. /** additional data for the event */
  32775. additionalData?: any;
  32776. /**
  32777. * Creates a new ActionEvent
  32778. * @param source The mesh or sprite that triggered the action
  32779. * @param pointerX The X mouse cursor position at the time of the event
  32780. * @param pointerY The Y mouse cursor position at the time of the event
  32781. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32782. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32783. * @param additionalData additional data for the event
  32784. */
  32785. constructor(
  32786. /** The mesh or sprite that triggered the action */
  32787. source: any,
  32788. /** The X mouse cursor position at the time of the event */
  32789. pointerX: number,
  32790. /** The Y mouse cursor position at the time of the event */
  32791. pointerY: number,
  32792. /** The mesh that is currently pointed at (can be null) */
  32793. meshUnderPointer: Nullable<AbstractMesh>,
  32794. /** the original (browser) event that triggered the ActionEvent */
  32795. sourceEvent?: any,
  32796. /** additional data for the event */
  32797. additionalData?: any);
  32798. /**
  32799. * Helper function to auto-create an ActionEvent from a source mesh.
  32800. * @param source The source mesh that triggered the event
  32801. * @param evt The original (browser) event
  32802. * @param additionalData additional data for the event
  32803. * @returns the new ActionEvent
  32804. */
  32805. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32806. /**
  32807. * Helper function to auto-create an ActionEvent from a source sprite
  32808. * @param source The source sprite that triggered the event
  32809. * @param scene Scene associated with the sprite
  32810. * @param evt The original (browser) event
  32811. * @param additionalData additional data for the event
  32812. * @returns the new ActionEvent
  32813. */
  32814. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32815. /**
  32816. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32817. * @param scene the scene where the event occurred
  32818. * @param evt The original (browser) event
  32819. * @returns the new ActionEvent
  32820. */
  32821. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32822. /**
  32823. * Helper function to auto-create an ActionEvent from a primitive
  32824. * @param prim defines the target primitive
  32825. * @param pointerPos defines the pointer position
  32826. * @param evt The original (browser) event
  32827. * @param additionalData additional data for the event
  32828. * @returns the new ActionEvent
  32829. */
  32830. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32831. }
  32832. }
  32833. declare module "babylonjs/Actions/abstractActionManager" {
  32834. import { IDisposable } from "babylonjs/scene";
  32835. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  32836. import { IAction } from "babylonjs/Actions/action";
  32837. import { Nullable } from "babylonjs/types";
  32838. /**
  32839. * Abstract class used to decouple action Manager from scene and meshes.
  32840. * Do not instantiate.
  32841. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32842. */
  32843. export abstract class AbstractActionManager implements IDisposable {
  32844. /** Gets the list of active triggers */
  32845. static Triggers: {
  32846. [key: string]: number;
  32847. };
  32848. /** Gets the cursor to use when hovering items */
  32849. hoverCursor: string;
  32850. /** Gets the list of actions */
  32851. actions: IAction[];
  32852. /**
  32853. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32854. */
  32855. isRecursive: boolean;
  32856. /**
  32857. * Releases all associated resources
  32858. */
  32859. abstract dispose(): void;
  32860. /**
  32861. * Does this action manager has pointer triggers
  32862. */
  32863. abstract get hasPointerTriggers(): boolean;
  32864. /**
  32865. * Does this action manager has pick triggers
  32866. */
  32867. abstract get hasPickTriggers(): boolean;
  32868. /**
  32869. * Process a specific trigger
  32870. * @param trigger defines the trigger to process
  32871. * @param evt defines the event details to be processed
  32872. */
  32873. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32874. /**
  32875. * Does this action manager handles actions of any of the given triggers
  32876. * @param triggers defines the triggers to be tested
  32877. * @return a boolean indicating whether one (or more) of the triggers is handled
  32878. */
  32879. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32880. /**
  32881. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32882. * speed.
  32883. * @param triggerA defines the trigger to be tested
  32884. * @param triggerB defines the trigger to be tested
  32885. * @return a boolean indicating whether one (or more) of the triggers is handled
  32886. */
  32887. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32888. /**
  32889. * Does this action manager handles actions of a given trigger
  32890. * @param trigger defines the trigger to be tested
  32891. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32892. * @return whether the trigger is handled
  32893. */
  32894. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32895. /**
  32896. * Serialize this manager to a JSON object
  32897. * @param name defines the property name to store this manager
  32898. * @returns a JSON representation of this manager
  32899. */
  32900. abstract serialize(name: string): any;
  32901. /**
  32902. * Registers an action to this action manager
  32903. * @param action defines the action to be registered
  32904. * @return the action amended (prepared) after registration
  32905. */
  32906. abstract registerAction(action: IAction): Nullable<IAction>;
  32907. /**
  32908. * Unregisters an action to this action manager
  32909. * @param action defines the action to be unregistered
  32910. * @return a boolean indicating whether the action has been unregistered
  32911. */
  32912. abstract unregisterAction(action: IAction): Boolean;
  32913. /**
  32914. * Does exist one action manager with at least one trigger
  32915. **/
  32916. static get HasTriggers(): boolean;
  32917. /**
  32918. * Does exist one action manager with at least one pick trigger
  32919. **/
  32920. static get HasPickTriggers(): boolean;
  32921. /**
  32922. * Does exist one action manager that handles actions of a given trigger
  32923. * @param trigger defines the trigger to be tested
  32924. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32925. **/
  32926. static HasSpecificTrigger(trigger: number): boolean;
  32927. }
  32928. }
  32929. declare module "babylonjs/node" {
  32930. import { Scene } from "babylonjs/scene";
  32931. import { Nullable } from "babylonjs/types";
  32932. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  32933. import { Engine } from "babylonjs/Engines/engine";
  32934. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  32935. import { Observable } from "babylonjs/Misc/observable";
  32936. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32937. import { IInspectable } from "babylonjs/Misc/iInspectable";
  32938. import { Animatable } from "babylonjs/Animations/animatable";
  32939. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32940. import { Animation } from "babylonjs/Animations/animation";
  32941. import { AnimationRange } from "babylonjs/Animations/animationRange";
  32942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32943. /**
  32944. * Defines how a node can be built from a string name.
  32945. */
  32946. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32947. /**
  32948. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32949. */
  32950. export class Node implements IBehaviorAware<Node> {
  32951. /** @hidden */
  32952. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  32953. private static _NodeConstructors;
  32954. /**
  32955. * Add a new node constructor
  32956. * @param type defines the type name of the node to construct
  32957. * @param constructorFunc defines the constructor function
  32958. */
  32959. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32960. /**
  32961. * Returns a node constructor based on type name
  32962. * @param type defines the type name
  32963. * @param name defines the new node name
  32964. * @param scene defines the hosting scene
  32965. * @param options defines optional options to transmit to constructors
  32966. * @returns the new constructor or null
  32967. */
  32968. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32969. /**
  32970. * Gets or sets the name of the node
  32971. */
  32972. name: string;
  32973. /**
  32974. * Gets or sets the id of the node
  32975. */
  32976. id: string;
  32977. /**
  32978. * Gets or sets the unique id of the node
  32979. */
  32980. uniqueId: number;
  32981. /**
  32982. * Gets or sets a string used to store user defined state for the node
  32983. */
  32984. state: string;
  32985. /**
  32986. * Gets or sets an object used to store user defined information for the node
  32987. */
  32988. metadata: any;
  32989. /**
  32990. * For internal use only. Please do not use.
  32991. */
  32992. reservedDataStore: any;
  32993. /**
  32994. * List of inspectable custom properties (used by the Inspector)
  32995. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32996. */
  32997. inspectableCustomProperties: IInspectable[];
  32998. private _doNotSerialize;
  32999. /**
  33000. * Gets or sets a boolean used to define if the node must be serialized
  33001. */
  33002. get doNotSerialize(): boolean;
  33003. set doNotSerialize(value: boolean);
  33004. /** @hidden */
  33005. _isDisposed: boolean;
  33006. /**
  33007. * Gets a list of Animations associated with the node
  33008. */
  33009. animations: import("babylonjs/Animations/animation").Animation[];
  33010. protected _ranges: {
  33011. [name: string]: Nullable<AnimationRange>;
  33012. };
  33013. /**
  33014. * Callback raised when the node is ready to be used
  33015. */
  33016. onReady: Nullable<(node: Node) => void>;
  33017. private _isEnabled;
  33018. private _isParentEnabled;
  33019. private _isReady;
  33020. /** @hidden */
  33021. _currentRenderId: number;
  33022. private _parentUpdateId;
  33023. /** @hidden */
  33024. _childUpdateId: number;
  33025. /** @hidden */
  33026. _waitingParentId: Nullable<string>;
  33027. /** @hidden */
  33028. _scene: Scene;
  33029. /** @hidden */
  33030. _cache: any;
  33031. private _parentNode;
  33032. private _children;
  33033. /** @hidden */
  33034. _worldMatrix: Matrix;
  33035. /** @hidden */
  33036. _worldMatrixDeterminant: number;
  33037. /** @hidden */
  33038. _worldMatrixDeterminantIsDirty: boolean;
  33039. /** @hidden */
  33040. private _sceneRootNodesIndex;
  33041. /**
  33042. * Gets a boolean indicating if the node has been disposed
  33043. * @returns true if the node was disposed
  33044. */
  33045. isDisposed(): boolean;
  33046. /**
  33047. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33048. * @see https://doc.babylonjs.com/how_to/parenting
  33049. */
  33050. set parent(parent: Nullable<Node>);
  33051. get parent(): Nullable<Node>;
  33052. /** @hidden */
  33053. _addToSceneRootNodes(): void;
  33054. /** @hidden */
  33055. _removeFromSceneRootNodes(): void;
  33056. private _animationPropertiesOverride;
  33057. /**
  33058. * Gets or sets the animation properties override
  33059. */
  33060. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33061. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33062. /**
  33063. * Gets a string idenfifying the name of the class
  33064. * @returns "Node" string
  33065. */
  33066. getClassName(): string;
  33067. /** @hidden */
  33068. readonly _isNode: boolean;
  33069. /**
  33070. * An event triggered when the mesh is disposed
  33071. */
  33072. onDisposeObservable: Observable<Node>;
  33073. private _onDisposeObserver;
  33074. /**
  33075. * Sets a callback that will be raised when the node will be disposed
  33076. */
  33077. set onDispose(callback: () => void);
  33078. /**
  33079. * Creates a new Node
  33080. * @param name the name and id to be given to this node
  33081. * @param scene the scene this node will be added to
  33082. */
  33083. constructor(name: string, scene?: Nullable<Scene>);
  33084. /**
  33085. * Gets the scene of the node
  33086. * @returns a scene
  33087. */
  33088. getScene(): Scene;
  33089. /**
  33090. * Gets the engine of the node
  33091. * @returns a Engine
  33092. */
  33093. getEngine(): Engine;
  33094. private _behaviors;
  33095. /**
  33096. * Attach a behavior to the node
  33097. * @see http://doc.babylonjs.com/features/behaviour
  33098. * @param behavior defines the behavior to attach
  33099. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33100. * @returns the current Node
  33101. */
  33102. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33103. /**
  33104. * Remove an attached behavior
  33105. * @see http://doc.babylonjs.com/features/behaviour
  33106. * @param behavior defines the behavior to attach
  33107. * @returns the current Node
  33108. */
  33109. removeBehavior(behavior: Behavior<Node>): Node;
  33110. /**
  33111. * Gets the list of attached behaviors
  33112. * @see http://doc.babylonjs.com/features/behaviour
  33113. */
  33114. get behaviors(): Behavior<Node>[];
  33115. /**
  33116. * Gets an attached behavior by name
  33117. * @param name defines the name of the behavior to look for
  33118. * @see http://doc.babylonjs.com/features/behaviour
  33119. * @returns null if behavior was not found else the requested behavior
  33120. */
  33121. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33122. /**
  33123. * Returns the latest update of the World matrix
  33124. * @returns a Matrix
  33125. */
  33126. getWorldMatrix(): Matrix;
  33127. /** @hidden */
  33128. _getWorldMatrixDeterminant(): number;
  33129. /**
  33130. * Returns directly the latest state of the mesh World matrix.
  33131. * A Matrix is returned.
  33132. */
  33133. get worldMatrixFromCache(): Matrix;
  33134. /** @hidden */
  33135. _initCache(): void;
  33136. /** @hidden */
  33137. updateCache(force?: boolean): void;
  33138. /** @hidden */
  33139. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33140. /** @hidden */
  33141. _updateCache(ignoreParentClass?: boolean): void;
  33142. /** @hidden */
  33143. _isSynchronized(): boolean;
  33144. /** @hidden */
  33145. _markSyncedWithParent(): void;
  33146. /** @hidden */
  33147. isSynchronizedWithParent(): boolean;
  33148. /** @hidden */
  33149. isSynchronized(): boolean;
  33150. /**
  33151. * Is this node ready to be used/rendered
  33152. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33153. * @return true if the node is ready
  33154. */
  33155. isReady(completeCheck?: boolean): boolean;
  33156. /**
  33157. * Is this node enabled?
  33158. * 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
  33159. * @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
  33160. * @return whether this node (and its parent) is enabled
  33161. */
  33162. isEnabled(checkAncestors?: boolean): boolean;
  33163. /** @hidden */
  33164. protected _syncParentEnabledState(): void;
  33165. /**
  33166. * Set the enabled state of this node
  33167. * @param value defines the new enabled state
  33168. */
  33169. setEnabled(value: boolean): void;
  33170. /**
  33171. * Is this node a descendant of the given node?
  33172. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33173. * @param ancestor defines the parent node to inspect
  33174. * @returns a boolean indicating if this node is a descendant of the given node
  33175. */
  33176. isDescendantOf(ancestor: Node): boolean;
  33177. /** @hidden */
  33178. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33179. /**
  33180. * Will return all nodes that have this node as ascendant
  33181. * @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
  33182. * @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
  33183. * @return all children nodes of all types
  33184. */
  33185. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33186. /**
  33187. * Get all child-meshes of this node
  33188. * @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)
  33189. * @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
  33190. * @returns an array of AbstractMesh
  33191. */
  33192. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33193. /**
  33194. * Get all direct children of this node
  33195. * @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
  33196. * @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)
  33197. * @returns an array of Node
  33198. */
  33199. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33200. /** @hidden */
  33201. _setReady(state: boolean): void;
  33202. /**
  33203. * Get an animation by name
  33204. * @param name defines the name of the animation to look for
  33205. * @returns null if not found else the requested animation
  33206. */
  33207. getAnimationByName(name: string): Nullable<Animation>;
  33208. /**
  33209. * Creates an animation range for this node
  33210. * @param name defines the name of the range
  33211. * @param from defines the starting key
  33212. * @param to defines the end key
  33213. */
  33214. createAnimationRange(name: string, from: number, to: number): void;
  33215. /**
  33216. * Delete a specific animation range
  33217. * @param name defines the name of the range to delete
  33218. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33219. */
  33220. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33221. /**
  33222. * Get an animation range by name
  33223. * @param name defines the name of the animation range to look for
  33224. * @returns null if not found else the requested animation range
  33225. */
  33226. getAnimationRange(name: string): Nullable<AnimationRange>;
  33227. /**
  33228. * Gets the list of all animation ranges defined on this node
  33229. * @returns an array
  33230. */
  33231. getAnimationRanges(): Nullable<AnimationRange>[];
  33232. /**
  33233. * Will start the animation sequence
  33234. * @param name defines the range frames for animation sequence
  33235. * @param loop defines if the animation should loop (false by default)
  33236. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33237. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33238. * @returns the object created for this animation. If range does not exist, it will return null
  33239. */
  33240. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33241. /**
  33242. * Serialize animation ranges into a JSON compatible object
  33243. * @returns serialization object
  33244. */
  33245. serializeAnimationRanges(): any;
  33246. /**
  33247. * Computes the world matrix of the node
  33248. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33249. * @returns the world matrix
  33250. */
  33251. computeWorldMatrix(force?: boolean): Matrix;
  33252. /**
  33253. * Releases resources associated with this node.
  33254. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33255. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33256. */
  33257. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33258. /**
  33259. * Parse animation range data from a serialization object and store them into a given node
  33260. * @param node defines where to store the animation ranges
  33261. * @param parsedNode defines the serialization object to read data from
  33262. * @param scene defines the hosting scene
  33263. */
  33264. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33265. /**
  33266. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33267. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33268. * @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
  33269. * @returns the new bounding vectors
  33270. */
  33271. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33272. min: Vector3;
  33273. max: Vector3;
  33274. };
  33275. }
  33276. }
  33277. declare module "babylonjs/Animations/animation" {
  33278. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  33279. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  33280. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33281. import { Nullable } from "babylonjs/types";
  33282. import { Scene } from "babylonjs/scene";
  33283. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  33284. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33285. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  33286. import { Node } from "babylonjs/node";
  33287. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33288. import { Size } from "babylonjs/Maths/math.size";
  33289. import { Animatable } from "babylonjs/Animations/animatable";
  33290. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  33291. /**
  33292. * @hidden
  33293. */
  33294. export class _IAnimationState {
  33295. key: number;
  33296. repeatCount: number;
  33297. workValue?: any;
  33298. loopMode?: number;
  33299. offsetValue?: any;
  33300. highLimitValue?: any;
  33301. }
  33302. /**
  33303. * Class used to store any kind of animation
  33304. */
  33305. export class Animation {
  33306. /**Name of the animation */
  33307. name: string;
  33308. /**Property to animate */
  33309. targetProperty: string;
  33310. /**The frames per second of the animation */
  33311. framePerSecond: number;
  33312. /**The data type of the animation */
  33313. dataType: number;
  33314. /**The loop mode of the animation */
  33315. loopMode?: number | undefined;
  33316. /**Specifies if blending should be enabled */
  33317. enableBlending?: boolean | undefined;
  33318. /**
  33319. * Use matrix interpolation instead of using direct key value when animating matrices
  33320. */
  33321. static AllowMatricesInterpolation: boolean;
  33322. /**
  33323. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33324. */
  33325. static AllowMatrixDecomposeForInterpolation: boolean;
  33326. /**
  33327. * Stores the key frames of the animation
  33328. */
  33329. private _keys;
  33330. /**
  33331. * Stores the easing function of the animation
  33332. */
  33333. private _easingFunction;
  33334. /**
  33335. * @hidden Internal use only
  33336. */
  33337. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  33338. /**
  33339. * The set of event that will be linked to this animation
  33340. */
  33341. private _events;
  33342. /**
  33343. * Stores an array of target property paths
  33344. */
  33345. targetPropertyPath: string[];
  33346. /**
  33347. * Stores the blending speed of the animation
  33348. */
  33349. blendingSpeed: number;
  33350. /**
  33351. * Stores the animation ranges for the animation
  33352. */
  33353. private _ranges;
  33354. /**
  33355. * @hidden Internal use
  33356. */
  33357. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33358. /**
  33359. * Sets up an animation
  33360. * @param property The property to animate
  33361. * @param animationType The animation type to apply
  33362. * @param framePerSecond The frames per second of the animation
  33363. * @param easingFunction The easing function used in the animation
  33364. * @returns The created animation
  33365. */
  33366. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33367. /**
  33368. * Create and start an animation on a node
  33369. * @param name defines the name of the global animation that will be run on all nodes
  33370. * @param node defines the root node where the animation will take place
  33371. * @param targetProperty defines property to animate
  33372. * @param framePerSecond defines the number of frame per second yo use
  33373. * @param totalFrame defines the number of frames in total
  33374. * @param from defines the initial value
  33375. * @param to defines the final value
  33376. * @param loopMode defines which loop mode you want to use (off by default)
  33377. * @param easingFunction defines the easing function to use (linear by default)
  33378. * @param onAnimationEnd defines the callback to call when animation end
  33379. * @returns the animatable created for this animation
  33380. */
  33381. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33382. /**
  33383. * Create and start an animation on a node and its descendants
  33384. * @param name defines the name of the global animation that will be run on all nodes
  33385. * @param node defines the root node where the animation will take place
  33386. * @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
  33387. * @param targetProperty defines property to animate
  33388. * @param framePerSecond defines the number of frame per second to use
  33389. * @param totalFrame defines the number of frames in total
  33390. * @param from defines the initial value
  33391. * @param to defines the final value
  33392. * @param loopMode defines which loop mode you want to use (off by default)
  33393. * @param easingFunction defines the easing function to use (linear by default)
  33394. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33395. * @returns the list of animatables created for all nodes
  33396. * @example https://www.babylonjs-playground.com/#MH0VLI
  33397. */
  33398. 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[]>;
  33399. /**
  33400. * Creates a new animation, merges it with the existing animations and starts it
  33401. * @param name Name of the animation
  33402. * @param node Node which contains the scene that begins the animations
  33403. * @param targetProperty Specifies which property to animate
  33404. * @param framePerSecond The frames per second of the animation
  33405. * @param totalFrame The total number of frames
  33406. * @param from The frame at the beginning of the animation
  33407. * @param to The frame at the end of the animation
  33408. * @param loopMode Specifies the loop mode of the animation
  33409. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33410. * @param onAnimationEnd Callback to run once the animation is complete
  33411. * @returns Nullable animation
  33412. */
  33413. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33414. /**
  33415. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33416. * @param sourceAnimation defines the Animation containing keyframes to convert
  33417. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33418. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33419. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33420. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33421. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33422. */
  33423. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33424. /**
  33425. * Transition property of an host to the target Value
  33426. * @param property The property to transition
  33427. * @param targetValue The target Value of the property
  33428. * @param host The object where the property to animate belongs
  33429. * @param scene Scene used to run the animation
  33430. * @param frameRate Framerate (in frame/s) to use
  33431. * @param transition The transition type we want to use
  33432. * @param duration The duration of the animation, in milliseconds
  33433. * @param onAnimationEnd Callback trigger at the end of the animation
  33434. * @returns Nullable animation
  33435. */
  33436. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33437. /**
  33438. * Return the array of runtime animations currently using this animation
  33439. */
  33440. get runtimeAnimations(): RuntimeAnimation[];
  33441. /**
  33442. * Specifies if any of the runtime animations are currently running
  33443. */
  33444. get hasRunningRuntimeAnimations(): boolean;
  33445. /**
  33446. * Initializes the animation
  33447. * @param name Name of the animation
  33448. * @param targetProperty Property to animate
  33449. * @param framePerSecond The frames per second of the animation
  33450. * @param dataType The data type of the animation
  33451. * @param loopMode The loop mode of the animation
  33452. * @param enableBlending Specifies if blending should be enabled
  33453. */
  33454. constructor(
  33455. /**Name of the animation */
  33456. name: string,
  33457. /**Property to animate */
  33458. targetProperty: string,
  33459. /**The frames per second of the animation */
  33460. framePerSecond: number,
  33461. /**The data type of the animation */
  33462. dataType: number,
  33463. /**The loop mode of the animation */
  33464. loopMode?: number | undefined,
  33465. /**Specifies if blending should be enabled */
  33466. enableBlending?: boolean | undefined);
  33467. /**
  33468. * Converts the animation to a string
  33469. * @param fullDetails support for multiple levels of logging within scene loading
  33470. * @returns String form of the animation
  33471. */
  33472. toString(fullDetails?: boolean): string;
  33473. /**
  33474. * Add an event to this animation
  33475. * @param event Event to add
  33476. */
  33477. addEvent(event: AnimationEvent): void;
  33478. /**
  33479. * Remove all events found at the given frame
  33480. * @param frame The frame to remove events from
  33481. */
  33482. removeEvents(frame: number): void;
  33483. /**
  33484. * Retrieves all the events from the animation
  33485. * @returns Events from the animation
  33486. */
  33487. getEvents(): AnimationEvent[];
  33488. /**
  33489. * Creates an animation range
  33490. * @param name Name of the animation range
  33491. * @param from Starting frame of the animation range
  33492. * @param to Ending frame of the animation
  33493. */
  33494. createRange(name: string, from: number, to: number): void;
  33495. /**
  33496. * Deletes an animation range by name
  33497. * @param name Name of the animation range to delete
  33498. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33499. */
  33500. deleteRange(name: string, deleteFrames?: boolean): void;
  33501. /**
  33502. * Gets the animation range by name, or null if not defined
  33503. * @param name Name of the animation range
  33504. * @returns Nullable animation range
  33505. */
  33506. getRange(name: string): Nullable<AnimationRange>;
  33507. /**
  33508. * Gets the key frames from the animation
  33509. * @returns The key frames of the animation
  33510. */
  33511. getKeys(): Array<IAnimationKey>;
  33512. /**
  33513. * Gets the highest frame rate of the animation
  33514. * @returns Highest frame rate of the animation
  33515. */
  33516. getHighestFrame(): number;
  33517. /**
  33518. * Gets the easing function of the animation
  33519. * @returns Easing function of the animation
  33520. */
  33521. getEasingFunction(): IEasingFunction;
  33522. /**
  33523. * Sets the easing function of the animation
  33524. * @param easingFunction A custom mathematical formula for animation
  33525. */
  33526. setEasingFunction(easingFunction: EasingFunction): void;
  33527. /**
  33528. * Interpolates a scalar linearly
  33529. * @param startValue Start value of the animation curve
  33530. * @param endValue End value of the animation curve
  33531. * @param gradient Scalar amount to interpolate
  33532. * @returns Interpolated scalar value
  33533. */
  33534. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33535. /**
  33536. * Interpolates a scalar cubically
  33537. * @param startValue Start value of the animation curve
  33538. * @param outTangent End tangent of the animation
  33539. * @param endValue End value of the animation curve
  33540. * @param inTangent Start tangent of the animation curve
  33541. * @param gradient Scalar amount to interpolate
  33542. * @returns Interpolated scalar value
  33543. */
  33544. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33545. /**
  33546. * Interpolates a quaternion using a spherical linear interpolation
  33547. * @param startValue Start value of the animation curve
  33548. * @param endValue End value of the animation curve
  33549. * @param gradient Scalar amount to interpolate
  33550. * @returns Interpolated quaternion value
  33551. */
  33552. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33553. /**
  33554. * Interpolates a quaternion cubically
  33555. * @param startValue Start value of the animation curve
  33556. * @param outTangent End tangent of the animation curve
  33557. * @param endValue End value of the animation curve
  33558. * @param inTangent Start tangent of the animation curve
  33559. * @param gradient Scalar amount to interpolate
  33560. * @returns Interpolated quaternion value
  33561. */
  33562. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33563. /**
  33564. * Interpolates a Vector3 linearl
  33565. * @param startValue Start value of the animation curve
  33566. * @param endValue End value of the animation curve
  33567. * @param gradient Scalar amount to interpolate
  33568. * @returns Interpolated scalar value
  33569. */
  33570. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33571. /**
  33572. * Interpolates a Vector3 cubically
  33573. * @param startValue Start value of the animation curve
  33574. * @param outTangent End tangent of the animation
  33575. * @param endValue End value of the animation curve
  33576. * @param inTangent Start tangent of the animation curve
  33577. * @param gradient Scalar amount to interpolate
  33578. * @returns InterpolatedVector3 value
  33579. */
  33580. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33581. /**
  33582. * Interpolates a Vector2 linearly
  33583. * @param startValue Start value of the animation curve
  33584. * @param endValue End value of the animation curve
  33585. * @param gradient Scalar amount to interpolate
  33586. * @returns Interpolated Vector2 value
  33587. */
  33588. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33589. /**
  33590. * Interpolates a Vector2 cubically
  33591. * @param startValue Start value of the animation curve
  33592. * @param outTangent End tangent of the animation
  33593. * @param endValue End value of the animation curve
  33594. * @param inTangent Start tangent of the animation curve
  33595. * @param gradient Scalar amount to interpolate
  33596. * @returns Interpolated Vector2 value
  33597. */
  33598. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33599. /**
  33600. * Interpolates a size linearly
  33601. * @param startValue Start value of the animation curve
  33602. * @param endValue End value of the animation curve
  33603. * @param gradient Scalar amount to interpolate
  33604. * @returns Interpolated Size value
  33605. */
  33606. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33607. /**
  33608. * Interpolates a Color3 linearly
  33609. * @param startValue Start value of the animation curve
  33610. * @param endValue End value of the animation curve
  33611. * @param gradient Scalar amount to interpolate
  33612. * @returns Interpolated Color3 value
  33613. */
  33614. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33615. /**
  33616. * Interpolates a Color4 linearly
  33617. * @param startValue Start value of the animation curve
  33618. * @param endValue End value of the animation curve
  33619. * @param gradient Scalar amount to interpolate
  33620. * @returns Interpolated Color3 value
  33621. */
  33622. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33623. /**
  33624. * @hidden Internal use only
  33625. */
  33626. _getKeyValue(value: any): any;
  33627. /**
  33628. * @hidden Internal use only
  33629. */
  33630. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33631. /**
  33632. * Defines the function to use to interpolate matrices
  33633. * @param startValue defines the start matrix
  33634. * @param endValue defines the end matrix
  33635. * @param gradient defines the gradient between both matrices
  33636. * @param result defines an optional target matrix where to store the interpolation
  33637. * @returns the interpolated matrix
  33638. */
  33639. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33640. /**
  33641. * Makes a copy of the animation
  33642. * @returns Cloned animation
  33643. */
  33644. clone(): Animation;
  33645. /**
  33646. * Sets the key frames of the animation
  33647. * @param values The animation key frames to set
  33648. */
  33649. setKeys(values: Array<IAnimationKey>): void;
  33650. /**
  33651. * Serializes the animation to an object
  33652. * @returns Serialized object
  33653. */
  33654. serialize(): any;
  33655. /**
  33656. * Float animation type
  33657. */
  33658. static readonly ANIMATIONTYPE_FLOAT: number;
  33659. /**
  33660. * Vector3 animation type
  33661. */
  33662. static readonly ANIMATIONTYPE_VECTOR3: number;
  33663. /**
  33664. * Quaternion animation type
  33665. */
  33666. static readonly ANIMATIONTYPE_QUATERNION: number;
  33667. /**
  33668. * Matrix animation type
  33669. */
  33670. static readonly ANIMATIONTYPE_MATRIX: number;
  33671. /**
  33672. * Color3 animation type
  33673. */
  33674. static readonly ANIMATIONTYPE_COLOR3: number;
  33675. /**
  33676. * Color3 animation type
  33677. */
  33678. static readonly ANIMATIONTYPE_COLOR4: number;
  33679. /**
  33680. * Vector2 animation type
  33681. */
  33682. static readonly ANIMATIONTYPE_VECTOR2: number;
  33683. /**
  33684. * Size animation type
  33685. */
  33686. static readonly ANIMATIONTYPE_SIZE: number;
  33687. /**
  33688. * Relative Loop Mode
  33689. */
  33690. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33691. /**
  33692. * Cycle Loop Mode
  33693. */
  33694. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33695. /**
  33696. * Constant Loop Mode
  33697. */
  33698. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33699. /** @hidden */
  33700. static _UniversalLerp(left: any, right: any, amount: number): any;
  33701. /**
  33702. * Parses an animation object and creates an animation
  33703. * @param parsedAnimation Parsed animation object
  33704. * @returns Animation object
  33705. */
  33706. static Parse(parsedAnimation: any): Animation;
  33707. /**
  33708. * Appends the serialized animations from the source animations
  33709. * @param source Source containing the animations
  33710. * @param destination Target to store the animations
  33711. */
  33712. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33713. }
  33714. }
  33715. declare module "babylonjs/Animations/animatable.interface" {
  33716. import { Nullable } from "babylonjs/types";
  33717. import { Animation } from "babylonjs/Animations/animation";
  33718. /**
  33719. * Interface containing an array of animations
  33720. */
  33721. export interface IAnimatable {
  33722. /**
  33723. * Array of animations
  33724. */
  33725. animations: Nullable<Array<Animation>>;
  33726. }
  33727. }
  33728. declare module "babylonjs/Misc/decorators" {
  33729. import { Nullable } from "babylonjs/types";
  33730. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33731. import { Scene } from "babylonjs/scene";
  33732. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33733. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33734. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33735. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33736. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33737. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33738. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33739. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33740. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33741. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33742. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33743. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33744. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33745. /**
  33746. * Decorator used to define property that can be serialized as reference to a camera
  33747. * @param sourceName defines the name of the property to decorate
  33748. */
  33749. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33750. /**
  33751. * Class used to help serialization objects
  33752. */
  33753. export class SerializationHelper {
  33754. /** @hidden */
  33755. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  33756. /** @hidden */
  33757. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  33758. /** @hidden */
  33759. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  33760. /** @hidden */
  33761. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  33762. /**
  33763. * Appends the serialized animations from the source animations
  33764. * @param source Source containing the animations
  33765. * @param destination Target to store the animations
  33766. */
  33767. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33768. /**
  33769. * Static function used to serialized a specific entity
  33770. * @param entity defines the entity to serialize
  33771. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33772. * @returns a JSON compatible object representing the serialization of the entity
  33773. */
  33774. static Serialize<T>(entity: T, serializationObject?: any): any;
  33775. /**
  33776. * Creates a new entity from a serialization data object
  33777. * @param creationFunction defines a function used to instanciated the new entity
  33778. * @param source defines the source serialization data
  33779. * @param scene defines the hosting scene
  33780. * @param rootUrl defines the root url for resources
  33781. * @returns a new entity
  33782. */
  33783. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33784. /**
  33785. * Clones an object
  33786. * @param creationFunction defines the function used to instanciate the new object
  33787. * @param source defines the source object
  33788. * @returns the cloned object
  33789. */
  33790. static Clone<T>(creationFunction: () => T, source: T): T;
  33791. /**
  33792. * Instanciates a new object based on a source one (some data will be shared between both object)
  33793. * @param creationFunction defines the function used to instanciate the new object
  33794. * @param source defines the source object
  33795. * @returns the new object
  33796. */
  33797. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33798. }
  33799. }
  33800. declare module "babylonjs/Materials/Textures/baseTexture" {
  33801. import { Observable } from "babylonjs/Misc/observable";
  33802. import { Nullable } from "babylonjs/types";
  33803. import { Scene } from "babylonjs/scene";
  33804. import { Matrix } from "babylonjs/Maths/math.vector";
  33805. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33806. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33807. import { ISize } from "babylonjs/Maths/math.size";
  33808. import "babylonjs/Misc/fileTools";
  33809. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33810. /**
  33811. * Base class of all the textures in babylon.
  33812. * It groups all the common properties the materials, post process, lights... might need
  33813. * in order to make a correct use of the texture.
  33814. */
  33815. export class BaseTexture implements IAnimatable {
  33816. /**
  33817. * Default anisotropic filtering level for the application.
  33818. * It is set to 4 as a good tradeoff between perf and quality.
  33819. */
  33820. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33821. /**
  33822. * Gets or sets the unique id of the texture
  33823. */
  33824. uniqueId: number;
  33825. /**
  33826. * Define the name of the texture.
  33827. */
  33828. name: string;
  33829. /**
  33830. * Gets or sets an object used to store user defined information.
  33831. */
  33832. metadata: any;
  33833. /**
  33834. * For internal use only. Please do not use.
  33835. */
  33836. reservedDataStore: any;
  33837. private _hasAlpha;
  33838. /**
  33839. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33840. */
  33841. set hasAlpha(value: boolean);
  33842. get hasAlpha(): boolean;
  33843. /**
  33844. * Defines if the alpha value should be determined via the rgb values.
  33845. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33846. */
  33847. getAlphaFromRGB: boolean;
  33848. /**
  33849. * Intensity or strength of the texture.
  33850. * It is commonly used by materials to fine tune the intensity of the texture
  33851. */
  33852. level: number;
  33853. /**
  33854. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33855. * This is part of the texture as textures usually maps to one uv set.
  33856. */
  33857. coordinatesIndex: number;
  33858. private _coordinatesMode;
  33859. /**
  33860. * How a texture is mapped.
  33861. *
  33862. * | Value | Type | Description |
  33863. * | ----- | ----------------------------------- | ----------- |
  33864. * | 0 | EXPLICIT_MODE | |
  33865. * | 1 | SPHERICAL_MODE | |
  33866. * | 2 | PLANAR_MODE | |
  33867. * | 3 | CUBIC_MODE | |
  33868. * | 4 | PROJECTION_MODE | |
  33869. * | 5 | SKYBOX_MODE | |
  33870. * | 6 | INVCUBIC_MODE | |
  33871. * | 7 | EQUIRECTANGULAR_MODE | |
  33872. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33873. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33874. */
  33875. set coordinatesMode(value: number);
  33876. get coordinatesMode(): number;
  33877. /**
  33878. * | Value | Type | Description |
  33879. * | ----- | ------------------ | ----------- |
  33880. * | 0 | CLAMP_ADDRESSMODE | |
  33881. * | 1 | WRAP_ADDRESSMODE | |
  33882. * | 2 | MIRROR_ADDRESSMODE | |
  33883. */
  33884. wrapU: number;
  33885. /**
  33886. * | Value | Type | Description |
  33887. * | ----- | ------------------ | ----------- |
  33888. * | 0 | CLAMP_ADDRESSMODE | |
  33889. * | 1 | WRAP_ADDRESSMODE | |
  33890. * | 2 | MIRROR_ADDRESSMODE | |
  33891. */
  33892. wrapV: number;
  33893. /**
  33894. * | Value | Type | Description |
  33895. * | ----- | ------------------ | ----------- |
  33896. * | 0 | CLAMP_ADDRESSMODE | |
  33897. * | 1 | WRAP_ADDRESSMODE | |
  33898. * | 2 | MIRROR_ADDRESSMODE | |
  33899. */
  33900. wrapR: number;
  33901. /**
  33902. * With compliant hardware and browser (supporting anisotropic filtering)
  33903. * this defines the level of anisotropic filtering in the texture.
  33904. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33905. */
  33906. anisotropicFilteringLevel: number;
  33907. /**
  33908. * Define if the texture is a cube texture or if false a 2d texture.
  33909. */
  33910. get isCube(): boolean;
  33911. set isCube(value: boolean);
  33912. /**
  33913. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33914. */
  33915. get is3D(): boolean;
  33916. set is3D(value: boolean);
  33917. /**
  33918. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33919. */
  33920. get is2DArray(): boolean;
  33921. set is2DArray(value: boolean);
  33922. /**
  33923. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33924. * HDR texture are usually stored in linear space.
  33925. * This only impacts the PBR and Background materials
  33926. */
  33927. gammaSpace: boolean;
  33928. /**
  33929. * Gets or sets whether or not the texture contains RGBD data.
  33930. */
  33931. get isRGBD(): boolean;
  33932. set isRGBD(value: boolean);
  33933. /**
  33934. * Is Z inverted in the texture (useful in a cube texture).
  33935. */
  33936. invertZ: boolean;
  33937. /**
  33938. * Are mip maps generated for this texture or not.
  33939. */
  33940. get noMipmap(): boolean;
  33941. /**
  33942. * @hidden
  33943. */
  33944. lodLevelInAlpha: boolean;
  33945. /**
  33946. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33947. */
  33948. get lodGenerationOffset(): number;
  33949. set lodGenerationOffset(value: number);
  33950. /**
  33951. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33952. */
  33953. get lodGenerationScale(): number;
  33954. set lodGenerationScale(value: number);
  33955. /**
  33956. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33957. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33958. * average roughness values.
  33959. */
  33960. get linearSpecularLOD(): boolean;
  33961. set linearSpecularLOD(value: boolean);
  33962. /**
  33963. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33964. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33965. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33966. */
  33967. get irradianceTexture(): Nullable<BaseTexture>;
  33968. set irradianceTexture(value: Nullable<BaseTexture>);
  33969. /**
  33970. * Define if the texture is a render target.
  33971. */
  33972. isRenderTarget: boolean;
  33973. /**
  33974. * Define the unique id of the texture in the scene.
  33975. */
  33976. get uid(): string;
  33977. /** @hidden */
  33978. _prefiltered: boolean;
  33979. /**
  33980. * Return a string representation of the texture.
  33981. * @returns the texture as a string
  33982. */
  33983. toString(): string;
  33984. /**
  33985. * Get the class name of the texture.
  33986. * @returns "BaseTexture"
  33987. */
  33988. getClassName(): string;
  33989. /**
  33990. * Define the list of animation attached to the texture.
  33991. */
  33992. animations: import("babylonjs/Animations/animation").Animation[];
  33993. /**
  33994. * An event triggered when the texture is disposed.
  33995. */
  33996. onDisposeObservable: Observable<BaseTexture>;
  33997. private _onDisposeObserver;
  33998. /**
  33999. * Callback triggered when the texture has been disposed.
  34000. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34001. */
  34002. set onDispose(callback: () => void);
  34003. /**
  34004. * Define the current state of the loading sequence when in delayed load mode.
  34005. */
  34006. delayLoadState: number;
  34007. private _scene;
  34008. private _engine;
  34009. /** @hidden */
  34010. _texture: Nullable<InternalTexture>;
  34011. private _uid;
  34012. /**
  34013. * Define if the texture is preventinga material to render or not.
  34014. * If not and the texture is not ready, the engine will use a default black texture instead.
  34015. */
  34016. get isBlocking(): boolean;
  34017. /**
  34018. * Instantiates a new BaseTexture.
  34019. * Base class of all the textures in babylon.
  34020. * It groups all the common properties the materials, post process, lights... might need
  34021. * in order to make a correct use of the texture.
  34022. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34023. */
  34024. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34025. /**
  34026. * Get the scene the texture belongs to.
  34027. * @returns the scene or null if undefined
  34028. */
  34029. getScene(): Nullable<Scene>;
  34030. /** @hidden */
  34031. protected _getEngine(): Nullable<ThinEngine>;
  34032. /**
  34033. * Get the texture transform matrix used to offset tile the texture for istance.
  34034. * @returns the transformation matrix
  34035. */
  34036. getTextureMatrix(): Matrix;
  34037. /**
  34038. * Get the texture reflection matrix used to rotate/transform the reflection.
  34039. * @returns the reflection matrix
  34040. */
  34041. getReflectionTextureMatrix(): Matrix;
  34042. /**
  34043. * Get the underlying lower level texture from Babylon.
  34044. * @returns the insternal texture
  34045. */
  34046. getInternalTexture(): Nullable<InternalTexture>;
  34047. /**
  34048. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34049. * @returns true if ready or not blocking
  34050. */
  34051. isReadyOrNotBlocking(): boolean;
  34052. /**
  34053. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34054. * @returns true if fully ready
  34055. */
  34056. isReady(): boolean;
  34057. private _cachedSize;
  34058. /**
  34059. * Get the size of the texture.
  34060. * @returns the texture size.
  34061. */
  34062. getSize(): ISize;
  34063. /**
  34064. * Get the base size of the texture.
  34065. * It can be different from the size if the texture has been resized for POT for instance
  34066. * @returns the base size
  34067. */
  34068. getBaseSize(): ISize;
  34069. /**
  34070. * Update the sampling mode of the texture.
  34071. * Default is Trilinear mode.
  34072. *
  34073. * | Value | Type | Description |
  34074. * | ----- | ------------------ | ----------- |
  34075. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34076. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34077. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34078. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34079. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34080. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34081. * | 7 | NEAREST_LINEAR | |
  34082. * | 8 | NEAREST_NEAREST | |
  34083. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34084. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34085. * | 11 | LINEAR_LINEAR | |
  34086. * | 12 | LINEAR_NEAREST | |
  34087. *
  34088. * > _mag_: magnification filter (close to the viewer)
  34089. * > _min_: minification filter (far from the viewer)
  34090. * > _mip_: filter used between mip map levels
  34091. *@param samplingMode Define the new sampling mode of the texture
  34092. */
  34093. updateSamplingMode(samplingMode: number): void;
  34094. /**
  34095. * Scales the texture if is `canRescale()`
  34096. * @param ratio the resize factor we want to use to rescale
  34097. */
  34098. scale(ratio: number): void;
  34099. /**
  34100. * Get if the texture can rescale.
  34101. */
  34102. get canRescale(): boolean;
  34103. /** @hidden */
  34104. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34105. /** @hidden */
  34106. _rebuild(): void;
  34107. /**
  34108. * Triggers the load sequence in delayed load mode.
  34109. */
  34110. delayLoad(): void;
  34111. /**
  34112. * Clones the texture.
  34113. * @returns the cloned texture
  34114. */
  34115. clone(): Nullable<BaseTexture>;
  34116. /**
  34117. * Get the texture underlying type (INT, FLOAT...)
  34118. */
  34119. get textureType(): number;
  34120. /**
  34121. * Get the texture underlying format (RGB, RGBA...)
  34122. */
  34123. get textureFormat(): number;
  34124. /**
  34125. * Indicates that textures need to be re-calculated for all materials
  34126. */
  34127. protected _markAllSubMeshesAsTexturesDirty(): void;
  34128. /**
  34129. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34130. * This will returns an RGBA array buffer containing either in values (0-255) or
  34131. * float values (0-1) depending of the underlying buffer type.
  34132. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34133. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34134. * @param buffer defines a user defined buffer to fill with data (can be null)
  34135. * @returns The Array buffer containing the pixels data.
  34136. */
  34137. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34138. /**
  34139. * Release and destroy the underlying lower level texture aka internalTexture.
  34140. */
  34141. releaseInternalTexture(): void;
  34142. /** @hidden */
  34143. get _lodTextureHigh(): Nullable<BaseTexture>;
  34144. /** @hidden */
  34145. get _lodTextureMid(): Nullable<BaseTexture>;
  34146. /** @hidden */
  34147. get _lodTextureLow(): Nullable<BaseTexture>;
  34148. /**
  34149. * Dispose the texture and release its associated resources.
  34150. */
  34151. dispose(): void;
  34152. /**
  34153. * Serialize the texture into a JSON representation that can be parsed later on.
  34154. * @returns the JSON representation of the texture
  34155. */
  34156. serialize(): any;
  34157. /**
  34158. * Helper function to be called back once a list of texture contains only ready textures.
  34159. * @param textures Define the list of textures to wait for
  34160. * @param callback Define the callback triggered once the entire list will be ready
  34161. */
  34162. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34163. private static _isScene;
  34164. }
  34165. }
  34166. declare module "babylonjs/Materials/effect" {
  34167. import { Observable } from "babylonjs/Misc/observable";
  34168. import { Nullable } from "babylonjs/types";
  34169. import { IDisposable } from "babylonjs/scene";
  34170. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34171. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34172. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  34173. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34174. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  34175. import { Engine } from "babylonjs/Engines/engine";
  34176. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34177. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34178. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34179. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34180. /**
  34181. * Options to be used when creating an effect.
  34182. */
  34183. export interface IEffectCreationOptions {
  34184. /**
  34185. * Atrributes that will be used in the shader.
  34186. */
  34187. attributes: string[];
  34188. /**
  34189. * Uniform varible names that will be set in the shader.
  34190. */
  34191. uniformsNames: string[];
  34192. /**
  34193. * Uniform buffer variable names that will be set in the shader.
  34194. */
  34195. uniformBuffersNames: string[];
  34196. /**
  34197. * Sampler texture variable names that will be set in the shader.
  34198. */
  34199. samplers: string[];
  34200. /**
  34201. * Define statements that will be set in the shader.
  34202. */
  34203. defines: any;
  34204. /**
  34205. * Possible fallbacks for this effect to improve performance when needed.
  34206. */
  34207. fallbacks: Nullable<IEffectFallbacks>;
  34208. /**
  34209. * Callback that will be called when the shader is compiled.
  34210. */
  34211. onCompiled: Nullable<(effect: Effect) => void>;
  34212. /**
  34213. * Callback that will be called if an error occurs during shader compilation.
  34214. */
  34215. onError: Nullable<(effect: Effect, errors: string) => void>;
  34216. /**
  34217. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34218. */
  34219. indexParameters?: any;
  34220. /**
  34221. * Max number of lights that can be used in the shader.
  34222. */
  34223. maxSimultaneousLights?: number;
  34224. /**
  34225. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34226. */
  34227. transformFeedbackVaryings?: Nullable<string[]>;
  34228. /**
  34229. * 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
  34230. */
  34231. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34232. }
  34233. /**
  34234. * Effect containing vertex and fragment shader that can be executed on an object.
  34235. */
  34236. export class Effect implements IDisposable {
  34237. /**
  34238. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34239. */
  34240. static ShadersRepository: string;
  34241. /**
  34242. * Enable logging of the shader code when a compilation error occurs
  34243. */
  34244. static LogShaderCodeOnCompilationError: boolean;
  34245. /**
  34246. * Name of the effect.
  34247. */
  34248. name: any;
  34249. /**
  34250. * String container all the define statements that should be set on the shader.
  34251. */
  34252. defines: string;
  34253. /**
  34254. * Callback that will be called when the shader is compiled.
  34255. */
  34256. onCompiled: Nullable<(effect: Effect) => void>;
  34257. /**
  34258. * Callback that will be called if an error occurs during shader compilation.
  34259. */
  34260. onError: Nullable<(effect: Effect, errors: string) => void>;
  34261. /**
  34262. * Callback that will be called when effect is bound.
  34263. */
  34264. onBind: Nullable<(effect: Effect) => void>;
  34265. /**
  34266. * Unique ID of the effect.
  34267. */
  34268. uniqueId: number;
  34269. /**
  34270. * Observable that will be called when the shader is compiled.
  34271. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34272. */
  34273. onCompileObservable: Observable<Effect>;
  34274. /**
  34275. * Observable that will be called if an error occurs during shader compilation.
  34276. */
  34277. onErrorObservable: Observable<Effect>;
  34278. /** @hidden */
  34279. _onBindObservable: Nullable<Observable<Effect>>;
  34280. /**
  34281. * @hidden
  34282. * Specifies if the effect was previously ready
  34283. */
  34284. _wasPreviouslyReady: boolean;
  34285. /**
  34286. * Observable that will be called when effect is bound.
  34287. */
  34288. get onBindObservable(): Observable<Effect>;
  34289. /** @hidden */
  34290. _bonesComputationForcedToCPU: boolean;
  34291. private static _uniqueIdSeed;
  34292. private _engine;
  34293. private _uniformBuffersNames;
  34294. private _uniformBuffersNamesList;
  34295. private _uniformsNames;
  34296. private _samplerList;
  34297. private _samplers;
  34298. private _isReady;
  34299. private _compilationError;
  34300. private _allFallbacksProcessed;
  34301. private _attributesNames;
  34302. private _attributes;
  34303. private _attributeLocationByName;
  34304. private _uniforms;
  34305. /**
  34306. * Key for the effect.
  34307. * @hidden
  34308. */
  34309. _key: string;
  34310. private _indexParameters;
  34311. private _fallbacks;
  34312. private _vertexSourceCode;
  34313. private _fragmentSourceCode;
  34314. private _vertexSourceCodeOverride;
  34315. private _fragmentSourceCodeOverride;
  34316. private _transformFeedbackVaryings;
  34317. /**
  34318. * Compiled shader to webGL program.
  34319. * @hidden
  34320. */
  34321. _pipelineContext: Nullable<IPipelineContext>;
  34322. private _valueCache;
  34323. private static _baseCache;
  34324. /**
  34325. * Instantiates an effect.
  34326. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34327. * @param baseName Name of the effect.
  34328. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34329. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34330. * @param samplers List of sampler variables that will be passed to the shader.
  34331. * @param engine Engine to be used to render the effect
  34332. * @param defines Define statements to be added to the shader.
  34333. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34334. * @param onCompiled Callback that will be called when the shader is compiled.
  34335. * @param onError Callback that will be called if an error occurs during shader compilation.
  34336. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34337. */
  34338. 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);
  34339. private _useFinalCode;
  34340. /**
  34341. * Unique key for this effect
  34342. */
  34343. get key(): string;
  34344. /**
  34345. * If the effect has been compiled and prepared.
  34346. * @returns if the effect is compiled and prepared.
  34347. */
  34348. isReady(): boolean;
  34349. private _isReadyInternal;
  34350. /**
  34351. * The engine the effect was initialized with.
  34352. * @returns the engine.
  34353. */
  34354. getEngine(): Engine;
  34355. /**
  34356. * The pipeline context for this effect
  34357. * @returns the associated pipeline context
  34358. */
  34359. getPipelineContext(): Nullable<IPipelineContext>;
  34360. /**
  34361. * The set of names of attribute variables for the shader.
  34362. * @returns An array of attribute names.
  34363. */
  34364. getAttributesNames(): string[];
  34365. /**
  34366. * Returns the attribute at the given index.
  34367. * @param index The index of the attribute.
  34368. * @returns The location of the attribute.
  34369. */
  34370. getAttributeLocation(index: number): number;
  34371. /**
  34372. * Returns the attribute based on the name of the variable.
  34373. * @param name of the attribute to look up.
  34374. * @returns the attribute location.
  34375. */
  34376. getAttributeLocationByName(name: string): number;
  34377. /**
  34378. * The number of attributes.
  34379. * @returns the numnber of attributes.
  34380. */
  34381. getAttributesCount(): number;
  34382. /**
  34383. * Gets the index of a uniform variable.
  34384. * @param uniformName of the uniform to look up.
  34385. * @returns the index.
  34386. */
  34387. getUniformIndex(uniformName: string): number;
  34388. /**
  34389. * Returns the attribute based on the name of the variable.
  34390. * @param uniformName of the uniform to look up.
  34391. * @returns the location of the uniform.
  34392. */
  34393. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34394. /**
  34395. * Returns an array of sampler variable names
  34396. * @returns The array of sampler variable names.
  34397. */
  34398. getSamplers(): string[];
  34399. /**
  34400. * Returns an array of uniform variable names
  34401. * @returns The array of uniform variable names.
  34402. */
  34403. getUniformNames(): string[];
  34404. /**
  34405. * Returns an array of uniform buffer variable names
  34406. * @returns The array of uniform buffer variable names.
  34407. */
  34408. getUniformBuffersNames(): string[];
  34409. /**
  34410. * Returns the index parameters used to create the effect
  34411. * @returns The index parameters object
  34412. */
  34413. getIndexParameters(): any;
  34414. /**
  34415. * The error from the last compilation.
  34416. * @returns the error string.
  34417. */
  34418. getCompilationError(): string;
  34419. /**
  34420. * Gets a boolean indicating that all fallbacks were used during compilation
  34421. * @returns true if all fallbacks were used
  34422. */
  34423. allFallbacksProcessed(): boolean;
  34424. /**
  34425. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34426. * @param func The callback to be used.
  34427. */
  34428. executeWhenCompiled(func: (effect: Effect) => void): void;
  34429. private _checkIsReady;
  34430. private _loadShader;
  34431. /**
  34432. * Gets the vertex shader source code of this effect
  34433. */
  34434. get vertexSourceCode(): string;
  34435. /**
  34436. * Gets the fragment shader source code of this effect
  34437. */
  34438. get fragmentSourceCode(): string;
  34439. /**
  34440. * Recompiles the webGL program
  34441. * @param vertexSourceCode The source code for the vertex shader.
  34442. * @param fragmentSourceCode The source code for the fragment shader.
  34443. * @param onCompiled Callback called when completed.
  34444. * @param onError Callback called on error.
  34445. * @hidden
  34446. */
  34447. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34448. /**
  34449. * Prepares the effect
  34450. * @hidden
  34451. */
  34452. _prepareEffect(): void;
  34453. private _getShaderCodeAndErrorLine;
  34454. private _processCompilationErrors;
  34455. /**
  34456. * Checks if the effect is supported. (Must be called after compilation)
  34457. */
  34458. get isSupported(): boolean;
  34459. /**
  34460. * Binds a texture to the engine to be used as output of the shader.
  34461. * @param channel Name of the output variable.
  34462. * @param texture Texture to bind.
  34463. * @hidden
  34464. */
  34465. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34466. /**
  34467. * Sets a texture on the engine to be used in the shader.
  34468. * @param channel Name of the sampler variable.
  34469. * @param texture Texture to set.
  34470. */
  34471. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34472. /**
  34473. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34474. * @param channel Name of the sampler variable.
  34475. * @param texture Texture to set.
  34476. */
  34477. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34478. /**
  34479. * Sets an array of textures on the engine to be used in the shader.
  34480. * @param channel Name of the variable.
  34481. * @param textures Textures to set.
  34482. */
  34483. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34484. /**
  34485. * 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)
  34486. * @param channel Name of the sampler variable.
  34487. * @param postProcess Post process to get the input texture from.
  34488. */
  34489. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34490. /**
  34491. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34492. * 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)
  34493. * @param channel Name of the sampler variable.
  34494. * @param postProcess Post process to get the output texture from.
  34495. */
  34496. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34497. /** @hidden */
  34498. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34499. /** @hidden */
  34500. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34501. /** @hidden */
  34502. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34503. /** @hidden */
  34504. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34505. /**
  34506. * Binds a buffer to a uniform.
  34507. * @param buffer Buffer to bind.
  34508. * @param name Name of the uniform variable to bind to.
  34509. */
  34510. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34511. /**
  34512. * Binds block to a uniform.
  34513. * @param blockName Name of the block to bind.
  34514. * @param index Index to bind.
  34515. */
  34516. bindUniformBlock(blockName: string, index: number): void;
  34517. /**
  34518. * Sets an interger value on a uniform variable.
  34519. * @param uniformName Name of the variable.
  34520. * @param value Value to be set.
  34521. * @returns this effect.
  34522. */
  34523. setInt(uniformName: string, value: number): Effect;
  34524. /**
  34525. * Sets an int array on a uniform variable.
  34526. * @param uniformName Name of the variable.
  34527. * @param array array to be set.
  34528. * @returns this effect.
  34529. */
  34530. setIntArray(uniformName: string, array: Int32Array): Effect;
  34531. /**
  34532. * 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)
  34533. * @param uniformName Name of the variable.
  34534. * @param array array to be set.
  34535. * @returns this effect.
  34536. */
  34537. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34538. /**
  34539. * 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)
  34540. * @param uniformName Name of the variable.
  34541. * @param array array to be set.
  34542. * @returns this effect.
  34543. */
  34544. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34545. /**
  34546. * 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)
  34547. * @param uniformName Name of the variable.
  34548. * @param array array to be set.
  34549. * @returns this effect.
  34550. */
  34551. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34552. /**
  34553. * Sets an float array on a uniform variable.
  34554. * @param uniformName Name of the variable.
  34555. * @param array array to be set.
  34556. * @returns this effect.
  34557. */
  34558. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34559. /**
  34560. * 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)
  34561. * @param uniformName Name of the variable.
  34562. * @param array array to be set.
  34563. * @returns this effect.
  34564. */
  34565. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34566. /**
  34567. * 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)
  34568. * @param uniformName Name of the variable.
  34569. * @param array array to be set.
  34570. * @returns this effect.
  34571. */
  34572. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34573. /**
  34574. * 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)
  34575. * @param uniformName Name of the variable.
  34576. * @param array array to be set.
  34577. * @returns this effect.
  34578. */
  34579. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34580. /**
  34581. * Sets an array on a uniform variable.
  34582. * @param uniformName Name of the variable.
  34583. * @param array array to be set.
  34584. * @returns this effect.
  34585. */
  34586. setArray(uniformName: string, array: number[]): Effect;
  34587. /**
  34588. * 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)
  34589. * @param uniformName Name of the variable.
  34590. * @param array array to be set.
  34591. * @returns this effect.
  34592. */
  34593. setArray2(uniformName: string, array: number[]): Effect;
  34594. /**
  34595. * 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)
  34596. * @param uniformName Name of the variable.
  34597. * @param array array to be set.
  34598. * @returns this effect.
  34599. */
  34600. setArray3(uniformName: string, array: number[]): Effect;
  34601. /**
  34602. * 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)
  34603. * @param uniformName Name of the variable.
  34604. * @param array array to be set.
  34605. * @returns this effect.
  34606. */
  34607. setArray4(uniformName: string, array: number[]): Effect;
  34608. /**
  34609. * Sets matrices on a uniform variable.
  34610. * @param uniformName Name of the variable.
  34611. * @param matrices matrices to be set.
  34612. * @returns this effect.
  34613. */
  34614. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  34615. /**
  34616. * Sets matrix on a uniform variable.
  34617. * @param uniformName Name of the variable.
  34618. * @param matrix matrix to be set.
  34619. * @returns this effect.
  34620. */
  34621. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34622. /**
  34623. * 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)
  34624. * @param uniformName Name of the variable.
  34625. * @param matrix matrix to be set.
  34626. * @returns this effect.
  34627. */
  34628. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  34629. /**
  34630. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34631. * @param uniformName Name of the variable.
  34632. * @param matrix matrix to be set.
  34633. * @returns this effect.
  34634. */
  34635. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  34636. /**
  34637. * Sets a float on a uniform variable.
  34638. * @param uniformName Name of the variable.
  34639. * @param value value to be set.
  34640. * @returns this effect.
  34641. */
  34642. setFloat(uniformName: string, value: number): Effect;
  34643. /**
  34644. * Sets a boolean on a uniform variable.
  34645. * @param uniformName Name of the variable.
  34646. * @param bool value to be set.
  34647. * @returns this effect.
  34648. */
  34649. setBool(uniformName: string, bool: boolean): Effect;
  34650. /**
  34651. * Sets a Vector2 on a uniform variable.
  34652. * @param uniformName Name of the variable.
  34653. * @param vector2 vector2 to be set.
  34654. * @returns this effect.
  34655. */
  34656. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34657. /**
  34658. * Sets a float2 on a uniform variable.
  34659. * @param uniformName Name of the variable.
  34660. * @param x First float in float2.
  34661. * @param y Second float in float2.
  34662. * @returns this effect.
  34663. */
  34664. setFloat2(uniformName: string, x: number, y: number): Effect;
  34665. /**
  34666. * Sets a Vector3 on a uniform variable.
  34667. * @param uniformName Name of the variable.
  34668. * @param vector3 Value to be set.
  34669. * @returns this effect.
  34670. */
  34671. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34672. /**
  34673. * Sets a float3 on a uniform variable.
  34674. * @param uniformName Name of the variable.
  34675. * @param x First float in float3.
  34676. * @param y Second float in float3.
  34677. * @param z Third float in float3.
  34678. * @returns this effect.
  34679. */
  34680. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34681. /**
  34682. * Sets a Vector4 on a uniform variable.
  34683. * @param uniformName Name of the variable.
  34684. * @param vector4 Value to be set.
  34685. * @returns this effect.
  34686. */
  34687. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34688. /**
  34689. * Sets a float4 on a uniform variable.
  34690. * @param uniformName Name of the variable.
  34691. * @param x First float in float4.
  34692. * @param y Second float in float4.
  34693. * @param z Third float in float4.
  34694. * @param w Fourth float in float4.
  34695. * @returns this effect.
  34696. */
  34697. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34698. /**
  34699. * Sets a Color3 on a uniform variable.
  34700. * @param uniformName Name of the variable.
  34701. * @param color3 Value to be set.
  34702. * @returns this effect.
  34703. */
  34704. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34705. /**
  34706. * Sets a Color4 on a uniform variable.
  34707. * @param uniformName Name of the variable.
  34708. * @param color3 Value to be set.
  34709. * @param alpha Alpha value to be set.
  34710. * @returns this effect.
  34711. */
  34712. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34713. /**
  34714. * Sets a Color4 on a uniform variable
  34715. * @param uniformName defines the name of the variable
  34716. * @param color4 defines the value to be set
  34717. * @returns this effect.
  34718. */
  34719. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34720. /** Release all associated resources */
  34721. dispose(): void;
  34722. /**
  34723. * This function will add a new shader to the shader store
  34724. * @param name the name of the shader
  34725. * @param pixelShader optional pixel shader content
  34726. * @param vertexShader optional vertex shader content
  34727. */
  34728. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34729. /**
  34730. * Store of each shader (The can be looked up using effect.key)
  34731. */
  34732. static ShadersStore: {
  34733. [key: string]: string;
  34734. };
  34735. /**
  34736. * Store of each included file for a shader (The can be looked up using effect.key)
  34737. */
  34738. static IncludesShadersStore: {
  34739. [key: string]: string;
  34740. };
  34741. /**
  34742. * Resets the cache of effects.
  34743. */
  34744. static ResetCache(): void;
  34745. }
  34746. }
  34747. declare module "babylonjs/Engines/engineCapabilities" {
  34748. /**
  34749. * Interface used to describe the capabilities of the engine relatively to the current browser
  34750. */
  34751. export interface EngineCapabilities {
  34752. /** Maximum textures units per fragment shader */
  34753. maxTexturesImageUnits: number;
  34754. /** Maximum texture units per vertex shader */
  34755. maxVertexTextureImageUnits: number;
  34756. /** Maximum textures units in the entire pipeline */
  34757. maxCombinedTexturesImageUnits: number;
  34758. /** Maximum texture size */
  34759. maxTextureSize: number;
  34760. /** Maximum texture samples */
  34761. maxSamples?: number;
  34762. /** Maximum cube texture size */
  34763. maxCubemapTextureSize: number;
  34764. /** Maximum render texture size */
  34765. maxRenderTextureSize: number;
  34766. /** Maximum number of vertex attributes */
  34767. maxVertexAttribs: number;
  34768. /** Maximum number of varyings */
  34769. maxVaryingVectors: number;
  34770. /** Maximum number of uniforms per vertex shader */
  34771. maxVertexUniformVectors: number;
  34772. /** Maximum number of uniforms per fragment shader */
  34773. maxFragmentUniformVectors: number;
  34774. /** Defines if standard derivates (dx/dy) are supported */
  34775. standardDerivatives: boolean;
  34776. /** Defines if s3tc texture compression is supported */
  34777. s3tc?: WEBGL_compressed_texture_s3tc;
  34778. /** Defines if pvrtc texture compression is supported */
  34779. pvrtc: any;
  34780. /** Defines if etc1 texture compression is supported */
  34781. etc1: any;
  34782. /** Defines if etc2 texture compression is supported */
  34783. etc2: any;
  34784. /** Defines if astc texture compression is supported */
  34785. astc: any;
  34786. /** Defines if float textures are supported */
  34787. textureFloat: boolean;
  34788. /** Defines if vertex array objects are supported */
  34789. vertexArrayObject: boolean;
  34790. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34791. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34792. /** Gets the maximum level of anisotropy supported */
  34793. maxAnisotropy: number;
  34794. /** Defines if instancing is supported */
  34795. instancedArrays: boolean;
  34796. /** Defines if 32 bits indices are supported */
  34797. uintIndices: boolean;
  34798. /** Defines if high precision shaders are supported */
  34799. highPrecisionShaderSupported: boolean;
  34800. /** Defines if depth reading in the fragment shader is supported */
  34801. fragmentDepthSupported: boolean;
  34802. /** Defines if float texture linear filtering is supported*/
  34803. textureFloatLinearFiltering: boolean;
  34804. /** Defines if rendering to float textures is supported */
  34805. textureFloatRender: boolean;
  34806. /** Defines if half float textures are supported*/
  34807. textureHalfFloat: boolean;
  34808. /** Defines if half float texture linear filtering is supported*/
  34809. textureHalfFloatLinearFiltering: boolean;
  34810. /** Defines if rendering to half float textures is supported */
  34811. textureHalfFloatRender: boolean;
  34812. /** Defines if textureLOD shader command is supported */
  34813. textureLOD: boolean;
  34814. /** Defines if draw buffers extension is supported */
  34815. drawBuffersExtension: boolean;
  34816. /** Defines if depth textures are supported */
  34817. depthTextureExtension: boolean;
  34818. /** Defines if float color buffer are supported */
  34819. colorBufferFloat: boolean;
  34820. /** Gets disjoint timer query extension (null if not supported) */
  34821. timerQuery?: EXT_disjoint_timer_query;
  34822. /** Defines if timestamp can be used with timer query */
  34823. canUseTimestampForTimerQuery: boolean;
  34824. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34825. multiview?: any;
  34826. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34827. oculusMultiview?: any;
  34828. /** Function used to let the system compiles shaders in background */
  34829. parallelShaderCompile?: {
  34830. COMPLETION_STATUS_KHR: number;
  34831. };
  34832. /** Max number of texture samples for MSAA */
  34833. maxMSAASamples: number;
  34834. /** Defines if the blend min max extension is supported */
  34835. blendMinMax: boolean;
  34836. }
  34837. }
  34838. declare module "babylonjs/States/depthCullingState" {
  34839. import { Nullable } from "babylonjs/types";
  34840. /**
  34841. * @hidden
  34842. **/
  34843. export class DepthCullingState {
  34844. private _isDepthTestDirty;
  34845. private _isDepthMaskDirty;
  34846. private _isDepthFuncDirty;
  34847. private _isCullFaceDirty;
  34848. private _isCullDirty;
  34849. private _isZOffsetDirty;
  34850. private _isFrontFaceDirty;
  34851. private _depthTest;
  34852. private _depthMask;
  34853. private _depthFunc;
  34854. private _cull;
  34855. private _cullFace;
  34856. private _zOffset;
  34857. private _frontFace;
  34858. /**
  34859. * Initializes the state.
  34860. */
  34861. constructor();
  34862. get isDirty(): boolean;
  34863. get zOffset(): number;
  34864. set zOffset(value: number);
  34865. get cullFace(): Nullable<number>;
  34866. set cullFace(value: Nullable<number>);
  34867. get cull(): Nullable<boolean>;
  34868. set cull(value: Nullable<boolean>);
  34869. get depthFunc(): Nullable<number>;
  34870. set depthFunc(value: Nullable<number>);
  34871. get depthMask(): boolean;
  34872. set depthMask(value: boolean);
  34873. get depthTest(): boolean;
  34874. set depthTest(value: boolean);
  34875. get frontFace(): Nullable<number>;
  34876. set frontFace(value: Nullable<number>);
  34877. reset(): void;
  34878. apply(gl: WebGLRenderingContext): void;
  34879. }
  34880. }
  34881. declare module "babylonjs/States/stencilState" {
  34882. /**
  34883. * @hidden
  34884. **/
  34885. export class StencilState {
  34886. /** 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 */
  34887. static readonly ALWAYS: number;
  34888. /** Passed to stencilOperation to specify that stencil value must be kept */
  34889. static readonly KEEP: number;
  34890. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34891. static readonly REPLACE: number;
  34892. private _isStencilTestDirty;
  34893. private _isStencilMaskDirty;
  34894. private _isStencilFuncDirty;
  34895. private _isStencilOpDirty;
  34896. private _stencilTest;
  34897. private _stencilMask;
  34898. private _stencilFunc;
  34899. private _stencilFuncRef;
  34900. private _stencilFuncMask;
  34901. private _stencilOpStencilFail;
  34902. private _stencilOpDepthFail;
  34903. private _stencilOpStencilDepthPass;
  34904. get isDirty(): boolean;
  34905. get stencilFunc(): number;
  34906. set stencilFunc(value: number);
  34907. get stencilFuncRef(): number;
  34908. set stencilFuncRef(value: number);
  34909. get stencilFuncMask(): number;
  34910. set stencilFuncMask(value: number);
  34911. get stencilOpStencilFail(): number;
  34912. set stencilOpStencilFail(value: number);
  34913. get stencilOpDepthFail(): number;
  34914. set stencilOpDepthFail(value: number);
  34915. get stencilOpStencilDepthPass(): number;
  34916. set stencilOpStencilDepthPass(value: number);
  34917. get stencilMask(): number;
  34918. set stencilMask(value: number);
  34919. get stencilTest(): boolean;
  34920. set stencilTest(value: boolean);
  34921. constructor();
  34922. reset(): void;
  34923. apply(gl: WebGLRenderingContext): void;
  34924. }
  34925. }
  34926. declare module "babylonjs/States/alphaCullingState" {
  34927. /**
  34928. * @hidden
  34929. **/
  34930. export class AlphaState {
  34931. private _isAlphaBlendDirty;
  34932. private _isBlendFunctionParametersDirty;
  34933. private _isBlendEquationParametersDirty;
  34934. private _isBlendConstantsDirty;
  34935. private _alphaBlend;
  34936. private _blendFunctionParameters;
  34937. private _blendEquationParameters;
  34938. private _blendConstants;
  34939. /**
  34940. * Initializes the state.
  34941. */
  34942. constructor();
  34943. get isDirty(): boolean;
  34944. get alphaBlend(): boolean;
  34945. set alphaBlend(value: boolean);
  34946. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34947. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34948. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34949. reset(): void;
  34950. apply(gl: WebGLRenderingContext): void;
  34951. }
  34952. }
  34953. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  34954. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  34955. /** @hidden */
  34956. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34957. attributeProcessor(attribute: string): string;
  34958. varyingProcessor(varying: string, isFragment: boolean): string;
  34959. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34960. }
  34961. }
  34962. declare module "babylonjs/Engines/instancingAttributeInfo" {
  34963. /**
  34964. * Interface for attribute information associated with buffer instanciation
  34965. */
  34966. export interface InstancingAttributeInfo {
  34967. /**
  34968. * Name of the GLSL attribute
  34969. * if attribute index is not specified, this is used to retrieve the index from the effect
  34970. */
  34971. attributeName: string;
  34972. /**
  34973. * Index/offset of the attribute in the vertex shader
  34974. * if not specified, this will be computes from the name.
  34975. */
  34976. index?: number;
  34977. /**
  34978. * size of the attribute, 1, 2, 3 or 4
  34979. */
  34980. attributeSize: number;
  34981. /**
  34982. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34983. */
  34984. offset: number;
  34985. /**
  34986. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34987. * default to 1
  34988. */
  34989. divisor?: number;
  34990. /**
  34991. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34992. * default is FLOAT
  34993. */
  34994. attributeType?: number;
  34995. /**
  34996. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34997. */
  34998. normalized?: boolean;
  34999. }
  35000. }
  35001. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  35002. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35003. import { Nullable } from "babylonjs/types";
  35004. module "babylonjs/Engines/thinEngine" {
  35005. interface ThinEngine {
  35006. /**
  35007. * Update a video texture
  35008. * @param texture defines the texture to update
  35009. * @param video defines the video element to use
  35010. * @param invertY defines if data must be stored with Y axis inverted
  35011. */
  35012. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35013. }
  35014. }
  35015. }
  35016. declare module "babylonjs/Materials/Textures/videoTexture" {
  35017. import { Observable } from "babylonjs/Misc/observable";
  35018. import { Nullable } from "babylonjs/types";
  35019. import { Scene } from "babylonjs/scene";
  35020. import { Texture } from "babylonjs/Materials/Textures/texture";
  35021. import "babylonjs/Engines/Extensions/engine.videoTexture";
  35022. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  35023. /**
  35024. * Settings for finer control over video usage
  35025. */
  35026. export interface VideoTextureSettings {
  35027. /**
  35028. * Applies `autoplay` to video, if specified
  35029. */
  35030. autoPlay?: boolean;
  35031. /**
  35032. * Applies `loop` to video, if specified
  35033. */
  35034. loop?: boolean;
  35035. /**
  35036. * Automatically updates internal texture from video at every frame in the render loop
  35037. */
  35038. autoUpdateTexture: boolean;
  35039. /**
  35040. * Image src displayed during the video loading or until the user interacts with the video.
  35041. */
  35042. poster?: string;
  35043. }
  35044. /**
  35045. * If you want to display a video in your scene, this is the special texture for that.
  35046. * This special texture works similar to other textures, with the exception of a few parameters.
  35047. * @see https://doc.babylonjs.com/how_to/video_texture
  35048. */
  35049. export class VideoTexture extends Texture {
  35050. /**
  35051. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35052. */
  35053. readonly autoUpdateTexture: boolean;
  35054. /**
  35055. * The video instance used by the texture internally
  35056. */
  35057. readonly video: HTMLVideoElement;
  35058. private _onUserActionRequestedObservable;
  35059. /**
  35060. * Event triggerd when a dom action is required by the user to play the video.
  35061. * This happens due to recent changes in browser policies preventing video to auto start.
  35062. */
  35063. get onUserActionRequestedObservable(): Observable<Texture>;
  35064. private _generateMipMaps;
  35065. private _stillImageCaptured;
  35066. private _displayingPosterTexture;
  35067. private _settings;
  35068. private _createInternalTextureOnEvent;
  35069. private _frameId;
  35070. private _currentSrc;
  35071. /**
  35072. * Creates a video texture.
  35073. * If you want to display a video in your scene, this is the special texture for that.
  35074. * This special texture works similar to other textures, with the exception of a few parameters.
  35075. * @see https://doc.babylonjs.com/how_to/video_texture
  35076. * @param name optional name, will detect from video source, if not defined
  35077. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35078. * @param scene is obviously the current scene.
  35079. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35080. * @param invertY is false by default but can be used to invert video on Y axis
  35081. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35082. * @param settings allows finer control over video usage
  35083. */
  35084. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35085. private _getName;
  35086. private _getVideo;
  35087. private _createInternalTexture;
  35088. private reset;
  35089. /**
  35090. * @hidden Internal method to initiate `update`.
  35091. */
  35092. _rebuild(): void;
  35093. /**
  35094. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35095. */
  35096. update(): void;
  35097. /**
  35098. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35099. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35100. */
  35101. updateTexture(isVisible: boolean): void;
  35102. protected _updateInternalTexture: () => void;
  35103. /**
  35104. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35105. * @param url New url.
  35106. */
  35107. updateURL(url: string): void;
  35108. /**
  35109. * Clones the texture.
  35110. * @returns the cloned texture
  35111. */
  35112. clone(): VideoTexture;
  35113. /**
  35114. * Dispose the texture and release its associated resources.
  35115. */
  35116. dispose(): void;
  35117. /**
  35118. * Creates a video texture straight from a stream.
  35119. * @param scene Define the scene the texture should be created in
  35120. * @param stream Define the stream the texture should be created from
  35121. * @returns The created video texture as a promise
  35122. */
  35123. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35124. /**
  35125. * Creates a video texture straight from your WebCam video feed.
  35126. * @param scene Define the scene the texture should be created in
  35127. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35128. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35129. * @returns The created video texture as a promise
  35130. */
  35131. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35132. minWidth: number;
  35133. maxWidth: number;
  35134. minHeight: number;
  35135. maxHeight: number;
  35136. deviceId: string;
  35137. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35138. /**
  35139. * Creates a video texture straight from your WebCam video feed.
  35140. * @param scene Define the scene the texture should be created in
  35141. * @param onReady Define a callback to triggered once the texture will be ready
  35142. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35143. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35144. */
  35145. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35146. minWidth: number;
  35147. maxWidth: number;
  35148. minHeight: number;
  35149. maxHeight: number;
  35150. deviceId: string;
  35151. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35152. }
  35153. }
  35154. declare module "babylonjs/Engines/thinEngine" {
  35155. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  35156. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  35157. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35158. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35159. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  35160. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  35161. import { Observable } from "babylonjs/Misc/observable";
  35162. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  35163. import { StencilState } from "babylonjs/States/stencilState";
  35164. import { AlphaState } from "babylonjs/States/alphaCullingState";
  35165. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35166. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  35167. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35168. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35169. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35170. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  35171. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  35172. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  35173. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35174. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35175. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35176. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  35177. import { WebRequest } from "babylonjs/Misc/webRequest";
  35178. import { LoadFileError } from "babylonjs/Misc/fileTools";
  35179. /**
  35180. * Defines the interface used by objects working like Scene
  35181. * @hidden
  35182. */
  35183. export interface ISceneLike {
  35184. _addPendingData(data: any): void;
  35185. _removePendingData(data: any): void;
  35186. offlineProvider: IOfflineProvider;
  35187. }
  35188. /** Interface defining initialization parameters for Engine class */
  35189. export interface EngineOptions extends WebGLContextAttributes {
  35190. /**
  35191. * Defines if the engine should no exceed a specified device ratio
  35192. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35193. */
  35194. limitDeviceRatio?: number;
  35195. /**
  35196. * Defines if webvr should be enabled automatically
  35197. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35198. */
  35199. autoEnableWebVR?: boolean;
  35200. /**
  35201. * Defines if webgl2 should be turned off even if supported
  35202. * @see http://doc.babylonjs.com/features/webgl2
  35203. */
  35204. disableWebGL2Support?: boolean;
  35205. /**
  35206. * Defines if webaudio should be initialized as well
  35207. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35208. */
  35209. audioEngine?: boolean;
  35210. /**
  35211. * Defines if animations should run using a deterministic lock step
  35212. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35213. */
  35214. deterministicLockstep?: boolean;
  35215. /** Defines the maximum steps to use with deterministic lock step mode */
  35216. lockstepMaxSteps?: number;
  35217. /** Defines the seconds between each deterministic lock step */
  35218. timeStep?: number;
  35219. /**
  35220. * Defines that engine should ignore context lost events
  35221. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35222. */
  35223. doNotHandleContextLost?: boolean;
  35224. /**
  35225. * Defines that engine should ignore modifying touch action attribute and style
  35226. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35227. */
  35228. doNotHandleTouchAction?: boolean;
  35229. /**
  35230. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35231. */
  35232. useHighPrecisionFloats?: boolean;
  35233. /**
  35234. * Make the canvas XR Compatible for XR sessions
  35235. */
  35236. xrCompatible?: boolean;
  35237. }
  35238. /**
  35239. * The base engine class (root of all engines)
  35240. */
  35241. export class ThinEngine {
  35242. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35243. static ExceptionList: ({
  35244. key: string;
  35245. capture: string;
  35246. captureConstraint: number;
  35247. targets: string[];
  35248. } | {
  35249. key: string;
  35250. capture: null;
  35251. captureConstraint: null;
  35252. targets: string[];
  35253. })[];
  35254. /** @hidden */
  35255. static _TextureLoaders: IInternalTextureLoader[];
  35256. /**
  35257. * Returns the current npm package of the sdk
  35258. */
  35259. static get NpmPackage(): string;
  35260. /**
  35261. * Returns the current version of the framework
  35262. */
  35263. static get Version(): string;
  35264. /**
  35265. * Returns a string describing the current engine
  35266. */
  35267. get description(): string;
  35268. /**
  35269. * Gets or sets the epsilon value used by collision engine
  35270. */
  35271. static CollisionsEpsilon: number;
  35272. /**
  35273. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35274. */
  35275. static get ShadersRepository(): string;
  35276. static set ShadersRepository(value: string);
  35277. /** @hidden */
  35278. _shaderProcessor: IShaderProcessor;
  35279. /**
  35280. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35281. */
  35282. forcePOTTextures: boolean;
  35283. /**
  35284. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35285. */
  35286. isFullscreen: boolean;
  35287. /**
  35288. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35289. */
  35290. cullBackFaces: boolean;
  35291. /**
  35292. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35293. */
  35294. renderEvenInBackground: boolean;
  35295. /**
  35296. * Gets or sets a boolean indicating that cache can be kept between frames
  35297. */
  35298. preventCacheWipeBetweenFrames: boolean;
  35299. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35300. validateShaderPrograms: boolean;
  35301. /**
  35302. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35303. * This can provide greater z depth for distant objects.
  35304. */
  35305. useReverseDepthBuffer: boolean;
  35306. /**
  35307. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35308. */
  35309. disableUniformBuffers: boolean;
  35310. /** @hidden */
  35311. _uniformBuffers: UniformBuffer[];
  35312. /**
  35313. * Gets a boolean indicating that the engine supports uniform buffers
  35314. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35315. */
  35316. get supportsUniformBuffers(): boolean;
  35317. /** @hidden */
  35318. _gl: WebGLRenderingContext;
  35319. /** @hidden */
  35320. _webGLVersion: number;
  35321. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35322. protected _windowIsBackground: boolean;
  35323. protected _creationOptions: EngineOptions;
  35324. protected _highPrecisionShadersAllowed: boolean;
  35325. /** @hidden */
  35326. get _shouldUseHighPrecisionShader(): boolean;
  35327. /**
  35328. * Gets a boolean indicating that only power of 2 textures are supported
  35329. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35330. */
  35331. get needPOTTextures(): boolean;
  35332. /** @hidden */
  35333. _badOS: boolean;
  35334. /** @hidden */
  35335. _badDesktopOS: boolean;
  35336. private _hardwareScalingLevel;
  35337. /** @hidden */
  35338. _caps: EngineCapabilities;
  35339. private _isStencilEnable;
  35340. private _glVersion;
  35341. private _glRenderer;
  35342. private _glVendor;
  35343. /** @hidden */
  35344. _videoTextureSupported: boolean;
  35345. protected _renderingQueueLaunched: boolean;
  35346. protected _activeRenderLoops: (() => void)[];
  35347. /**
  35348. * Observable signaled when a context lost event is raised
  35349. */
  35350. onContextLostObservable: Observable<ThinEngine>;
  35351. /**
  35352. * Observable signaled when a context restored event is raised
  35353. */
  35354. onContextRestoredObservable: Observable<ThinEngine>;
  35355. private _onContextLost;
  35356. private _onContextRestored;
  35357. protected _contextWasLost: boolean;
  35358. /** @hidden */
  35359. _doNotHandleContextLost: boolean;
  35360. /**
  35361. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35362. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35363. */
  35364. get doNotHandleContextLost(): boolean;
  35365. set doNotHandleContextLost(value: boolean);
  35366. /**
  35367. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35368. */
  35369. disableVertexArrayObjects: boolean;
  35370. /** @hidden */
  35371. protected _colorWrite: boolean;
  35372. /** @hidden */
  35373. protected _colorWriteChanged: boolean;
  35374. /** @hidden */
  35375. protected _depthCullingState: DepthCullingState;
  35376. /** @hidden */
  35377. protected _stencilState: StencilState;
  35378. /** @hidden */
  35379. _alphaState: AlphaState;
  35380. /** @hidden */
  35381. _alphaMode: number;
  35382. /** @hidden */
  35383. _alphaEquation: number;
  35384. /** @hidden */
  35385. _internalTexturesCache: InternalTexture[];
  35386. /** @hidden */
  35387. protected _activeChannel: number;
  35388. private _currentTextureChannel;
  35389. /** @hidden */
  35390. protected _boundTexturesCache: {
  35391. [key: string]: Nullable<InternalTexture>;
  35392. };
  35393. /** @hidden */
  35394. protected _currentEffect: Nullable<Effect>;
  35395. /** @hidden */
  35396. protected _currentProgram: Nullable<WebGLProgram>;
  35397. private _compiledEffects;
  35398. private _vertexAttribArraysEnabled;
  35399. /** @hidden */
  35400. protected _cachedViewport: Nullable<IViewportLike>;
  35401. private _cachedVertexArrayObject;
  35402. /** @hidden */
  35403. protected _cachedVertexBuffers: any;
  35404. /** @hidden */
  35405. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35406. /** @hidden */
  35407. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35408. /** @hidden */
  35409. _currentRenderTarget: Nullable<InternalTexture>;
  35410. private _uintIndicesCurrentlySet;
  35411. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35412. /** @hidden */
  35413. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35414. /** @hidden */
  35415. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35416. private _currentBufferPointers;
  35417. private _currentInstanceLocations;
  35418. private _currentInstanceBuffers;
  35419. private _textureUnits;
  35420. /** @hidden */
  35421. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35422. /** @hidden */
  35423. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35424. /** @hidden */
  35425. _boundRenderFunction: any;
  35426. private _vaoRecordInProgress;
  35427. private _mustWipeVertexAttributes;
  35428. private _emptyTexture;
  35429. private _emptyCubeTexture;
  35430. private _emptyTexture3D;
  35431. private _emptyTexture2DArray;
  35432. /** @hidden */
  35433. _frameHandler: number;
  35434. private _nextFreeTextureSlots;
  35435. private _maxSimultaneousTextures;
  35436. private _activeRequests;
  35437. /** @hidden */
  35438. _transformTextureUrl: Nullable<(url: string) => string>;
  35439. protected get _supportsHardwareTextureRescaling(): boolean;
  35440. private _framebufferDimensionsObject;
  35441. /**
  35442. * sets the object from which width and height will be taken from when getting render width and height
  35443. * Will fallback to the gl object
  35444. * @param dimensions the framebuffer width and height that will be used.
  35445. */
  35446. set framebufferDimensionsObject(dimensions: Nullable<{
  35447. framebufferWidth: number;
  35448. framebufferHeight: number;
  35449. }>);
  35450. /**
  35451. * Gets the current viewport
  35452. */
  35453. get currentViewport(): Nullable<IViewportLike>;
  35454. /**
  35455. * Gets the default empty texture
  35456. */
  35457. get emptyTexture(): InternalTexture;
  35458. /**
  35459. * Gets the default empty 3D texture
  35460. */
  35461. get emptyTexture3D(): InternalTexture;
  35462. /**
  35463. * Gets the default empty 2D array texture
  35464. */
  35465. get emptyTexture2DArray(): InternalTexture;
  35466. /**
  35467. * Gets the default empty cube texture
  35468. */
  35469. get emptyCubeTexture(): InternalTexture;
  35470. /**
  35471. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35472. */
  35473. readonly premultipliedAlpha: boolean;
  35474. /**
  35475. * Observable event triggered before each texture is initialized
  35476. */
  35477. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  35478. /**
  35479. * Creates a new engine
  35480. * @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
  35481. * @param antialias defines enable antialiasing (default: false)
  35482. * @param options defines further options to be sent to the getContext() function
  35483. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35484. */
  35485. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35486. private _rebuildInternalTextures;
  35487. private _rebuildEffects;
  35488. /**
  35489. * Gets a boolean indicating if all created effects are ready
  35490. * @returns true if all effects are ready
  35491. */
  35492. areAllEffectsReady(): boolean;
  35493. protected _rebuildBuffers(): void;
  35494. protected _initGLContext(): void;
  35495. /**
  35496. * Gets version of the current webGL context
  35497. */
  35498. get webGLVersion(): number;
  35499. /**
  35500. * Gets a string idenfifying the name of the class
  35501. * @returns "Engine" string
  35502. */
  35503. getClassName(): string;
  35504. /**
  35505. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35506. */
  35507. get isStencilEnable(): boolean;
  35508. /** @hidden */
  35509. _prepareWorkingCanvas(): void;
  35510. /**
  35511. * Reset the texture cache to empty state
  35512. */
  35513. resetTextureCache(): void;
  35514. /**
  35515. * Gets an object containing information about the current webGL context
  35516. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35517. */
  35518. getGlInfo(): {
  35519. vendor: string;
  35520. renderer: string;
  35521. version: string;
  35522. };
  35523. /**
  35524. * Defines the hardware scaling level.
  35525. * By default the hardware scaling level is computed from the window device ratio.
  35526. * 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.
  35527. * @param level defines the level to use
  35528. */
  35529. setHardwareScalingLevel(level: number): void;
  35530. /**
  35531. * Gets the current hardware scaling level.
  35532. * By default the hardware scaling level is computed from the window device ratio.
  35533. * 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.
  35534. * @returns a number indicating the current hardware scaling level
  35535. */
  35536. getHardwareScalingLevel(): number;
  35537. /**
  35538. * Gets the list of loaded textures
  35539. * @returns an array containing all loaded textures
  35540. */
  35541. getLoadedTexturesCache(): InternalTexture[];
  35542. /**
  35543. * Gets the object containing all engine capabilities
  35544. * @returns the EngineCapabilities object
  35545. */
  35546. getCaps(): EngineCapabilities;
  35547. /**
  35548. * stop executing a render loop function and remove it from the execution array
  35549. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35550. */
  35551. stopRenderLoop(renderFunction?: () => void): void;
  35552. /** @hidden */
  35553. _renderLoop(): void;
  35554. /**
  35555. * Gets the HTML canvas attached with the current webGL context
  35556. * @returns a HTML canvas
  35557. */
  35558. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35559. /**
  35560. * Gets host window
  35561. * @returns the host window object
  35562. */
  35563. getHostWindow(): Nullable<Window>;
  35564. /**
  35565. * Gets the current render width
  35566. * @param useScreen defines if screen size must be used (or the current render target if any)
  35567. * @returns a number defining the current render width
  35568. */
  35569. getRenderWidth(useScreen?: boolean): number;
  35570. /**
  35571. * Gets the current render height
  35572. * @param useScreen defines if screen size must be used (or the current render target if any)
  35573. * @returns a number defining the current render height
  35574. */
  35575. getRenderHeight(useScreen?: boolean): number;
  35576. /**
  35577. * Can be used to override the current requestAnimationFrame requester.
  35578. * @hidden
  35579. */
  35580. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35581. /**
  35582. * Register and execute a render loop. The engine can have more than one render function
  35583. * @param renderFunction defines the function to continuously execute
  35584. */
  35585. runRenderLoop(renderFunction: () => void): void;
  35586. /**
  35587. * Clear the current render buffer or the current render target (if any is set up)
  35588. * @param color defines the color to use
  35589. * @param backBuffer defines if the back buffer must be cleared
  35590. * @param depth defines if the depth buffer must be cleared
  35591. * @param stencil defines if the stencil buffer must be cleared
  35592. */
  35593. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35594. private _viewportCached;
  35595. /** @hidden */
  35596. _viewport(x: number, y: number, width: number, height: number): void;
  35597. /**
  35598. * Set the WebGL's viewport
  35599. * @param viewport defines the viewport element to be used
  35600. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35601. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35602. */
  35603. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35604. /**
  35605. * Begin a new frame
  35606. */
  35607. beginFrame(): void;
  35608. /**
  35609. * Enf the current frame
  35610. */
  35611. endFrame(): void;
  35612. /**
  35613. * Resize the view according to the canvas' size
  35614. */
  35615. resize(): void;
  35616. /**
  35617. * Force a specific size of the canvas
  35618. * @param width defines the new canvas' width
  35619. * @param height defines the new canvas' height
  35620. */
  35621. setSize(width: number, height: number): void;
  35622. /**
  35623. * Binds the frame buffer to the specified texture.
  35624. * @param texture The texture to render to or null for the default canvas
  35625. * @param faceIndex The face of the texture to render to in case of cube texture
  35626. * @param requiredWidth The width of the target to render to
  35627. * @param requiredHeight The height of the target to render to
  35628. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35629. * @param lodLevel defines the lod level to bind to the frame buffer
  35630. * @param layer defines the 2d array index to bind to frame buffer to
  35631. */
  35632. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35633. /** @hidden */
  35634. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35635. /**
  35636. * Unbind the current render target texture from the webGL context
  35637. * @param texture defines the render target texture to unbind
  35638. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35639. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35640. */
  35641. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35642. /**
  35643. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35644. */
  35645. flushFramebuffer(): void;
  35646. /**
  35647. * Unbind the current render target and bind the default framebuffer
  35648. */
  35649. restoreDefaultFramebuffer(): void;
  35650. /** @hidden */
  35651. protected _resetVertexBufferBinding(): void;
  35652. /**
  35653. * Creates a vertex buffer
  35654. * @param data the data for the vertex buffer
  35655. * @returns the new WebGL static buffer
  35656. */
  35657. createVertexBuffer(data: DataArray): DataBuffer;
  35658. private _createVertexBuffer;
  35659. /**
  35660. * Creates a dynamic vertex buffer
  35661. * @param data the data for the dynamic vertex buffer
  35662. * @returns the new WebGL dynamic buffer
  35663. */
  35664. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35665. protected _resetIndexBufferBinding(): void;
  35666. /**
  35667. * Creates a new index buffer
  35668. * @param indices defines the content of the index buffer
  35669. * @param updatable defines if the index buffer must be updatable
  35670. * @returns a new webGL buffer
  35671. */
  35672. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35673. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35674. /**
  35675. * Bind a webGL buffer to the webGL context
  35676. * @param buffer defines the buffer to bind
  35677. */
  35678. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35679. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35680. private bindBuffer;
  35681. /**
  35682. * update the bound buffer with the given data
  35683. * @param data defines the data to update
  35684. */
  35685. updateArrayBuffer(data: Float32Array): void;
  35686. private _vertexAttribPointer;
  35687. /** @hidden */
  35688. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35689. private _bindVertexBuffersAttributes;
  35690. /**
  35691. * Records a vertex array object
  35692. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35693. * @param vertexBuffers defines the list of vertex buffers to store
  35694. * @param indexBuffer defines the index buffer to store
  35695. * @param effect defines the effect to store
  35696. * @returns the new vertex array object
  35697. */
  35698. recordVertexArrayObject(vertexBuffers: {
  35699. [key: string]: VertexBuffer;
  35700. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35701. /**
  35702. * Bind a specific vertex array object
  35703. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35704. * @param vertexArrayObject defines the vertex array object to bind
  35705. * @param indexBuffer defines the index buffer to bind
  35706. */
  35707. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35708. /**
  35709. * Bind webGl buffers directly to the webGL context
  35710. * @param vertexBuffer defines the vertex buffer to bind
  35711. * @param indexBuffer defines the index buffer to bind
  35712. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35713. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35714. * @param effect defines the effect associated with the vertex buffer
  35715. */
  35716. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35717. private _unbindVertexArrayObject;
  35718. /**
  35719. * Bind a list of vertex buffers to the webGL context
  35720. * @param vertexBuffers defines the list of vertex buffers to bind
  35721. * @param indexBuffer defines the index buffer to bind
  35722. * @param effect defines the effect associated with the vertex buffers
  35723. */
  35724. bindBuffers(vertexBuffers: {
  35725. [key: string]: Nullable<VertexBuffer>;
  35726. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35727. /**
  35728. * Unbind all instance attributes
  35729. */
  35730. unbindInstanceAttributes(): void;
  35731. /**
  35732. * Release and free the memory of a vertex array object
  35733. * @param vao defines the vertex array object to delete
  35734. */
  35735. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35736. /** @hidden */
  35737. _releaseBuffer(buffer: DataBuffer): boolean;
  35738. protected _deleteBuffer(buffer: DataBuffer): void;
  35739. /**
  35740. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35741. * @param instancesBuffer defines the webGL buffer to update and bind
  35742. * @param data defines the data to store in the buffer
  35743. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35744. */
  35745. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35746. /**
  35747. * Bind the content of a webGL buffer used with instantiation
  35748. * @param instancesBuffer defines the webGL buffer to bind
  35749. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35750. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35751. */
  35752. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35753. /**
  35754. * Disable the instance attribute corresponding to the name in parameter
  35755. * @param name defines the name of the attribute to disable
  35756. */
  35757. disableInstanceAttributeByName(name: string): void;
  35758. /**
  35759. * Disable the instance attribute corresponding to the location in parameter
  35760. * @param attributeLocation defines the attribute location of the attribute to disable
  35761. */
  35762. disableInstanceAttribute(attributeLocation: number): void;
  35763. /**
  35764. * Disable the attribute corresponding to the location in parameter
  35765. * @param attributeLocation defines the attribute location of the attribute to disable
  35766. */
  35767. disableAttributeByIndex(attributeLocation: number): void;
  35768. /**
  35769. * Send a draw order
  35770. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35771. * @param indexStart defines the starting index
  35772. * @param indexCount defines the number of index to draw
  35773. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35774. */
  35775. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35776. /**
  35777. * Draw a list of points
  35778. * @param verticesStart defines the index of first vertex to draw
  35779. * @param verticesCount defines the count of vertices to draw
  35780. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35781. */
  35782. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35783. /**
  35784. * Draw a list of unindexed primitives
  35785. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35786. * @param verticesStart defines the index of first vertex to draw
  35787. * @param verticesCount defines the count of vertices to draw
  35788. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35789. */
  35790. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35791. /**
  35792. * Draw a list of indexed primitives
  35793. * @param fillMode defines the primitive to use
  35794. * @param indexStart defines the starting index
  35795. * @param indexCount defines the number of index to draw
  35796. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35797. */
  35798. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35799. /**
  35800. * Draw a list of unindexed primitives
  35801. * @param fillMode defines the primitive to use
  35802. * @param verticesStart defines the index of first vertex to draw
  35803. * @param verticesCount defines the count of vertices to draw
  35804. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35805. */
  35806. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35807. private _drawMode;
  35808. /** @hidden */
  35809. protected _reportDrawCall(): void;
  35810. /** @hidden */
  35811. _releaseEffect(effect: Effect): void;
  35812. /** @hidden */
  35813. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35814. /**
  35815. * Create a new effect (used to store vertex/fragment shaders)
  35816. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35817. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35818. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35819. * @param samplers defines an array of string used to represent textures
  35820. * @param defines defines the string containing the defines to use to compile the shaders
  35821. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35822. * @param onCompiled defines a function to call when the effect creation is successful
  35823. * @param onError defines a function to call when the effect creation has failed
  35824. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35825. * @returns the new Effect
  35826. */
  35827. 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;
  35828. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35829. private _compileShader;
  35830. private _compileRawShader;
  35831. /** @hidden */
  35832. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35833. /**
  35834. * Directly creates a webGL program
  35835. * @param pipelineContext defines the pipeline context to attach to
  35836. * @param vertexCode defines the vertex shader code to use
  35837. * @param fragmentCode defines the fragment shader code to use
  35838. * @param context defines the webGL context to use (if not set, the current one will be used)
  35839. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35840. * @returns the new webGL program
  35841. */
  35842. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35843. /**
  35844. * Creates a webGL program
  35845. * @param pipelineContext defines the pipeline context to attach to
  35846. * @param vertexCode defines the vertex shader code to use
  35847. * @param fragmentCode defines the fragment shader code to use
  35848. * @param defines defines the string containing the defines to use to compile the shaders
  35849. * @param context defines the webGL context to use (if not set, the current one will be used)
  35850. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35851. * @returns the new webGL program
  35852. */
  35853. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35854. /**
  35855. * Creates a new pipeline context
  35856. * @returns the new pipeline
  35857. */
  35858. createPipelineContext(): IPipelineContext;
  35859. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35860. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35861. /** @hidden */
  35862. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35863. /** @hidden */
  35864. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35865. /** @hidden */
  35866. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35867. /**
  35868. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35869. * @param pipelineContext defines the pipeline context to use
  35870. * @param uniformsNames defines the list of uniform names
  35871. * @returns an array of webGL uniform locations
  35872. */
  35873. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35874. /**
  35875. * Gets the lsit of active attributes for a given webGL program
  35876. * @param pipelineContext defines the pipeline context to use
  35877. * @param attributesNames defines the list of attribute names to get
  35878. * @returns an array of indices indicating the offset of each attribute
  35879. */
  35880. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  35881. /**
  35882. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  35883. * @param effect defines the effect to activate
  35884. */
  35885. enableEffect(effect: Nullable<Effect>): void;
  35886. /**
  35887. * Set the value of an uniform to a number (int)
  35888. * @param uniform defines the webGL uniform location where to store the value
  35889. * @param value defines the int number to store
  35890. */
  35891. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35892. /**
  35893. * Set the value of an uniform to an array of int32
  35894. * @param uniform defines the webGL uniform location where to store the value
  35895. * @param array defines the array of int32 to store
  35896. */
  35897. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35898. /**
  35899. * Set the value of an uniform to an array of int32 (stored as vec2)
  35900. * @param uniform defines the webGL uniform location where to store the value
  35901. * @param array defines the array of int32 to store
  35902. */
  35903. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35904. /**
  35905. * Set the value of an uniform to an array of int32 (stored as vec3)
  35906. * @param uniform defines the webGL uniform location where to store the value
  35907. * @param array defines the array of int32 to store
  35908. */
  35909. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35910. /**
  35911. * Set the value of an uniform to an array of int32 (stored as vec4)
  35912. * @param uniform defines the webGL uniform location where to store the value
  35913. * @param array defines the array of int32 to store
  35914. */
  35915. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35916. /**
  35917. * Set the value of an uniform to an array of number
  35918. * @param uniform defines the webGL uniform location where to store the value
  35919. * @param array defines the array of number to store
  35920. */
  35921. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35922. /**
  35923. * Set the value of an uniform to an array of number (stored as vec2)
  35924. * @param uniform defines the webGL uniform location where to store the value
  35925. * @param array defines the array of number to store
  35926. */
  35927. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35928. /**
  35929. * Set the value of an uniform to an array of number (stored as vec3)
  35930. * @param uniform defines the webGL uniform location where to store the value
  35931. * @param array defines the array of number to store
  35932. */
  35933. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35934. /**
  35935. * Set the value of an uniform to an array of number (stored as vec4)
  35936. * @param uniform defines the webGL uniform location where to store the value
  35937. * @param array defines the array of number to store
  35938. */
  35939. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35940. /**
  35941. * Set the value of an uniform to an array of float32 (stored as matrices)
  35942. * @param uniform defines the webGL uniform location where to store the value
  35943. * @param matrices defines the array of float32 to store
  35944. */
  35945. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35946. /**
  35947. * Set the value of an uniform to a matrix (3x3)
  35948. * @param uniform defines the webGL uniform location where to store the value
  35949. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35950. */
  35951. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35952. /**
  35953. * Set the value of an uniform to a matrix (2x2)
  35954. * @param uniform defines the webGL uniform location where to store the value
  35955. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35956. */
  35957. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35958. /**
  35959. * Set the value of an uniform to a number (float)
  35960. * @param uniform defines the webGL uniform location where to store the value
  35961. * @param value defines the float number to store
  35962. */
  35963. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35964. /**
  35965. * Set the value of an uniform to a vec2
  35966. * @param uniform defines the webGL uniform location where to store the value
  35967. * @param x defines the 1st component of the value
  35968. * @param y defines the 2nd component of the value
  35969. */
  35970. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35971. /**
  35972. * Set the value of an uniform to a vec3
  35973. * @param uniform defines the webGL uniform location where to store the value
  35974. * @param x defines the 1st component of the value
  35975. * @param y defines the 2nd component of the value
  35976. * @param z defines the 3rd component of the value
  35977. */
  35978. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35979. /**
  35980. * Set the value of an uniform to a vec4
  35981. * @param uniform defines the webGL uniform location where to store the value
  35982. * @param x defines the 1st component of the value
  35983. * @param y defines the 2nd component of the value
  35984. * @param z defines the 3rd component of the value
  35985. * @param w defines the 4th component of the value
  35986. */
  35987. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35988. /**
  35989. * Apply all cached states (depth, culling, stencil and alpha)
  35990. */
  35991. applyStates(): void;
  35992. /**
  35993. * Enable or disable color writing
  35994. * @param enable defines the state to set
  35995. */
  35996. setColorWrite(enable: boolean): void;
  35997. /**
  35998. * Gets a boolean indicating if color writing is enabled
  35999. * @returns the current color writing state
  36000. */
  36001. getColorWrite(): boolean;
  36002. /**
  36003. * Gets the depth culling state manager
  36004. */
  36005. get depthCullingState(): DepthCullingState;
  36006. /**
  36007. * Gets the alpha state manager
  36008. */
  36009. get alphaState(): AlphaState;
  36010. /**
  36011. * Gets the stencil state manager
  36012. */
  36013. get stencilState(): StencilState;
  36014. /**
  36015. * Clears the list of texture accessible through engine.
  36016. * This can help preventing texture load conflict due to name collision.
  36017. */
  36018. clearInternalTexturesCache(): void;
  36019. /**
  36020. * Force the entire cache to be cleared
  36021. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36022. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36023. */
  36024. wipeCaches(bruteForce?: boolean): void;
  36025. /** @hidden */
  36026. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36027. min: number;
  36028. mag: number;
  36029. };
  36030. /** @hidden */
  36031. _createTexture(): WebGLTexture;
  36032. /**
  36033. * Usually called from Texture.ts.
  36034. * Passed information to create a WebGLTexture
  36035. * @param url defines a value which contains one of the following:
  36036. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36037. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36038. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36039. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36040. * @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)
  36041. * @param scene needed for loading to the correct scene
  36042. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36043. * @param onLoad optional callback to be called upon successful completion
  36044. * @param onError optional callback to be called upon failure
  36045. * @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
  36046. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36047. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36048. * @param forcedExtension defines the extension to use to pick the right loader
  36049. * @param mimeType defines an optional mime type
  36050. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36051. */
  36052. 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;
  36053. /**
  36054. * Loads an image as an HTMLImageElement.
  36055. * @param input url string, ArrayBuffer, or Blob to load
  36056. * @param onLoad callback called when the image successfully loads
  36057. * @param onError callback called when the image fails to load
  36058. * @param offlineProvider offline provider for caching
  36059. * @param mimeType optional mime type
  36060. * @returns the HTMLImageElement of the loaded image
  36061. * @hidden
  36062. */
  36063. 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>;
  36064. /**
  36065. * @hidden
  36066. */
  36067. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36068. private _unpackFlipYCached;
  36069. /**
  36070. * In case you are sharing the context with other applications, it might
  36071. * be interested to not cache the unpack flip y state to ensure a consistent
  36072. * value would be set.
  36073. */
  36074. enableUnpackFlipYCached: boolean;
  36075. /** @hidden */
  36076. _unpackFlipY(value: boolean): void;
  36077. /** @hidden */
  36078. _getUnpackAlignement(): number;
  36079. private _getTextureTarget;
  36080. /**
  36081. * Update the sampling mode of a given texture
  36082. * @param samplingMode defines the required sampling mode
  36083. * @param texture defines the texture to update
  36084. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36085. */
  36086. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36087. /**
  36088. * Update the sampling mode of a given texture
  36089. * @param texture defines the texture to update
  36090. * @param wrapU defines the texture wrap mode of the u coordinates
  36091. * @param wrapV defines the texture wrap mode of the v coordinates
  36092. * @param wrapR defines the texture wrap mode of the r coordinates
  36093. */
  36094. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36095. /** @hidden */
  36096. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36097. width: number;
  36098. height: number;
  36099. layers?: number;
  36100. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36101. /** @hidden */
  36102. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36103. /** @hidden */
  36104. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36105. /**
  36106. * Update a portion of an internal texture
  36107. * @param texture defines the texture to update
  36108. * @param imageData defines the data to store into the texture
  36109. * @param xOffset defines the x coordinates of the update rectangle
  36110. * @param yOffset defines the y coordinates of the update rectangle
  36111. * @param width defines the width of the update rectangle
  36112. * @param height defines the height of the update rectangle
  36113. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36114. * @param lod defines the lod level to update (0 by default)
  36115. */
  36116. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36117. /** @hidden */
  36118. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36119. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36120. private _prepareWebGLTexture;
  36121. /** @hidden */
  36122. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36123. private _getDepthStencilBuffer;
  36124. /** @hidden */
  36125. _releaseFramebufferObjects(texture: InternalTexture): void;
  36126. /** @hidden */
  36127. _releaseTexture(texture: InternalTexture): void;
  36128. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36129. protected _setProgram(program: WebGLProgram): void;
  36130. protected _boundUniforms: {
  36131. [key: number]: WebGLUniformLocation;
  36132. };
  36133. /**
  36134. * Binds an effect to the webGL context
  36135. * @param effect defines the effect to bind
  36136. */
  36137. bindSamplers(effect: Effect): void;
  36138. private _activateCurrentTexture;
  36139. /** @hidden */
  36140. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36141. /** @hidden */
  36142. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36143. /**
  36144. * Unbind all textures from the webGL context
  36145. */
  36146. unbindAllTextures(): void;
  36147. /**
  36148. * Sets a texture to the according uniform.
  36149. * @param channel The texture channel
  36150. * @param uniform The uniform to set
  36151. * @param texture The texture to apply
  36152. */
  36153. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36154. private _bindSamplerUniformToChannel;
  36155. private _getTextureWrapMode;
  36156. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36157. /**
  36158. * Sets an array of texture to the webGL context
  36159. * @param channel defines the channel where the texture array must be set
  36160. * @param uniform defines the associated uniform location
  36161. * @param textures defines the array of textures to bind
  36162. */
  36163. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36164. /** @hidden */
  36165. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36166. private _setTextureParameterFloat;
  36167. private _setTextureParameterInteger;
  36168. /**
  36169. * Unbind all vertex attributes from the webGL context
  36170. */
  36171. unbindAllAttributes(): void;
  36172. /**
  36173. * 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
  36174. */
  36175. releaseEffects(): void;
  36176. /**
  36177. * Dispose and release all associated resources
  36178. */
  36179. dispose(): void;
  36180. /**
  36181. * Attach a new callback raised when context lost event is fired
  36182. * @param callback defines the callback to call
  36183. */
  36184. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36185. /**
  36186. * Attach a new callback raised when context restored event is fired
  36187. * @param callback defines the callback to call
  36188. */
  36189. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36190. /**
  36191. * Get the current error code of the webGL context
  36192. * @returns the error code
  36193. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36194. */
  36195. getError(): number;
  36196. private _canRenderToFloatFramebuffer;
  36197. private _canRenderToHalfFloatFramebuffer;
  36198. private _canRenderToFramebuffer;
  36199. /** @hidden */
  36200. _getWebGLTextureType(type: number): number;
  36201. /** @hidden */
  36202. _getInternalFormat(format: number): number;
  36203. /** @hidden */
  36204. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36205. /** @hidden */
  36206. _getRGBAMultiSampleBufferFormat(type: number): number;
  36207. /** @hidden */
  36208. _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;
  36209. /**
  36210. * Loads a file from a url
  36211. * @param url url to load
  36212. * @param onSuccess callback called when the file successfully loads
  36213. * @param onProgress callback called while file is loading (if the server supports this mode)
  36214. * @param offlineProvider defines the offline provider for caching
  36215. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36216. * @param onError callback called when the file fails to load
  36217. * @returns a file request object
  36218. * @hidden
  36219. */
  36220. 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;
  36221. /**
  36222. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36223. * @param x defines the x coordinate of the rectangle where pixels must be read
  36224. * @param y defines the y coordinate of the rectangle where pixels must be read
  36225. * @param width defines the width of the rectangle where pixels must be read
  36226. * @param height defines the height of the rectangle where pixels must be read
  36227. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36228. * @returns a Uint8Array containing RGBA colors
  36229. */
  36230. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36231. private static _isSupported;
  36232. /**
  36233. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36234. * @returns true if the engine can be created
  36235. * @ignorenaming
  36236. */
  36237. static isSupported(): boolean;
  36238. /**
  36239. * Find the next highest power of two.
  36240. * @param x Number to start search from.
  36241. * @return Next highest power of two.
  36242. */
  36243. static CeilingPOT(x: number): number;
  36244. /**
  36245. * Find the next lowest power of two.
  36246. * @param x Number to start search from.
  36247. * @return Next lowest power of two.
  36248. */
  36249. static FloorPOT(x: number): number;
  36250. /**
  36251. * Find the nearest power of two.
  36252. * @param x Number to start search from.
  36253. * @return Next nearest power of two.
  36254. */
  36255. static NearestPOT(x: number): number;
  36256. /**
  36257. * Get the closest exponent of two
  36258. * @param value defines the value to approximate
  36259. * @param max defines the maximum value to return
  36260. * @param mode defines how to define the closest value
  36261. * @returns closest exponent of two of the given value
  36262. */
  36263. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36264. /**
  36265. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36266. * @param func - the function to be called
  36267. * @param requester - the object that will request the next frame. Falls back to window.
  36268. * @returns frame number
  36269. */
  36270. static QueueNewFrame(func: () => void, requester?: any): number;
  36271. /**
  36272. * Gets host document
  36273. * @returns the host document object
  36274. */
  36275. getHostDocument(): Nullable<Document>;
  36276. }
  36277. }
  36278. declare module "babylonjs/Maths/sphericalPolynomial" {
  36279. import { Vector3 } from "babylonjs/Maths/math.vector";
  36280. import { Color3 } from "babylonjs/Maths/math.color";
  36281. /**
  36282. * Class representing spherical harmonics coefficients to the 3rd degree
  36283. */
  36284. export class SphericalHarmonics {
  36285. /**
  36286. * Defines whether or not the harmonics have been prescaled for rendering.
  36287. */
  36288. preScaled: boolean;
  36289. /**
  36290. * The l0,0 coefficients of the spherical harmonics
  36291. */
  36292. l00: Vector3;
  36293. /**
  36294. * The l1,-1 coefficients of the spherical harmonics
  36295. */
  36296. l1_1: Vector3;
  36297. /**
  36298. * The l1,0 coefficients of the spherical harmonics
  36299. */
  36300. l10: Vector3;
  36301. /**
  36302. * The l1,1 coefficients of the spherical harmonics
  36303. */
  36304. l11: Vector3;
  36305. /**
  36306. * The l2,-2 coefficients of the spherical harmonics
  36307. */
  36308. l2_2: Vector3;
  36309. /**
  36310. * The l2,-1 coefficients of the spherical harmonics
  36311. */
  36312. l2_1: Vector3;
  36313. /**
  36314. * The l2,0 coefficients of the spherical harmonics
  36315. */
  36316. l20: Vector3;
  36317. /**
  36318. * The l2,1 coefficients of the spherical harmonics
  36319. */
  36320. l21: Vector3;
  36321. /**
  36322. * The l2,2 coefficients of the spherical harmonics
  36323. */
  36324. l22: Vector3;
  36325. /**
  36326. * Adds a light to the spherical harmonics
  36327. * @param direction the direction of the light
  36328. * @param color the color of the light
  36329. * @param deltaSolidAngle the delta solid angle of the light
  36330. */
  36331. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36332. /**
  36333. * Scales the spherical harmonics by the given amount
  36334. * @param scale the amount to scale
  36335. */
  36336. scaleInPlace(scale: number): void;
  36337. /**
  36338. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36339. *
  36340. * ```
  36341. * E_lm = A_l * L_lm
  36342. * ```
  36343. *
  36344. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36345. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36346. * the scaling factors are given in equation 9.
  36347. */
  36348. convertIncidentRadianceToIrradiance(): void;
  36349. /**
  36350. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36351. *
  36352. * ```
  36353. * L = (1/pi) * E * rho
  36354. * ```
  36355. *
  36356. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36357. */
  36358. convertIrradianceToLambertianRadiance(): void;
  36359. /**
  36360. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36361. * required operations at run time.
  36362. *
  36363. * This is simply done by scaling back the SH with Ylm constants parameter.
  36364. * The trigonometric part being applied by the shader at run time.
  36365. */
  36366. preScaleForRendering(): void;
  36367. /**
  36368. * Constructs a spherical harmonics from an array.
  36369. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36370. * @returns the spherical harmonics
  36371. */
  36372. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36373. /**
  36374. * Gets the spherical harmonics from polynomial
  36375. * @param polynomial the spherical polynomial
  36376. * @returns the spherical harmonics
  36377. */
  36378. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36379. }
  36380. /**
  36381. * Class representing spherical polynomial coefficients to the 3rd degree
  36382. */
  36383. export class SphericalPolynomial {
  36384. private _harmonics;
  36385. /**
  36386. * The spherical harmonics used to create the polynomials.
  36387. */
  36388. get preScaledHarmonics(): SphericalHarmonics;
  36389. /**
  36390. * The x coefficients of the spherical polynomial
  36391. */
  36392. x: Vector3;
  36393. /**
  36394. * The y coefficients of the spherical polynomial
  36395. */
  36396. y: Vector3;
  36397. /**
  36398. * The z coefficients of the spherical polynomial
  36399. */
  36400. z: Vector3;
  36401. /**
  36402. * The xx coefficients of the spherical polynomial
  36403. */
  36404. xx: Vector3;
  36405. /**
  36406. * The yy coefficients of the spherical polynomial
  36407. */
  36408. yy: Vector3;
  36409. /**
  36410. * The zz coefficients of the spherical polynomial
  36411. */
  36412. zz: Vector3;
  36413. /**
  36414. * The xy coefficients of the spherical polynomial
  36415. */
  36416. xy: Vector3;
  36417. /**
  36418. * The yz coefficients of the spherical polynomial
  36419. */
  36420. yz: Vector3;
  36421. /**
  36422. * The zx coefficients of the spherical polynomial
  36423. */
  36424. zx: Vector3;
  36425. /**
  36426. * Adds an ambient color to the spherical polynomial
  36427. * @param color the color to add
  36428. */
  36429. addAmbient(color: Color3): void;
  36430. /**
  36431. * Scales the spherical polynomial by the given amount
  36432. * @param scale the amount to scale
  36433. */
  36434. scaleInPlace(scale: number): void;
  36435. /**
  36436. * Gets the spherical polynomial from harmonics
  36437. * @param harmonics the spherical harmonics
  36438. * @returns the spherical polynomial
  36439. */
  36440. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36441. /**
  36442. * Constructs a spherical polynomial from an array.
  36443. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36444. * @returns the spherical polynomial
  36445. */
  36446. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36447. }
  36448. }
  36449. declare module "babylonjs/Materials/Textures/internalTexture" {
  36450. import { Observable } from "babylonjs/Misc/observable";
  36451. import { Nullable, int } from "babylonjs/types";
  36452. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  36453. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36454. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  36455. /**
  36456. * Defines the source of the internal texture
  36457. */
  36458. export enum InternalTextureSource {
  36459. /**
  36460. * The source of the texture data is unknown
  36461. */
  36462. Unknown = 0,
  36463. /**
  36464. * Texture data comes from an URL
  36465. */
  36466. Url = 1,
  36467. /**
  36468. * Texture data is only used for temporary storage
  36469. */
  36470. Temp = 2,
  36471. /**
  36472. * Texture data comes from raw data (ArrayBuffer)
  36473. */
  36474. Raw = 3,
  36475. /**
  36476. * Texture content is dynamic (video or dynamic texture)
  36477. */
  36478. Dynamic = 4,
  36479. /**
  36480. * Texture content is generated by rendering to it
  36481. */
  36482. RenderTarget = 5,
  36483. /**
  36484. * Texture content is part of a multi render target process
  36485. */
  36486. MultiRenderTarget = 6,
  36487. /**
  36488. * Texture data comes from a cube data file
  36489. */
  36490. Cube = 7,
  36491. /**
  36492. * Texture data comes from a raw cube data
  36493. */
  36494. CubeRaw = 8,
  36495. /**
  36496. * Texture data come from a prefiltered cube data file
  36497. */
  36498. CubePrefiltered = 9,
  36499. /**
  36500. * Texture content is raw 3D data
  36501. */
  36502. Raw3D = 10,
  36503. /**
  36504. * Texture content is raw 2D array data
  36505. */
  36506. Raw2DArray = 11,
  36507. /**
  36508. * Texture content is a depth texture
  36509. */
  36510. Depth = 12,
  36511. /**
  36512. * Texture data comes from a raw cube data encoded with RGBD
  36513. */
  36514. CubeRawRGBD = 13
  36515. }
  36516. /**
  36517. * Class used to store data associated with WebGL texture data for the engine
  36518. * This class should not be used directly
  36519. */
  36520. export class InternalTexture {
  36521. /** @hidden */
  36522. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36523. /**
  36524. * Defines if the texture is ready
  36525. */
  36526. isReady: boolean;
  36527. /**
  36528. * Defines if the texture is a cube texture
  36529. */
  36530. isCube: boolean;
  36531. /**
  36532. * Defines if the texture contains 3D data
  36533. */
  36534. is3D: boolean;
  36535. /**
  36536. * Defines if the texture contains 2D array data
  36537. */
  36538. is2DArray: boolean;
  36539. /**
  36540. * Defines if the texture contains multiview data
  36541. */
  36542. isMultiview: boolean;
  36543. /**
  36544. * Gets the URL used to load this texture
  36545. */
  36546. url: string;
  36547. /**
  36548. * Gets the sampling mode of the texture
  36549. */
  36550. samplingMode: number;
  36551. /**
  36552. * Gets a boolean indicating if the texture needs mipmaps generation
  36553. */
  36554. generateMipMaps: boolean;
  36555. /**
  36556. * Gets the number of samples used by the texture (WebGL2+ only)
  36557. */
  36558. samples: number;
  36559. /**
  36560. * Gets the type of the texture (int, float...)
  36561. */
  36562. type: number;
  36563. /**
  36564. * Gets the format of the texture (RGB, RGBA...)
  36565. */
  36566. format: number;
  36567. /**
  36568. * Observable called when the texture is loaded
  36569. */
  36570. onLoadedObservable: Observable<InternalTexture>;
  36571. /**
  36572. * Gets the width of the texture
  36573. */
  36574. width: number;
  36575. /**
  36576. * Gets the height of the texture
  36577. */
  36578. height: number;
  36579. /**
  36580. * Gets the depth of the texture
  36581. */
  36582. depth: number;
  36583. /**
  36584. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36585. */
  36586. baseWidth: number;
  36587. /**
  36588. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36589. */
  36590. baseHeight: number;
  36591. /**
  36592. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36593. */
  36594. baseDepth: number;
  36595. /**
  36596. * Gets a boolean indicating if the texture is inverted on Y axis
  36597. */
  36598. invertY: boolean;
  36599. /** @hidden */
  36600. _invertVScale: boolean;
  36601. /** @hidden */
  36602. _associatedChannel: number;
  36603. /** @hidden */
  36604. _source: InternalTextureSource;
  36605. /** @hidden */
  36606. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36607. /** @hidden */
  36608. _bufferView: Nullable<ArrayBufferView>;
  36609. /** @hidden */
  36610. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36611. /** @hidden */
  36612. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36613. /** @hidden */
  36614. _size: number;
  36615. /** @hidden */
  36616. _extension: string;
  36617. /** @hidden */
  36618. _files: Nullable<string[]>;
  36619. /** @hidden */
  36620. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36621. /** @hidden */
  36622. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36623. /** @hidden */
  36624. _framebuffer: Nullable<WebGLFramebuffer>;
  36625. /** @hidden */
  36626. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36627. /** @hidden */
  36628. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36629. /** @hidden */
  36630. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36631. /** @hidden */
  36632. _attachments: Nullable<number[]>;
  36633. /** @hidden */
  36634. _cachedCoordinatesMode: Nullable<number>;
  36635. /** @hidden */
  36636. _cachedWrapU: Nullable<number>;
  36637. /** @hidden */
  36638. _cachedWrapV: Nullable<number>;
  36639. /** @hidden */
  36640. _cachedWrapR: Nullable<number>;
  36641. /** @hidden */
  36642. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36643. /** @hidden */
  36644. _isDisabled: boolean;
  36645. /** @hidden */
  36646. _compression: Nullable<string>;
  36647. /** @hidden */
  36648. _generateStencilBuffer: boolean;
  36649. /** @hidden */
  36650. _generateDepthBuffer: boolean;
  36651. /** @hidden */
  36652. _comparisonFunction: number;
  36653. /** @hidden */
  36654. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36655. /** @hidden */
  36656. _lodGenerationScale: number;
  36657. /** @hidden */
  36658. _lodGenerationOffset: number;
  36659. /** @hidden */
  36660. _depthStencilTexture: Nullable<InternalTexture>;
  36661. /** @hidden */
  36662. _colorTextureArray: Nullable<WebGLTexture>;
  36663. /** @hidden */
  36664. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36665. /** @hidden */
  36666. _lodTextureHigh: Nullable<BaseTexture>;
  36667. /** @hidden */
  36668. _lodTextureMid: Nullable<BaseTexture>;
  36669. /** @hidden */
  36670. _lodTextureLow: Nullable<BaseTexture>;
  36671. /** @hidden */
  36672. _isRGBD: boolean;
  36673. /** @hidden */
  36674. _linearSpecularLOD: boolean;
  36675. /** @hidden */
  36676. _irradianceTexture: Nullable<BaseTexture>;
  36677. /** @hidden */
  36678. _webGLTexture: Nullable<WebGLTexture>;
  36679. /** @hidden */
  36680. _references: number;
  36681. private _engine;
  36682. /**
  36683. * Gets the Engine the texture belongs to.
  36684. * @returns The babylon engine
  36685. */
  36686. getEngine(): ThinEngine;
  36687. /**
  36688. * Gets the data source type of the texture
  36689. */
  36690. get source(): InternalTextureSource;
  36691. /**
  36692. * Creates a new InternalTexture
  36693. * @param engine defines the engine to use
  36694. * @param source defines the type of data that will be used
  36695. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36696. */
  36697. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36698. /**
  36699. * Increments the number of references (ie. the number of Texture that point to it)
  36700. */
  36701. incrementReferences(): void;
  36702. /**
  36703. * Change the size of the texture (not the size of the content)
  36704. * @param width defines the new width
  36705. * @param height defines the new height
  36706. * @param depth defines the new depth (1 by default)
  36707. */
  36708. updateSize(width: int, height: int, depth?: int): void;
  36709. /** @hidden */
  36710. _rebuild(): void;
  36711. /** @hidden */
  36712. _swapAndDie(target: InternalTexture): void;
  36713. /**
  36714. * Dispose the current allocated resources
  36715. */
  36716. dispose(): void;
  36717. }
  36718. }
  36719. declare module "babylonjs/Audio/analyser" {
  36720. import { Scene } from "babylonjs/scene";
  36721. /**
  36722. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36723. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36724. */
  36725. export class Analyser {
  36726. /**
  36727. * Gets or sets the smoothing
  36728. * @ignorenaming
  36729. */
  36730. SMOOTHING: number;
  36731. /**
  36732. * Gets or sets the FFT table size
  36733. * @ignorenaming
  36734. */
  36735. FFT_SIZE: number;
  36736. /**
  36737. * Gets or sets the bar graph amplitude
  36738. * @ignorenaming
  36739. */
  36740. BARGRAPHAMPLITUDE: number;
  36741. /**
  36742. * Gets or sets the position of the debug canvas
  36743. * @ignorenaming
  36744. */
  36745. DEBUGCANVASPOS: {
  36746. x: number;
  36747. y: number;
  36748. };
  36749. /**
  36750. * Gets or sets the debug canvas size
  36751. * @ignorenaming
  36752. */
  36753. DEBUGCANVASSIZE: {
  36754. width: number;
  36755. height: number;
  36756. };
  36757. private _byteFreqs;
  36758. private _byteTime;
  36759. private _floatFreqs;
  36760. private _webAudioAnalyser;
  36761. private _debugCanvas;
  36762. private _debugCanvasContext;
  36763. private _scene;
  36764. private _registerFunc;
  36765. private _audioEngine;
  36766. /**
  36767. * Creates a new analyser
  36768. * @param scene defines hosting scene
  36769. */
  36770. constructor(scene: Scene);
  36771. /**
  36772. * Get the number of data values you will have to play with for the visualization
  36773. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36774. * @returns a number
  36775. */
  36776. getFrequencyBinCount(): number;
  36777. /**
  36778. * Gets the current frequency data as a byte array
  36779. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36780. * @returns a Uint8Array
  36781. */
  36782. getByteFrequencyData(): Uint8Array;
  36783. /**
  36784. * Gets the current waveform as a byte array
  36785. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36786. * @returns a Uint8Array
  36787. */
  36788. getByteTimeDomainData(): Uint8Array;
  36789. /**
  36790. * Gets the current frequency data as a float array
  36791. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36792. * @returns a Float32Array
  36793. */
  36794. getFloatFrequencyData(): Float32Array;
  36795. /**
  36796. * Renders the debug canvas
  36797. */
  36798. drawDebugCanvas(): void;
  36799. /**
  36800. * Stops rendering the debug canvas and removes it
  36801. */
  36802. stopDebugCanvas(): void;
  36803. /**
  36804. * Connects two audio nodes
  36805. * @param inputAudioNode defines first node to connect
  36806. * @param outputAudioNode defines second node to connect
  36807. */
  36808. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36809. /**
  36810. * Releases all associated resources
  36811. */
  36812. dispose(): void;
  36813. }
  36814. }
  36815. declare module "babylonjs/Audio/audioEngine" {
  36816. import { IDisposable } from "babylonjs/scene";
  36817. import { Analyser } from "babylonjs/Audio/analyser";
  36818. import { Nullable } from "babylonjs/types";
  36819. import { Observable } from "babylonjs/Misc/observable";
  36820. /**
  36821. * This represents an audio engine and it is responsible
  36822. * to play, synchronize and analyse sounds throughout the application.
  36823. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36824. */
  36825. export interface IAudioEngine extends IDisposable {
  36826. /**
  36827. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36828. */
  36829. readonly canUseWebAudio: boolean;
  36830. /**
  36831. * Gets the current AudioContext if available.
  36832. */
  36833. readonly audioContext: Nullable<AudioContext>;
  36834. /**
  36835. * The master gain node defines the global audio volume of your audio engine.
  36836. */
  36837. readonly masterGain: GainNode;
  36838. /**
  36839. * Gets whether or not mp3 are supported by your browser.
  36840. */
  36841. readonly isMP3supported: boolean;
  36842. /**
  36843. * Gets whether or not ogg are supported by your browser.
  36844. */
  36845. readonly isOGGsupported: boolean;
  36846. /**
  36847. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36848. * @ignoreNaming
  36849. */
  36850. WarnedWebAudioUnsupported: boolean;
  36851. /**
  36852. * Defines if the audio engine relies on a custom unlocked button.
  36853. * In this case, the embedded button will not be displayed.
  36854. */
  36855. useCustomUnlockedButton: boolean;
  36856. /**
  36857. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36858. */
  36859. readonly unlocked: boolean;
  36860. /**
  36861. * Event raised when audio has been unlocked on the browser.
  36862. */
  36863. onAudioUnlockedObservable: Observable<AudioEngine>;
  36864. /**
  36865. * Event raised when audio has been locked on the browser.
  36866. */
  36867. onAudioLockedObservable: Observable<AudioEngine>;
  36868. /**
  36869. * Flags the audio engine in Locked state.
  36870. * This happens due to new browser policies preventing audio to autoplay.
  36871. */
  36872. lock(): void;
  36873. /**
  36874. * Unlocks the audio engine once a user action has been done on the dom.
  36875. * This is helpful to resume play once browser policies have been satisfied.
  36876. */
  36877. unlock(): void;
  36878. /**
  36879. * Gets the global volume sets on the master gain.
  36880. * @returns the global volume if set or -1 otherwise
  36881. */
  36882. getGlobalVolume(): number;
  36883. /**
  36884. * Sets the global volume of your experience (sets on the master gain).
  36885. * @param newVolume Defines the new global volume of the application
  36886. */
  36887. setGlobalVolume(newVolume: number): void;
  36888. /**
  36889. * Connect the audio engine to an audio analyser allowing some amazing
  36890. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36892. * @param analyser The analyser to connect to the engine
  36893. */
  36894. connectToAnalyser(analyser: Analyser): void;
  36895. }
  36896. /**
  36897. * This represents the default audio engine used in babylon.
  36898. * It is responsible to play, synchronize and analyse sounds throughout the application.
  36899. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36900. */
  36901. export class AudioEngine implements IAudioEngine {
  36902. private _audioContext;
  36903. private _audioContextInitialized;
  36904. private _muteButton;
  36905. private _hostElement;
  36906. /**
  36907. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36908. */
  36909. canUseWebAudio: boolean;
  36910. /**
  36911. * The master gain node defines the global audio volume of your audio engine.
  36912. */
  36913. masterGain: GainNode;
  36914. /**
  36915. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36916. * @ignoreNaming
  36917. */
  36918. WarnedWebAudioUnsupported: boolean;
  36919. /**
  36920. * Gets whether or not mp3 are supported by your browser.
  36921. */
  36922. isMP3supported: boolean;
  36923. /**
  36924. * Gets whether or not ogg are supported by your browser.
  36925. */
  36926. isOGGsupported: boolean;
  36927. /**
  36928. * Gets whether audio has been unlocked on the device.
  36929. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  36930. * a user interaction has happened.
  36931. */
  36932. unlocked: boolean;
  36933. /**
  36934. * Defines if the audio engine relies on a custom unlocked button.
  36935. * In this case, the embedded button will not be displayed.
  36936. */
  36937. useCustomUnlockedButton: boolean;
  36938. /**
  36939. * Event raised when audio has been unlocked on the browser.
  36940. */
  36941. onAudioUnlockedObservable: Observable<AudioEngine>;
  36942. /**
  36943. * Event raised when audio has been locked on the browser.
  36944. */
  36945. onAudioLockedObservable: Observable<AudioEngine>;
  36946. /**
  36947. * Gets the current AudioContext if available.
  36948. */
  36949. get audioContext(): Nullable<AudioContext>;
  36950. private _connectedAnalyser;
  36951. /**
  36952. * Instantiates a new audio engine.
  36953. *
  36954. * There should be only one per page as some browsers restrict the number
  36955. * of audio contexts you can create.
  36956. * @param hostElement defines the host element where to display the mute icon if necessary
  36957. */
  36958. constructor(hostElement?: Nullable<HTMLElement>);
  36959. /**
  36960. * Flags the audio engine in Locked state.
  36961. * This happens due to new browser policies preventing audio to autoplay.
  36962. */
  36963. lock(): void;
  36964. /**
  36965. * Unlocks the audio engine once a user action has been done on the dom.
  36966. * This is helpful to resume play once browser policies have been satisfied.
  36967. */
  36968. unlock(): void;
  36969. private _resumeAudioContext;
  36970. private _initializeAudioContext;
  36971. private _tryToRun;
  36972. private _triggerRunningState;
  36973. private _triggerSuspendedState;
  36974. private _displayMuteButton;
  36975. private _moveButtonToTopLeft;
  36976. private _onResize;
  36977. private _hideMuteButton;
  36978. /**
  36979. * Destroy and release the resources associated with the audio ccontext.
  36980. */
  36981. dispose(): void;
  36982. /**
  36983. * Gets the global volume sets on the master gain.
  36984. * @returns the global volume if set or -1 otherwise
  36985. */
  36986. getGlobalVolume(): number;
  36987. /**
  36988. * Sets the global volume of your experience (sets on the master gain).
  36989. * @param newVolume Defines the new global volume of the application
  36990. */
  36991. setGlobalVolume(newVolume: number): void;
  36992. /**
  36993. * Connect the audio engine to an audio analyser allowing some amazing
  36994. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36995. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36996. * @param analyser The analyser to connect to the engine
  36997. */
  36998. connectToAnalyser(analyser: Analyser): void;
  36999. }
  37000. }
  37001. declare module "babylonjs/Loading/loadingScreen" {
  37002. /**
  37003. * Interface used to present a loading screen while loading a scene
  37004. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37005. */
  37006. export interface ILoadingScreen {
  37007. /**
  37008. * Function called to display the loading screen
  37009. */
  37010. displayLoadingUI: () => void;
  37011. /**
  37012. * Function called to hide the loading screen
  37013. */
  37014. hideLoadingUI: () => void;
  37015. /**
  37016. * Gets or sets the color to use for the background
  37017. */
  37018. loadingUIBackgroundColor: string;
  37019. /**
  37020. * Gets or sets the text to display while loading
  37021. */
  37022. loadingUIText: string;
  37023. }
  37024. /**
  37025. * Class used for the default loading screen
  37026. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37027. */
  37028. export class DefaultLoadingScreen implements ILoadingScreen {
  37029. private _renderingCanvas;
  37030. private _loadingText;
  37031. private _loadingDivBackgroundColor;
  37032. private _loadingDiv;
  37033. private _loadingTextDiv;
  37034. /** Gets or sets the logo url to use for the default loading screen */
  37035. static DefaultLogoUrl: string;
  37036. /** Gets or sets the spinner url to use for the default loading screen */
  37037. static DefaultSpinnerUrl: string;
  37038. /**
  37039. * Creates a new default loading screen
  37040. * @param _renderingCanvas defines the canvas used to render the scene
  37041. * @param _loadingText defines the default text to display
  37042. * @param _loadingDivBackgroundColor defines the default background color
  37043. */
  37044. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37045. /**
  37046. * Function called to display the loading screen
  37047. */
  37048. displayLoadingUI(): void;
  37049. /**
  37050. * Function called to hide the loading screen
  37051. */
  37052. hideLoadingUI(): void;
  37053. /**
  37054. * Gets or sets the text to display while loading
  37055. */
  37056. set loadingUIText(text: string);
  37057. get loadingUIText(): string;
  37058. /**
  37059. * Gets or sets the color to use for the background
  37060. */
  37061. get loadingUIBackgroundColor(): string;
  37062. set loadingUIBackgroundColor(color: string);
  37063. private _resizeLoadingUI;
  37064. }
  37065. }
  37066. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  37067. /**
  37068. * Interface for any object that can request an animation frame
  37069. */
  37070. export interface ICustomAnimationFrameRequester {
  37071. /**
  37072. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37073. */
  37074. renderFunction?: Function;
  37075. /**
  37076. * Called to request the next frame to render to
  37077. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37078. */
  37079. requestAnimationFrame: Function;
  37080. /**
  37081. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37082. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37083. */
  37084. requestID?: number;
  37085. }
  37086. }
  37087. declare module "babylonjs/Misc/performanceMonitor" {
  37088. /**
  37089. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37090. */
  37091. export class PerformanceMonitor {
  37092. private _enabled;
  37093. private _rollingFrameTime;
  37094. private _lastFrameTimeMs;
  37095. /**
  37096. * constructor
  37097. * @param frameSampleSize The number of samples required to saturate the sliding window
  37098. */
  37099. constructor(frameSampleSize?: number);
  37100. /**
  37101. * Samples current frame
  37102. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37103. */
  37104. sampleFrame(timeMs?: number): void;
  37105. /**
  37106. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37107. */
  37108. get averageFrameTime(): number;
  37109. /**
  37110. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37111. */
  37112. get averageFrameTimeVariance(): number;
  37113. /**
  37114. * Returns the frame time of the most recent frame
  37115. */
  37116. get instantaneousFrameTime(): number;
  37117. /**
  37118. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37119. */
  37120. get averageFPS(): number;
  37121. /**
  37122. * Returns the average framerate in frames per second using the most recent frame time
  37123. */
  37124. get instantaneousFPS(): number;
  37125. /**
  37126. * Returns true if enough samples have been taken to completely fill the sliding window
  37127. */
  37128. get isSaturated(): boolean;
  37129. /**
  37130. * Enables contributions to the sliding window sample set
  37131. */
  37132. enable(): void;
  37133. /**
  37134. * Disables contributions to the sliding window sample set
  37135. * Samples will not be interpolated over the disabled period
  37136. */
  37137. disable(): void;
  37138. /**
  37139. * Returns true if sampling is enabled
  37140. */
  37141. get isEnabled(): boolean;
  37142. /**
  37143. * Resets performance monitor
  37144. */
  37145. reset(): void;
  37146. }
  37147. /**
  37148. * RollingAverage
  37149. *
  37150. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37151. */
  37152. export class RollingAverage {
  37153. /**
  37154. * Current average
  37155. */
  37156. average: number;
  37157. /**
  37158. * Current variance
  37159. */
  37160. variance: number;
  37161. protected _samples: Array<number>;
  37162. protected _sampleCount: number;
  37163. protected _pos: number;
  37164. protected _m2: number;
  37165. /**
  37166. * constructor
  37167. * @param length The number of samples required to saturate the sliding window
  37168. */
  37169. constructor(length: number);
  37170. /**
  37171. * Adds a sample to the sample set
  37172. * @param v The sample value
  37173. */
  37174. add(v: number): void;
  37175. /**
  37176. * Returns previously added values or null if outside of history or outside the sliding window domain
  37177. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37178. * @return Value previously recorded with add() or null if outside of range
  37179. */
  37180. history(i: number): number;
  37181. /**
  37182. * Returns true if enough samples have been taken to completely fill the sliding window
  37183. * @return true if sample-set saturated
  37184. */
  37185. isSaturated(): boolean;
  37186. /**
  37187. * Resets the rolling average (equivalent to 0 samples taken so far)
  37188. */
  37189. reset(): void;
  37190. /**
  37191. * Wraps a value around the sample range boundaries
  37192. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37193. * @return Wrapped position in sample range
  37194. */
  37195. protected _wrapPosition(i: number): number;
  37196. }
  37197. }
  37198. declare module "babylonjs/Misc/perfCounter" {
  37199. /**
  37200. * This class is used to track a performance counter which is number based.
  37201. * The user has access to many properties which give statistics of different nature.
  37202. *
  37203. * The implementer can track two kinds of Performance Counter: time and count.
  37204. * 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.
  37205. * 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.
  37206. */
  37207. export class PerfCounter {
  37208. /**
  37209. * Gets or sets a global boolean to turn on and off all the counters
  37210. */
  37211. static Enabled: boolean;
  37212. /**
  37213. * Returns the smallest value ever
  37214. */
  37215. get min(): number;
  37216. /**
  37217. * Returns the biggest value ever
  37218. */
  37219. get max(): number;
  37220. /**
  37221. * Returns the average value since the performance counter is running
  37222. */
  37223. get average(): number;
  37224. /**
  37225. * Returns the average value of the last second the counter was monitored
  37226. */
  37227. get lastSecAverage(): number;
  37228. /**
  37229. * Returns the current value
  37230. */
  37231. get current(): number;
  37232. /**
  37233. * Gets the accumulated total
  37234. */
  37235. get total(): number;
  37236. /**
  37237. * Gets the total value count
  37238. */
  37239. get count(): number;
  37240. /**
  37241. * Creates a new counter
  37242. */
  37243. constructor();
  37244. /**
  37245. * Call this method to start monitoring a new frame.
  37246. * 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.
  37247. */
  37248. fetchNewFrame(): void;
  37249. /**
  37250. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37251. * @param newCount the count value to add to the monitored count
  37252. * @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.
  37253. */
  37254. addCount(newCount: number, fetchResult: boolean): void;
  37255. /**
  37256. * Start monitoring this performance counter
  37257. */
  37258. beginMonitoring(): void;
  37259. /**
  37260. * Compute the time lapsed since the previous beginMonitoring() call.
  37261. * @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
  37262. */
  37263. endMonitoring(newFrame?: boolean): void;
  37264. private _fetchResult;
  37265. private _startMonitoringTime;
  37266. private _min;
  37267. private _max;
  37268. private _average;
  37269. private _current;
  37270. private _totalValueCount;
  37271. private _totalAccumulated;
  37272. private _lastSecAverage;
  37273. private _lastSecAccumulated;
  37274. private _lastSecTime;
  37275. private _lastSecValueCount;
  37276. }
  37277. }
  37278. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  37279. module "babylonjs/Engines/thinEngine" {
  37280. interface ThinEngine {
  37281. /**
  37282. * Sets alpha constants used by some alpha blending modes
  37283. * @param r defines the red component
  37284. * @param g defines the green component
  37285. * @param b defines the blue component
  37286. * @param a defines the alpha component
  37287. */
  37288. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37289. /**
  37290. * Sets the current alpha mode
  37291. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37292. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37293. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37294. */
  37295. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37296. /**
  37297. * Gets the current alpha mode
  37298. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37299. * @returns the current alpha mode
  37300. */
  37301. getAlphaMode(): number;
  37302. /**
  37303. * Sets the current alpha equation
  37304. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37305. */
  37306. setAlphaEquation(equation: number): void;
  37307. /**
  37308. * Gets the current alpha equation.
  37309. * @returns the current alpha equation
  37310. */
  37311. getAlphaEquation(): number;
  37312. }
  37313. }
  37314. }
  37315. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  37316. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37317. import { Nullable } from "babylonjs/types";
  37318. module "babylonjs/Engines/thinEngine" {
  37319. interface ThinEngine {
  37320. /** @hidden */
  37321. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37322. }
  37323. }
  37324. }
  37325. declare module "babylonjs/Engines/engine" {
  37326. import { Observable } from "babylonjs/Misc/observable";
  37327. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  37328. import { Scene } from "babylonjs/scene";
  37329. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37330. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  37331. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  37332. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  37333. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  37334. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  37335. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  37336. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  37337. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  37338. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  37339. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  37340. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  37341. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  37342. import "babylonjs/Engines/Extensions/engine.alpha";
  37343. import "babylonjs/Engines/Extensions/engine.readTexture";
  37344. import { Material } from "babylonjs/Materials/material";
  37345. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37346. /**
  37347. * Defines the interface used by display changed events
  37348. */
  37349. export interface IDisplayChangedEventArgs {
  37350. /** Gets the vrDisplay object (if any) */
  37351. vrDisplay: Nullable<any>;
  37352. /** Gets a boolean indicating if webVR is supported */
  37353. vrSupported: boolean;
  37354. }
  37355. /**
  37356. * Defines the interface used by objects containing a viewport (like a camera)
  37357. */
  37358. interface IViewportOwnerLike {
  37359. /**
  37360. * Gets or sets the viewport
  37361. */
  37362. viewport: IViewportLike;
  37363. }
  37364. /**
  37365. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37366. */
  37367. export class Engine extends ThinEngine {
  37368. /** Defines that alpha blending is disabled */
  37369. static readonly ALPHA_DISABLE: number;
  37370. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37371. static readonly ALPHA_ADD: number;
  37372. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37373. static readonly ALPHA_COMBINE: number;
  37374. /** Defines that alpha blending to DEST - SRC * DEST */
  37375. static readonly ALPHA_SUBTRACT: number;
  37376. /** Defines that alpha blending to SRC * DEST */
  37377. static readonly ALPHA_MULTIPLY: number;
  37378. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37379. static readonly ALPHA_MAXIMIZED: number;
  37380. /** Defines that alpha blending to SRC + DEST */
  37381. static readonly ALPHA_ONEONE: number;
  37382. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37383. static readonly ALPHA_PREMULTIPLIED: number;
  37384. /**
  37385. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37386. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37387. */
  37388. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37389. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37390. static readonly ALPHA_INTERPOLATE: number;
  37391. /**
  37392. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37393. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37394. */
  37395. static readonly ALPHA_SCREENMODE: number;
  37396. /** Defines that the ressource is not delayed*/
  37397. static readonly DELAYLOADSTATE_NONE: number;
  37398. /** Defines that the ressource was successfully delay loaded */
  37399. static readonly DELAYLOADSTATE_LOADED: number;
  37400. /** Defines that the ressource is currently delay loading */
  37401. static readonly DELAYLOADSTATE_LOADING: number;
  37402. /** Defines that the ressource is delayed and has not started loading */
  37403. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37404. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37405. static readonly NEVER: number;
  37406. /** 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 */
  37407. static readonly ALWAYS: number;
  37408. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37409. static readonly LESS: number;
  37410. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37411. static readonly EQUAL: number;
  37412. /** 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 */
  37413. static readonly LEQUAL: number;
  37414. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37415. static readonly GREATER: number;
  37416. /** 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 */
  37417. static readonly GEQUAL: number;
  37418. /** 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 */
  37419. static readonly NOTEQUAL: number;
  37420. /** Passed to stencilOperation to specify that stencil value must be kept */
  37421. static readonly KEEP: number;
  37422. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37423. static readonly REPLACE: number;
  37424. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37425. static readonly INCR: number;
  37426. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37427. static readonly DECR: number;
  37428. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37429. static readonly INVERT: number;
  37430. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37431. static readonly INCR_WRAP: number;
  37432. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37433. static readonly DECR_WRAP: number;
  37434. /** Texture is not repeating outside of 0..1 UVs */
  37435. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37436. /** Texture is repeating outside of 0..1 UVs */
  37437. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37438. /** Texture is repeating and mirrored */
  37439. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37440. /** ALPHA */
  37441. static readonly TEXTUREFORMAT_ALPHA: number;
  37442. /** LUMINANCE */
  37443. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37444. /** LUMINANCE_ALPHA */
  37445. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37446. /** RGB */
  37447. static readonly TEXTUREFORMAT_RGB: number;
  37448. /** RGBA */
  37449. static readonly TEXTUREFORMAT_RGBA: number;
  37450. /** RED */
  37451. static readonly TEXTUREFORMAT_RED: number;
  37452. /** RED (2nd reference) */
  37453. static readonly TEXTUREFORMAT_R: number;
  37454. /** RG */
  37455. static readonly TEXTUREFORMAT_RG: number;
  37456. /** RED_INTEGER */
  37457. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37458. /** RED_INTEGER (2nd reference) */
  37459. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37460. /** RG_INTEGER */
  37461. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37462. /** RGB_INTEGER */
  37463. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37464. /** RGBA_INTEGER */
  37465. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37466. /** UNSIGNED_BYTE */
  37467. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37468. /** UNSIGNED_BYTE (2nd reference) */
  37469. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37470. /** FLOAT */
  37471. static readonly TEXTURETYPE_FLOAT: number;
  37472. /** HALF_FLOAT */
  37473. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37474. /** BYTE */
  37475. static readonly TEXTURETYPE_BYTE: number;
  37476. /** SHORT */
  37477. static readonly TEXTURETYPE_SHORT: number;
  37478. /** UNSIGNED_SHORT */
  37479. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37480. /** INT */
  37481. static readonly TEXTURETYPE_INT: number;
  37482. /** UNSIGNED_INT */
  37483. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37484. /** UNSIGNED_SHORT_4_4_4_4 */
  37485. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37486. /** UNSIGNED_SHORT_5_5_5_1 */
  37487. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37488. /** UNSIGNED_SHORT_5_6_5 */
  37489. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37490. /** UNSIGNED_INT_2_10_10_10_REV */
  37491. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37492. /** UNSIGNED_INT_24_8 */
  37493. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37494. /** UNSIGNED_INT_10F_11F_11F_REV */
  37495. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37496. /** UNSIGNED_INT_5_9_9_9_REV */
  37497. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37498. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37499. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37500. /** nearest is mag = nearest and min = nearest and mip = linear */
  37501. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37502. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37503. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37504. /** Trilinear is mag = linear and min = linear and mip = linear */
  37505. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37506. /** nearest is mag = nearest and min = nearest and mip = linear */
  37507. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37508. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37509. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37510. /** Trilinear is mag = linear and min = linear and mip = linear */
  37511. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37512. /** mag = nearest and min = nearest and mip = nearest */
  37513. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37514. /** mag = nearest and min = linear and mip = nearest */
  37515. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37516. /** mag = nearest and min = linear and mip = linear */
  37517. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37518. /** mag = nearest and min = linear and mip = none */
  37519. static readonly TEXTURE_NEAREST_LINEAR: number;
  37520. /** mag = nearest and min = nearest and mip = none */
  37521. static readonly TEXTURE_NEAREST_NEAREST: number;
  37522. /** mag = linear and min = nearest and mip = nearest */
  37523. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37524. /** mag = linear and min = nearest and mip = linear */
  37525. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37526. /** mag = linear and min = linear and mip = none */
  37527. static readonly TEXTURE_LINEAR_LINEAR: number;
  37528. /** mag = linear and min = nearest and mip = none */
  37529. static readonly TEXTURE_LINEAR_NEAREST: number;
  37530. /** Explicit coordinates mode */
  37531. static readonly TEXTURE_EXPLICIT_MODE: number;
  37532. /** Spherical coordinates mode */
  37533. static readonly TEXTURE_SPHERICAL_MODE: number;
  37534. /** Planar coordinates mode */
  37535. static readonly TEXTURE_PLANAR_MODE: number;
  37536. /** Cubic coordinates mode */
  37537. static readonly TEXTURE_CUBIC_MODE: number;
  37538. /** Projection coordinates mode */
  37539. static readonly TEXTURE_PROJECTION_MODE: number;
  37540. /** Skybox coordinates mode */
  37541. static readonly TEXTURE_SKYBOX_MODE: number;
  37542. /** Inverse Cubic coordinates mode */
  37543. static readonly TEXTURE_INVCUBIC_MODE: number;
  37544. /** Equirectangular coordinates mode */
  37545. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37546. /** Equirectangular Fixed coordinates mode */
  37547. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37548. /** Equirectangular Fixed Mirrored coordinates mode */
  37549. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37550. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37551. static readonly SCALEMODE_FLOOR: number;
  37552. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37553. static readonly SCALEMODE_NEAREST: number;
  37554. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37555. static readonly SCALEMODE_CEILING: number;
  37556. /**
  37557. * Returns the current npm package of the sdk
  37558. */
  37559. static get NpmPackage(): string;
  37560. /**
  37561. * Returns the current version of the framework
  37562. */
  37563. static get Version(): string;
  37564. /** Gets the list of created engines */
  37565. static get Instances(): Engine[];
  37566. /**
  37567. * Gets the latest created engine
  37568. */
  37569. static get LastCreatedEngine(): Nullable<Engine>;
  37570. /**
  37571. * Gets the latest created scene
  37572. */
  37573. static get LastCreatedScene(): Nullable<Scene>;
  37574. /**
  37575. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37576. * @param flag defines which part of the materials must be marked as dirty
  37577. * @param predicate defines a predicate used to filter which materials should be affected
  37578. */
  37579. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37580. /**
  37581. * Method called to create the default loading screen.
  37582. * This can be overriden in your own app.
  37583. * @param canvas The rendering canvas element
  37584. * @returns The loading screen
  37585. */
  37586. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37587. /**
  37588. * Method called to create the default rescale post process on each engine.
  37589. */
  37590. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37591. /**
  37592. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37593. **/
  37594. enableOfflineSupport: boolean;
  37595. /**
  37596. * 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)
  37597. **/
  37598. disableManifestCheck: boolean;
  37599. /**
  37600. * Gets the list of created scenes
  37601. */
  37602. scenes: Scene[];
  37603. /**
  37604. * Event raised when a new scene is created
  37605. */
  37606. onNewSceneAddedObservable: Observable<Scene>;
  37607. /**
  37608. * Gets the list of created postprocesses
  37609. */
  37610. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  37611. /**
  37612. * Gets a boolean indicating if the pointer is currently locked
  37613. */
  37614. isPointerLock: boolean;
  37615. /**
  37616. * Observable event triggered each time the rendering canvas is resized
  37617. */
  37618. onResizeObservable: Observable<Engine>;
  37619. /**
  37620. * Observable event triggered each time the canvas loses focus
  37621. */
  37622. onCanvasBlurObservable: Observable<Engine>;
  37623. /**
  37624. * Observable event triggered each time the canvas gains focus
  37625. */
  37626. onCanvasFocusObservable: Observable<Engine>;
  37627. /**
  37628. * Observable event triggered each time the canvas receives pointerout event
  37629. */
  37630. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37631. /**
  37632. * Observable raised when the engine begins a new frame
  37633. */
  37634. onBeginFrameObservable: Observable<Engine>;
  37635. /**
  37636. * If set, will be used to request the next animation frame for the render loop
  37637. */
  37638. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37639. /**
  37640. * Observable raised when the engine ends the current frame
  37641. */
  37642. onEndFrameObservable: Observable<Engine>;
  37643. /**
  37644. * Observable raised when the engine is about to compile a shader
  37645. */
  37646. onBeforeShaderCompilationObservable: Observable<Engine>;
  37647. /**
  37648. * Observable raised when the engine has jsut compiled a shader
  37649. */
  37650. onAfterShaderCompilationObservable: Observable<Engine>;
  37651. /**
  37652. * Gets the audio engine
  37653. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37654. * @ignorenaming
  37655. */
  37656. static audioEngine: IAudioEngine;
  37657. /**
  37658. * Default AudioEngine factory responsible of creating the Audio Engine.
  37659. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37660. */
  37661. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37662. /**
  37663. * Default offline support factory responsible of creating a tool used to store data locally.
  37664. * By default, this will create a Database object if the workload has been embedded.
  37665. */
  37666. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37667. private _loadingScreen;
  37668. private _pointerLockRequested;
  37669. private _rescalePostProcess;
  37670. private _deterministicLockstep;
  37671. private _lockstepMaxSteps;
  37672. private _timeStep;
  37673. protected get _supportsHardwareTextureRescaling(): boolean;
  37674. private _fps;
  37675. private _deltaTime;
  37676. /** @hidden */
  37677. _drawCalls: PerfCounter;
  37678. /** 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 */
  37679. canvasTabIndex: number;
  37680. /**
  37681. * Turn this value on if you want to pause FPS computation when in background
  37682. */
  37683. disablePerformanceMonitorInBackground: boolean;
  37684. private _performanceMonitor;
  37685. /**
  37686. * Gets the performance monitor attached to this engine
  37687. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37688. */
  37689. get performanceMonitor(): PerformanceMonitor;
  37690. private _onFocus;
  37691. private _onBlur;
  37692. private _onCanvasPointerOut;
  37693. private _onCanvasBlur;
  37694. private _onCanvasFocus;
  37695. private _onFullscreenChange;
  37696. private _onPointerLockChange;
  37697. /**
  37698. * Gets the HTML element used to attach event listeners
  37699. * @returns a HTML element
  37700. */
  37701. getInputElement(): Nullable<HTMLElement>;
  37702. /**
  37703. * Creates a new engine
  37704. * @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
  37705. * @param antialias defines enable antialiasing (default: false)
  37706. * @param options defines further options to be sent to the getContext() function
  37707. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37708. */
  37709. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37710. /**
  37711. * Gets current aspect ratio
  37712. * @param viewportOwner defines the camera to use to get the aspect ratio
  37713. * @param useScreen defines if screen size must be used (or the current render target if any)
  37714. * @returns a number defining the aspect ratio
  37715. */
  37716. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37717. /**
  37718. * Gets current screen aspect ratio
  37719. * @returns a number defining the aspect ratio
  37720. */
  37721. getScreenAspectRatio(): number;
  37722. /**
  37723. * Gets the client rect of the HTML canvas attached with the current webGL context
  37724. * @returns a client rectanglee
  37725. */
  37726. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37727. /**
  37728. * Gets the client rect of the HTML element used for events
  37729. * @returns a client rectanglee
  37730. */
  37731. getInputElementClientRect(): Nullable<ClientRect>;
  37732. /**
  37733. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37734. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37735. * @returns true if engine is in deterministic lock step mode
  37736. */
  37737. isDeterministicLockStep(): boolean;
  37738. /**
  37739. * Gets the max steps when engine is running in deterministic lock step
  37740. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37741. * @returns the max steps
  37742. */
  37743. getLockstepMaxSteps(): number;
  37744. /**
  37745. * Returns the time in ms between steps when using deterministic lock step.
  37746. * @returns time step in (ms)
  37747. */
  37748. getTimeStep(): number;
  37749. /**
  37750. * Force the mipmap generation for the given render target texture
  37751. * @param texture defines the render target texture to use
  37752. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37753. */
  37754. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37755. /** States */
  37756. /**
  37757. * Set various states to the webGL context
  37758. * @param culling defines backface culling state
  37759. * @param zOffset defines the value to apply to zOffset (0 by default)
  37760. * @param force defines if states must be applied even if cache is up to date
  37761. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37762. */
  37763. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37764. /**
  37765. * Set the z offset to apply to current rendering
  37766. * @param value defines the offset to apply
  37767. */
  37768. setZOffset(value: number): void;
  37769. /**
  37770. * Gets the current value of the zOffset
  37771. * @returns the current zOffset state
  37772. */
  37773. getZOffset(): number;
  37774. /**
  37775. * Enable or disable depth buffering
  37776. * @param enable defines the state to set
  37777. */
  37778. setDepthBuffer(enable: boolean): void;
  37779. /**
  37780. * Gets a boolean indicating if depth writing is enabled
  37781. * @returns the current depth writing state
  37782. */
  37783. getDepthWrite(): boolean;
  37784. /**
  37785. * Enable or disable depth writing
  37786. * @param enable defines the state to set
  37787. */
  37788. setDepthWrite(enable: boolean): void;
  37789. /**
  37790. * Gets a boolean indicating if stencil buffer is enabled
  37791. * @returns the current stencil buffer state
  37792. */
  37793. getStencilBuffer(): boolean;
  37794. /**
  37795. * Enable or disable the stencil buffer
  37796. * @param enable defines if the stencil buffer must be enabled or disabled
  37797. */
  37798. setStencilBuffer(enable: boolean): void;
  37799. /**
  37800. * Gets the current stencil mask
  37801. * @returns a number defining the new stencil mask to use
  37802. */
  37803. getStencilMask(): number;
  37804. /**
  37805. * Sets the current stencil mask
  37806. * @param mask defines the new stencil mask to use
  37807. */
  37808. setStencilMask(mask: number): void;
  37809. /**
  37810. * Gets the current stencil function
  37811. * @returns a number defining the stencil function to use
  37812. */
  37813. getStencilFunction(): number;
  37814. /**
  37815. * Gets the current stencil reference value
  37816. * @returns a number defining the stencil reference value to use
  37817. */
  37818. getStencilFunctionReference(): number;
  37819. /**
  37820. * Gets the current stencil mask
  37821. * @returns a number defining the stencil mask to use
  37822. */
  37823. getStencilFunctionMask(): number;
  37824. /**
  37825. * Sets the current stencil function
  37826. * @param stencilFunc defines the new stencil function to use
  37827. */
  37828. setStencilFunction(stencilFunc: number): void;
  37829. /**
  37830. * Sets the current stencil reference
  37831. * @param reference defines the new stencil reference to use
  37832. */
  37833. setStencilFunctionReference(reference: number): void;
  37834. /**
  37835. * Sets the current stencil mask
  37836. * @param mask defines the new stencil mask to use
  37837. */
  37838. setStencilFunctionMask(mask: number): void;
  37839. /**
  37840. * Gets the current stencil operation when stencil fails
  37841. * @returns a number defining stencil operation to use when stencil fails
  37842. */
  37843. getStencilOperationFail(): number;
  37844. /**
  37845. * Gets the current stencil operation when depth fails
  37846. * @returns a number defining stencil operation to use when depth fails
  37847. */
  37848. getStencilOperationDepthFail(): number;
  37849. /**
  37850. * Gets the current stencil operation when stencil passes
  37851. * @returns a number defining stencil operation to use when stencil passes
  37852. */
  37853. getStencilOperationPass(): number;
  37854. /**
  37855. * Sets the stencil operation to use when stencil fails
  37856. * @param operation defines the stencil operation to use when stencil fails
  37857. */
  37858. setStencilOperationFail(operation: number): void;
  37859. /**
  37860. * Sets the stencil operation to use when depth fails
  37861. * @param operation defines the stencil operation to use when depth fails
  37862. */
  37863. setStencilOperationDepthFail(operation: number): void;
  37864. /**
  37865. * Sets the stencil operation to use when stencil passes
  37866. * @param operation defines the stencil operation to use when stencil passes
  37867. */
  37868. setStencilOperationPass(operation: number): void;
  37869. /**
  37870. * Sets a boolean indicating if the dithering state is enabled or disabled
  37871. * @param value defines the dithering state
  37872. */
  37873. setDitheringState(value: boolean): void;
  37874. /**
  37875. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37876. * @param value defines the rasterizer state
  37877. */
  37878. setRasterizerState(value: boolean): void;
  37879. /**
  37880. * Gets the current depth function
  37881. * @returns a number defining the depth function
  37882. */
  37883. getDepthFunction(): Nullable<number>;
  37884. /**
  37885. * Sets the current depth function
  37886. * @param depthFunc defines the function to use
  37887. */
  37888. setDepthFunction(depthFunc: number): void;
  37889. /**
  37890. * Sets the current depth function to GREATER
  37891. */
  37892. setDepthFunctionToGreater(): void;
  37893. /**
  37894. * Sets the current depth function to GEQUAL
  37895. */
  37896. setDepthFunctionToGreaterOrEqual(): void;
  37897. /**
  37898. * Sets the current depth function to LESS
  37899. */
  37900. setDepthFunctionToLess(): void;
  37901. /**
  37902. * Sets the current depth function to LEQUAL
  37903. */
  37904. setDepthFunctionToLessOrEqual(): void;
  37905. private _cachedStencilBuffer;
  37906. private _cachedStencilFunction;
  37907. private _cachedStencilMask;
  37908. private _cachedStencilOperationPass;
  37909. private _cachedStencilOperationFail;
  37910. private _cachedStencilOperationDepthFail;
  37911. private _cachedStencilReference;
  37912. /**
  37913. * Caches the the state of the stencil buffer
  37914. */
  37915. cacheStencilState(): void;
  37916. /**
  37917. * Restores the state of the stencil buffer
  37918. */
  37919. restoreStencilState(): void;
  37920. /**
  37921. * Directly set the WebGL Viewport
  37922. * @param x defines the x coordinate of the viewport (in screen space)
  37923. * @param y defines the y coordinate of the viewport (in screen space)
  37924. * @param width defines the width of the viewport (in screen space)
  37925. * @param height defines the height of the viewport (in screen space)
  37926. * @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
  37927. */
  37928. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37929. /**
  37930. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37931. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37932. * @param y defines the y-coordinate of the corner of the clear rectangle
  37933. * @param width defines the width of the clear rectangle
  37934. * @param height defines the height of the clear rectangle
  37935. * @param clearColor defines the clear color
  37936. */
  37937. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  37938. /**
  37939. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  37940. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37941. * @param y defines the y-coordinate of the corner of the clear rectangle
  37942. * @param width defines the width of the clear rectangle
  37943. * @param height defines the height of the clear rectangle
  37944. */
  37945. enableScissor(x: number, y: number, width: number, height: number): void;
  37946. /**
  37947. * Disable previously set scissor test rectangle
  37948. */
  37949. disableScissor(): void;
  37950. protected _reportDrawCall(): void;
  37951. /**
  37952. * Initializes a webVR display and starts listening to display change events
  37953. * The onVRDisplayChangedObservable will be notified upon these changes
  37954. * @returns The onVRDisplayChangedObservable
  37955. */
  37956. initWebVR(): Observable<IDisplayChangedEventArgs>;
  37957. /** @hidden */
  37958. _prepareVRComponent(): void;
  37959. /** @hidden */
  37960. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  37961. /** @hidden */
  37962. _submitVRFrame(): void;
  37963. /**
  37964. * Call this function to leave webVR mode
  37965. * Will do nothing if webVR is not supported or if there is no webVR device
  37966. * @see http://doc.babylonjs.com/how_to/webvr_camera
  37967. */
  37968. disableVR(): void;
  37969. /**
  37970. * Gets a boolean indicating that the system is in VR mode and is presenting
  37971. * @returns true if VR mode is engaged
  37972. */
  37973. isVRPresenting(): boolean;
  37974. /** @hidden */
  37975. _requestVRFrame(): void;
  37976. /** @hidden */
  37977. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37978. /**
  37979. * Gets the source code of the vertex shader associated with a specific webGL program
  37980. * @param program defines the program to use
  37981. * @returns a string containing the source code of the vertex shader associated with the program
  37982. */
  37983. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37984. /**
  37985. * Gets the source code of the fragment shader associated with a specific webGL program
  37986. * @param program defines the program to use
  37987. * @returns a string containing the source code of the fragment shader associated with the program
  37988. */
  37989. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37990. /**
  37991. * Sets a depth stencil texture from a render target to the according uniform.
  37992. * @param channel The texture channel
  37993. * @param uniform The uniform to set
  37994. * @param texture The render target texture containing the depth stencil texture to apply
  37995. */
  37996. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37997. /**
  37998. * Sets a texture to the webGL context from a postprocess
  37999. * @param channel defines the channel to use
  38000. * @param postProcess defines the source postprocess
  38001. */
  38002. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  38003. /**
  38004. * Binds the output of the passed in post process to the texture channel specified
  38005. * @param channel The channel the texture should be bound to
  38006. * @param postProcess The post process which's output should be bound
  38007. */
  38008. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  38009. protected _rebuildBuffers(): void;
  38010. /** @hidden */
  38011. _renderFrame(): void;
  38012. _renderLoop(): void;
  38013. /** @hidden */
  38014. _renderViews(): boolean;
  38015. /**
  38016. * Toggle full screen mode
  38017. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38018. */
  38019. switchFullscreen(requestPointerLock: boolean): void;
  38020. /**
  38021. * Enters full screen mode
  38022. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38023. */
  38024. enterFullscreen(requestPointerLock: boolean): void;
  38025. /**
  38026. * Exits full screen mode
  38027. */
  38028. exitFullscreen(): void;
  38029. /**
  38030. * Enters Pointerlock mode
  38031. */
  38032. enterPointerlock(): void;
  38033. /**
  38034. * Exits Pointerlock mode
  38035. */
  38036. exitPointerlock(): void;
  38037. /**
  38038. * Begin a new frame
  38039. */
  38040. beginFrame(): void;
  38041. /**
  38042. * Enf the current frame
  38043. */
  38044. endFrame(): void;
  38045. resize(): void;
  38046. /**
  38047. * Force a specific size of the canvas
  38048. * @param width defines the new canvas' width
  38049. * @param height defines the new canvas' height
  38050. */
  38051. setSize(width: number, height: number): void;
  38052. /**
  38053. * Updates a dynamic vertex buffer.
  38054. * @param vertexBuffer the vertex buffer to update
  38055. * @param data the data used to update the vertex buffer
  38056. * @param byteOffset the byte offset of the data
  38057. * @param byteLength the byte length of the data
  38058. */
  38059. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  38060. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38061. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38062. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38063. _releaseTexture(texture: InternalTexture): void;
  38064. /**
  38065. * @hidden
  38066. * Rescales a texture
  38067. * @param source input texutre
  38068. * @param destination destination texture
  38069. * @param scene scene to use to render the resize
  38070. * @param internalFormat format to use when resizing
  38071. * @param onComplete callback to be called when resize has completed
  38072. */
  38073. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38074. /**
  38075. * Gets the current framerate
  38076. * @returns a number representing the framerate
  38077. */
  38078. getFps(): number;
  38079. /**
  38080. * Gets the time spent between current and previous frame
  38081. * @returns a number representing the delta time in ms
  38082. */
  38083. getDeltaTime(): number;
  38084. private _measureFps;
  38085. /** @hidden */
  38086. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38087. /**
  38088. * Update a dynamic index buffer
  38089. * @param indexBuffer defines the target index buffer
  38090. * @param indices defines the data to update
  38091. * @param offset defines the offset in the target index buffer where update should start
  38092. */
  38093. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  38094. /**
  38095. * Updates the sample count of a render target texture
  38096. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38097. * @param texture defines the texture to update
  38098. * @param samples defines the sample count to set
  38099. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38100. */
  38101. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38102. /**
  38103. * Updates a depth texture Comparison Mode and Function.
  38104. * If the comparison Function is equal to 0, the mode will be set to none.
  38105. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38106. * @param texture The texture to set the comparison function for
  38107. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38108. */
  38109. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38110. /**
  38111. * Creates a webGL buffer to use with instanciation
  38112. * @param capacity defines the size of the buffer
  38113. * @returns the webGL buffer
  38114. */
  38115. createInstancesBuffer(capacity: number): DataBuffer;
  38116. /**
  38117. * Delete a webGL buffer used with instanciation
  38118. * @param buffer defines the webGL buffer to delete
  38119. */
  38120. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38121. private _clientWaitAsync;
  38122. /** @hidden */
  38123. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38124. dispose(): void;
  38125. private _disableTouchAction;
  38126. /**
  38127. * Display the loading screen
  38128. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38129. */
  38130. displayLoadingUI(): void;
  38131. /**
  38132. * Hide the loading screen
  38133. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38134. */
  38135. hideLoadingUI(): void;
  38136. /**
  38137. * Gets the current loading screen object
  38138. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38139. */
  38140. get loadingScreen(): ILoadingScreen;
  38141. /**
  38142. * Sets the current loading screen object
  38143. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38144. */
  38145. set loadingScreen(loadingScreen: ILoadingScreen);
  38146. /**
  38147. * Sets the current loading screen text
  38148. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38149. */
  38150. set loadingUIText(text: string);
  38151. /**
  38152. * Sets the current loading screen background color
  38153. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38154. */
  38155. set loadingUIBackgroundColor(color: string);
  38156. /** Pointerlock and fullscreen */
  38157. /**
  38158. * Ask the browser to promote the current element to pointerlock mode
  38159. * @param element defines the DOM element to promote
  38160. */
  38161. static _RequestPointerlock(element: HTMLElement): void;
  38162. /**
  38163. * Asks the browser to exit pointerlock mode
  38164. */
  38165. static _ExitPointerlock(): void;
  38166. /**
  38167. * Ask the browser to promote the current element to fullscreen rendering mode
  38168. * @param element defines the DOM element to promote
  38169. */
  38170. static _RequestFullscreen(element: HTMLElement): void;
  38171. /**
  38172. * Asks the browser to exit fullscreen mode
  38173. */
  38174. static _ExitFullscreen(): void;
  38175. }
  38176. }
  38177. declare module "babylonjs/Engines/engineStore" {
  38178. import { Nullable } from "babylonjs/types";
  38179. import { Engine } from "babylonjs/Engines/engine";
  38180. import { Scene } from "babylonjs/scene";
  38181. /**
  38182. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38183. * during the life time of the application.
  38184. */
  38185. export class EngineStore {
  38186. /** Gets the list of created engines */
  38187. static Instances: import("babylonjs/Engines/engine").Engine[];
  38188. /** @hidden */
  38189. static _LastCreatedScene: Nullable<Scene>;
  38190. /**
  38191. * Gets the latest created engine
  38192. */
  38193. static get LastCreatedEngine(): Nullable<Engine>;
  38194. /**
  38195. * Gets the latest created scene
  38196. */
  38197. static get LastCreatedScene(): Nullable<Scene>;
  38198. /**
  38199. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38200. * @ignorenaming
  38201. */
  38202. static UseFallbackTexture: boolean;
  38203. /**
  38204. * Texture content used if a texture cannot loaded
  38205. * @ignorenaming
  38206. */
  38207. static FallbackTexture: string;
  38208. }
  38209. }
  38210. declare module "babylonjs/Misc/promise" {
  38211. /**
  38212. * Helper class that provides a small promise polyfill
  38213. */
  38214. export class PromisePolyfill {
  38215. /**
  38216. * Static function used to check if the polyfill is required
  38217. * If this is the case then the function will inject the polyfill to window.Promise
  38218. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38219. */
  38220. static Apply(force?: boolean): void;
  38221. }
  38222. }
  38223. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  38224. /**
  38225. * Interface for screenshot methods with describe argument called `size` as object with options
  38226. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38227. */
  38228. export interface IScreenshotSize {
  38229. /**
  38230. * number in pixels for canvas height
  38231. */
  38232. height?: number;
  38233. /**
  38234. * multiplier allowing render at a higher or lower resolution
  38235. * If value is defined then height and width will be ignored and taken from camera
  38236. */
  38237. precision?: number;
  38238. /**
  38239. * number in pixels for canvas width
  38240. */
  38241. width?: number;
  38242. }
  38243. }
  38244. declare module "babylonjs/Misc/tools" {
  38245. import { Nullable, float } from "babylonjs/types";
  38246. import { DomManagement } from "babylonjs/Misc/domManagement";
  38247. import { WebRequest } from "babylonjs/Misc/webRequest";
  38248. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  38249. import { ReadFileError } from "babylonjs/Misc/fileTools";
  38250. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38251. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  38252. import { Camera } from "babylonjs/Cameras/camera";
  38253. import { Engine } from "babylonjs/Engines/engine";
  38254. interface IColor4Like {
  38255. r: float;
  38256. g: float;
  38257. b: float;
  38258. a: float;
  38259. }
  38260. /**
  38261. * Class containing a set of static utilities functions
  38262. */
  38263. export class Tools {
  38264. /**
  38265. * Gets or sets the base URL to use to load assets
  38266. */
  38267. static get BaseUrl(): string;
  38268. static set BaseUrl(value: string);
  38269. /**
  38270. * Enable/Disable Custom HTTP Request Headers globally.
  38271. * default = false
  38272. * @see CustomRequestHeaders
  38273. */
  38274. static UseCustomRequestHeaders: boolean;
  38275. /**
  38276. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38277. * i.e. when loading files, where the server/service expects an Authorization header
  38278. */
  38279. static CustomRequestHeaders: {
  38280. [key: string]: string;
  38281. };
  38282. /**
  38283. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38284. */
  38285. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38286. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38287. /**
  38288. * Default behaviour for cors in the application.
  38289. * It can be a string if the expected behavior is identical in the entire app.
  38290. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38291. */
  38292. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38293. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38294. /**
  38295. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38296. * @ignorenaming
  38297. */
  38298. static get UseFallbackTexture(): boolean;
  38299. static set UseFallbackTexture(value: boolean);
  38300. /**
  38301. * Use this object to register external classes like custom textures or material
  38302. * to allow the laoders to instantiate them
  38303. */
  38304. static get RegisteredExternalClasses(): {
  38305. [key: string]: Object;
  38306. };
  38307. static set RegisteredExternalClasses(classes: {
  38308. [key: string]: Object;
  38309. });
  38310. /**
  38311. * Texture content used if a texture cannot loaded
  38312. * @ignorenaming
  38313. */
  38314. static get fallbackTexture(): string;
  38315. static set fallbackTexture(value: string);
  38316. /**
  38317. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38318. * @param u defines the coordinate on X axis
  38319. * @param v defines the coordinate on Y axis
  38320. * @param width defines the width of the source data
  38321. * @param height defines the height of the source data
  38322. * @param pixels defines the source byte array
  38323. * @param color defines the output color
  38324. */
  38325. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38326. /**
  38327. * Interpolates between a and b via alpha
  38328. * @param a The lower value (returned when alpha = 0)
  38329. * @param b The upper value (returned when alpha = 1)
  38330. * @param alpha The interpolation-factor
  38331. * @return The mixed value
  38332. */
  38333. static Mix(a: number, b: number, alpha: number): number;
  38334. /**
  38335. * Tries to instantiate a new object from a given class name
  38336. * @param className defines the class name to instantiate
  38337. * @returns the new object or null if the system was not able to do the instantiation
  38338. */
  38339. static Instantiate(className: string): any;
  38340. /**
  38341. * Provides a slice function that will work even on IE
  38342. * @param data defines the array to slice
  38343. * @param start defines the start of the data (optional)
  38344. * @param end defines the end of the data (optional)
  38345. * @returns the new sliced array
  38346. */
  38347. static Slice<T>(data: T, start?: number, end?: number): T;
  38348. /**
  38349. * Polyfill for setImmediate
  38350. * @param action defines the action to execute after the current execution block
  38351. */
  38352. static SetImmediate(action: () => void): void;
  38353. /**
  38354. * Function indicating if a number is an exponent of 2
  38355. * @param value defines the value to test
  38356. * @returns true if the value is an exponent of 2
  38357. */
  38358. static IsExponentOfTwo(value: number): boolean;
  38359. private static _tmpFloatArray;
  38360. /**
  38361. * Returns the nearest 32-bit single precision float representation of a Number
  38362. * @param value A Number. If the parameter is of a different type, it will get converted
  38363. * to a number or to NaN if it cannot be converted
  38364. * @returns number
  38365. */
  38366. static FloatRound(value: number): number;
  38367. /**
  38368. * Extracts the filename from a path
  38369. * @param path defines the path to use
  38370. * @returns the filename
  38371. */
  38372. static GetFilename(path: string): string;
  38373. /**
  38374. * Extracts the "folder" part of a path (everything before the filename).
  38375. * @param uri The URI to extract the info from
  38376. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38377. * @returns The "folder" part of the path
  38378. */
  38379. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38380. /**
  38381. * Extracts text content from a DOM element hierarchy
  38382. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38383. */
  38384. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38385. /**
  38386. * Convert an angle in radians to degrees
  38387. * @param angle defines the angle to convert
  38388. * @returns the angle in degrees
  38389. */
  38390. static ToDegrees(angle: number): number;
  38391. /**
  38392. * Convert an angle in degrees to radians
  38393. * @param angle defines the angle to convert
  38394. * @returns the angle in radians
  38395. */
  38396. static ToRadians(angle: number): number;
  38397. /**
  38398. * Returns an array if obj is not an array
  38399. * @param obj defines the object to evaluate as an array
  38400. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38401. * @returns either obj directly if obj is an array or a new array containing obj
  38402. */
  38403. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38404. /**
  38405. * Gets the pointer prefix to use
  38406. * @param engine defines the engine we are finding the prefix for
  38407. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38408. */
  38409. static GetPointerPrefix(engine: Engine): string;
  38410. /**
  38411. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38412. * @param url define the url we are trying
  38413. * @param element define the dom element where to configure the cors policy
  38414. */
  38415. static SetCorsBehavior(url: string | string[], element: {
  38416. crossOrigin: string | null;
  38417. }): void;
  38418. /**
  38419. * Removes unwanted characters from an url
  38420. * @param url defines the url to clean
  38421. * @returns the cleaned url
  38422. */
  38423. static CleanUrl(url: string): string;
  38424. /**
  38425. * Gets or sets a function used to pre-process url before using them to load assets
  38426. */
  38427. static get PreprocessUrl(): (url: string) => string;
  38428. static set PreprocessUrl(processor: (url: string) => string);
  38429. /**
  38430. * Loads an image as an HTMLImageElement.
  38431. * @param input url string, ArrayBuffer, or Blob to load
  38432. * @param onLoad callback called when the image successfully loads
  38433. * @param onError callback called when the image fails to load
  38434. * @param offlineProvider offline provider for caching
  38435. * @param mimeType optional mime type
  38436. * @returns the HTMLImageElement of the loaded image
  38437. */
  38438. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38439. /**
  38440. * Loads a file from a url
  38441. * @param url url string, ArrayBuffer, or Blob to load
  38442. * @param onSuccess callback called when the file successfully loads
  38443. * @param onProgress callback called while file is loading (if the server supports this mode)
  38444. * @param offlineProvider defines the offline provider for caching
  38445. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38446. * @param onError callback called when the file fails to load
  38447. * @returns a file request object
  38448. */
  38449. 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;
  38450. /**
  38451. * Loads a file from a url
  38452. * @param url the file url to load
  38453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38454. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38455. */
  38456. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38457. /**
  38458. * Load a script (identified by an url). When the url returns, the
  38459. * content of this file is added into a new script element, attached to the DOM (body element)
  38460. * @param scriptUrl defines the url of the script to laod
  38461. * @param onSuccess defines the callback called when the script is loaded
  38462. * @param onError defines the callback to call if an error occurs
  38463. * @param scriptId defines the id of the script element
  38464. */
  38465. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38466. /**
  38467. * Load an asynchronous script (identified by an url). When the url returns, the
  38468. * content of this file is added into a new script element, attached to the DOM (body element)
  38469. * @param scriptUrl defines the url of the script to laod
  38470. * @param scriptId defines the id of the script element
  38471. * @returns a promise request object
  38472. */
  38473. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38474. /**
  38475. * Loads a file from a blob
  38476. * @param fileToLoad defines the blob to use
  38477. * @param callback defines the callback to call when data is loaded
  38478. * @param progressCallback defines the callback to call during loading process
  38479. * @returns a file request object
  38480. */
  38481. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38482. /**
  38483. * Reads a file from a File object
  38484. * @param file defines the file to load
  38485. * @param onSuccess defines the callback to call when data is loaded
  38486. * @param onProgress defines the callback to call during loading process
  38487. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38488. * @param onError defines the callback to call when an error occurs
  38489. * @returns a file request object
  38490. */
  38491. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38492. /**
  38493. * Creates a data url from a given string content
  38494. * @param content defines the content to convert
  38495. * @returns the new data url link
  38496. */
  38497. static FileAsURL(content: string): string;
  38498. /**
  38499. * Format the given number to a specific decimal format
  38500. * @param value defines the number to format
  38501. * @param decimals defines the number of decimals to use
  38502. * @returns the formatted string
  38503. */
  38504. static Format(value: number, decimals?: number): string;
  38505. /**
  38506. * Tries to copy an object by duplicating every property
  38507. * @param source defines the source object
  38508. * @param destination defines the target object
  38509. * @param doNotCopyList defines a list of properties to avoid
  38510. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38511. */
  38512. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38513. /**
  38514. * Gets a boolean indicating if the given object has no own property
  38515. * @param obj defines the object to test
  38516. * @returns true if object has no own property
  38517. */
  38518. static IsEmpty(obj: any): boolean;
  38519. /**
  38520. * Function used to register events at window level
  38521. * @param windowElement defines the Window object to use
  38522. * @param events defines the events to register
  38523. */
  38524. static RegisterTopRootEvents(windowElement: Window, events: {
  38525. name: string;
  38526. handler: Nullable<(e: FocusEvent) => any>;
  38527. }[]): void;
  38528. /**
  38529. * Function used to unregister events from window level
  38530. * @param windowElement defines the Window object to use
  38531. * @param events defines the events to unregister
  38532. */
  38533. static UnregisterTopRootEvents(windowElement: Window, events: {
  38534. name: string;
  38535. handler: Nullable<(e: FocusEvent) => any>;
  38536. }[]): void;
  38537. /**
  38538. * @ignore
  38539. */
  38540. static _ScreenshotCanvas: HTMLCanvasElement;
  38541. /**
  38542. * Dumps the current bound framebuffer
  38543. * @param width defines the rendering width
  38544. * @param height defines the rendering height
  38545. * @param engine defines the hosting engine
  38546. * @param successCallback defines the callback triggered once the data are available
  38547. * @param mimeType defines the mime type of the result
  38548. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38549. */
  38550. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38551. /**
  38552. * Converts the canvas data to blob.
  38553. * This acts as a polyfill for browsers not supporting the to blob function.
  38554. * @param canvas Defines the canvas to extract the data from
  38555. * @param successCallback Defines the callback triggered once the data are available
  38556. * @param mimeType Defines the mime type of the result
  38557. */
  38558. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38559. /**
  38560. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38561. * @param successCallback defines the callback triggered once the data are available
  38562. * @param mimeType defines the mime type of the result
  38563. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38564. */
  38565. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38566. /**
  38567. * Downloads a blob in the browser
  38568. * @param blob defines the blob to download
  38569. * @param fileName defines the name of the downloaded file
  38570. */
  38571. static Download(blob: Blob, fileName: string): void;
  38572. /**
  38573. * Captures a screenshot of the current rendering
  38574. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38575. * @param engine defines the rendering engine
  38576. * @param camera defines the source camera
  38577. * @param size This parameter can be set to a single number or to an object with the
  38578. * following (optional) properties: precision, width, height. If a single number is passed,
  38579. * it will be used for both width and height. If an object is passed, the screenshot size
  38580. * will be derived from the parameters. The precision property is a multiplier allowing
  38581. * rendering at a higher or lower resolution
  38582. * @param successCallback defines the callback receives a single parameter which contains the
  38583. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38584. * src parameter of an <img> to display it
  38585. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38586. * Check your browser for supported MIME types
  38587. */
  38588. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38589. /**
  38590. * Captures a screenshot of the current rendering
  38591. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38592. * @param engine defines the rendering engine
  38593. * @param camera defines the source camera
  38594. * @param size This parameter can be set to a single number or to an object with the
  38595. * following (optional) properties: precision, width, height. If a single number is passed,
  38596. * it will be used for both width and height. If an object is passed, the screenshot size
  38597. * will be derived from the parameters. The precision property is a multiplier allowing
  38598. * rendering at a higher or lower resolution
  38599. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38600. * Check your browser for supported MIME types
  38601. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38602. * to the src parameter of an <img> to display it
  38603. */
  38604. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38605. /**
  38606. * Generates an image screenshot from the specified camera.
  38607. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38608. * @param engine The engine to use for rendering
  38609. * @param camera The camera to use for rendering
  38610. * @param size This parameter can be set to a single number or to an object with the
  38611. * following (optional) properties: precision, width, height. If a single number is passed,
  38612. * it will be used for both width and height. If an object is passed, the screenshot size
  38613. * will be derived from the parameters. The precision property is a multiplier allowing
  38614. * rendering at a higher or lower resolution
  38615. * @param successCallback The callback receives a single parameter which contains the
  38616. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38617. * src parameter of an <img> to display it
  38618. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38619. * Check your browser for supported MIME types
  38620. * @param samples Texture samples (default: 1)
  38621. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38622. * @param fileName A name for for the downloaded file.
  38623. */
  38624. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38625. /**
  38626. * Generates an image screenshot from the specified camera.
  38627. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38628. * @param engine The engine to use for rendering
  38629. * @param camera The camera to use for rendering
  38630. * @param size This parameter can be set to a single number or to an object with the
  38631. * following (optional) properties: precision, width, height. If a single number is passed,
  38632. * it will be used for both width and height. If an object is passed, the screenshot size
  38633. * will be derived from the parameters. The precision property is a multiplier allowing
  38634. * rendering at a higher or lower resolution
  38635. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38636. * Check your browser for supported MIME types
  38637. * @param samples Texture samples (default: 1)
  38638. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38639. * @param fileName A name for for the downloaded file.
  38640. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38641. * to the src parameter of an <img> to display it
  38642. */
  38643. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38644. /**
  38645. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38646. * Be aware Math.random() could cause collisions, but:
  38647. * "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"
  38648. * @returns a pseudo random id
  38649. */
  38650. static RandomId(): string;
  38651. /**
  38652. * Test if the given uri is a base64 string
  38653. * @param uri The uri to test
  38654. * @return True if the uri is a base64 string or false otherwise
  38655. */
  38656. static IsBase64(uri: string): boolean;
  38657. /**
  38658. * Decode the given base64 uri.
  38659. * @param uri The uri to decode
  38660. * @return The decoded base64 data.
  38661. */
  38662. static DecodeBase64(uri: string): ArrayBuffer;
  38663. /**
  38664. * Gets the absolute url.
  38665. * @param url the input url
  38666. * @return the absolute url
  38667. */
  38668. static GetAbsoluteUrl(url: string): string;
  38669. /**
  38670. * No log
  38671. */
  38672. static readonly NoneLogLevel: number;
  38673. /**
  38674. * Only message logs
  38675. */
  38676. static readonly MessageLogLevel: number;
  38677. /**
  38678. * Only warning logs
  38679. */
  38680. static readonly WarningLogLevel: number;
  38681. /**
  38682. * Only error logs
  38683. */
  38684. static readonly ErrorLogLevel: number;
  38685. /**
  38686. * All logs
  38687. */
  38688. static readonly AllLogLevel: number;
  38689. /**
  38690. * Gets a value indicating the number of loading errors
  38691. * @ignorenaming
  38692. */
  38693. static get errorsCount(): number;
  38694. /**
  38695. * Callback called when a new log is added
  38696. */
  38697. static OnNewCacheEntry: (entry: string) => void;
  38698. /**
  38699. * Log a message to the console
  38700. * @param message defines the message to log
  38701. */
  38702. static Log(message: string): void;
  38703. /**
  38704. * Write a warning message to the console
  38705. * @param message defines the message to log
  38706. */
  38707. static Warn(message: string): void;
  38708. /**
  38709. * Write an error message to the console
  38710. * @param message defines the message to log
  38711. */
  38712. static Error(message: string): void;
  38713. /**
  38714. * Gets current log cache (list of logs)
  38715. */
  38716. static get LogCache(): string;
  38717. /**
  38718. * Clears the log cache
  38719. */
  38720. static ClearLogCache(): void;
  38721. /**
  38722. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38723. */
  38724. static set LogLevels(level: number);
  38725. /**
  38726. * Checks if the window object exists
  38727. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38728. */
  38729. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38730. /**
  38731. * No performance log
  38732. */
  38733. static readonly PerformanceNoneLogLevel: number;
  38734. /**
  38735. * Use user marks to log performance
  38736. */
  38737. static readonly PerformanceUserMarkLogLevel: number;
  38738. /**
  38739. * Log performance to the console
  38740. */
  38741. static readonly PerformanceConsoleLogLevel: number;
  38742. private static _performance;
  38743. /**
  38744. * Sets the current performance log level
  38745. */
  38746. static set PerformanceLogLevel(level: number);
  38747. private static _StartPerformanceCounterDisabled;
  38748. private static _EndPerformanceCounterDisabled;
  38749. private static _StartUserMark;
  38750. private static _EndUserMark;
  38751. private static _StartPerformanceConsole;
  38752. private static _EndPerformanceConsole;
  38753. /**
  38754. * Starts a performance counter
  38755. */
  38756. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38757. /**
  38758. * Ends a specific performance coutner
  38759. */
  38760. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38761. /**
  38762. * Gets either window.performance.now() if supported or Date.now() else
  38763. */
  38764. static get Now(): number;
  38765. /**
  38766. * This method will return the name of the class used to create the instance of the given object.
  38767. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38768. * @param object the object to get the class name from
  38769. * @param isType defines if the object is actually a type
  38770. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38771. */
  38772. static GetClassName(object: any, isType?: boolean): string;
  38773. /**
  38774. * Gets the first element of an array satisfying a given predicate
  38775. * @param array defines the array to browse
  38776. * @param predicate defines the predicate to use
  38777. * @returns null if not found or the element
  38778. */
  38779. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38780. /**
  38781. * This method will return the name of the full name of the class, including its owning module (if any).
  38782. * 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).
  38783. * @param object the object to get the class name from
  38784. * @param isType defines if the object is actually a type
  38785. * @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.
  38786. * @ignorenaming
  38787. */
  38788. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38789. /**
  38790. * Returns a promise that resolves after the given amount of time.
  38791. * @param delay Number of milliseconds to delay
  38792. * @returns Promise that resolves after the given amount of time
  38793. */
  38794. static DelayAsync(delay: number): Promise<void>;
  38795. /**
  38796. * Utility function to detect if the current user agent is Safari
  38797. * @returns whether or not the current user agent is safari
  38798. */
  38799. static IsSafari(): boolean;
  38800. }
  38801. /**
  38802. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38803. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38804. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38805. * @param name The name of the class, case should be preserved
  38806. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38807. */
  38808. export function className(name: string, module?: string): (target: Object) => void;
  38809. /**
  38810. * An implementation of a loop for asynchronous functions.
  38811. */
  38812. export class AsyncLoop {
  38813. /**
  38814. * Defines the number of iterations for the loop
  38815. */
  38816. iterations: number;
  38817. /**
  38818. * Defines the current index of the loop.
  38819. */
  38820. index: number;
  38821. private _done;
  38822. private _fn;
  38823. private _successCallback;
  38824. /**
  38825. * Constructor.
  38826. * @param iterations the number of iterations.
  38827. * @param func the function to run each iteration
  38828. * @param successCallback the callback that will be called upon succesful execution
  38829. * @param offset starting offset.
  38830. */
  38831. constructor(
  38832. /**
  38833. * Defines the number of iterations for the loop
  38834. */
  38835. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38836. /**
  38837. * Execute the next iteration. Must be called after the last iteration was finished.
  38838. */
  38839. executeNext(): void;
  38840. /**
  38841. * Break the loop and run the success callback.
  38842. */
  38843. breakLoop(): void;
  38844. /**
  38845. * Create and run an async loop.
  38846. * @param iterations the number of iterations.
  38847. * @param fn the function to run each iteration
  38848. * @param successCallback the callback that will be called upon succesful execution
  38849. * @param offset starting offset.
  38850. * @returns the created async loop object
  38851. */
  38852. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38853. /**
  38854. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38855. * @param iterations total number of iterations
  38856. * @param syncedIterations number of synchronous iterations in each async iteration.
  38857. * @param fn the function to call each iteration.
  38858. * @param callback a success call back that will be called when iterating stops.
  38859. * @param breakFunction a break condition (optional)
  38860. * @param timeout timeout settings for the setTimeout function. default - 0.
  38861. * @returns the created async loop object
  38862. */
  38863. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38864. }
  38865. }
  38866. declare module "babylonjs/Misc/stringDictionary" {
  38867. import { Nullable } from "babylonjs/types";
  38868. /**
  38869. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38870. * The underlying implementation relies on an associative array to ensure the best performances.
  38871. * The value can be anything including 'null' but except 'undefined'
  38872. */
  38873. export class StringDictionary<T> {
  38874. /**
  38875. * This will clear this dictionary and copy the content from the 'source' one.
  38876. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38877. * @param source the dictionary to take the content from and copy to this dictionary
  38878. */
  38879. copyFrom(source: StringDictionary<T>): void;
  38880. /**
  38881. * Get a value based from its key
  38882. * @param key the given key to get the matching value from
  38883. * @return the value if found, otherwise undefined is returned
  38884. */
  38885. get(key: string): T | undefined;
  38886. /**
  38887. * Get a value from its key or add it if it doesn't exist.
  38888. * This method will ensure you that a given key/data will be present in the dictionary.
  38889. * @param key the given key to get the matching value from
  38890. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38891. * The factory will only be invoked if there's no data for the given key.
  38892. * @return the value corresponding to the key.
  38893. */
  38894. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38895. /**
  38896. * Get a value from its key if present in the dictionary otherwise add it
  38897. * @param key the key to get the value from
  38898. * @param val if there's no such key/value pair in the dictionary add it with this value
  38899. * @return the value corresponding to the key
  38900. */
  38901. getOrAdd(key: string, val: T): T;
  38902. /**
  38903. * Check if there's a given key in the dictionary
  38904. * @param key the key to check for
  38905. * @return true if the key is present, false otherwise
  38906. */
  38907. contains(key: string): boolean;
  38908. /**
  38909. * Add a new key and its corresponding value
  38910. * @param key the key to add
  38911. * @param value the value corresponding to the key
  38912. * @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
  38913. */
  38914. add(key: string, value: T): boolean;
  38915. /**
  38916. * Update a specific value associated to a key
  38917. * @param key defines the key to use
  38918. * @param value defines the value to store
  38919. * @returns true if the value was updated (or false if the key was not found)
  38920. */
  38921. set(key: string, value: T): boolean;
  38922. /**
  38923. * Get the element of the given key and remove it from the dictionary
  38924. * @param key defines the key to search
  38925. * @returns the value associated with the key or null if not found
  38926. */
  38927. getAndRemove(key: string): Nullable<T>;
  38928. /**
  38929. * Remove a key/value from the dictionary.
  38930. * @param key the key to remove
  38931. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38932. */
  38933. remove(key: string): boolean;
  38934. /**
  38935. * Clear the whole content of the dictionary
  38936. */
  38937. clear(): void;
  38938. /**
  38939. * Gets the current count
  38940. */
  38941. get count(): number;
  38942. /**
  38943. * Execute a callback on each key/val of the dictionary.
  38944. * Note that you can remove any element in this dictionary in the callback implementation
  38945. * @param callback the callback to execute on a given key/value pair
  38946. */
  38947. forEach(callback: (key: string, val: T) => void): void;
  38948. /**
  38949. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38950. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38951. * Note that you can remove any element in this dictionary in the callback implementation
  38952. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38953. * @returns the first item
  38954. */
  38955. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38956. private _count;
  38957. private _data;
  38958. }
  38959. }
  38960. declare module "babylonjs/Collisions/collisionCoordinator" {
  38961. import { Nullable } from "babylonjs/types";
  38962. import { Scene } from "babylonjs/scene";
  38963. import { Vector3 } from "babylonjs/Maths/math.vector";
  38964. import { Collider } from "babylonjs/Collisions/collider";
  38965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38966. /** @hidden */
  38967. export interface ICollisionCoordinator {
  38968. createCollider(): Collider;
  38969. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38970. init(scene: Scene): void;
  38971. }
  38972. /** @hidden */
  38973. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  38974. private _scene;
  38975. private _scaledPosition;
  38976. private _scaledVelocity;
  38977. private _finalPosition;
  38978. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38979. createCollider(): Collider;
  38980. init(scene: Scene): void;
  38981. private _collideWithWorld;
  38982. }
  38983. }
  38984. declare module "babylonjs/Inputs/scene.inputManager" {
  38985. import { Nullable } from "babylonjs/types";
  38986. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  38987. import { Vector2 } from "babylonjs/Maths/math.vector";
  38988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38989. import { Scene } from "babylonjs/scene";
  38990. /**
  38991. * Class used to manage all inputs for the scene.
  38992. */
  38993. export class InputManager {
  38994. /** The distance in pixel that you have to move to prevent some events */
  38995. static DragMovementThreshold: number;
  38996. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38997. static LongPressDelay: number;
  38998. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38999. static DoubleClickDelay: number;
  39000. /** If you need to check double click without raising a single click at first click, enable this flag */
  39001. static ExclusiveDoubleClickMode: boolean;
  39002. private _wheelEventName;
  39003. private _onPointerMove;
  39004. private _onPointerDown;
  39005. private _onPointerUp;
  39006. private _initClickEvent;
  39007. private _initActionManager;
  39008. private _delayedSimpleClick;
  39009. private _delayedSimpleClickTimeout;
  39010. private _previousDelayedSimpleClickTimeout;
  39011. private _meshPickProceed;
  39012. private _previousButtonPressed;
  39013. private _currentPickResult;
  39014. private _previousPickResult;
  39015. private _totalPointersPressed;
  39016. private _doubleClickOccured;
  39017. private _pointerOverMesh;
  39018. private _pickedDownMesh;
  39019. private _pickedUpMesh;
  39020. private _pointerX;
  39021. private _pointerY;
  39022. private _unTranslatedPointerX;
  39023. private _unTranslatedPointerY;
  39024. private _startingPointerPosition;
  39025. private _previousStartingPointerPosition;
  39026. private _startingPointerTime;
  39027. private _previousStartingPointerTime;
  39028. private _pointerCaptures;
  39029. private _onKeyDown;
  39030. private _onKeyUp;
  39031. private _onCanvasFocusObserver;
  39032. private _onCanvasBlurObserver;
  39033. private _scene;
  39034. /**
  39035. * Creates a new InputManager
  39036. * @param scene defines the hosting scene
  39037. */
  39038. constructor(scene: Scene);
  39039. /**
  39040. * Gets the mesh that is currently under the pointer
  39041. */
  39042. get meshUnderPointer(): Nullable<AbstractMesh>;
  39043. /**
  39044. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39045. */
  39046. get unTranslatedPointer(): Vector2;
  39047. /**
  39048. * Gets or sets the current on-screen X position of the pointer
  39049. */
  39050. get pointerX(): number;
  39051. set pointerX(value: number);
  39052. /**
  39053. * Gets or sets the current on-screen Y position of the pointer
  39054. */
  39055. get pointerY(): number;
  39056. set pointerY(value: number);
  39057. private _updatePointerPosition;
  39058. private _processPointerMove;
  39059. private _setRayOnPointerInfo;
  39060. private _checkPrePointerObservable;
  39061. /**
  39062. * Use this method to simulate a pointer move on a mesh
  39063. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39064. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39065. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39066. */
  39067. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39068. /**
  39069. * Use this method to simulate a pointer down on a mesh
  39070. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39071. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39072. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39073. */
  39074. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39075. private _processPointerDown;
  39076. /** @hidden */
  39077. _isPointerSwiping(): boolean;
  39078. /**
  39079. * Use this method to simulate a pointer up on a mesh
  39080. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39081. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39082. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39083. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39084. */
  39085. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39086. private _processPointerUp;
  39087. /**
  39088. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39089. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39090. * @returns true if the pointer was captured
  39091. */
  39092. isPointerCaptured(pointerId?: number): boolean;
  39093. /**
  39094. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39095. * @param attachUp defines if you want to attach events to pointerup
  39096. * @param attachDown defines if you want to attach events to pointerdown
  39097. * @param attachMove defines if you want to attach events to pointermove
  39098. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39099. */
  39100. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39101. /**
  39102. * Detaches all event handlers
  39103. */
  39104. detachControl(): void;
  39105. /**
  39106. * Force the value of meshUnderPointer
  39107. * @param mesh defines the mesh to use
  39108. */
  39109. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39110. /**
  39111. * Gets the mesh under the pointer
  39112. * @returns a Mesh or null if no mesh is under the pointer
  39113. */
  39114. getPointerOverMesh(): Nullable<AbstractMesh>;
  39115. }
  39116. }
  39117. declare module "babylonjs/Animations/animationGroup" {
  39118. import { Animatable } from "babylonjs/Animations/animatable";
  39119. import { Animation } from "babylonjs/Animations/animation";
  39120. import { Scene, IDisposable } from "babylonjs/scene";
  39121. import { Observable } from "babylonjs/Misc/observable";
  39122. import { Nullable } from "babylonjs/types";
  39123. import "babylonjs/Animations/animatable";
  39124. /**
  39125. * This class defines the direct association between an animation and a target
  39126. */
  39127. export class TargetedAnimation {
  39128. /**
  39129. * Animation to perform
  39130. */
  39131. animation: Animation;
  39132. /**
  39133. * Target to animate
  39134. */
  39135. target: any;
  39136. /**
  39137. * Returns the string "TargetedAnimation"
  39138. * @returns "TargetedAnimation"
  39139. */
  39140. getClassName(): string;
  39141. /**
  39142. * Serialize the object
  39143. * @returns the JSON object representing the current entity
  39144. */
  39145. serialize(): any;
  39146. }
  39147. /**
  39148. * Use this class to create coordinated animations on multiple targets
  39149. */
  39150. export class AnimationGroup implements IDisposable {
  39151. /** The name of the animation group */
  39152. name: string;
  39153. private _scene;
  39154. private _targetedAnimations;
  39155. private _animatables;
  39156. private _from;
  39157. private _to;
  39158. private _isStarted;
  39159. private _isPaused;
  39160. private _speedRatio;
  39161. private _loopAnimation;
  39162. private _isAdditive;
  39163. /**
  39164. * Gets or sets the unique id of the node
  39165. */
  39166. uniqueId: number;
  39167. /**
  39168. * This observable will notify when one animation have ended
  39169. */
  39170. onAnimationEndObservable: Observable<TargetedAnimation>;
  39171. /**
  39172. * Observer raised when one animation loops
  39173. */
  39174. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39175. /**
  39176. * Observer raised when all animations have looped
  39177. */
  39178. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39179. /**
  39180. * This observable will notify when all animations have ended.
  39181. */
  39182. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39183. /**
  39184. * This observable will notify when all animations have paused.
  39185. */
  39186. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39187. /**
  39188. * This observable will notify when all animations are playing.
  39189. */
  39190. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39191. /**
  39192. * Gets the first frame
  39193. */
  39194. get from(): number;
  39195. /**
  39196. * Gets the last frame
  39197. */
  39198. get to(): number;
  39199. /**
  39200. * Define if the animations are started
  39201. */
  39202. get isStarted(): boolean;
  39203. /**
  39204. * Gets a value indicating that the current group is playing
  39205. */
  39206. get isPlaying(): boolean;
  39207. /**
  39208. * Gets or sets the speed ratio to use for all animations
  39209. */
  39210. get speedRatio(): number;
  39211. /**
  39212. * Gets or sets the speed ratio to use for all animations
  39213. */
  39214. set speedRatio(value: number);
  39215. /**
  39216. * Gets or sets if all animations should loop or not
  39217. */
  39218. get loopAnimation(): boolean;
  39219. set loopAnimation(value: boolean);
  39220. /**
  39221. * Gets or sets if all animations should be evaluated additively
  39222. */
  39223. get isAdditive(): boolean;
  39224. set isAdditive(value: boolean);
  39225. /**
  39226. * Gets the targeted animations for this animation group
  39227. */
  39228. get targetedAnimations(): Array<TargetedAnimation>;
  39229. /**
  39230. * returning the list of animatables controlled by this animation group.
  39231. */
  39232. get animatables(): Array<Animatable>;
  39233. /**
  39234. * Gets the list of target animations
  39235. */
  39236. get children(): TargetedAnimation[];
  39237. /**
  39238. * Instantiates a new Animation Group.
  39239. * This helps managing several animations at once.
  39240. * @see http://doc.babylonjs.com/how_to/group
  39241. * @param name Defines the name of the group
  39242. * @param scene Defines the scene the group belongs to
  39243. */
  39244. constructor(
  39245. /** The name of the animation group */
  39246. name: string, scene?: Nullable<Scene>);
  39247. /**
  39248. * Add an animation (with its target) in the group
  39249. * @param animation defines the animation we want to add
  39250. * @param target defines the target of the animation
  39251. * @returns the TargetedAnimation object
  39252. */
  39253. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39254. /**
  39255. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39256. * It can add constant keys at begin or end
  39257. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39258. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39259. * @returns the animation group
  39260. */
  39261. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39262. private _animationLoopCount;
  39263. private _animationLoopFlags;
  39264. private _processLoop;
  39265. /**
  39266. * Start all animations on given targets
  39267. * @param loop defines if animations must loop
  39268. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39269. * @param from defines the from key (optional)
  39270. * @param to defines the to key (optional)
  39271. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39272. * @returns the current animation group
  39273. */
  39274. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39275. /**
  39276. * Pause all animations
  39277. * @returns the animation group
  39278. */
  39279. pause(): AnimationGroup;
  39280. /**
  39281. * Play all animations to initial state
  39282. * This function will start() the animations if they were not started or will restart() them if they were paused
  39283. * @param loop defines if animations must loop
  39284. * @returns the animation group
  39285. */
  39286. play(loop?: boolean): AnimationGroup;
  39287. /**
  39288. * Reset all animations to initial state
  39289. * @returns the animation group
  39290. */
  39291. reset(): AnimationGroup;
  39292. /**
  39293. * Restart animations from key 0
  39294. * @returns the animation group
  39295. */
  39296. restart(): AnimationGroup;
  39297. /**
  39298. * Stop all animations
  39299. * @returns the animation group
  39300. */
  39301. stop(): AnimationGroup;
  39302. /**
  39303. * Set animation weight for all animatables
  39304. * @param weight defines the weight to use
  39305. * @return the animationGroup
  39306. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  39307. */
  39308. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39309. /**
  39310. * Synchronize and normalize all animatables with a source animatable
  39311. * @param root defines the root animatable to synchronize with
  39312. * @return the animationGroup
  39313. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  39314. */
  39315. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39316. /**
  39317. * Goes to a specific frame in this animation group
  39318. * @param frame the frame number to go to
  39319. * @return the animationGroup
  39320. */
  39321. goToFrame(frame: number): AnimationGroup;
  39322. /**
  39323. * Dispose all associated resources
  39324. */
  39325. dispose(): void;
  39326. private _checkAnimationGroupEnded;
  39327. /**
  39328. * Clone the current animation group and returns a copy
  39329. * @param newName defines the name of the new group
  39330. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39331. * @returns the new aniamtion group
  39332. */
  39333. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39334. /**
  39335. * Serializes the animationGroup to an object
  39336. * @returns Serialized object
  39337. */
  39338. serialize(): any;
  39339. /**
  39340. * Returns a new AnimationGroup object parsed from the source provided.
  39341. * @param parsedAnimationGroup defines the source
  39342. * @param scene defines the scene that will receive the animationGroup
  39343. * @returns a new AnimationGroup
  39344. */
  39345. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39346. /**
  39347. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39348. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39349. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39350. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39351. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39352. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39353. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39354. */
  39355. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39356. /**
  39357. * Returns the string "AnimationGroup"
  39358. * @returns "AnimationGroup"
  39359. */
  39360. getClassName(): string;
  39361. /**
  39362. * Creates a detailled string about the object
  39363. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39364. * @returns a string representing the object
  39365. */
  39366. toString(fullDetails?: boolean): string;
  39367. }
  39368. }
  39369. declare module "babylonjs/scene" {
  39370. import { Nullable } from "babylonjs/types";
  39371. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  39372. import { Observable } from "babylonjs/Misc/observable";
  39373. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  39374. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  39375. import { Geometry } from "babylonjs/Meshes/geometry";
  39376. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39377. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39379. import { Mesh } from "babylonjs/Meshes/mesh";
  39380. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  39381. import { Bone } from "babylonjs/Bones/bone";
  39382. import { Skeleton } from "babylonjs/Bones/skeleton";
  39383. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  39384. import { Camera } from "babylonjs/Cameras/camera";
  39385. import { AbstractScene } from "babylonjs/abstractScene";
  39386. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39387. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39388. import { Material } from "babylonjs/Materials/material";
  39389. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39390. import { Effect } from "babylonjs/Materials/effect";
  39391. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39392. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  39393. import { Light } from "babylonjs/Lights/light";
  39394. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39395. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  39396. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  39397. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  39398. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39399. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  39400. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39401. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  39402. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  39403. import { Engine } from "babylonjs/Engines/engine";
  39404. import { Node } from "babylonjs/node";
  39405. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  39406. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  39407. import { WebRequest } from "babylonjs/Misc/webRequest";
  39408. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  39409. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  39410. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39411. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  39412. import { Plane } from "babylonjs/Maths/math.plane";
  39413. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  39414. import { Ray } from "babylonjs/Culling/ray";
  39415. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  39416. import { Animation } from "babylonjs/Animations/animation";
  39417. import { Animatable } from "babylonjs/Animations/animatable";
  39418. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  39419. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  39420. import { Collider } from "babylonjs/Collisions/collider";
  39421. /**
  39422. * Define an interface for all classes that will hold resources
  39423. */
  39424. export interface IDisposable {
  39425. /**
  39426. * Releases all held resources
  39427. */
  39428. dispose(): void;
  39429. }
  39430. /** Interface defining initialization parameters for Scene class */
  39431. export interface SceneOptions {
  39432. /**
  39433. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39434. * It will improve performance when the number of geometries becomes important.
  39435. */
  39436. useGeometryUniqueIdsMap?: boolean;
  39437. /**
  39438. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39439. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39440. */
  39441. useMaterialMeshMap?: boolean;
  39442. /**
  39443. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39444. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39445. */
  39446. useClonedMeshMap?: boolean;
  39447. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39448. virtual?: boolean;
  39449. }
  39450. /**
  39451. * Represents a scene to be rendered by the engine.
  39452. * @see http://doc.babylonjs.com/features/scene
  39453. */
  39454. export class Scene extends AbstractScene implements IAnimatable {
  39455. /** The fog is deactivated */
  39456. static readonly FOGMODE_NONE: number;
  39457. /** The fog density is following an exponential function */
  39458. static readonly FOGMODE_EXP: number;
  39459. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39460. static readonly FOGMODE_EXP2: number;
  39461. /** The fog density is following a linear function. */
  39462. static readonly FOGMODE_LINEAR: number;
  39463. /**
  39464. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39465. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39466. */
  39467. static MinDeltaTime: number;
  39468. /**
  39469. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39470. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39471. */
  39472. static MaxDeltaTime: number;
  39473. /**
  39474. * Factory used to create the default material.
  39475. * @param name The name of the material to create
  39476. * @param scene The scene to create the material for
  39477. * @returns The default material
  39478. */
  39479. static DefaultMaterialFactory(scene: Scene): Material;
  39480. /**
  39481. * Factory used to create the a collision coordinator.
  39482. * @returns The collision coordinator
  39483. */
  39484. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39485. /** @hidden */
  39486. _inputManager: InputManager;
  39487. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39488. cameraToUseForPointers: Nullable<Camera>;
  39489. /** @hidden */
  39490. readonly _isScene: boolean;
  39491. /** @hidden */
  39492. _blockEntityCollection: boolean;
  39493. /**
  39494. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39495. */
  39496. autoClear: boolean;
  39497. /**
  39498. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39499. */
  39500. autoClearDepthAndStencil: boolean;
  39501. /**
  39502. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39503. */
  39504. clearColor: Color4;
  39505. /**
  39506. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39507. */
  39508. ambientColor: Color3;
  39509. /**
  39510. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39511. * It should only be one of the following (if not the default embedded one):
  39512. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39513. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39514. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39515. * The material properties need to be setup according to the type of texture in use.
  39516. */
  39517. environmentBRDFTexture: BaseTexture;
  39518. /** @hidden */
  39519. protected _environmentTexture: Nullable<BaseTexture>;
  39520. /**
  39521. * Texture used in all pbr material as the reflection texture.
  39522. * As in the majority of the scene they are the same (exception for multi room and so on),
  39523. * this is easier to reference from here than from all the materials.
  39524. */
  39525. get environmentTexture(): Nullable<BaseTexture>;
  39526. /**
  39527. * Texture used in all pbr material as the reflection texture.
  39528. * As in the majority of the scene they are the same (exception for multi room and so on),
  39529. * this is easier to set here than in all the materials.
  39530. */
  39531. set environmentTexture(value: Nullable<BaseTexture>);
  39532. /** @hidden */
  39533. protected _environmentIntensity: number;
  39534. /**
  39535. * Intensity of the environment in all pbr material.
  39536. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39537. * As in the majority of the scene they are the same (exception for multi room and so on),
  39538. * this is easier to reference from here than from all the materials.
  39539. */
  39540. get environmentIntensity(): number;
  39541. /**
  39542. * Intensity of the environment in all pbr material.
  39543. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39544. * As in the majority of the scene they are the same (exception for multi room and so on),
  39545. * this is easier to set here than in all the materials.
  39546. */
  39547. set environmentIntensity(value: number);
  39548. /** @hidden */
  39549. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39550. /**
  39551. * Default image processing configuration used either in the rendering
  39552. * Forward main pass or through the imageProcessingPostProcess if present.
  39553. * As in the majority of the scene they are the same (exception for multi camera),
  39554. * this is easier to reference from here than from all the materials and post process.
  39555. *
  39556. * No setter as we it is a shared configuration, you can set the values instead.
  39557. */
  39558. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39559. private _forceWireframe;
  39560. /**
  39561. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39562. */
  39563. set forceWireframe(value: boolean);
  39564. get forceWireframe(): boolean;
  39565. private _skipFrustumClipping;
  39566. /**
  39567. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39568. */
  39569. set skipFrustumClipping(value: boolean);
  39570. get skipFrustumClipping(): boolean;
  39571. private _forcePointsCloud;
  39572. /**
  39573. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39574. */
  39575. set forcePointsCloud(value: boolean);
  39576. get forcePointsCloud(): boolean;
  39577. /**
  39578. * Gets or sets the active clipplane 1
  39579. */
  39580. clipPlane: Nullable<Plane>;
  39581. /**
  39582. * Gets or sets the active clipplane 2
  39583. */
  39584. clipPlane2: Nullable<Plane>;
  39585. /**
  39586. * Gets or sets the active clipplane 3
  39587. */
  39588. clipPlane3: Nullable<Plane>;
  39589. /**
  39590. * Gets or sets the active clipplane 4
  39591. */
  39592. clipPlane4: Nullable<Plane>;
  39593. /**
  39594. * Gets or sets the active clipplane 5
  39595. */
  39596. clipPlane5: Nullable<Plane>;
  39597. /**
  39598. * Gets or sets the active clipplane 6
  39599. */
  39600. clipPlane6: Nullable<Plane>;
  39601. /**
  39602. * Gets or sets a boolean indicating if animations are enabled
  39603. */
  39604. animationsEnabled: boolean;
  39605. private _animationPropertiesOverride;
  39606. /**
  39607. * Gets or sets the animation properties override
  39608. */
  39609. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39610. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39611. /**
  39612. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39613. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39614. */
  39615. useConstantAnimationDeltaTime: boolean;
  39616. /**
  39617. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39618. * Please note that it requires to run a ray cast through the scene on every frame
  39619. */
  39620. constantlyUpdateMeshUnderPointer: boolean;
  39621. /**
  39622. * Defines the HTML cursor to use when hovering over interactive elements
  39623. */
  39624. hoverCursor: string;
  39625. /**
  39626. * Defines the HTML default cursor to use (empty by default)
  39627. */
  39628. defaultCursor: string;
  39629. /**
  39630. * Defines whether cursors are handled by the scene.
  39631. */
  39632. doNotHandleCursors: boolean;
  39633. /**
  39634. * This is used to call preventDefault() on pointer down
  39635. * in order to block unwanted artifacts like system double clicks
  39636. */
  39637. preventDefaultOnPointerDown: boolean;
  39638. /**
  39639. * This is used to call preventDefault() on pointer up
  39640. * in order to block unwanted artifacts like system double clicks
  39641. */
  39642. preventDefaultOnPointerUp: boolean;
  39643. /**
  39644. * Gets or sets user defined metadata
  39645. */
  39646. metadata: any;
  39647. /**
  39648. * For internal use only. Please do not use.
  39649. */
  39650. reservedDataStore: any;
  39651. /**
  39652. * Gets the name of the plugin used to load this scene (null by default)
  39653. */
  39654. loadingPluginName: string;
  39655. /**
  39656. * Use this array to add regular expressions used to disable offline support for specific urls
  39657. */
  39658. disableOfflineSupportExceptionRules: RegExp[];
  39659. /**
  39660. * An event triggered when the scene is disposed.
  39661. */
  39662. onDisposeObservable: Observable<Scene>;
  39663. private _onDisposeObserver;
  39664. /** Sets a function to be executed when this scene is disposed. */
  39665. set onDispose(callback: () => void);
  39666. /**
  39667. * An event triggered before rendering the scene (right after animations and physics)
  39668. */
  39669. onBeforeRenderObservable: Observable<Scene>;
  39670. private _onBeforeRenderObserver;
  39671. /** Sets a function to be executed before rendering this scene */
  39672. set beforeRender(callback: Nullable<() => void>);
  39673. /**
  39674. * An event triggered after rendering the scene
  39675. */
  39676. onAfterRenderObservable: Observable<Scene>;
  39677. /**
  39678. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39679. */
  39680. onAfterRenderCameraObservable: Observable<Camera>;
  39681. private _onAfterRenderObserver;
  39682. /** Sets a function to be executed after rendering this scene */
  39683. set afterRender(callback: Nullable<() => void>);
  39684. /**
  39685. * An event triggered before animating the scene
  39686. */
  39687. onBeforeAnimationsObservable: Observable<Scene>;
  39688. /**
  39689. * An event triggered after animations processing
  39690. */
  39691. onAfterAnimationsObservable: Observable<Scene>;
  39692. /**
  39693. * An event triggered before draw calls are ready to be sent
  39694. */
  39695. onBeforeDrawPhaseObservable: Observable<Scene>;
  39696. /**
  39697. * An event triggered after draw calls have been sent
  39698. */
  39699. onAfterDrawPhaseObservable: Observable<Scene>;
  39700. /**
  39701. * An event triggered when the scene is ready
  39702. */
  39703. onReadyObservable: Observable<Scene>;
  39704. /**
  39705. * An event triggered before rendering a camera
  39706. */
  39707. onBeforeCameraRenderObservable: Observable<Camera>;
  39708. private _onBeforeCameraRenderObserver;
  39709. /** Sets a function to be executed before rendering a camera*/
  39710. set beforeCameraRender(callback: () => void);
  39711. /**
  39712. * An event triggered after rendering a camera
  39713. */
  39714. onAfterCameraRenderObservable: Observable<Camera>;
  39715. private _onAfterCameraRenderObserver;
  39716. /** Sets a function to be executed after rendering a camera*/
  39717. set afterCameraRender(callback: () => void);
  39718. /**
  39719. * An event triggered when active meshes evaluation is about to start
  39720. */
  39721. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39722. /**
  39723. * An event triggered when active meshes evaluation is done
  39724. */
  39725. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39726. /**
  39727. * An event triggered when particles rendering is about to start
  39728. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39729. */
  39730. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39731. /**
  39732. * An event triggered when particles rendering is done
  39733. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39734. */
  39735. onAfterParticlesRenderingObservable: Observable<Scene>;
  39736. /**
  39737. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39738. */
  39739. onDataLoadedObservable: Observable<Scene>;
  39740. /**
  39741. * An event triggered when a camera is created
  39742. */
  39743. onNewCameraAddedObservable: Observable<Camera>;
  39744. /**
  39745. * An event triggered when a camera is removed
  39746. */
  39747. onCameraRemovedObservable: Observable<Camera>;
  39748. /**
  39749. * An event triggered when a light is created
  39750. */
  39751. onNewLightAddedObservable: Observable<Light>;
  39752. /**
  39753. * An event triggered when a light is removed
  39754. */
  39755. onLightRemovedObservable: Observable<Light>;
  39756. /**
  39757. * An event triggered when a geometry is created
  39758. */
  39759. onNewGeometryAddedObservable: Observable<Geometry>;
  39760. /**
  39761. * An event triggered when a geometry is removed
  39762. */
  39763. onGeometryRemovedObservable: Observable<Geometry>;
  39764. /**
  39765. * An event triggered when a transform node is created
  39766. */
  39767. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39768. /**
  39769. * An event triggered when a transform node is removed
  39770. */
  39771. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39772. /**
  39773. * An event triggered when a mesh is created
  39774. */
  39775. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39776. /**
  39777. * An event triggered when a mesh is removed
  39778. */
  39779. onMeshRemovedObservable: Observable<AbstractMesh>;
  39780. /**
  39781. * An event triggered when a skeleton is created
  39782. */
  39783. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39784. /**
  39785. * An event triggered when a skeleton is removed
  39786. */
  39787. onSkeletonRemovedObservable: Observable<Skeleton>;
  39788. /**
  39789. * An event triggered when a material is created
  39790. */
  39791. onNewMaterialAddedObservable: Observable<Material>;
  39792. /**
  39793. * An event triggered when a material is removed
  39794. */
  39795. onMaterialRemovedObservable: Observable<Material>;
  39796. /**
  39797. * An event triggered when a texture is created
  39798. */
  39799. onNewTextureAddedObservable: Observable<BaseTexture>;
  39800. /**
  39801. * An event triggered when a texture is removed
  39802. */
  39803. onTextureRemovedObservable: Observable<BaseTexture>;
  39804. /**
  39805. * An event triggered when render targets are about to be rendered
  39806. * Can happen multiple times per frame.
  39807. */
  39808. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39809. /**
  39810. * An event triggered when render targets were rendered.
  39811. * Can happen multiple times per frame.
  39812. */
  39813. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39814. /**
  39815. * An event triggered before calculating deterministic simulation step
  39816. */
  39817. onBeforeStepObservable: Observable<Scene>;
  39818. /**
  39819. * An event triggered after calculating deterministic simulation step
  39820. */
  39821. onAfterStepObservable: Observable<Scene>;
  39822. /**
  39823. * An event triggered when the activeCamera property is updated
  39824. */
  39825. onActiveCameraChanged: Observable<Scene>;
  39826. /**
  39827. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39828. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39829. * 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)
  39830. */
  39831. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39832. /**
  39833. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39834. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39835. * 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)
  39836. */
  39837. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39838. /**
  39839. * This Observable will when a mesh has been imported into the scene.
  39840. */
  39841. onMeshImportedObservable: Observable<AbstractMesh>;
  39842. /**
  39843. * This Observable will when an animation file has been imported into the scene.
  39844. */
  39845. onAnimationFileImportedObservable: Observable<Scene>;
  39846. /**
  39847. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39848. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39849. */
  39850. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39851. /** @hidden */
  39852. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39853. /**
  39854. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39855. */
  39856. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39857. /**
  39858. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39859. */
  39860. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39861. /**
  39862. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39863. */
  39864. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39865. /** Callback called when a pointer move is detected */
  39866. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39867. /** Callback called when a pointer down is detected */
  39868. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39869. /** Callback called when a pointer up is detected */
  39870. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39871. /** Callback called when a pointer pick is detected */
  39872. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39873. /**
  39874. * 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).
  39875. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39876. */
  39877. onPrePointerObservable: Observable<PointerInfoPre>;
  39878. /**
  39879. * Observable event triggered each time an input event is received from the rendering canvas
  39880. */
  39881. onPointerObservable: Observable<PointerInfo>;
  39882. /**
  39883. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39884. */
  39885. get unTranslatedPointer(): Vector2;
  39886. /**
  39887. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39888. */
  39889. static get DragMovementThreshold(): number;
  39890. static set DragMovementThreshold(value: number);
  39891. /**
  39892. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39893. */
  39894. static get LongPressDelay(): number;
  39895. static set LongPressDelay(value: number);
  39896. /**
  39897. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39898. */
  39899. static get DoubleClickDelay(): number;
  39900. static set DoubleClickDelay(value: number);
  39901. /** If you need to check double click without raising a single click at first click, enable this flag */
  39902. static get ExclusiveDoubleClickMode(): boolean;
  39903. static set ExclusiveDoubleClickMode(value: boolean);
  39904. /** @hidden */
  39905. _mirroredCameraPosition: Nullable<Vector3>;
  39906. /**
  39907. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39908. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39909. */
  39910. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39911. /**
  39912. * Observable event triggered each time an keyboard event is received from the hosting window
  39913. */
  39914. onKeyboardObservable: Observable<KeyboardInfo>;
  39915. private _useRightHandedSystem;
  39916. /**
  39917. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39918. */
  39919. set useRightHandedSystem(value: boolean);
  39920. get useRightHandedSystem(): boolean;
  39921. private _timeAccumulator;
  39922. private _currentStepId;
  39923. private _currentInternalStep;
  39924. /**
  39925. * Sets the step Id used by deterministic lock step
  39926. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39927. * @param newStepId defines the step Id
  39928. */
  39929. setStepId(newStepId: number): void;
  39930. /**
  39931. * Gets the step Id used by deterministic lock step
  39932. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39933. * @returns the step Id
  39934. */
  39935. getStepId(): number;
  39936. /**
  39937. * Gets the internal step used by deterministic lock step
  39938. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39939. * @returns the internal step
  39940. */
  39941. getInternalStep(): number;
  39942. private _fogEnabled;
  39943. /**
  39944. * Gets or sets a boolean indicating if fog is enabled on this scene
  39945. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39946. * (Default is true)
  39947. */
  39948. set fogEnabled(value: boolean);
  39949. get fogEnabled(): boolean;
  39950. private _fogMode;
  39951. /**
  39952. * Gets or sets the fog mode to use
  39953. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39954. * | mode | value |
  39955. * | --- | --- |
  39956. * | FOGMODE_NONE | 0 |
  39957. * | FOGMODE_EXP | 1 |
  39958. * | FOGMODE_EXP2 | 2 |
  39959. * | FOGMODE_LINEAR | 3 |
  39960. */
  39961. set fogMode(value: number);
  39962. get fogMode(): number;
  39963. /**
  39964. * Gets or sets the fog color to use
  39965. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39966. * (Default is Color3(0.2, 0.2, 0.3))
  39967. */
  39968. fogColor: Color3;
  39969. /**
  39970. * Gets or sets the fog density to use
  39971. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39972. * (Default is 0.1)
  39973. */
  39974. fogDensity: number;
  39975. /**
  39976. * Gets or sets the fog start distance to use
  39977. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39978. * (Default is 0)
  39979. */
  39980. fogStart: number;
  39981. /**
  39982. * Gets or sets the fog end distance to use
  39983. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39984. * (Default is 1000)
  39985. */
  39986. fogEnd: number;
  39987. private _shadowsEnabled;
  39988. /**
  39989. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39990. */
  39991. set shadowsEnabled(value: boolean);
  39992. get shadowsEnabled(): boolean;
  39993. private _lightsEnabled;
  39994. /**
  39995. * Gets or sets a boolean indicating if lights are enabled on this scene
  39996. */
  39997. set lightsEnabled(value: boolean);
  39998. get lightsEnabled(): boolean;
  39999. /** All of the active cameras added to this scene. */
  40000. activeCameras: Camera[];
  40001. /** @hidden */
  40002. _activeCamera: Nullable<Camera>;
  40003. /** Gets or sets the current active camera */
  40004. get activeCamera(): Nullable<Camera>;
  40005. set activeCamera(value: Nullable<Camera>);
  40006. private _defaultMaterial;
  40007. /** The default material used on meshes when no material is affected */
  40008. get defaultMaterial(): Material;
  40009. /** The default material used on meshes when no material is affected */
  40010. set defaultMaterial(value: Material);
  40011. private _texturesEnabled;
  40012. /**
  40013. * Gets or sets a boolean indicating if textures are enabled on this scene
  40014. */
  40015. set texturesEnabled(value: boolean);
  40016. get texturesEnabled(): boolean;
  40017. /**
  40018. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  40019. */
  40020. physicsEnabled: boolean;
  40021. /**
  40022. * Gets or sets a boolean indicating if particles are enabled on this scene
  40023. */
  40024. particlesEnabled: boolean;
  40025. /**
  40026. * Gets or sets a boolean indicating if sprites are enabled on this scene
  40027. */
  40028. spritesEnabled: boolean;
  40029. private _skeletonsEnabled;
  40030. /**
  40031. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  40032. */
  40033. set skeletonsEnabled(value: boolean);
  40034. get skeletonsEnabled(): boolean;
  40035. /**
  40036. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  40037. */
  40038. lensFlaresEnabled: boolean;
  40039. /**
  40040. * Gets or sets a boolean indicating if collisions are enabled on this scene
  40041. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40042. */
  40043. collisionsEnabled: boolean;
  40044. private _collisionCoordinator;
  40045. /** @hidden */
  40046. get collisionCoordinator(): ICollisionCoordinator;
  40047. /**
  40048. * Defines the gravity applied to this scene (used only for collisions)
  40049. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40050. */
  40051. gravity: Vector3;
  40052. /**
  40053. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  40054. */
  40055. postProcessesEnabled: boolean;
  40056. /**
  40057. * The list of postprocesses added to the scene
  40058. */
  40059. postProcesses: PostProcess[];
  40060. /**
  40061. * Gets the current postprocess manager
  40062. */
  40063. postProcessManager: PostProcessManager;
  40064. /**
  40065. * Gets or sets a boolean indicating if render targets are enabled on this scene
  40066. */
  40067. renderTargetsEnabled: boolean;
  40068. /**
  40069. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  40070. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  40071. */
  40072. dumpNextRenderTargets: boolean;
  40073. /**
  40074. * The list of user defined render targets added to the scene
  40075. */
  40076. customRenderTargets: RenderTargetTexture[];
  40077. /**
  40078. * Defines if texture loading must be delayed
  40079. * If true, textures will only be loaded when they need to be rendered
  40080. */
  40081. useDelayedTextureLoading: boolean;
  40082. /**
  40083. * Gets the list of meshes imported to the scene through SceneLoader
  40084. */
  40085. importedMeshesFiles: String[];
  40086. /**
  40087. * Gets or sets a boolean indicating if probes are enabled on this scene
  40088. */
  40089. probesEnabled: boolean;
  40090. /**
  40091. * Gets or sets the current offline provider to use to store scene data
  40092. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40093. */
  40094. offlineProvider: IOfflineProvider;
  40095. /**
  40096. * Gets or sets the action manager associated with the scene
  40097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40098. */
  40099. actionManager: AbstractActionManager;
  40100. private _meshesForIntersections;
  40101. /**
  40102. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40103. */
  40104. proceduralTexturesEnabled: boolean;
  40105. private _engine;
  40106. private _totalVertices;
  40107. /** @hidden */
  40108. _activeIndices: PerfCounter;
  40109. /** @hidden */
  40110. _activeParticles: PerfCounter;
  40111. /** @hidden */
  40112. _activeBones: PerfCounter;
  40113. private _animationRatio;
  40114. /** @hidden */
  40115. _animationTimeLast: number;
  40116. /** @hidden */
  40117. _animationTime: number;
  40118. /**
  40119. * Gets or sets a general scale for animation speed
  40120. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40121. */
  40122. animationTimeScale: number;
  40123. /** @hidden */
  40124. _cachedMaterial: Nullable<Material>;
  40125. /** @hidden */
  40126. _cachedEffect: Nullable<Effect>;
  40127. /** @hidden */
  40128. _cachedVisibility: Nullable<number>;
  40129. private _renderId;
  40130. private _frameId;
  40131. private _executeWhenReadyTimeoutId;
  40132. private _intermediateRendering;
  40133. private _viewUpdateFlag;
  40134. private _projectionUpdateFlag;
  40135. /** @hidden */
  40136. _toBeDisposed: Nullable<IDisposable>[];
  40137. private _activeRequests;
  40138. /** @hidden */
  40139. _pendingData: any[];
  40140. private _isDisposed;
  40141. /**
  40142. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40143. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40144. */
  40145. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40146. private _activeMeshes;
  40147. private _processedMaterials;
  40148. private _renderTargets;
  40149. /** @hidden */
  40150. _activeParticleSystems: SmartArray<IParticleSystem>;
  40151. private _activeSkeletons;
  40152. private _softwareSkinnedMeshes;
  40153. private _renderingManager;
  40154. /** @hidden */
  40155. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  40156. private _transformMatrix;
  40157. private _sceneUbo;
  40158. /** @hidden */
  40159. _viewMatrix: Matrix;
  40160. private _projectionMatrix;
  40161. /** @hidden */
  40162. _forcedViewPosition: Nullable<Vector3>;
  40163. /** @hidden */
  40164. _frustumPlanes: Plane[];
  40165. /**
  40166. * Gets the list of frustum planes (built from the active camera)
  40167. */
  40168. get frustumPlanes(): Plane[];
  40169. /**
  40170. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40171. * This is useful if there are more lights that the maximum simulteanous authorized
  40172. */
  40173. requireLightSorting: boolean;
  40174. /** @hidden */
  40175. readonly useMaterialMeshMap: boolean;
  40176. /** @hidden */
  40177. readonly useClonedMeshMap: boolean;
  40178. private _externalData;
  40179. private _uid;
  40180. /**
  40181. * @hidden
  40182. * Backing store of defined scene components.
  40183. */
  40184. _components: ISceneComponent[];
  40185. /**
  40186. * @hidden
  40187. * Backing store of defined scene components.
  40188. */
  40189. _serializableComponents: ISceneSerializableComponent[];
  40190. /**
  40191. * List of components to register on the next registration step.
  40192. */
  40193. private _transientComponents;
  40194. /**
  40195. * Registers the transient components if needed.
  40196. */
  40197. private _registerTransientComponents;
  40198. /**
  40199. * @hidden
  40200. * Add a component to the scene.
  40201. * Note that the ccomponent could be registered on th next frame if this is called after
  40202. * the register component stage.
  40203. * @param component Defines the component to add to the scene
  40204. */
  40205. _addComponent(component: ISceneComponent): void;
  40206. /**
  40207. * @hidden
  40208. * Gets a component from the scene.
  40209. * @param name defines the name of the component to retrieve
  40210. * @returns the component or null if not present
  40211. */
  40212. _getComponent(name: string): Nullable<ISceneComponent>;
  40213. /**
  40214. * @hidden
  40215. * Defines the actions happening before camera updates.
  40216. */
  40217. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40218. /**
  40219. * @hidden
  40220. * Defines the actions happening before clear the canvas.
  40221. */
  40222. _beforeClearStage: Stage<SimpleStageAction>;
  40223. /**
  40224. * @hidden
  40225. * Defines the actions when collecting render targets for the frame.
  40226. */
  40227. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40228. /**
  40229. * @hidden
  40230. * Defines the actions happening for one camera in the frame.
  40231. */
  40232. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40233. /**
  40234. * @hidden
  40235. * Defines the actions happening during the per mesh ready checks.
  40236. */
  40237. _isReadyForMeshStage: Stage<MeshStageAction>;
  40238. /**
  40239. * @hidden
  40240. * Defines the actions happening before evaluate active mesh checks.
  40241. */
  40242. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40243. /**
  40244. * @hidden
  40245. * Defines the actions happening during the evaluate sub mesh checks.
  40246. */
  40247. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40248. /**
  40249. * @hidden
  40250. * Defines the actions happening during the active mesh stage.
  40251. */
  40252. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40253. /**
  40254. * @hidden
  40255. * Defines the actions happening during the per camera render target step.
  40256. */
  40257. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40258. /**
  40259. * @hidden
  40260. * Defines the actions happening just before the active camera is drawing.
  40261. */
  40262. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40263. /**
  40264. * @hidden
  40265. * Defines the actions happening just before a render target is drawing.
  40266. */
  40267. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40268. /**
  40269. * @hidden
  40270. * Defines the actions happening just before a rendering group is drawing.
  40271. */
  40272. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40273. /**
  40274. * @hidden
  40275. * Defines the actions happening just before a mesh is drawing.
  40276. */
  40277. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40278. /**
  40279. * @hidden
  40280. * Defines the actions happening just after a mesh has been drawn.
  40281. */
  40282. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40283. /**
  40284. * @hidden
  40285. * Defines the actions happening just after a rendering group has been drawn.
  40286. */
  40287. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40288. /**
  40289. * @hidden
  40290. * Defines the actions happening just after the active camera has been drawn.
  40291. */
  40292. _afterCameraDrawStage: Stage<CameraStageAction>;
  40293. /**
  40294. * @hidden
  40295. * Defines the actions happening just after a render target has been drawn.
  40296. */
  40297. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40298. /**
  40299. * @hidden
  40300. * Defines the actions happening just after rendering all cameras and computing intersections.
  40301. */
  40302. _afterRenderStage: Stage<SimpleStageAction>;
  40303. /**
  40304. * @hidden
  40305. * Defines the actions happening when a pointer move event happens.
  40306. */
  40307. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40308. /**
  40309. * @hidden
  40310. * Defines the actions happening when a pointer down event happens.
  40311. */
  40312. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40313. /**
  40314. * @hidden
  40315. * Defines the actions happening when a pointer up event happens.
  40316. */
  40317. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40318. /**
  40319. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40320. */
  40321. private geometriesByUniqueId;
  40322. /**
  40323. * Creates a new Scene
  40324. * @param engine defines the engine to use to render this scene
  40325. * @param options defines the scene options
  40326. */
  40327. constructor(engine: Engine, options?: SceneOptions);
  40328. /**
  40329. * Gets a string idenfifying the name of the class
  40330. * @returns "Scene" string
  40331. */
  40332. getClassName(): string;
  40333. private _defaultMeshCandidates;
  40334. /**
  40335. * @hidden
  40336. */
  40337. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40338. private _defaultSubMeshCandidates;
  40339. /**
  40340. * @hidden
  40341. */
  40342. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40343. /**
  40344. * Sets the default candidate providers for the scene.
  40345. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40346. * and getCollidingSubMeshCandidates to their default function
  40347. */
  40348. setDefaultCandidateProviders(): void;
  40349. /**
  40350. * Gets the mesh that is currently under the pointer
  40351. */
  40352. get meshUnderPointer(): Nullable<AbstractMesh>;
  40353. /**
  40354. * Gets or sets the current on-screen X position of the pointer
  40355. */
  40356. get pointerX(): number;
  40357. set pointerX(value: number);
  40358. /**
  40359. * Gets or sets the current on-screen Y position of the pointer
  40360. */
  40361. get pointerY(): number;
  40362. set pointerY(value: number);
  40363. /**
  40364. * Gets the cached material (ie. the latest rendered one)
  40365. * @returns the cached material
  40366. */
  40367. getCachedMaterial(): Nullable<Material>;
  40368. /**
  40369. * Gets the cached effect (ie. the latest rendered one)
  40370. * @returns the cached effect
  40371. */
  40372. getCachedEffect(): Nullable<Effect>;
  40373. /**
  40374. * Gets the cached visibility state (ie. the latest rendered one)
  40375. * @returns the cached visibility state
  40376. */
  40377. getCachedVisibility(): Nullable<number>;
  40378. /**
  40379. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40380. * @param material defines the current material
  40381. * @param effect defines the current effect
  40382. * @param visibility defines the current visibility state
  40383. * @returns true if one parameter is not cached
  40384. */
  40385. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40386. /**
  40387. * Gets the engine associated with the scene
  40388. * @returns an Engine
  40389. */
  40390. getEngine(): Engine;
  40391. /**
  40392. * Gets the total number of vertices rendered per frame
  40393. * @returns the total number of vertices rendered per frame
  40394. */
  40395. getTotalVertices(): number;
  40396. /**
  40397. * Gets the performance counter for total vertices
  40398. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40399. */
  40400. get totalVerticesPerfCounter(): PerfCounter;
  40401. /**
  40402. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40403. * @returns the total number of active indices rendered per frame
  40404. */
  40405. getActiveIndices(): number;
  40406. /**
  40407. * Gets the performance counter for active indices
  40408. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40409. */
  40410. get totalActiveIndicesPerfCounter(): PerfCounter;
  40411. /**
  40412. * Gets the total number of active particles rendered per frame
  40413. * @returns the total number of active particles rendered per frame
  40414. */
  40415. getActiveParticles(): number;
  40416. /**
  40417. * Gets the performance counter for active particles
  40418. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40419. */
  40420. get activeParticlesPerfCounter(): PerfCounter;
  40421. /**
  40422. * Gets the total number of active bones rendered per frame
  40423. * @returns the total number of active bones rendered per frame
  40424. */
  40425. getActiveBones(): number;
  40426. /**
  40427. * Gets the performance counter for active bones
  40428. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40429. */
  40430. get activeBonesPerfCounter(): PerfCounter;
  40431. /**
  40432. * Gets the array of active meshes
  40433. * @returns an array of AbstractMesh
  40434. */
  40435. getActiveMeshes(): SmartArray<AbstractMesh>;
  40436. /**
  40437. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40438. * @returns a number
  40439. */
  40440. getAnimationRatio(): number;
  40441. /**
  40442. * Gets an unique Id for the current render phase
  40443. * @returns a number
  40444. */
  40445. getRenderId(): number;
  40446. /**
  40447. * Gets an unique Id for the current frame
  40448. * @returns a number
  40449. */
  40450. getFrameId(): number;
  40451. /** Call this function if you want to manually increment the render Id*/
  40452. incrementRenderId(): void;
  40453. private _createUbo;
  40454. /**
  40455. * Use this method to simulate a pointer move on a mesh
  40456. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40457. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40458. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40459. * @returns the current scene
  40460. */
  40461. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40462. /**
  40463. * Use this method to simulate a pointer down on a mesh
  40464. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40465. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40466. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40467. * @returns the current scene
  40468. */
  40469. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40470. /**
  40471. * Use this method to simulate a pointer up on a mesh
  40472. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40473. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40474. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40475. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40476. * @returns the current scene
  40477. */
  40478. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40479. /**
  40480. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40481. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40482. * @returns true if the pointer was captured
  40483. */
  40484. isPointerCaptured(pointerId?: number): boolean;
  40485. /**
  40486. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40487. * @param attachUp defines if you want to attach events to pointerup
  40488. * @param attachDown defines if you want to attach events to pointerdown
  40489. * @param attachMove defines if you want to attach events to pointermove
  40490. */
  40491. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40492. /** Detaches all event handlers*/
  40493. detachControl(): void;
  40494. /**
  40495. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40496. * Delay loaded resources are not taking in account
  40497. * @return true if all required resources are ready
  40498. */
  40499. isReady(): boolean;
  40500. /** Resets all cached information relative to material (including effect and visibility) */
  40501. resetCachedMaterial(): void;
  40502. /**
  40503. * Registers a function to be called before every frame render
  40504. * @param func defines the function to register
  40505. */
  40506. registerBeforeRender(func: () => void): void;
  40507. /**
  40508. * Unregisters a function called before every frame render
  40509. * @param func defines the function to unregister
  40510. */
  40511. unregisterBeforeRender(func: () => void): void;
  40512. /**
  40513. * Registers a function to be called after every frame render
  40514. * @param func defines the function to register
  40515. */
  40516. registerAfterRender(func: () => void): void;
  40517. /**
  40518. * Unregisters a function called after every frame render
  40519. * @param func defines the function to unregister
  40520. */
  40521. unregisterAfterRender(func: () => void): void;
  40522. private _executeOnceBeforeRender;
  40523. /**
  40524. * The provided function will run before render once and will be disposed afterwards.
  40525. * A timeout delay can be provided so that the function will be executed in N ms.
  40526. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40527. * @param func The function to be executed.
  40528. * @param timeout optional delay in ms
  40529. */
  40530. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40531. /** @hidden */
  40532. _addPendingData(data: any): void;
  40533. /** @hidden */
  40534. _removePendingData(data: any): void;
  40535. /**
  40536. * Returns the number of items waiting to be loaded
  40537. * @returns the number of items waiting to be loaded
  40538. */
  40539. getWaitingItemsCount(): number;
  40540. /**
  40541. * Returns a boolean indicating if the scene is still loading data
  40542. */
  40543. get isLoading(): boolean;
  40544. /**
  40545. * Registers a function to be executed when the scene is ready
  40546. * @param {Function} func - the function to be executed
  40547. */
  40548. executeWhenReady(func: () => void): void;
  40549. /**
  40550. * Returns a promise that resolves when the scene is ready
  40551. * @returns A promise that resolves when the scene is ready
  40552. */
  40553. whenReadyAsync(): Promise<void>;
  40554. /** @hidden */
  40555. _checkIsReady(): void;
  40556. /**
  40557. * Gets all animatable attached to the scene
  40558. */
  40559. get animatables(): Animatable[];
  40560. /**
  40561. * Resets the last animation time frame.
  40562. * Useful to override when animations start running when loading a scene for the first time.
  40563. */
  40564. resetLastAnimationTimeFrame(): void;
  40565. /**
  40566. * Gets the current view matrix
  40567. * @returns a Matrix
  40568. */
  40569. getViewMatrix(): Matrix;
  40570. /**
  40571. * Gets the current projection matrix
  40572. * @returns a Matrix
  40573. */
  40574. getProjectionMatrix(): Matrix;
  40575. /**
  40576. * Gets the current transform matrix
  40577. * @returns a Matrix made of View * Projection
  40578. */
  40579. getTransformMatrix(): Matrix;
  40580. /**
  40581. * Sets the current transform matrix
  40582. * @param viewL defines the View matrix to use
  40583. * @param projectionL defines the Projection matrix to use
  40584. * @param viewR defines the right View matrix to use (if provided)
  40585. * @param projectionR defines the right Projection matrix to use (if provided)
  40586. */
  40587. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40588. /**
  40589. * Gets the uniform buffer used to store scene data
  40590. * @returns a UniformBuffer
  40591. */
  40592. getSceneUniformBuffer(): UniformBuffer;
  40593. /**
  40594. * Gets an unique (relatively to the current scene) Id
  40595. * @returns an unique number for the scene
  40596. */
  40597. getUniqueId(): number;
  40598. /**
  40599. * Add a mesh to the list of scene's meshes
  40600. * @param newMesh defines the mesh to add
  40601. * @param recursive if all child meshes should also be added to the scene
  40602. */
  40603. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40604. /**
  40605. * Remove a mesh for the list of scene's meshes
  40606. * @param toRemove defines the mesh to remove
  40607. * @param recursive if all child meshes should also be removed from the scene
  40608. * @returns the index where the mesh was in the mesh list
  40609. */
  40610. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40611. /**
  40612. * Add a transform node to the list of scene's transform nodes
  40613. * @param newTransformNode defines the transform node to add
  40614. */
  40615. addTransformNode(newTransformNode: TransformNode): void;
  40616. /**
  40617. * Remove a transform node for the list of scene's transform nodes
  40618. * @param toRemove defines the transform node to remove
  40619. * @returns the index where the transform node was in the transform node list
  40620. */
  40621. removeTransformNode(toRemove: TransformNode): number;
  40622. /**
  40623. * Remove a skeleton for the list of scene's skeletons
  40624. * @param toRemove defines the skeleton to remove
  40625. * @returns the index where the skeleton was in the skeleton list
  40626. */
  40627. removeSkeleton(toRemove: Skeleton): number;
  40628. /**
  40629. * Remove a morph target for the list of scene's morph targets
  40630. * @param toRemove defines the morph target to remove
  40631. * @returns the index where the morph target was in the morph target list
  40632. */
  40633. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40634. /**
  40635. * Remove a light for the list of scene's lights
  40636. * @param toRemove defines the light to remove
  40637. * @returns the index where the light was in the light list
  40638. */
  40639. removeLight(toRemove: Light): number;
  40640. /**
  40641. * Remove a camera for the list of scene's cameras
  40642. * @param toRemove defines the camera to remove
  40643. * @returns the index where the camera was in the camera list
  40644. */
  40645. removeCamera(toRemove: Camera): number;
  40646. /**
  40647. * Remove a particle system for the list of scene's particle systems
  40648. * @param toRemove defines the particle system to remove
  40649. * @returns the index where the particle system was in the particle system list
  40650. */
  40651. removeParticleSystem(toRemove: IParticleSystem): number;
  40652. /**
  40653. * Remove a animation for the list of scene's animations
  40654. * @param toRemove defines the animation to remove
  40655. * @returns the index where the animation was in the animation list
  40656. */
  40657. removeAnimation(toRemove: Animation): number;
  40658. /**
  40659. * Will stop the animation of the given target
  40660. * @param target - the target
  40661. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40662. * @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)
  40663. */
  40664. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40665. /**
  40666. * Removes the given animation group from this scene.
  40667. * @param toRemove The animation group to remove
  40668. * @returns The index of the removed animation group
  40669. */
  40670. removeAnimationGroup(toRemove: AnimationGroup): number;
  40671. /**
  40672. * Removes the given multi-material from this scene.
  40673. * @param toRemove The multi-material to remove
  40674. * @returns The index of the removed multi-material
  40675. */
  40676. removeMultiMaterial(toRemove: MultiMaterial): number;
  40677. /**
  40678. * Removes the given material from this scene.
  40679. * @param toRemove The material to remove
  40680. * @returns The index of the removed material
  40681. */
  40682. removeMaterial(toRemove: Material): number;
  40683. /**
  40684. * Removes the given action manager from this scene.
  40685. * @param toRemove The action manager to remove
  40686. * @returns The index of the removed action manager
  40687. */
  40688. removeActionManager(toRemove: AbstractActionManager): number;
  40689. /**
  40690. * Removes the given texture from this scene.
  40691. * @param toRemove The texture to remove
  40692. * @returns The index of the removed texture
  40693. */
  40694. removeTexture(toRemove: BaseTexture): number;
  40695. /**
  40696. * Adds the given light to this scene
  40697. * @param newLight The light to add
  40698. */
  40699. addLight(newLight: Light): void;
  40700. /**
  40701. * Sorts the list list based on light priorities
  40702. */
  40703. sortLightsByPriority(): void;
  40704. /**
  40705. * Adds the given camera to this scene
  40706. * @param newCamera The camera to add
  40707. */
  40708. addCamera(newCamera: Camera): void;
  40709. /**
  40710. * Adds the given skeleton to this scene
  40711. * @param newSkeleton The skeleton to add
  40712. */
  40713. addSkeleton(newSkeleton: Skeleton): void;
  40714. /**
  40715. * Adds the given particle system to this scene
  40716. * @param newParticleSystem The particle system to add
  40717. */
  40718. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40719. /**
  40720. * Adds the given animation to this scene
  40721. * @param newAnimation The animation to add
  40722. */
  40723. addAnimation(newAnimation: Animation): void;
  40724. /**
  40725. * Adds the given animation group to this scene.
  40726. * @param newAnimationGroup The animation group to add
  40727. */
  40728. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40729. /**
  40730. * Adds the given multi-material to this scene
  40731. * @param newMultiMaterial The multi-material to add
  40732. */
  40733. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40734. /**
  40735. * Adds the given material to this scene
  40736. * @param newMaterial The material to add
  40737. */
  40738. addMaterial(newMaterial: Material): void;
  40739. /**
  40740. * Adds the given morph target to this scene
  40741. * @param newMorphTargetManager The morph target to add
  40742. */
  40743. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40744. /**
  40745. * Adds the given geometry to this scene
  40746. * @param newGeometry The geometry to add
  40747. */
  40748. addGeometry(newGeometry: Geometry): void;
  40749. /**
  40750. * Adds the given action manager to this scene
  40751. * @param newActionManager The action manager to add
  40752. */
  40753. addActionManager(newActionManager: AbstractActionManager): void;
  40754. /**
  40755. * Adds the given texture to this scene.
  40756. * @param newTexture The texture to add
  40757. */
  40758. addTexture(newTexture: BaseTexture): void;
  40759. /**
  40760. * Switch active camera
  40761. * @param newCamera defines the new active camera
  40762. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40763. */
  40764. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40765. /**
  40766. * sets the active camera of the scene using its ID
  40767. * @param id defines the camera's ID
  40768. * @return the new active camera or null if none found.
  40769. */
  40770. setActiveCameraByID(id: string): Nullable<Camera>;
  40771. /**
  40772. * sets the active camera of the scene using its name
  40773. * @param name defines the camera's name
  40774. * @returns the new active camera or null if none found.
  40775. */
  40776. setActiveCameraByName(name: string): Nullable<Camera>;
  40777. /**
  40778. * get an animation group using its name
  40779. * @param name defines the material's name
  40780. * @return the animation group or null if none found.
  40781. */
  40782. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40783. /**
  40784. * Get a material using its unique id
  40785. * @param uniqueId defines the material's unique id
  40786. * @return the material or null if none found.
  40787. */
  40788. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40789. /**
  40790. * get a material using its id
  40791. * @param id defines the material's ID
  40792. * @return the material or null if none found.
  40793. */
  40794. getMaterialByID(id: string): Nullable<Material>;
  40795. /**
  40796. * Gets a the last added material using a given id
  40797. * @param id defines the material's ID
  40798. * @return the last material with the given id or null if none found.
  40799. */
  40800. getLastMaterialByID(id: string): Nullable<Material>;
  40801. /**
  40802. * Gets a material using its name
  40803. * @param name defines the material's name
  40804. * @return the material or null if none found.
  40805. */
  40806. getMaterialByName(name: string): Nullable<Material>;
  40807. /**
  40808. * Get a texture using its unique id
  40809. * @param uniqueId defines the texture's unique id
  40810. * @return the texture or null if none found.
  40811. */
  40812. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40813. /**
  40814. * Gets a camera using its id
  40815. * @param id defines the id to look for
  40816. * @returns the camera or null if not found
  40817. */
  40818. getCameraByID(id: string): Nullable<Camera>;
  40819. /**
  40820. * Gets a camera using its unique id
  40821. * @param uniqueId defines the unique id to look for
  40822. * @returns the camera or null if not found
  40823. */
  40824. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40825. /**
  40826. * Gets a camera using its name
  40827. * @param name defines the camera's name
  40828. * @return the camera or null if none found.
  40829. */
  40830. getCameraByName(name: string): Nullable<Camera>;
  40831. /**
  40832. * Gets a bone using its id
  40833. * @param id defines the bone's id
  40834. * @return the bone or null if not found
  40835. */
  40836. getBoneByID(id: string): Nullable<Bone>;
  40837. /**
  40838. * Gets a bone using its id
  40839. * @param name defines the bone's name
  40840. * @return the bone or null if not found
  40841. */
  40842. getBoneByName(name: string): Nullable<Bone>;
  40843. /**
  40844. * Gets a light node using its name
  40845. * @param name defines the the light's name
  40846. * @return the light or null if none found.
  40847. */
  40848. getLightByName(name: string): Nullable<Light>;
  40849. /**
  40850. * Gets a light node using its id
  40851. * @param id defines the light's id
  40852. * @return the light or null if none found.
  40853. */
  40854. getLightByID(id: string): Nullable<Light>;
  40855. /**
  40856. * Gets a light node using its scene-generated unique ID
  40857. * @param uniqueId defines the light's unique id
  40858. * @return the light or null if none found.
  40859. */
  40860. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40861. /**
  40862. * Gets a particle system by id
  40863. * @param id defines the particle system id
  40864. * @return the corresponding system or null if none found
  40865. */
  40866. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40867. /**
  40868. * Gets a geometry using its ID
  40869. * @param id defines the geometry's id
  40870. * @return the geometry or null if none found.
  40871. */
  40872. getGeometryByID(id: string): Nullable<Geometry>;
  40873. private _getGeometryByUniqueID;
  40874. /**
  40875. * Add a new geometry to this scene
  40876. * @param geometry defines the geometry to be added to the scene.
  40877. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40878. * @return a boolean defining if the geometry was added or not
  40879. */
  40880. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40881. /**
  40882. * Removes an existing geometry
  40883. * @param geometry defines the geometry to be removed from the scene
  40884. * @return a boolean defining if the geometry was removed or not
  40885. */
  40886. removeGeometry(geometry: Geometry): boolean;
  40887. /**
  40888. * Gets the list of geometries attached to the scene
  40889. * @returns an array of Geometry
  40890. */
  40891. getGeometries(): Geometry[];
  40892. /**
  40893. * Gets the first added mesh found of a given ID
  40894. * @param id defines the id to search for
  40895. * @return the mesh found or null if not found at all
  40896. */
  40897. getMeshByID(id: string): Nullable<AbstractMesh>;
  40898. /**
  40899. * Gets a list of meshes using their id
  40900. * @param id defines the id to search for
  40901. * @returns a list of meshes
  40902. */
  40903. getMeshesByID(id: string): Array<AbstractMesh>;
  40904. /**
  40905. * Gets the first added transform node found of a given ID
  40906. * @param id defines the id to search for
  40907. * @return the found transform node or null if not found at all.
  40908. */
  40909. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40910. /**
  40911. * Gets a transform node with its auto-generated unique id
  40912. * @param uniqueId efines the unique id to search for
  40913. * @return the found transform node or null if not found at all.
  40914. */
  40915. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40916. /**
  40917. * Gets a list of transform nodes using their id
  40918. * @param id defines the id to search for
  40919. * @returns a list of transform nodes
  40920. */
  40921. getTransformNodesByID(id: string): Array<TransformNode>;
  40922. /**
  40923. * Gets a mesh with its auto-generated unique id
  40924. * @param uniqueId defines the unique id to search for
  40925. * @return the found mesh or null if not found at all.
  40926. */
  40927. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40928. /**
  40929. * Gets a the last added mesh using a given id
  40930. * @param id defines the id to search for
  40931. * @return the found mesh or null if not found at all.
  40932. */
  40933. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40934. /**
  40935. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40936. * @param id defines the id to search for
  40937. * @return the found node or null if not found at all
  40938. */
  40939. getLastEntryByID(id: string): Nullable<Node>;
  40940. /**
  40941. * Gets a node (Mesh, Camera, Light) using a given id
  40942. * @param id defines the id to search for
  40943. * @return the found node or null if not found at all
  40944. */
  40945. getNodeByID(id: string): Nullable<Node>;
  40946. /**
  40947. * Gets a node (Mesh, Camera, Light) using a given name
  40948. * @param name defines the name to search for
  40949. * @return the found node or null if not found at all.
  40950. */
  40951. getNodeByName(name: string): Nullable<Node>;
  40952. /**
  40953. * Gets a mesh using a given name
  40954. * @param name defines the name to search for
  40955. * @return the found mesh or null if not found at all.
  40956. */
  40957. getMeshByName(name: string): Nullable<AbstractMesh>;
  40958. /**
  40959. * Gets a transform node using a given name
  40960. * @param name defines the name to search for
  40961. * @return the found transform node or null if not found at all.
  40962. */
  40963. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40964. /**
  40965. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40966. * @param id defines the id to search for
  40967. * @return the found skeleton or null if not found at all.
  40968. */
  40969. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40970. /**
  40971. * Gets a skeleton using a given auto generated unique id
  40972. * @param uniqueId defines the unique id to search for
  40973. * @return the found skeleton or null if not found at all.
  40974. */
  40975. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40976. /**
  40977. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40978. * @param id defines the id to search for
  40979. * @return the found skeleton or null if not found at all.
  40980. */
  40981. getSkeletonById(id: string): Nullable<Skeleton>;
  40982. /**
  40983. * Gets a skeleton using a given name
  40984. * @param name defines the name to search for
  40985. * @return the found skeleton or null if not found at all.
  40986. */
  40987. getSkeletonByName(name: string): Nullable<Skeleton>;
  40988. /**
  40989. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40990. * @param id defines the id to search for
  40991. * @return the found morph target manager or null if not found at all.
  40992. */
  40993. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40994. /**
  40995. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40996. * @param id defines the id to search for
  40997. * @return the found morph target or null if not found at all.
  40998. */
  40999. getMorphTargetById(id: string): Nullable<MorphTarget>;
  41000. /**
  41001. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  41002. * @param name defines the name to search for
  41003. * @return the found morph target or null if not found at all.
  41004. */
  41005. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  41006. /**
  41007. * Gets a boolean indicating if the given mesh is active
  41008. * @param mesh defines the mesh to look for
  41009. * @returns true if the mesh is in the active list
  41010. */
  41011. isActiveMesh(mesh: AbstractMesh): boolean;
  41012. /**
  41013. * Return a unique id as a string which can serve as an identifier for the scene
  41014. */
  41015. get uid(): string;
  41016. /**
  41017. * Add an externaly attached data from its key.
  41018. * This method call will fail and return false, if such key already exists.
  41019. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  41020. * @param key the unique key that identifies the data
  41021. * @param data the data object to associate to the key for this Engine instance
  41022. * @return true if no such key were already present and the data was added successfully, false otherwise
  41023. */
  41024. addExternalData<T>(key: string, data: T): boolean;
  41025. /**
  41026. * Get an externaly attached data from its key
  41027. * @param key the unique key that identifies the data
  41028. * @return the associated data, if present (can be null), or undefined if not present
  41029. */
  41030. getExternalData<T>(key: string): Nullable<T>;
  41031. /**
  41032. * Get an externaly attached data from its key, create it using a factory if it's not already present
  41033. * @param key the unique key that identifies the data
  41034. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  41035. * @return the associated data, can be null if the factory returned null.
  41036. */
  41037. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  41038. /**
  41039. * Remove an externaly attached data from the Engine instance
  41040. * @param key the unique key that identifies the data
  41041. * @return true if the data was successfully removed, false if it doesn't exist
  41042. */
  41043. removeExternalData(key: string): boolean;
  41044. private _evaluateSubMesh;
  41045. /**
  41046. * Clear the processed materials smart array preventing retention point in material dispose.
  41047. */
  41048. freeProcessedMaterials(): void;
  41049. private _preventFreeActiveMeshesAndRenderingGroups;
  41050. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  41051. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  41052. * when disposing several meshes in a row or a hierarchy of meshes.
  41053. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  41054. */
  41055. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  41056. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  41057. /**
  41058. * Clear the active meshes smart array preventing retention point in mesh dispose.
  41059. */
  41060. freeActiveMeshes(): void;
  41061. /**
  41062. * Clear the info related to rendering groups preventing retention points during dispose.
  41063. */
  41064. freeRenderingGroups(): void;
  41065. /** @hidden */
  41066. _isInIntermediateRendering(): boolean;
  41067. /**
  41068. * Lambda returning the list of potentially active meshes.
  41069. */
  41070. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41071. /**
  41072. * Lambda returning the list of potentially active sub meshes.
  41073. */
  41074. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41075. /**
  41076. * Lambda returning the list of potentially intersecting sub meshes.
  41077. */
  41078. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41079. /**
  41080. * Lambda returning the list of potentially colliding sub meshes.
  41081. */
  41082. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41083. private _activeMeshesFrozen;
  41084. private _skipEvaluateActiveMeshesCompletely;
  41085. /**
  41086. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41087. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41088. * @returns the current scene
  41089. */
  41090. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41091. /**
  41092. * Use this function to restart evaluating active meshes on every frame
  41093. * @returns the current scene
  41094. */
  41095. unfreezeActiveMeshes(): Scene;
  41096. private _evaluateActiveMeshes;
  41097. private _activeMesh;
  41098. /**
  41099. * Update the transform matrix to update from the current active camera
  41100. * @param force defines a boolean used to force the update even if cache is up to date
  41101. */
  41102. updateTransformMatrix(force?: boolean): void;
  41103. private _bindFrameBuffer;
  41104. /** @hidden */
  41105. _allowPostProcessClearColor: boolean;
  41106. /** @hidden */
  41107. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41108. private _processSubCameras;
  41109. private _checkIntersections;
  41110. /** @hidden */
  41111. _advancePhysicsEngineStep(step: number): void;
  41112. /**
  41113. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41114. */
  41115. getDeterministicFrameTime: () => number;
  41116. /** @hidden */
  41117. _animate(): void;
  41118. /** Execute all animations (for a frame) */
  41119. animate(): void;
  41120. /**
  41121. * Render the scene
  41122. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41123. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41124. */
  41125. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41126. /**
  41127. * Freeze all materials
  41128. * A frozen material will not be updatable but should be faster to render
  41129. */
  41130. freezeMaterials(): void;
  41131. /**
  41132. * Unfreeze all materials
  41133. * A frozen material will not be updatable but should be faster to render
  41134. */
  41135. unfreezeMaterials(): void;
  41136. /**
  41137. * Releases all held ressources
  41138. */
  41139. dispose(): void;
  41140. /**
  41141. * Gets if the scene is already disposed
  41142. */
  41143. get isDisposed(): boolean;
  41144. /**
  41145. * Call this function to reduce memory footprint of the scene.
  41146. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41147. */
  41148. clearCachedVertexData(): void;
  41149. /**
  41150. * This function will remove the local cached buffer data from texture.
  41151. * It will save memory but will prevent the texture from being rebuilt
  41152. */
  41153. cleanCachedTextureBuffer(): void;
  41154. /**
  41155. * Get the world extend vectors with an optional filter
  41156. *
  41157. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41158. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41159. */
  41160. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41161. min: Vector3;
  41162. max: Vector3;
  41163. };
  41164. /**
  41165. * Creates a ray that can be used to pick in the scene
  41166. * @param x defines the x coordinate of the origin (on-screen)
  41167. * @param y defines the y coordinate of the origin (on-screen)
  41168. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41169. * @param camera defines the camera to use for the picking
  41170. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41171. * @returns a Ray
  41172. */
  41173. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41174. /**
  41175. * Creates a ray that can be used to pick in the scene
  41176. * @param x defines the x coordinate of the origin (on-screen)
  41177. * @param y defines the y coordinate of the origin (on-screen)
  41178. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41179. * @param result defines the ray where to store the picking ray
  41180. * @param camera defines the camera to use for the picking
  41181. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41182. * @returns the current scene
  41183. */
  41184. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41185. /**
  41186. * Creates a ray that can be used to pick in the scene
  41187. * @param x defines the x coordinate of the origin (on-screen)
  41188. * @param y defines the y coordinate of the origin (on-screen)
  41189. * @param camera defines the camera to use for the picking
  41190. * @returns a Ray
  41191. */
  41192. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41193. /**
  41194. * Creates a ray that can be used to pick in the scene
  41195. * @param x defines the x coordinate of the origin (on-screen)
  41196. * @param y defines the y coordinate of the origin (on-screen)
  41197. * @param result defines the ray where to store the picking ray
  41198. * @param camera defines the camera to use for the picking
  41199. * @returns the current scene
  41200. */
  41201. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41202. /** Launch a ray to try to pick a mesh in the scene
  41203. * @param x position on screen
  41204. * @param y position on screen
  41205. * @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
  41206. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41207. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41208. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41209. * @returns a PickingInfo
  41210. */
  41211. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41212. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41213. * @param x position on screen
  41214. * @param y position on screen
  41215. * @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
  41216. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41217. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41218. * @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)
  41219. */
  41220. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41221. /** Use the given ray to pick a mesh in the scene
  41222. * @param ray The ray to use to pick meshes
  41223. * @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
  41224. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41225. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41226. * @returns a PickingInfo
  41227. */
  41228. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41229. /**
  41230. * Launch a ray to try to pick a mesh in the scene
  41231. * @param x X position on screen
  41232. * @param y Y position on screen
  41233. * @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
  41234. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41235. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41236. * @returns an array of PickingInfo
  41237. */
  41238. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41239. /**
  41240. * Launch a ray to try to pick a mesh in the scene
  41241. * @param ray Ray to use
  41242. * @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
  41243. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41244. * @returns an array of PickingInfo
  41245. */
  41246. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41247. /**
  41248. * Force the value of meshUnderPointer
  41249. * @param mesh defines the mesh to use
  41250. */
  41251. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  41252. /**
  41253. * Gets the mesh under the pointer
  41254. * @returns a Mesh or null if no mesh is under the pointer
  41255. */
  41256. getPointerOverMesh(): Nullable<AbstractMesh>;
  41257. /** @hidden */
  41258. _rebuildGeometries(): void;
  41259. /** @hidden */
  41260. _rebuildTextures(): void;
  41261. private _getByTags;
  41262. /**
  41263. * Get a list of meshes by tags
  41264. * @param tagsQuery defines the tags query to use
  41265. * @param forEach defines a predicate used to filter results
  41266. * @returns an array of Mesh
  41267. */
  41268. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41269. /**
  41270. * Get a list of cameras by tags
  41271. * @param tagsQuery defines the tags query to use
  41272. * @param forEach defines a predicate used to filter results
  41273. * @returns an array of Camera
  41274. */
  41275. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41276. /**
  41277. * Get a list of lights by tags
  41278. * @param tagsQuery defines the tags query to use
  41279. * @param forEach defines a predicate used to filter results
  41280. * @returns an array of Light
  41281. */
  41282. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41283. /**
  41284. * Get a list of materials by tags
  41285. * @param tagsQuery defines the tags query to use
  41286. * @param forEach defines a predicate used to filter results
  41287. * @returns an array of Material
  41288. */
  41289. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41290. /**
  41291. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41292. * This allowed control for front to back rendering or reversly depending of the special needs.
  41293. *
  41294. * @param renderingGroupId The rendering group id corresponding to its index
  41295. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41296. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41297. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41298. */
  41299. 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;
  41300. /**
  41301. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41302. *
  41303. * @param renderingGroupId The rendering group id corresponding to its index
  41304. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41305. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41306. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41307. */
  41308. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41309. /**
  41310. * Gets the current auto clear configuration for one rendering group of the rendering
  41311. * manager.
  41312. * @param index the rendering group index to get the information for
  41313. * @returns The auto clear setup for the requested rendering group
  41314. */
  41315. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41316. private _blockMaterialDirtyMechanism;
  41317. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41318. get blockMaterialDirtyMechanism(): boolean;
  41319. set blockMaterialDirtyMechanism(value: boolean);
  41320. /**
  41321. * Will flag all materials as dirty to trigger new shader compilation
  41322. * @param flag defines the flag used to specify which material part must be marked as dirty
  41323. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41324. */
  41325. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41326. /** @hidden */
  41327. _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;
  41328. /** @hidden */
  41329. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41330. /** @hidden */
  41331. _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;
  41332. /** @hidden */
  41333. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41334. /** @hidden */
  41335. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41336. /** @hidden */
  41337. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41338. }
  41339. }
  41340. declare module "babylonjs/assetContainer" {
  41341. import { AbstractScene } from "babylonjs/abstractScene";
  41342. import { Scene } from "babylonjs/scene";
  41343. import { Mesh } from "babylonjs/Meshes/mesh";
  41344. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41345. import { Skeleton } from "babylonjs/Bones/skeleton";
  41346. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41347. import { Animatable } from "babylonjs/Animations/animatable";
  41348. import { Nullable } from "babylonjs/types";
  41349. import { Node } from "babylonjs/node";
  41350. /**
  41351. * Set of assets to keep when moving a scene into an asset container.
  41352. */
  41353. export class KeepAssets extends AbstractScene {
  41354. }
  41355. /**
  41356. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41357. */
  41358. export class InstantiatedEntries {
  41359. /**
  41360. * List of new root nodes (eg. nodes with no parent)
  41361. */
  41362. rootNodes: TransformNode[];
  41363. /**
  41364. * List of new skeletons
  41365. */
  41366. skeletons: Skeleton[];
  41367. /**
  41368. * List of new animation groups
  41369. */
  41370. animationGroups: AnimationGroup[];
  41371. }
  41372. /**
  41373. * Container with a set of assets that can be added or removed from a scene.
  41374. */
  41375. export class AssetContainer extends AbstractScene {
  41376. private _wasAddedToScene;
  41377. /**
  41378. * The scene the AssetContainer belongs to.
  41379. */
  41380. scene: Scene;
  41381. /**
  41382. * Instantiates an AssetContainer.
  41383. * @param scene The scene the AssetContainer belongs to.
  41384. */
  41385. constructor(scene: Scene);
  41386. /**
  41387. * Instantiate or clone all meshes and add the new ones to the scene.
  41388. * Skeletons and animation groups will all be cloned
  41389. * @param nameFunction defines an optional function used to get new names for clones
  41390. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41391. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41392. */
  41393. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41394. /**
  41395. * Adds all the assets from the container to the scene.
  41396. */
  41397. addAllToScene(): void;
  41398. /**
  41399. * Removes all the assets in the container from the scene
  41400. */
  41401. removeAllFromScene(): void;
  41402. /**
  41403. * Disposes all the assets in the container
  41404. */
  41405. dispose(): void;
  41406. private _moveAssets;
  41407. /**
  41408. * Removes all the assets contained in the scene and adds them to the container.
  41409. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41410. */
  41411. moveAllFromScene(keepAssets?: KeepAssets): void;
  41412. /**
  41413. * 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.
  41414. * @returns the root mesh
  41415. */
  41416. createRootMesh(): Mesh;
  41417. /**
  41418. * Merge animations (direct and animation groups) from this asset container into a scene
  41419. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41420. * @param animatables set of animatables to retarget to a node from the scene
  41421. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41422. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41423. */
  41424. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41425. }
  41426. }
  41427. declare module "babylonjs/abstractScene" {
  41428. import { Scene } from "babylonjs/scene";
  41429. import { Nullable } from "babylonjs/types";
  41430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41431. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41432. import { Geometry } from "babylonjs/Meshes/geometry";
  41433. import { Skeleton } from "babylonjs/Bones/skeleton";
  41434. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  41435. import { AssetContainer } from "babylonjs/assetContainer";
  41436. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41437. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41438. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41439. import { Material } from "babylonjs/Materials/material";
  41440. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  41441. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  41442. import { Camera } from "babylonjs/Cameras/camera";
  41443. import { Light } from "babylonjs/Lights/light";
  41444. import { Node } from "babylonjs/node";
  41445. import { Animation } from "babylonjs/Animations/animation";
  41446. /**
  41447. * Defines how the parser contract is defined.
  41448. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41449. */
  41450. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41451. /**
  41452. * Defines how the individual parser contract is defined.
  41453. * These parser can parse an individual asset
  41454. */
  41455. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41456. /**
  41457. * Base class of the scene acting as a container for the different elements composing a scene.
  41458. * This class is dynamically extended by the different components of the scene increasing
  41459. * flexibility and reducing coupling
  41460. */
  41461. export abstract class AbstractScene {
  41462. /**
  41463. * Stores the list of available parsers in the application.
  41464. */
  41465. private static _BabylonFileParsers;
  41466. /**
  41467. * Stores the list of available individual parsers in the application.
  41468. */
  41469. private static _IndividualBabylonFileParsers;
  41470. /**
  41471. * Adds a parser in the list of available ones
  41472. * @param name Defines the name of the parser
  41473. * @param parser Defines the parser to add
  41474. */
  41475. static AddParser(name: string, parser: BabylonFileParser): void;
  41476. /**
  41477. * Gets a general parser from the list of avaialble ones
  41478. * @param name Defines the name of the parser
  41479. * @returns the requested parser or null
  41480. */
  41481. static GetParser(name: string): Nullable<BabylonFileParser>;
  41482. /**
  41483. * Adds n individual parser in the list of available ones
  41484. * @param name Defines the name of the parser
  41485. * @param parser Defines the parser to add
  41486. */
  41487. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41488. /**
  41489. * Gets an individual parser from the list of avaialble ones
  41490. * @param name Defines the name of the parser
  41491. * @returns the requested parser or null
  41492. */
  41493. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41494. /**
  41495. * Parser json data and populate both a scene and its associated container object
  41496. * @param jsonData Defines the data to parse
  41497. * @param scene Defines the scene to parse the data for
  41498. * @param container Defines the container attached to the parsing sequence
  41499. * @param rootUrl Defines the root url of the data
  41500. */
  41501. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41502. /**
  41503. * Gets the list of root nodes (ie. nodes with no parent)
  41504. */
  41505. rootNodes: Node[];
  41506. /** All of the cameras added to this scene
  41507. * @see http://doc.babylonjs.com/babylon101/cameras
  41508. */
  41509. cameras: Camera[];
  41510. /**
  41511. * All of the lights added to this scene
  41512. * @see http://doc.babylonjs.com/babylon101/lights
  41513. */
  41514. lights: Light[];
  41515. /**
  41516. * All of the (abstract) meshes added to this scene
  41517. */
  41518. meshes: AbstractMesh[];
  41519. /**
  41520. * The list of skeletons added to the scene
  41521. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41522. */
  41523. skeletons: Skeleton[];
  41524. /**
  41525. * All of the particle systems added to this scene
  41526. * @see http://doc.babylonjs.com/babylon101/particles
  41527. */
  41528. particleSystems: IParticleSystem[];
  41529. /**
  41530. * Gets a list of Animations associated with the scene
  41531. */
  41532. animations: Animation[];
  41533. /**
  41534. * All of the animation groups added to this scene
  41535. * @see http://doc.babylonjs.com/how_to/group
  41536. */
  41537. animationGroups: AnimationGroup[];
  41538. /**
  41539. * All of the multi-materials added to this scene
  41540. * @see http://doc.babylonjs.com/how_to/multi_materials
  41541. */
  41542. multiMaterials: MultiMaterial[];
  41543. /**
  41544. * All of the materials added to this scene
  41545. * In the context of a Scene, it is not supposed to be modified manually.
  41546. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41547. * Note also that the order of the Material within the array is not significant and might change.
  41548. * @see http://doc.babylonjs.com/babylon101/materials
  41549. */
  41550. materials: Material[];
  41551. /**
  41552. * The list of morph target managers added to the scene
  41553. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41554. */
  41555. morphTargetManagers: MorphTargetManager[];
  41556. /**
  41557. * The list of geometries used in the scene.
  41558. */
  41559. geometries: Geometry[];
  41560. /**
  41561. * All of the tranform nodes added to this scene
  41562. * In the context of a Scene, it is not supposed to be modified manually.
  41563. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41564. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41565. * @see http://doc.babylonjs.com/how_to/transformnode
  41566. */
  41567. transformNodes: TransformNode[];
  41568. /**
  41569. * ActionManagers available on the scene.
  41570. */
  41571. actionManagers: AbstractActionManager[];
  41572. /**
  41573. * Textures to keep.
  41574. */
  41575. textures: BaseTexture[];
  41576. /**
  41577. * Environment texture for the scene
  41578. */
  41579. environmentTexture: Nullable<BaseTexture>;
  41580. /**
  41581. * @returns all meshes, lights, cameras, transformNodes and bones
  41582. */
  41583. getNodes(): Array<Node>;
  41584. }
  41585. }
  41586. declare module "babylonjs/Audio/sound" {
  41587. import { Observable } from "babylonjs/Misc/observable";
  41588. import { Vector3 } from "babylonjs/Maths/math.vector";
  41589. import { Nullable } from "babylonjs/types";
  41590. import { Scene } from "babylonjs/scene";
  41591. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41592. /**
  41593. * Interface used to define options for Sound class
  41594. */
  41595. export interface ISoundOptions {
  41596. /**
  41597. * Does the sound autoplay once loaded.
  41598. */
  41599. autoplay?: boolean;
  41600. /**
  41601. * Does the sound loop after it finishes playing once.
  41602. */
  41603. loop?: boolean;
  41604. /**
  41605. * Sound's volume
  41606. */
  41607. volume?: number;
  41608. /**
  41609. * Is it a spatial sound?
  41610. */
  41611. spatialSound?: boolean;
  41612. /**
  41613. * Maximum distance to hear that sound
  41614. */
  41615. maxDistance?: number;
  41616. /**
  41617. * Uses user defined attenuation function
  41618. */
  41619. useCustomAttenuation?: boolean;
  41620. /**
  41621. * Define the roll off factor of spatial sounds.
  41622. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41623. */
  41624. rolloffFactor?: number;
  41625. /**
  41626. * Define the reference distance the sound should be heard perfectly.
  41627. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41628. */
  41629. refDistance?: number;
  41630. /**
  41631. * Define the distance attenuation model the sound will follow.
  41632. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41633. */
  41634. distanceModel?: string;
  41635. /**
  41636. * Defines the playback speed (1 by default)
  41637. */
  41638. playbackRate?: number;
  41639. /**
  41640. * Defines if the sound is from a streaming source
  41641. */
  41642. streaming?: boolean;
  41643. /**
  41644. * Defines an optional length (in seconds) inside the sound file
  41645. */
  41646. length?: number;
  41647. /**
  41648. * Defines an optional offset (in seconds) inside the sound file
  41649. */
  41650. offset?: number;
  41651. /**
  41652. * If true, URLs will not be required to state the audio file codec to use.
  41653. */
  41654. skipCodecCheck?: boolean;
  41655. }
  41656. /**
  41657. * Defines a sound that can be played in the application.
  41658. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41659. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41660. */
  41661. export class Sound {
  41662. /**
  41663. * The name of the sound in the scene.
  41664. */
  41665. name: string;
  41666. /**
  41667. * Does the sound autoplay once loaded.
  41668. */
  41669. autoplay: boolean;
  41670. /**
  41671. * Does the sound loop after it finishes playing once.
  41672. */
  41673. loop: boolean;
  41674. /**
  41675. * Does the sound use a custom attenuation curve to simulate the falloff
  41676. * happening when the source gets further away from the camera.
  41677. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41678. */
  41679. useCustomAttenuation: boolean;
  41680. /**
  41681. * The sound track id this sound belongs to.
  41682. */
  41683. soundTrackId: number;
  41684. /**
  41685. * Is this sound currently played.
  41686. */
  41687. isPlaying: boolean;
  41688. /**
  41689. * Is this sound currently paused.
  41690. */
  41691. isPaused: boolean;
  41692. /**
  41693. * Does this sound enables spatial sound.
  41694. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41695. */
  41696. spatialSound: boolean;
  41697. /**
  41698. * Define the reference distance the sound should be heard perfectly.
  41699. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41700. */
  41701. refDistance: number;
  41702. /**
  41703. * Define the roll off factor of spatial sounds.
  41704. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41705. */
  41706. rolloffFactor: number;
  41707. /**
  41708. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41709. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41710. */
  41711. maxDistance: number;
  41712. /**
  41713. * Define the distance attenuation model the sound will follow.
  41714. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41715. */
  41716. distanceModel: string;
  41717. /**
  41718. * @hidden
  41719. * Back Compat
  41720. **/
  41721. onended: () => any;
  41722. /**
  41723. * Gets or sets an object used to store user defined information for the sound.
  41724. */
  41725. metadata: any;
  41726. /**
  41727. * Observable event when the current playing sound finishes.
  41728. */
  41729. onEndedObservable: Observable<Sound>;
  41730. private _panningModel;
  41731. private _playbackRate;
  41732. private _streaming;
  41733. private _startTime;
  41734. private _startOffset;
  41735. private _position;
  41736. /** @hidden */
  41737. _positionInEmitterSpace: boolean;
  41738. private _localDirection;
  41739. private _volume;
  41740. private _isReadyToPlay;
  41741. private _isDirectional;
  41742. private _readyToPlayCallback;
  41743. private _audioBuffer;
  41744. private _soundSource;
  41745. private _streamingSource;
  41746. private _soundPanner;
  41747. private _soundGain;
  41748. private _inputAudioNode;
  41749. private _outputAudioNode;
  41750. private _coneInnerAngle;
  41751. private _coneOuterAngle;
  41752. private _coneOuterGain;
  41753. private _scene;
  41754. private _connectedTransformNode;
  41755. private _customAttenuationFunction;
  41756. private _registerFunc;
  41757. private _isOutputConnected;
  41758. private _htmlAudioElement;
  41759. private _urlType;
  41760. private _length?;
  41761. private _offset?;
  41762. /** @hidden */
  41763. static _SceneComponentInitialization: (scene: Scene) => void;
  41764. /**
  41765. * Create a sound and attach it to a scene
  41766. * @param name Name of your sound
  41767. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41768. * @param scene defines the scene the sound belongs to
  41769. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41770. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41771. */
  41772. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41773. /**
  41774. * Release the sound and its associated resources
  41775. */
  41776. dispose(): void;
  41777. /**
  41778. * Gets if the sounds is ready to be played or not.
  41779. * @returns true if ready, otherwise false
  41780. */
  41781. isReady(): boolean;
  41782. private _soundLoaded;
  41783. /**
  41784. * Sets the data of the sound from an audiobuffer
  41785. * @param audioBuffer The audioBuffer containing the data
  41786. */
  41787. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41788. /**
  41789. * Updates the current sounds options such as maxdistance, loop...
  41790. * @param options A JSON object containing values named as the object properties
  41791. */
  41792. updateOptions(options: ISoundOptions): void;
  41793. private _createSpatialParameters;
  41794. private _updateSpatialParameters;
  41795. /**
  41796. * Switch the panning model to HRTF:
  41797. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41798. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41799. */
  41800. switchPanningModelToHRTF(): void;
  41801. /**
  41802. * Switch the panning model to Equal Power:
  41803. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41804. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41805. */
  41806. switchPanningModelToEqualPower(): void;
  41807. private _switchPanningModel;
  41808. /**
  41809. * Connect this sound to a sound track audio node like gain...
  41810. * @param soundTrackAudioNode the sound track audio node to connect to
  41811. */
  41812. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41813. /**
  41814. * Transform this sound into a directional source
  41815. * @param coneInnerAngle Size of the inner cone in degree
  41816. * @param coneOuterAngle Size of the outer cone in degree
  41817. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41818. */
  41819. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41820. /**
  41821. * Gets or sets the inner angle for the directional cone.
  41822. */
  41823. get directionalConeInnerAngle(): number;
  41824. /**
  41825. * Gets or sets the inner angle for the directional cone.
  41826. */
  41827. set directionalConeInnerAngle(value: number);
  41828. /**
  41829. * Gets or sets the outer angle for the directional cone.
  41830. */
  41831. get directionalConeOuterAngle(): number;
  41832. /**
  41833. * Gets or sets the outer angle for the directional cone.
  41834. */
  41835. set directionalConeOuterAngle(value: number);
  41836. /**
  41837. * Sets the position of the emitter if spatial sound is enabled
  41838. * @param newPosition Defines the new posisiton
  41839. */
  41840. setPosition(newPosition: Vector3): void;
  41841. /**
  41842. * Sets the local direction of the emitter if spatial sound is enabled
  41843. * @param newLocalDirection Defines the new local direction
  41844. */
  41845. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41846. private _updateDirection;
  41847. /** @hidden */
  41848. updateDistanceFromListener(): void;
  41849. /**
  41850. * Sets a new custom attenuation function for the sound.
  41851. * @param callback Defines the function used for the attenuation
  41852. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41853. */
  41854. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41855. /**
  41856. * Play the sound
  41857. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41858. * @param offset (optional) Start the sound at a specific time in seconds
  41859. * @param length (optional) Sound duration (in seconds)
  41860. */
  41861. play(time?: number, offset?: number, length?: number): void;
  41862. private _onended;
  41863. /**
  41864. * Stop the sound
  41865. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41866. */
  41867. stop(time?: number): void;
  41868. /**
  41869. * Put the sound in pause
  41870. */
  41871. pause(): void;
  41872. /**
  41873. * Sets a dedicated volume for this sounds
  41874. * @param newVolume Define the new volume of the sound
  41875. * @param time Define time for gradual change to new volume
  41876. */
  41877. setVolume(newVolume: number, time?: number): void;
  41878. /**
  41879. * Set the sound play back rate
  41880. * @param newPlaybackRate Define the playback rate the sound should be played at
  41881. */
  41882. setPlaybackRate(newPlaybackRate: number): void;
  41883. /**
  41884. * Gets the volume of the sound.
  41885. * @returns the volume of the sound
  41886. */
  41887. getVolume(): number;
  41888. /**
  41889. * Attach the sound to a dedicated mesh
  41890. * @param transformNode The transform node to connect the sound with
  41891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41892. */
  41893. attachToMesh(transformNode: TransformNode): void;
  41894. /**
  41895. * Detach the sound from the previously attached mesh
  41896. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41897. */
  41898. detachFromMesh(): void;
  41899. private _onRegisterAfterWorldMatrixUpdate;
  41900. /**
  41901. * Clone the current sound in the scene.
  41902. * @returns the new sound clone
  41903. */
  41904. clone(): Nullable<Sound>;
  41905. /**
  41906. * Gets the current underlying audio buffer containing the data
  41907. * @returns the audio buffer
  41908. */
  41909. getAudioBuffer(): Nullable<AudioBuffer>;
  41910. /**
  41911. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41912. * @returns the source node
  41913. */
  41914. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41915. /**
  41916. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41917. * @returns the gain node
  41918. */
  41919. getSoundGain(): Nullable<GainNode>;
  41920. /**
  41921. * Serializes the Sound in a JSON representation
  41922. * @returns the JSON representation of the sound
  41923. */
  41924. serialize(): any;
  41925. /**
  41926. * Parse a JSON representation of a sound to innstantiate in a given scene
  41927. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41928. * @param scene Define the scene the new parsed sound should be created in
  41929. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41930. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41931. * @returns the newly parsed sound
  41932. */
  41933. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41934. }
  41935. }
  41936. declare module "babylonjs/Actions/directAudioActions" {
  41937. import { Action } from "babylonjs/Actions/action";
  41938. import { Condition } from "babylonjs/Actions/condition";
  41939. import { Sound } from "babylonjs/Audio/sound";
  41940. /**
  41941. * This defines an action helpful to play a defined sound on a triggered action.
  41942. */
  41943. export class PlaySoundAction extends Action {
  41944. private _sound;
  41945. /**
  41946. * Instantiate the action
  41947. * @param triggerOptions defines the trigger options
  41948. * @param sound defines the sound to play
  41949. * @param condition defines the trigger related conditions
  41950. */
  41951. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41952. /** @hidden */
  41953. _prepare(): void;
  41954. /**
  41955. * Execute the action and play the sound.
  41956. */
  41957. execute(): void;
  41958. /**
  41959. * Serializes the actions and its related information.
  41960. * @param parent defines the object to serialize in
  41961. * @returns the serialized object
  41962. */
  41963. serialize(parent: any): any;
  41964. }
  41965. /**
  41966. * This defines an action helpful to stop a defined sound on a triggered action.
  41967. */
  41968. export class StopSoundAction extends Action {
  41969. private _sound;
  41970. /**
  41971. * Instantiate the action
  41972. * @param triggerOptions defines the trigger options
  41973. * @param sound defines the sound to stop
  41974. * @param condition defines the trigger related conditions
  41975. */
  41976. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41977. /** @hidden */
  41978. _prepare(): void;
  41979. /**
  41980. * Execute the action and stop the sound.
  41981. */
  41982. execute(): void;
  41983. /**
  41984. * Serializes the actions and its related information.
  41985. * @param parent defines the object to serialize in
  41986. * @returns the serialized object
  41987. */
  41988. serialize(parent: any): any;
  41989. }
  41990. }
  41991. declare module "babylonjs/Actions/interpolateValueAction" {
  41992. import { Action } from "babylonjs/Actions/action";
  41993. import { Condition } from "babylonjs/Actions/condition";
  41994. import { Observable } from "babylonjs/Misc/observable";
  41995. /**
  41996. * This defines an action responsible to change the value of a property
  41997. * by interpolating between its current value and the newly set one once triggered.
  41998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  41999. */
  42000. export class InterpolateValueAction extends Action {
  42001. /**
  42002. * Defines the path of the property where the value should be interpolated
  42003. */
  42004. propertyPath: string;
  42005. /**
  42006. * Defines the target value at the end of the interpolation.
  42007. */
  42008. value: any;
  42009. /**
  42010. * Defines the time it will take for the property to interpolate to the value.
  42011. */
  42012. duration: number;
  42013. /**
  42014. * Defines if the other scene animations should be stopped when the action has been triggered
  42015. */
  42016. stopOtherAnimations?: boolean;
  42017. /**
  42018. * Defines a callback raised once the interpolation animation has been done.
  42019. */
  42020. onInterpolationDone?: () => void;
  42021. /**
  42022. * Observable triggered once the interpolation animation has been done.
  42023. */
  42024. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  42025. private _target;
  42026. private _effectiveTarget;
  42027. private _property;
  42028. /**
  42029. * Instantiate the action
  42030. * @param triggerOptions defines the trigger options
  42031. * @param target defines the object containing the value to interpolate
  42032. * @param propertyPath defines the path to the property in the target object
  42033. * @param value defines the target value at the end of the interpolation
  42034. * @param duration deines the time it will take for the property to interpolate to the value.
  42035. * @param condition defines the trigger related conditions
  42036. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  42037. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  42038. */
  42039. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  42040. /** @hidden */
  42041. _prepare(): void;
  42042. /**
  42043. * Execute the action starts the value interpolation.
  42044. */
  42045. execute(): void;
  42046. /**
  42047. * Serializes the actions and its related information.
  42048. * @param parent defines the object to serialize in
  42049. * @returns the serialized object
  42050. */
  42051. serialize(parent: any): any;
  42052. }
  42053. }
  42054. declare module "babylonjs/Actions/index" {
  42055. export * from "babylonjs/Actions/abstractActionManager";
  42056. export * from "babylonjs/Actions/action";
  42057. export * from "babylonjs/Actions/actionEvent";
  42058. export * from "babylonjs/Actions/actionManager";
  42059. export * from "babylonjs/Actions/condition";
  42060. export * from "babylonjs/Actions/directActions";
  42061. export * from "babylonjs/Actions/directAudioActions";
  42062. export * from "babylonjs/Actions/interpolateValueAction";
  42063. }
  42064. declare module "babylonjs/Animations/index" {
  42065. export * from "babylonjs/Animations/animatable";
  42066. export * from "babylonjs/Animations/animation";
  42067. export * from "babylonjs/Animations/animationGroup";
  42068. export * from "babylonjs/Animations/animationPropertiesOverride";
  42069. export * from "babylonjs/Animations/easing";
  42070. export * from "babylonjs/Animations/runtimeAnimation";
  42071. export * from "babylonjs/Animations/animationEvent";
  42072. export * from "babylonjs/Animations/animationGroup";
  42073. export * from "babylonjs/Animations/animationKey";
  42074. export * from "babylonjs/Animations/animationRange";
  42075. export * from "babylonjs/Animations/animatable.interface";
  42076. }
  42077. declare module "babylonjs/Audio/soundTrack" {
  42078. import { Sound } from "babylonjs/Audio/sound";
  42079. import { Analyser } from "babylonjs/Audio/analyser";
  42080. import { Scene } from "babylonjs/scene";
  42081. /**
  42082. * Options allowed during the creation of a sound track.
  42083. */
  42084. export interface ISoundTrackOptions {
  42085. /**
  42086. * The volume the sound track should take during creation
  42087. */
  42088. volume?: number;
  42089. /**
  42090. * Define if the sound track is the main sound track of the scene
  42091. */
  42092. mainTrack?: boolean;
  42093. }
  42094. /**
  42095. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  42096. * It will be also used in a future release to apply effects on a specific track.
  42097. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42098. */
  42099. export class SoundTrack {
  42100. /**
  42101. * The unique identifier of the sound track in the scene.
  42102. */
  42103. id: number;
  42104. /**
  42105. * The list of sounds included in the sound track.
  42106. */
  42107. soundCollection: Array<Sound>;
  42108. private _outputAudioNode;
  42109. private _scene;
  42110. private _connectedAnalyser;
  42111. private _options;
  42112. private _isInitialized;
  42113. /**
  42114. * Creates a new sound track.
  42115. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42116. * @param scene Define the scene the sound track belongs to
  42117. * @param options
  42118. */
  42119. constructor(scene: Scene, options?: ISoundTrackOptions);
  42120. private _initializeSoundTrackAudioGraph;
  42121. /**
  42122. * Release the sound track and its associated resources
  42123. */
  42124. dispose(): void;
  42125. /**
  42126. * Adds a sound to this sound track
  42127. * @param sound define the cound to add
  42128. * @ignoreNaming
  42129. */
  42130. AddSound(sound: Sound): void;
  42131. /**
  42132. * Removes a sound to this sound track
  42133. * @param sound define the cound to remove
  42134. * @ignoreNaming
  42135. */
  42136. RemoveSound(sound: Sound): void;
  42137. /**
  42138. * Set a global volume for the full sound track.
  42139. * @param newVolume Define the new volume of the sound track
  42140. */
  42141. setVolume(newVolume: number): void;
  42142. /**
  42143. * Switch the panning model to HRTF:
  42144. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42145. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42146. */
  42147. switchPanningModelToHRTF(): void;
  42148. /**
  42149. * Switch the panning model to Equal Power:
  42150. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42151. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42152. */
  42153. switchPanningModelToEqualPower(): void;
  42154. /**
  42155. * Connect the sound track to an audio analyser allowing some amazing
  42156. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42158. * @param analyser The analyser to connect to the engine
  42159. */
  42160. connectToAnalyser(analyser: Analyser): void;
  42161. }
  42162. }
  42163. declare module "babylonjs/Audio/audioSceneComponent" {
  42164. import { Sound } from "babylonjs/Audio/sound";
  42165. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  42166. import { Nullable } from "babylonjs/types";
  42167. import { Vector3 } from "babylonjs/Maths/math.vector";
  42168. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  42169. import { Scene } from "babylonjs/scene";
  42170. import { AbstractScene } from "babylonjs/abstractScene";
  42171. import "babylonjs/Audio/audioEngine";
  42172. module "babylonjs/abstractScene" {
  42173. interface AbstractScene {
  42174. /**
  42175. * The list of sounds used in the scene.
  42176. */
  42177. sounds: Nullable<Array<Sound>>;
  42178. }
  42179. }
  42180. module "babylonjs/scene" {
  42181. interface Scene {
  42182. /**
  42183. * @hidden
  42184. * Backing field
  42185. */
  42186. _mainSoundTrack: SoundTrack;
  42187. /**
  42188. * The main sound track played by the scene.
  42189. * It cotains your primary collection of sounds.
  42190. */
  42191. mainSoundTrack: SoundTrack;
  42192. /**
  42193. * The list of sound tracks added to the scene
  42194. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42195. */
  42196. soundTracks: Nullable<Array<SoundTrack>>;
  42197. /**
  42198. * Gets a sound using a given name
  42199. * @param name defines the name to search for
  42200. * @return the found sound or null if not found at all.
  42201. */
  42202. getSoundByName(name: string): Nullable<Sound>;
  42203. /**
  42204. * Gets or sets if audio support is enabled
  42205. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42206. */
  42207. audioEnabled: boolean;
  42208. /**
  42209. * Gets or sets if audio will be output to headphones
  42210. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42211. */
  42212. headphone: boolean;
  42213. /**
  42214. * Gets or sets custom audio listener position provider
  42215. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42216. */
  42217. audioListenerPositionProvider: Nullable<() => Vector3>;
  42218. /**
  42219. * Gets or sets a refresh rate when using 3D audio positioning
  42220. */
  42221. audioPositioningRefreshRate: number;
  42222. }
  42223. }
  42224. /**
  42225. * Defines the sound scene component responsible to manage any sounds
  42226. * in a given scene.
  42227. */
  42228. export class AudioSceneComponent implements ISceneSerializableComponent {
  42229. /**
  42230. * The component name helpfull to identify the component in the list of scene components.
  42231. */
  42232. readonly name: string;
  42233. /**
  42234. * The scene the component belongs to.
  42235. */
  42236. scene: Scene;
  42237. private _audioEnabled;
  42238. /**
  42239. * Gets whether audio is enabled or not.
  42240. * Please use related enable/disable method to switch state.
  42241. */
  42242. get audioEnabled(): boolean;
  42243. private _headphone;
  42244. /**
  42245. * Gets whether audio is outputing to headphone or not.
  42246. * Please use the according Switch methods to change output.
  42247. */
  42248. get headphone(): boolean;
  42249. /**
  42250. * Gets or sets a refresh rate when using 3D audio positioning
  42251. */
  42252. audioPositioningRefreshRate: number;
  42253. private _audioListenerPositionProvider;
  42254. /**
  42255. * Gets the current audio listener position provider
  42256. */
  42257. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42258. /**
  42259. * Sets a custom listener position for all sounds in the scene
  42260. * By default, this is the position of the first active camera
  42261. */
  42262. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42263. /**
  42264. * Creates a new instance of the component for the given scene
  42265. * @param scene Defines the scene to register the component in
  42266. */
  42267. constructor(scene: Scene);
  42268. /**
  42269. * Registers the component in a given scene
  42270. */
  42271. register(): void;
  42272. /**
  42273. * Rebuilds the elements related to this component in case of
  42274. * context lost for instance.
  42275. */
  42276. rebuild(): void;
  42277. /**
  42278. * Serializes the component data to the specified json object
  42279. * @param serializationObject The object to serialize to
  42280. */
  42281. serialize(serializationObject: any): void;
  42282. /**
  42283. * Adds all the elements from the container to the scene
  42284. * @param container the container holding the elements
  42285. */
  42286. addFromContainer(container: AbstractScene): void;
  42287. /**
  42288. * Removes all the elements in the container from the scene
  42289. * @param container contains the elements to remove
  42290. * @param dispose if the removed element should be disposed (default: false)
  42291. */
  42292. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42293. /**
  42294. * Disposes the component and the associated ressources.
  42295. */
  42296. dispose(): void;
  42297. /**
  42298. * Disables audio in the associated scene.
  42299. */
  42300. disableAudio(): void;
  42301. /**
  42302. * Enables audio in the associated scene.
  42303. */
  42304. enableAudio(): void;
  42305. /**
  42306. * Switch audio to headphone output.
  42307. */
  42308. switchAudioModeForHeadphones(): void;
  42309. /**
  42310. * Switch audio to normal speakers.
  42311. */
  42312. switchAudioModeForNormalSpeakers(): void;
  42313. private _cachedCameraDirection;
  42314. private _cachedCameraPosition;
  42315. private _lastCheck;
  42316. private _afterRender;
  42317. }
  42318. }
  42319. declare module "babylonjs/Audio/weightedsound" {
  42320. import { Sound } from "babylonjs/Audio/sound";
  42321. /**
  42322. * Wraps one or more Sound objects and selects one with random weight for playback.
  42323. */
  42324. export class WeightedSound {
  42325. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42326. loop: boolean;
  42327. private _coneInnerAngle;
  42328. private _coneOuterAngle;
  42329. private _volume;
  42330. /** A Sound is currently playing. */
  42331. isPlaying: boolean;
  42332. /** A Sound is currently paused. */
  42333. isPaused: boolean;
  42334. private _sounds;
  42335. private _weights;
  42336. private _currentIndex?;
  42337. /**
  42338. * Creates a new WeightedSound from the list of sounds given.
  42339. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42340. * @param sounds Array of Sounds that will be selected from.
  42341. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42342. */
  42343. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42344. /**
  42345. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42346. */
  42347. get directionalConeInnerAngle(): number;
  42348. /**
  42349. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42350. */
  42351. set directionalConeInnerAngle(value: number);
  42352. /**
  42353. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42354. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42355. */
  42356. get directionalConeOuterAngle(): number;
  42357. /**
  42358. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42359. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42360. */
  42361. set directionalConeOuterAngle(value: number);
  42362. /**
  42363. * Playback volume.
  42364. */
  42365. get volume(): number;
  42366. /**
  42367. * Playback volume.
  42368. */
  42369. set volume(value: number);
  42370. private _onended;
  42371. /**
  42372. * Suspend playback
  42373. */
  42374. pause(): void;
  42375. /**
  42376. * Stop playback
  42377. */
  42378. stop(): void;
  42379. /**
  42380. * Start playback.
  42381. * @param startOffset Position the clip head at a specific time in seconds.
  42382. */
  42383. play(startOffset?: number): void;
  42384. }
  42385. }
  42386. declare module "babylonjs/Audio/index" {
  42387. export * from "babylonjs/Audio/analyser";
  42388. export * from "babylonjs/Audio/audioEngine";
  42389. export * from "babylonjs/Audio/audioSceneComponent";
  42390. export * from "babylonjs/Audio/sound";
  42391. export * from "babylonjs/Audio/soundTrack";
  42392. export * from "babylonjs/Audio/weightedsound";
  42393. }
  42394. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  42395. import { Behavior } from "babylonjs/Behaviors/behavior";
  42396. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42397. import { BackEase } from "babylonjs/Animations/easing";
  42398. /**
  42399. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42400. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42401. */
  42402. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42403. /**
  42404. * Gets the name of the behavior.
  42405. */
  42406. get name(): string;
  42407. /**
  42408. * The easing function used by animations
  42409. */
  42410. static EasingFunction: BackEase;
  42411. /**
  42412. * The easing mode used by animations
  42413. */
  42414. static EasingMode: number;
  42415. /**
  42416. * The duration of the animation, in milliseconds
  42417. */
  42418. transitionDuration: number;
  42419. /**
  42420. * Length of the distance animated by the transition when lower radius is reached
  42421. */
  42422. lowerRadiusTransitionRange: number;
  42423. /**
  42424. * Length of the distance animated by the transition when upper radius is reached
  42425. */
  42426. upperRadiusTransitionRange: number;
  42427. private _autoTransitionRange;
  42428. /**
  42429. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42430. */
  42431. get autoTransitionRange(): boolean;
  42432. /**
  42433. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42434. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42435. */
  42436. set autoTransitionRange(value: boolean);
  42437. private _attachedCamera;
  42438. private _onAfterCheckInputsObserver;
  42439. private _onMeshTargetChangedObserver;
  42440. /**
  42441. * Initializes the behavior.
  42442. */
  42443. init(): void;
  42444. /**
  42445. * Attaches the behavior to its arc rotate camera.
  42446. * @param camera Defines the camera to attach the behavior to
  42447. */
  42448. attach(camera: ArcRotateCamera): void;
  42449. /**
  42450. * Detaches the behavior from its current arc rotate camera.
  42451. */
  42452. detach(): void;
  42453. private _radiusIsAnimating;
  42454. private _radiusBounceTransition;
  42455. private _animatables;
  42456. private _cachedWheelPrecision;
  42457. /**
  42458. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42459. * @param radiusLimit The limit to check against.
  42460. * @return Bool to indicate if at limit.
  42461. */
  42462. private _isRadiusAtLimit;
  42463. /**
  42464. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42465. * @param radiusDelta The delta by which to animate to. Can be negative.
  42466. */
  42467. private _applyBoundRadiusAnimation;
  42468. /**
  42469. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42470. */
  42471. protected _clearAnimationLocks(): void;
  42472. /**
  42473. * Stops and removes all animations that have been applied to the camera
  42474. */
  42475. stopAllAnimations(): void;
  42476. }
  42477. }
  42478. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  42479. import { Behavior } from "babylonjs/Behaviors/behavior";
  42480. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42481. import { ExponentialEase } from "babylonjs/Animations/easing";
  42482. import { Nullable } from "babylonjs/types";
  42483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42484. import { Vector3 } from "babylonjs/Maths/math.vector";
  42485. /**
  42486. * 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.
  42487. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42488. */
  42489. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42490. /**
  42491. * Gets the name of the behavior.
  42492. */
  42493. get name(): string;
  42494. private _mode;
  42495. private _radiusScale;
  42496. private _positionScale;
  42497. private _defaultElevation;
  42498. private _elevationReturnTime;
  42499. private _elevationReturnWaitTime;
  42500. private _zoomStopsAnimation;
  42501. private _framingTime;
  42502. /**
  42503. * The easing function used by animations
  42504. */
  42505. static EasingFunction: ExponentialEase;
  42506. /**
  42507. * The easing mode used by animations
  42508. */
  42509. static EasingMode: number;
  42510. /**
  42511. * Sets the current mode used by the behavior
  42512. */
  42513. set mode(mode: number);
  42514. /**
  42515. * Gets current mode used by the behavior.
  42516. */
  42517. get mode(): number;
  42518. /**
  42519. * Sets the scale applied to the radius (1 by default)
  42520. */
  42521. set radiusScale(radius: number);
  42522. /**
  42523. * Gets the scale applied to the radius
  42524. */
  42525. get radiusScale(): number;
  42526. /**
  42527. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42528. */
  42529. set positionScale(scale: number);
  42530. /**
  42531. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42532. */
  42533. get positionScale(): number;
  42534. /**
  42535. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42536. * behaviour is triggered, in radians.
  42537. */
  42538. set defaultElevation(elevation: number);
  42539. /**
  42540. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42541. * behaviour is triggered, in radians.
  42542. */
  42543. get defaultElevation(): number;
  42544. /**
  42545. * Sets the time (in milliseconds) taken to return to the default beta position.
  42546. * Negative value indicates camera should not return to default.
  42547. */
  42548. set elevationReturnTime(speed: number);
  42549. /**
  42550. * Gets the time (in milliseconds) taken to return to the default beta position.
  42551. * Negative value indicates camera should not return to default.
  42552. */
  42553. get elevationReturnTime(): number;
  42554. /**
  42555. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42556. */
  42557. set elevationReturnWaitTime(time: number);
  42558. /**
  42559. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42560. */
  42561. get elevationReturnWaitTime(): number;
  42562. /**
  42563. * Sets the flag that indicates if user zooming should stop animation.
  42564. */
  42565. set zoomStopsAnimation(flag: boolean);
  42566. /**
  42567. * Gets the flag that indicates if user zooming should stop animation.
  42568. */
  42569. get zoomStopsAnimation(): boolean;
  42570. /**
  42571. * Sets the transition time when framing the mesh, in milliseconds
  42572. */
  42573. set framingTime(time: number);
  42574. /**
  42575. * Gets the transition time when framing the mesh, in milliseconds
  42576. */
  42577. get framingTime(): number;
  42578. /**
  42579. * Define if the behavior should automatically change the configured
  42580. * camera limits and sensibilities.
  42581. */
  42582. autoCorrectCameraLimitsAndSensibility: boolean;
  42583. private _onPrePointerObservableObserver;
  42584. private _onAfterCheckInputsObserver;
  42585. private _onMeshTargetChangedObserver;
  42586. private _attachedCamera;
  42587. private _isPointerDown;
  42588. private _lastInteractionTime;
  42589. /**
  42590. * Initializes the behavior.
  42591. */
  42592. init(): void;
  42593. /**
  42594. * Attaches the behavior to its arc rotate camera.
  42595. * @param camera Defines the camera to attach the behavior to
  42596. */
  42597. attach(camera: ArcRotateCamera): void;
  42598. /**
  42599. * Detaches the behavior from its current arc rotate camera.
  42600. */
  42601. detach(): void;
  42602. private _animatables;
  42603. private _betaIsAnimating;
  42604. private _betaTransition;
  42605. private _radiusTransition;
  42606. private _vectorTransition;
  42607. /**
  42608. * Targets the given mesh and updates zoom level accordingly.
  42609. * @param mesh The mesh to target.
  42610. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42611. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42612. */
  42613. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42614. /**
  42615. * Targets the given mesh with its children and updates zoom level accordingly.
  42616. * @param mesh The mesh to target.
  42617. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42618. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42619. */
  42620. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42621. /**
  42622. * Targets the given meshes with their children and updates zoom level accordingly.
  42623. * @param meshes The mesh to target.
  42624. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42625. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42626. */
  42627. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42628. /**
  42629. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42630. * @param minimumWorld Determines the smaller position of the bounding box extend
  42631. * @param maximumWorld Determines the bigger position of the bounding box extend
  42632. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42633. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42634. */
  42635. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42636. /**
  42637. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42638. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42639. * frustum width.
  42640. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42641. * to fully enclose the mesh in the viewing frustum.
  42642. */
  42643. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42644. /**
  42645. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42646. * is automatically returned to its default position (expected to be above ground plane).
  42647. */
  42648. private _maintainCameraAboveGround;
  42649. /**
  42650. * Returns the frustum slope based on the canvas ratio and camera FOV
  42651. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42652. */
  42653. private _getFrustumSlope;
  42654. /**
  42655. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42656. */
  42657. private _clearAnimationLocks;
  42658. /**
  42659. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42660. */
  42661. private _applyUserInteraction;
  42662. /**
  42663. * Stops and removes all animations that have been applied to the camera
  42664. */
  42665. stopAllAnimations(): void;
  42666. /**
  42667. * Gets a value indicating if the user is moving the camera
  42668. */
  42669. get isUserIsMoving(): boolean;
  42670. /**
  42671. * The camera can move all the way towards the mesh.
  42672. */
  42673. static IgnoreBoundsSizeMode: number;
  42674. /**
  42675. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42676. */
  42677. static FitFrustumSidesMode: number;
  42678. }
  42679. }
  42680. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  42681. import { Nullable } from "babylonjs/types";
  42682. import { Camera } from "babylonjs/Cameras/camera";
  42683. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42684. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42685. /**
  42686. * Base class for Camera Pointer Inputs.
  42687. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42688. * for example usage.
  42689. */
  42690. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42691. /**
  42692. * Defines the camera the input is attached to.
  42693. */
  42694. abstract camera: Camera;
  42695. /**
  42696. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42697. */
  42698. protected _altKey: boolean;
  42699. protected _ctrlKey: boolean;
  42700. protected _metaKey: boolean;
  42701. protected _shiftKey: boolean;
  42702. /**
  42703. * Which mouse buttons were pressed at time of last mouse event.
  42704. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42705. */
  42706. protected _buttonsPressed: number;
  42707. /**
  42708. * Defines the buttons associated with the input to handle camera move.
  42709. */
  42710. buttons: number[];
  42711. /**
  42712. * Attach the input controls to a specific dom element to get the input from.
  42713. * @param element Defines the element the controls should be listened from
  42714. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42715. */
  42716. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42717. /**
  42718. * Detach the current controls from the specified dom element.
  42719. * @param element Defines the element to stop listening the inputs from
  42720. */
  42721. detachControl(element: Nullable<HTMLElement>): void;
  42722. /**
  42723. * Gets the class name of the current input.
  42724. * @returns the class name
  42725. */
  42726. getClassName(): string;
  42727. /**
  42728. * Get the friendly name associated with the input class.
  42729. * @returns the input friendly name
  42730. */
  42731. getSimpleName(): string;
  42732. /**
  42733. * Called on pointer POINTERDOUBLETAP event.
  42734. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42735. */
  42736. protected onDoubleTap(type: string): void;
  42737. /**
  42738. * Called on pointer POINTERMOVE event if only a single touch is active.
  42739. * Override this method to provide functionality.
  42740. */
  42741. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42742. /**
  42743. * Called on pointer POINTERMOVE event if multiple touches are active.
  42744. * Override this method to provide functionality.
  42745. */
  42746. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42747. /**
  42748. * Called on JS contextmenu event.
  42749. * Override this method to provide functionality.
  42750. */
  42751. protected onContextMenu(evt: PointerEvent): void;
  42752. /**
  42753. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42754. * press.
  42755. * Override this method to provide functionality.
  42756. */
  42757. protected onButtonDown(evt: PointerEvent): void;
  42758. /**
  42759. * Called each time a new POINTERUP event occurs. Ie, for each button
  42760. * release.
  42761. * Override this method to provide functionality.
  42762. */
  42763. protected onButtonUp(evt: PointerEvent): void;
  42764. /**
  42765. * Called when window becomes inactive.
  42766. * Override this method to provide functionality.
  42767. */
  42768. protected onLostFocus(): void;
  42769. private _pointerInput;
  42770. private _observer;
  42771. private _onLostFocus;
  42772. private pointA;
  42773. private pointB;
  42774. }
  42775. }
  42776. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  42777. import { Nullable } from "babylonjs/types";
  42778. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42779. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  42780. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42781. /**
  42782. * Manage the pointers inputs to control an arc rotate camera.
  42783. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42784. */
  42785. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42786. /**
  42787. * Defines the camera the input is attached to.
  42788. */
  42789. camera: ArcRotateCamera;
  42790. /**
  42791. * Gets the class name of the current input.
  42792. * @returns the class name
  42793. */
  42794. getClassName(): string;
  42795. /**
  42796. * Defines the buttons associated with the input to handle camera move.
  42797. */
  42798. buttons: number[];
  42799. /**
  42800. * Defines the pointer angular sensibility along the X axis or how fast is
  42801. * the camera rotating.
  42802. */
  42803. angularSensibilityX: number;
  42804. /**
  42805. * Defines the pointer angular sensibility along the Y axis or how fast is
  42806. * the camera rotating.
  42807. */
  42808. angularSensibilityY: number;
  42809. /**
  42810. * Defines the pointer pinch precision or how fast is the camera zooming.
  42811. */
  42812. pinchPrecision: number;
  42813. /**
  42814. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42815. * from 0.
  42816. * It defines the percentage of current camera.radius to use as delta when
  42817. * pinch zoom is used.
  42818. */
  42819. pinchDeltaPercentage: number;
  42820. /**
  42821. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42822. * that any object in the plane at the camera's target point will scale
  42823. * perfectly with finger motion.
  42824. * Overrides pinchDeltaPercentage and pinchPrecision.
  42825. */
  42826. useNaturalPinchZoom: boolean;
  42827. /**
  42828. * Defines the pointer panning sensibility or how fast is the camera moving.
  42829. */
  42830. panningSensibility: number;
  42831. /**
  42832. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42833. */
  42834. multiTouchPanning: boolean;
  42835. /**
  42836. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42837. * zoom (pinch) through multitouch.
  42838. */
  42839. multiTouchPanAndZoom: boolean;
  42840. /**
  42841. * Revers pinch action direction.
  42842. */
  42843. pinchInwards: boolean;
  42844. private _isPanClick;
  42845. private _twoFingerActivityCount;
  42846. private _isPinching;
  42847. /**
  42848. * Called on pointer POINTERMOVE event if only a single touch is active.
  42849. */
  42850. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42851. /**
  42852. * Called on pointer POINTERDOUBLETAP event.
  42853. */
  42854. protected onDoubleTap(type: string): void;
  42855. /**
  42856. * Called on pointer POINTERMOVE event if multiple touches are active.
  42857. */
  42858. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42859. /**
  42860. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42861. * press.
  42862. */
  42863. protected onButtonDown(evt: PointerEvent): void;
  42864. /**
  42865. * Called each time a new POINTERUP event occurs. Ie, for each button
  42866. * release.
  42867. */
  42868. protected onButtonUp(evt: PointerEvent): void;
  42869. /**
  42870. * Called when window becomes inactive.
  42871. */
  42872. protected onLostFocus(): void;
  42873. }
  42874. }
  42875. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  42876. import { Nullable } from "babylonjs/types";
  42877. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42878. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42879. /**
  42880. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42881. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42882. */
  42883. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42884. /**
  42885. * Defines the camera the input is attached to.
  42886. */
  42887. camera: ArcRotateCamera;
  42888. /**
  42889. * Defines the list of key codes associated with the up action (increase alpha)
  42890. */
  42891. keysUp: number[];
  42892. /**
  42893. * Defines the list of key codes associated with the down action (decrease alpha)
  42894. */
  42895. keysDown: number[];
  42896. /**
  42897. * Defines the list of key codes associated with the left action (increase beta)
  42898. */
  42899. keysLeft: number[];
  42900. /**
  42901. * Defines the list of key codes associated with the right action (decrease beta)
  42902. */
  42903. keysRight: number[];
  42904. /**
  42905. * Defines the list of key codes associated with the reset action.
  42906. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42907. */
  42908. keysReset: number[];
  42909. /**
  42910. * Defines the panning sensibility of the inputs.
  42911. * (How fast is the camera panning)
  42912. */
  42913. panningSensibility: number;
  42914. /**
  42915. * Defines the zooming sensibility of the inputs.
  42916. * (How fast is the camera zooming)
  42917. */
  42918. zoomingSensibility: number;
  42919. /**
  42920. * Defines whether maintaining the alt key down switch the movement mode from
  42921. * orientation to zoom.
  42922. */
  42923. useAltToZoom: boolean;
  42924. /**
  42925. * Rotation speed of the camera
  42926. */
  42927. angularSpeed: number;
  42928. private _keys;
  42929. private _ctrlPressed;
  42930. private _altPressed;
  42931. private _onCanvasBlurObserver;
  42932. private _onKeyboardObserver;
  42933. private _engine;
  42934. private _scene;
  42935. /**
  42936. * Attach the input controls to a specific dom element to get the input from.
  42937. * @param element Defines the element the controls should be listened from
  42938. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42939. */
  42940. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42941. /**
  42942. * Detach the current controls from the specified dom element.
  42943. * @param element Defines the element to stop listening the inputs from
  42944. */
  42945. detachControl(element: Nullable<HTMLElement>): void;
  42946. /**
  42947. * Update the current camera state depending on the inputs that have been used this frame.
  42948. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42949. */
  42950. checkInputs(): void;
  42951. /**
  42952. * Gets the class name of the current intput.
  42953. * @returns the class name
  42954. */
  42955. getClassName(): string;
  42956. /**
  42957. * Get the friendly name associated with the input class.
  42958. * @returns the input friendly name
  42959. */
  42960. getSimpleName(): string;
  42961. }
  42962. }
  42963. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  42964. import { Nullable } from "babylonjs/types";
  42965. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42966. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42967. /**
  42968. * Manage the mouse wheel inputs to control an arc rotate camera.
  42969. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42970. */
  42971. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42972. /**
  42973. * Defines the camera the input is attached to.
  42974. */
  42975. camera: ArcRotateCamera;
  42976. /**
  42977. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42978. */
  42979. wheelPrecision: number;
  42980. /**
  42981. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42982. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42983. */
  42984. wheelDeltaPercentage: number;
  42985. private _wheel;
  42986. private _observer;
  42987. private computeDeltaFromMouseWheelLegacyEvent;
  42988. /**
  42989. * Attach the input controls to a specific dom element to get the input from.
  42990. * @param element Defines the element the controls should be listened from
  42991. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42992. */
  42993. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42994. /**
  42995. * Detach the current controls from the specified dom element.
  42996. * @param element Defines the element to stop listening the inputs from
  42997. */
  42998. detachControl(element: Nullable<HTMLElement>): void;
  42999. /**
  43000. * Gets the class name of the current intput.
  43001. * @returns the class name
  43002. */
  43003. getClassName(): string;
  43004. /**
  43005. * Get the friendly name associated with the input class.
  43006. * @returns the input friendly name
  43007. */
  43008. getSimpleName(): string;
  43009. }
  43010. }
  43011. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43012. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43013. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  43014. /**
  43015. * Default Inputs manager for the ArcRotateCamera.
  43016. * It groups all the default supported inputs for ease of use.
  43017. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43018. */
  43019. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  43020. /**
  43021. * Instantiates a new ArcRotateCameraInputsManager.
  43022. * @param camera Defines the camera the inputs belong to
  43023. */
  43024. constructor(camera: ArcRotateCamera);
  43025. /**
  43026. * Add mouse wheel input support to the input manager.
  43027. * @returns the current input manager
  43028. */
  43029. addMouseWheel(): ArcRotateCameraInputsManager;
  43030. /**
  43031. * Add pointers input support to the input manager.
  43032. * @returns the current input manager
  43033. */
  43034. addPointers(): ArcRotateCameraInputsManager;
  43035. /**
  43036. * Add keyboard input support to the input manager.
  43037. * @returns the current input manager
  43038. */
  43039. addKeyboard(): ArcRotateCameraInputsManager;
  43040. }
  43041. }
  43042. declare module "babylonjs/Cameras/arcRotateCamera" {
  43043. import { Observable } from "babylonjs/Misc/observable";
  43044. import { Nullable } from "babylonjs/types";
  43045. import { Scene } from "babylonjs/scene";
  43046. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  43047. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43048. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43049. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43050. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  43051. import { Camera } from "babylonjs/Cameras/camera";
  43052. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  43053. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43054. import { Collider } from "babylonjs/Collisions/collider";
  43055. /**
  43056. * This represents an orbital type of camera.
  43057. *
  43058. * 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.
  43059. * 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.
  43060. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  43061. */
  43062. export class ArcRotateCamera extends TargetCamera {
  43063. /**
  43064. * Defines the rotation angle of the camera along the longitudinal axis.
  43065. */
  43066. alpha: number;
  43067. /**
  43068. * Defines the rotation angle of the camera along the latitudinal axis.
  43069. */
  43070. beta: number;
  43071. /**
  43072. * Defines the radius of the camera from it s target point.
  43073. */
  43074. radius: number;
  43075. protected _target: Vector3;
  43076. protected _targetHost: Nullable<AbstractMesh>;
  43077. /**
  43078. * Defines the target point of the camera.
  43079. * The camera looks towards it form the radius distance.
  43080. */
  43081. get target(): Vector3;
  43082. set target(value: Vector3);
  43083. /**
  43084. * Define the current local position of the camera in the scene
  43085. */
  43086. get position(): Vector3;
  43087. set position(newPosition: Vector3);
  43088. protected _upVector: Vector3;
  43089. protected _upToYMatrix: Matrix;
  43090. protected _YToUpMatrix: Matrix;
  43091. /**
  43092. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  43093. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  43094. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  43095. */
  43096. set upVector(vec: Vector3);
  43097. get upVector(): Vector3;
  43098. /**
  43099. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  43100. */
  43101. setMatUp(): void;
  43102. /**
  43103. * Current inertia value on the longitudinal axis.
  43104. * The bigger this number the longer it will take for the camera to stop.
  43105. */
  43106. inertialAlphaOffset: number;
  43107. /**
  43108. * Current inertia value on the latitudinal axis.
  43109. * The bigger this number the longer it will take for the camera to stop.
  43110. */
  43111. inertialBetaOffset: number;
  43112. /**
  43113. * Current inertia value on the radius axis.
  43114. * The bigger this number the longer it will take for the camera to stop.
  43115. */
  43116. inertialRadiusOffset: number;
  43117. /**
  43118. * Minimum allowed angle on the longitudinal axis.
  43119. * This can help limiting how the Camera is able to move in the scene.
  43120. */
  43121. lowerAlphaLimit: Nullable<number>;
  43122. /**
  43123. * Maximum allowed angle on the longitudinal axis.
  43124. * This can help limiting how the Camera is able to move in the scene.
  43125. */
  43126. upperAlphaLimit: Nullable<number>;
  43127. /**
  43128. * Minimum allowed angle on the latitudinal axis.
  43129. * This can help limiting how the Camera is able to move in the scene.
  43130. */
  43131. lowerBetaLimit: number;
  43132. /**
  43133. * Maximum allowed angle on the latitudinal axis.
  43134. * This can help limiting how the Camera is able to move in the scene.
  43135. */
  43136. upperBetaLimit: number;
  43137. /**
  43138. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43139. * This can help limiting how the Camera is able to move in the scene.
  43140. */
  43141. lowerRadiusLimit: Nullable<number>;
  43142. /**
  43143. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43144. * This can help limiting how the Camera is able to move in the scene.
  43145. */
  43146. upperRadiusLimit: Nullable<number>;
  43147. /**
  43148. * Defines the current inertia value used during panning of the camera along the X axis.
  43149. */
  43150. inertialPanningX: number;
  43151. /**
  43152. * Defines the current inertia value used during panning of the camera along the Y axis.
  43153. */
  43154. inertialPanningY: number;
  43155. /**
  43156. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43157. * Basically if your fingers moves away from more than this distance you will be considered
  43158. * in pinch mode.
  43159. */
  43160. pinchToPanMaxDistance: number;
  43161. /**
  43162. * Defines the maximum distance the camera can pan.
  43163. * This could help keeping the cammera always in your scene.
  43164. */
  43165. panningDistanceLimit: Nullable<number>;
  43166. /**
  43167. * Defines the target of the camera before paning.
  43168. */
  43169. panningOriginTarget: Vector3;
  43170. /**
  43171. * Defines the value of the inertia used during panning.
  43172. * 0 would mean stop inertia and one would mean no decelleration at all.
  43173. */
  43174. panningInertia: number;
  43175. /**
  43176. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43177. */
  43178. get angularSensibilityX(): number;
  43179. set angularSensibilityX(value: number);
  43180. /**
  43181. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43182. */
  43183. get angularSensibilityY(): number;
  43184. set angularSensibilityY(value: number);
  43185. /**
  43186. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43187. */
  43188. get pinchPrecision(): number;
  43189. set pinchPrecision(value: number);
  43190. /**
  43191. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43192. * It will be used instead of pinchDeltaPrecision if different from 0.
  43193. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43194. */
  43195. get pinchDeltaPercentage(): number;
  43196. set pinchDeltaPercentage(value: number);
  43197. /**
  43198. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43199. * and pinch delta percentage.
  43200. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43201. * that any object in the plane at the camera's target point will scale
  43202. * perfectly with finger motion.
  43203. */
  43204. get useNaturalPinchZoom(): boolean;
  43205. set useNaturalPinchZoom(value: boolean);
  43206. /**
  43207. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43208. */
  43209. get panningSensibility(): number;
  43210. set panningSensibility(value: number);
  43211. /**
  43212. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43213. */
  43214. get keysUp(): number[];
  43215. set keysUp(value: number[]);
  43216. /**
  43217. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43218. */
  43219. get keysDown(): number[];
  43220. set keysDown(value: number[]);
  43221. /**
  43222. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43223. */
  43224. get keysLeft(): number[];
  43225. set keysLeft(value: number[]);
  43226. /**
  43227. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43228. */
  43229. get keysRight(): number[];
  43230. set keysRight(value: number[]);
  43231. /**
  43232. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43233. */
  43234. get wheelPrecision(): number;
  43235. set wheelPrecision(value: number);
  43236. /**
  43237. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43238. * It will be used instead of pinchDeltaPrecision if different from 0.
  43239. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43240. */
  43241. get wheelDeltaPercentage(): number;
  43242. set wheelDeltaPercentage(value: number);
  43243. /**
  43244. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43245. */
  43246. zoomOnFactor: number;
  43247. /**
  43248. * Defines a screen offset for the camera position.
  43249. */
  43250. targetScreenOffset: Vector2;
  43251. /**
  43252. * Allows the camera to be completely reversed.
  43253. * If false the camera can not arrive upside down.
  43254. */
  43255. allowUpsideDown: boolean;
  43256. /**
  43257. * Define if double tap/click is used to restore the previously saved state of the camera.
  43258. */
  43259. useInputToRestoreState: boolean;
  43260. /** @hidden */
  43261. _viewMatrix: Matrix;
  43262. /** @hidden */
  43263. _useCtrlForPanning: boolean;
  43264. /** @hidden */
  43265. _panningMouseButton: number;
  43266. /**
  43267. * Defines the input associated to the camera.
  43268. */
  43269. inputs: ArcRotateCameraInputsManager;
  43270. /** @hidden */
  43271. _reset: () => void;
  43272. /**
  43273. * Defines the allowed panning axis.
  43274. */
  43275. panningAxis: Vector3;
  43276. protected _localDirection: Vector3;
  43277. protected _transformedDirection: Vector3;
  43278. private _bouncingBehavior;
  43279. /**
  43280. * Gets the bouncing behavior of the camera if it has been enabled.
  43281. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43282. */
  43283. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43284. /**
  43285. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43286. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43287. */
  43288. get useBouncingBehavior(): boolean;
  43289. set useBouncingBehavior(value: boolean);
  43290. private _framingBehavior;
  43291. /**
  43292. * Gets the framing behavior of the camera if it has been enabled.
  43293. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43294. */
  43295. get framingBehavior(): Nullable<FramingBehavior>;
  43296. /**
  43297. * Defines if the framing behavior of the camera is enabled on the camera.
  43298. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43299. */
  43300. get useFramingBehavior(): boolean;
  43301. set useFramingBehavior(value: boolean);
  43302. private _autoRotationBehavior;
  43303. /**
  43304. * Gets the auto rotation behavior of the camera if it has been enabled.
  43305. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43306. */
  43307. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43308. /**
  43309. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43310. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43311. */
  43312. get useAutoRotationBehavior(): boolean;
  43313. set useAutoRotationBehavior(value: boolean);
  43314. /**
  43315. * Observable triggered when the mesh target has been changed on the camera.
  43316. */
  43317. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43318. /**
  43319. * Event raised when the camera is colliding with a mesh.
  43320. */
  43321. onCollide: (collidedMesh: AbstractMesh) => void;
  43322. /**
  43323. * Defines whether the camera should check collision with the objects oh the scene.
  43324. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43325. */
  43326. checkCollisions: boolean;
  43327. /**
  43328. * Defines the collision radius of the camera.
  43329. * This simulates a sphere around the camera.
  43330. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43331. */
  43332. collisionRadius: Vector3;
  43333. protected _collider: Collider;
  43334. protected _previousPosition: Vector3;
  43335. protected _collisionVelocity: Vector3;
  43336. protected _newPosition: Vector3;
  43337. protected _previousAlpha: number;
  43338. protected _previousBeta: number;
  43339. protected _previousRadius: number;
  43340. protected _collisionTriggered: boolean;
  43341. protected _targetBoundingCenter: Nullable<Vector3>;
  43342. private _computationVector;
  43343. /**
  43344. * Instantiates a new ArcRotateCamera in a given scene
  43345. * @param name Defines the name of the camera
  43346. * @param alpha Defines the camera rotation along the logitudinal axis
  43347. * @param beta Defines the camera rotation along the latitudinal axis
  43348. * @param radius Defines the camera distance from its target
  43349. * @param target Defines the camera target
  43350. * @param scene Defines the scene the camera belongs to
  43351. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43352. */
  43353. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43354. /** @hidden */
  43355. _initCache(): void;
  43356. /** @hidden */
  43357. _updateCache(ignoreParentClass?: boolean): void;
  43358. protected _getTargetPosition(): Vector3;
  43359. private _storedAlpha;
  43360. private _storedBeta;
  43361. private _storedRadius;
  43362. private _storedTarget;
  43363. private _storedTargetScreenOffset;
  43364. /**
  43365. * Stores the current state of the camera (alpha, beta, radius and target)
  43366. * @returns the camera itself
  43367. */
  43368. storeState(): Camera;
  43369. /**
  43370. * @hidden
  43371. * Restored camera state. You must call storeState() first
  43372. */
  43373. _restoreStateValues(): boolean;
  43374. /** @hidden */
  43375. _isSynchronizedViewMatrix(): boolean;
  43376. /**
  43377. * Attached controls to the current camera.
  43378. * @param element Defines the element the controls should be listened from
  43379. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43380. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43381. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43382. */
  43383. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43384. /**
  43385. * Detach the current controls from the camera.
  43386. * The camera will stop reacting to inputs.
  43387. * @param element Defines the element to stop listening the inputs from
  43388. */
  43389. detachControl(element: HTMLElement): void;
  43390. /** @hidden */
  43391. _checkInputs(): void;
  43392. protected _checkLimits(): void;
  43393. /**
  43394. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43395. */
  43396. rebuildAnglesAndRadius(): void;
  43397. /**
  43398. * Use a position to define the current camera related information like alpha, beta and radius
  43399. * @param position Defines the position to set the camera at
  43400. */
  43401. setPosition(position: Vector3): void;
  43402. /**
  43403. * Defines the target the camera should look at.
  43404. * This will automatically adapt alpha beta and radius to fit within the new target.
  43405. * @param target Defines the new target as a Vector or a mesh
  43406. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43407. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43408. */
  43409. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43410. /** @hidden */
  43411. _getViewMatrix(): Matrix;
  43412. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43413. /**
  43414. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43415. * @param meshes Defines the mesh to zoom on
  43416. * @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)
  43417. */
  43418. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43419. /**
  43420. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43421. * The target will be changed but the radius
  43422. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43423. * @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)
  43424. */
  43425. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43426. min: Vector3;
  43427. max: Vector3;
  43428. distance: number;
  43429. }, doNotUpdateMaxZ?: boolean): void;
  43430. /**
  43431. * @override
  43432. * Override Camera.createRigCamera
  43433. */
  43434. createRigCamera(name: string, cameraIndex: number): Camera;
  43435. /**
  43436. * @hidden
  43437. * @override
  43438. * Override Camera._updateRigCameras
  43439. */
  43440. _updateRigCameras(): void;
  43441. /**
  43442. * Destroy the camera and release the current resources hold by it.
  43443. */
  43444. dispose(): void;
  43445. /**
  43446. * Gets the current object class name.
  43447. * @return the class name
  43448. */
  43449. getClassName(): string;
  43450. }
  43451. }
  43452. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  43453. import { Behavior } from "babylonjs/Behaviors/behavior";
  43454. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43455. /**
  43456. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43457. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43458. */
  43459. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43460. /**
  43461. * Gets the name of the behavior.
  43462. */
  43463. get name(): string;
  43464. private _zoomStopsAnimation;
  43465. private _idleRotationSpeed;
  43466. private _idleRotationWaitTime;
  43467. private _idleRotationSpinupTime;
  43468. /**
  43469. * Sets the flag that indicates if user zooming should stop animation.
  43470. */
  43471. set zoomStopsAnimation(flag: boolean);
  43472. /**
  43473. * Gets the flag that indicates if user zooming should stop animation.
  43474. */
  43475. get zoomStopsAnimation(): boolean;
  43476. /**
  43477. * Sets the default speed at which the camera rotates around the model.
  43478. */
  43479. set idleRotationSpeed(speed: number);
  43480. /**
  43481. * Gets the default speed at which the camera rotates around the model.
  43482. */
  43483. get idleRotationSpeed(): number;
  43484. /**
  43485. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43486. */
  43487. set idleRotationWaitTime(time: number);
  43488. /**
  43489. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43490. */
  43491. get idleRotationWaitTime(): number;
  43492. /**
  43493. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43494. */
  43495. set idleRotationSpinupTime(time: number);
  43496. /**
  43497. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43498. */
  43499. get idleRotationSpinupTime(): number;
  43500. /**
  43501. * Gets a value indicating if the camera is currently rotating because of this behavior
  43502. */
  43503. get rotationInProgress(): boolean;
  43504. private _onPrePointerObservableObserver;
  43505. private _onAfterCheckInputsObserver;
  43506. private _attachedCamera;
  43507. private _isPointerDown;
  43508. private _lastFrameTime;
  43509. private _lastInteractionTime;
  43510. private _cameraRotationSpeed;
  43511. /**
  43512. * Initializes the behavior.
  43513. */
  43514. init(): void;
  43515. /**
  43516. * Attaches the behavior to its arc rotate camera.
  43517. * @param camera Defines the camera to attach the behavior to
  43518. */
  43519. attach(camera: ArcRotateCamera): void;
  43520. /**
  43521. * Detaches the behavior from its current arc rotate camera.
  43522. */
  43523. detach(): void;
  43524. /**
  43525. * Returns true if user is scrolling.
  43526. * @return true if user is scrolling.
  43527. */
  43528. private _userIsZooming;
  43529. private _lastFrameRadius;
  43530. private _shouldAnimationStopForInteraction;
  43531. /**
  43532. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43533. */
  43534. private _applyUserInteraction;
  43535. private _userIsMoving;
  43536. }
  43537. }
  43538. declare module "babylonjs/Behaviors/Cameras/index" {
  43539. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43540. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43541. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  43542. }
  43543. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  43544. import { Mesh } from "babylonjs/Meshes/mesh";
  43545. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43546. import { Behavior } from "babylonjs/Behaviors/behavior";
  43547. /**
  43548. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43549. */
  43550. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43551. private ui;
  43552. /**
  43553. * The name of the behavior
  43554. */
  43555. name: string;
  43556. /**
  43557. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43558. */
  43559. distanceAwayFromFace: number;
  43560. /**
  43561. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43562. */
  43563. distanceAwayFromBottomOfFace: number;
  43564. private _faceVectors;
  43565. private _target;
  43566. private _scene;
  43567. private _onRenderObserver;
  43568. private _tmpMatrix;
  43569. private _tmpVector;
  43570. /**
  43571. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43572. * @param ui The transform node that should be attched to the mesh
  43573. */
  43574. constructor(ui: TransformNode);
  43575. /**
  43576. * Initializes the behavior
  43577. */
  43578. init(): void;
  43579. private _closestFace;
  43580. private _zeroVector;
  43581. private _lookAtTmpMatrix;
  43582. private _lookAtToRef;
  43583. /**
  43584. * Attaches the AttachToBoxBehavior to the passed in mesh
  43585. * @param target The mesh that the specified node will be attached to
  43586. */
  43587. attach(target: Mesh): void;
  43588. /**
  43589. * Detaches the behavior from the mesh
  43590. */
  43591. detach(): void;
  43592. }
  43593. }
  43594. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  43595. import { Behavior } from "babylonjs/Behaviors/behavior";
  43596. import { Mesh } from "babylonjs/Meshes/mesh";
  43597. /**
  43598. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43599. */
  43600. export class FadeInOutBehavior implements Behavior<Mesh> {
  43601. /**
  43602. * Time in milliseconds to delay before fading in (Default: 0)
  43603. */
  43604. delay: number;
  43605. /**
  43606. * Time in milliseconds for the mesh to fade in (Default: 300)
  43607. */
  43608. fadeInTime: number;
  43609. private _millisecondsPerFrame;
  43610. private _hovered;
  43611. private _hoverValue;
  43612. private _ownerNode;
  43613. /**
  43614. * Instatiates the FadeInOutBehavior
  43615. */
  43616. constructor();
  43617. /**
  43618. * The name of the behavior
  43619. */
  43620. get name(): string;
  43621. /**
  43622. * Initializes the behavior
  43623. */
  43624. init(): void;
  43625. /**
  43626. * Attaches the fade behavior on the passed in mesh
  43627. * @param ownerNode The mesh that will be faded in/out once attached
  43628. */
  43629. attach(ownerNode: Mesh): void;
  43630. /**
  43631. * Detaches the behavior from the mesh
  43632. */
  43633. detach(): void;
  43634. /**
  43635. * Triggers the mesh to begin fading in or out
  43636. * @param value if the object should fade in or out (true to fade in)
  43637. */
  43638. fadeIn(value: boolean): void;
  43639. private _update;
  43640. private _setAllVisibility;
  43641. }
  43642. }
  43643. declare module "babylonjs/Misc/pivotTools" {
  43644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43645. /**
  43646. * Class containing a set of static utilities functions for managing Pivots
  43647. * @hidden
  43648. */
  43649. export class PivotTools {
  43650. private static _PivotCached;
  43651. private static _OldPivotPoint;
  43652. private static _PivotTranslation;
  43653. private static _PivotTmpVector;
  43654. /** @hidden */
  43655. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43656. /** @hidden */
  43657. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43658. }
  43659. }
  43660. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  43661. import { Scene } from "babylonjs/scene";
  43662. import { Vector4 } from "babylonjs/Maths/math.vector";
  43663. import { Mesh } from "babylonjs/Meshes/mesh";
  43664. import { Nullable } from "babylonjs/types";
  43665. import { Plane } from "babylonjs/Maths/math.plane";
  43666. /**
  43667. * Class containing static functions to help procedurally build meshes
  43668. */
  43669. export class PlaneBuilder {
  43670. /**
  43671. * Creates a plane mesh
  43672. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43673. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43674. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43676. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43678. * @param name defines the name of the mesh
  43679. * @param options defines the options used to create the mesh
  43680. * @param scene defines the hosting scene
  43681. * @returns the plane mesh
  43682. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43683. */
  43684. static CreatePlane(name: string, options: {
  43685. size?: number;
  43686. width?: number;
  43687. height?: number;
  43688. sideOrientation?: number;
  43689. frontUVs?: Vector4;
  43690. backUVs?: Vector4;
  43691. updatable?: boolean;
  43692. sourcePlane?: Plane;
  43693. }, scene?: Nullable<Scene>): Mesh;
  43694. }
  43695. }
  43696. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  43697. import { Behavior } from "babylonjs/Behaviors/behavior";
  43698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43699. import { Observable } from "babylonjs/Misc/observable";
  43700. import { Vector3 } from "babylonjs/Maths/math.vector";
  43701. import { Ray } from "babylonjs/Culling/ray";
  43702. import "babylonjs/Meshes/Builders/planeBuilder";
  43703. /**
  43704. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43705. */
  43706. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43707. private static _AnyMouseID;
  43708. /**
  43709. * Abstract mesh the behavior is set on
  43710. */
  43711. attachedNode: AbstractMesh;
  43712. private _dragPlane;
  43713. private _scene;
  43714. private _pointerObserver;
  43715. private _beforeRenderObserver;
  43716. private static _planeScene;
  43717. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43718. /**
  43719. * 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)
  43720. */
  43721. maxDragAngle: number;
  43722. /**
  43723. * @hidden
  43724. */
  43725. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43726. /**
  43727. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43728. */
  43729. currentDraggingPointerID: number;
  43730. /**
  43731. * The last position where the pointer hit the drag plane in world space
  43732. */
  43733. lastDragPosition: Vector3;
  43734. /**
  43735. * If the behavior is currently in a dragging state
  43736. */
  43737. dragging: boolean;
  43738. /**
  43739. * 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)
  43740. */
  43741. dragDeltaRatio: number;
  43742. /**
  43743. * If the drag plane orientation should be updated during the dragging (Default: true)
  43744. */
  43745. updateDragPlane: boolean;
  43746. private _debugMode;
  43747. private _moving;
  43748. /**
  43749. * Fires each time the attached mesh is dragged with the pointer
  43750. * * delta between last drag position and current drag position in world space
  43751. * * dragDistance along the drag axis
  43752. * * dragPlaneNormal normal of the current drag plane used during the drag
  43753. * * dragPlanePoint in world space where the drag intersects the drag plane
  43754. */
  43755. onDragObservable: Observable<{
  43756. delta: Vector3;
  43757. dragPlanePoint: Vector3;
  43758. dragPlaneNormal: Vector3;
  43759. dragDistance: number;
  43760. pointerId: number;
  43761. }>;
  43762. /**
  43763. * Fires each time a drag begins (eg. mouse down on mesh)
  43764. */
  43765. onDragStartObservable: Observable<{
  43766. dragPlanePoint: Vector3;
  43767. pointerId: number;
  43768. }>;
  43769. /**
  43770. * Fires each time a drag ends (eg. mouse release after drag)
  43771. */
  43772. onDragEndObservable: Observable<{
  43773. dragPlanePoint: Vector3;
  43774. pointerId: number;
  43775. }>;
  43776. /**
  43777. * If the attached mesh should be moved when dragged
  43778. */
  43779. moveAttached: boolean;
  43780. /**
  43781. * If the drag behavior will react to drag events (Default: true)
  43782. */
  43783. enabled: boolean;
  43784. /**
  43785. * If pointer events should start and release the drag (Default: true)
  43786. */
  43787. startAndReleaseDragOnPointerEvents: boolean;
  43788. /**
  43789. * If camera controls should be detached during the drag
  43790. */
  43791. detachCameraControls: boolean;
  43792. /**
  43793. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43794. */
  43795. useObjectOrientationForDragging: boolean;
  43796. private _options;
  43797. /**
  43798. * Gets the options used by the behavior
  43799. */
  43800. get options(): {
  43801. dragAxis?: Vector3;
  43802. dragPlaneNormal?: Vector3;
  43803. };
  43804. /**
  43805. * Sets the options used by the behavior
  43806. */
  43807. set options(options: {
  43808. dragAxis?: Vector3;
  43809. dragPlaneNormal?: Vector3;
  43810. });
  43811. /**
  43812. * Creates a pointer drag behavior that can be attached to a mesh
  43813. * @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)
  43814. */
  43815. constructor(options?: {
  43816. dragAxis?: Vector3;
  43817. dragPlaneNormal?: Vector3;
  43818. });
  43819. /**
  43820. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43821. */
  43822. validateDrag: (targetPosition: Vector3) => boolean;
  43823. /**
  43824. * The name of the behavior
  43825. */
  43826. get name(): string;
  43827. /**
  43828. * Initializes the behavior
  43829. */
  43830. init(): void;
  43831. private _tmpVector;
  43832. private _alternatePickedPoint;
  43833. private _worldDragAxis;
  43834. private _targetPosition;
  43835. private _attachedElement;
  43836. /**
  43837. * Attaches the drag behavior the passed in mesh
  43838. * @param ownerNode The mesh that will be dragged around once attached
  43839. * @param predicate Predicate to use for pick filtering
  43840. */
  43841. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43842. /**
  43843. * Force relase the drag action by code.
  43844. */
  43845. releaseDrag(): void;
  43846. private _startDragRay;
  43847. private _lastPointerRay;
  43848. /**
  43849. * Simulates the start of a pointer drag event on the behavior
  43850. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43851. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43852. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43853. */
  43854. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43855. private _startDrag;
  43856. private _dragDelta;
  43857. private _moveDrag;
  43858. private _pickWithRayOnDragPlane;
  43859. private _pointA;
  43860. private _pointB;
  43861. private _pointC;
  43862. private _lineA;
  43863. private _lineB;
  43864. private _localAxis;
  43865. private _lookAt;
  43866. private _updateDragPlanePosition;
  43867. /**
  43868. * Detaches the behavior from the mesh
  43869. */
  43870. detach(): void;
  43871. }
  43872. }
  43873. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  43874. import { Mesh } from "babylonjs/Meshes/mesh";
  43875. import { Behavior } from "babylonjs/Behaviors/behavior";
  43876. /**
  43877. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43878. */
  43879. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43880. private _dragBehaviorA;
  43881. private _dragBehaviorB;
  43882. private _startDistance;
  43883. private _initialScale;
  43884. private _targetScale;
  43885. private _ownerNode;
  43886. private _sceneRenderObserver;
  43887. /**
  43888. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43889. */
  43890. constructor();
  43891. /**
  43892. * The name of the behavior
  43893. */
  43894. get name(): string;
  43895. /**
  43896. * Initializes the behavior
  43897. */
  43898. init(): void;
  43899. private _getCurrentDistance;
  43900. /**
  43901. * Attaches the scale behavior the passed in mesh
  43902. * @param ownerNode The mesh that will be scaled around once attached
  43903. */
  43904. attach(ownerNode: Mesh): void;
  43905. /**
  43906. * Detaches the behavior from the mesh
  43907. */
  43908. detach(): void;
  43909. }
  43910. }
  43911. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  43912. import { Behavior } from "babylonjs/Behaviors/behavior";
  43913. import { Mesh } from "babylonjs/Meshes/mesh";
  43914. import { Observable } from "babylonjs/Misc/observable";
  43915. /**
  43916. * 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
  43917. */
  43918. export class SixDofDragBehavior implements Behavior<Mesh> {
  43919. private static _virtualScene;
  43920. private _ownerNode;
  43921. private _sceneRenderObserver;
  43922. private _scene;
  43923. private _targetPosition;
  43924. private _virtualOriginMesh;
  43925. private _virtualDragMesh;
  43926. private _pointerObserver;
  43927. private _moving;
  43928. private _startingOrientation;
  43929. private _attachedElement;
  43930. /**
  43931. * 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)
  43932. */
  43933. private zDragFactor;
  43934. /**
  43935. * If the object should rotate to face the drag origin
  43936. */
  43937. rotateDraggedObject: boolean;
  43938. /**
  43939. * If the behavior is currently in a dragging state
  43940. */
  43941. dragging: boolean;
  43942. /**
  43943. * 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)
  43944. */
  43945. dragDeltaRatio: number;
  43946. /**
  43947. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43948. */
  43949. currentDraggingPointerID: number;
  43950. /**
  43951. * If camera controls should be detached during the drag
  43952. */
  43953. detachCameraControls: boolean;
  43954. /**
  43955. * Fires each time a drag starts
  43956. */
  43957. onDragStartObservable: Observable<{}>;
  43958. /**
  43959. * Fires each time a drag ends (eg. mouse release after drag)
  43960. */
  43961. onDragEndObservable: Observable<{}>;
  43962. /**
  43963. * 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
  43964. */
  43965. constructor();
  43966. /**
  43967. * The name of the behavior
  43968. */
  43969. get name(): string;
  43970. /**
  43971. * Initializes the behavior
  43972. */
  43973. init(): void;
  43974. /**
  43975. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43976. */
  43977. private get _pointerCamera();
  43978. /**
  43979. * Attaches the scale behavior the passed in mesh
  43980. * @param ownerNode The mesh that will be scaled around once attached
  43981. */
  43982. attach(ownerNode: Mesh): void;
  43983. /**
  43984. * Detaches the behavior from the mesh
  43985. */
  43986. detach(): void;
  43987. }
  43988. }
  43989. declare module "babylonjs/Behaviors/Meshes/index" {
  43990. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  43991. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  43992. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  43993. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43994. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43995. }
  43996. declare module "babylonjs/Behaviors/index" {
  43997. export * from "babylonjs/Behaviors/behavior";
  43998. export * from "babylonjs/Behaviors/Cameras/index";
  43999. export * from "babylonjs/Behaviors/Meshes/index";
  44000. }
  44001. declare module "babylonjs/Bones/boneIKController" {
  44002. import { Bone } from "babylonjs/Bones/bone";
  44003. import { Vector3 } from "babylonjs/Maths/math.vector";
  44004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44005. import { Nullable } from "babylonjs/types";
  44006. /**
  44007. * Class used to apply inverse kinematics to bones
  44008. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  44009. */
  44010. export class BoneIKController {
  44011. private static _tmpVecs;
  44012. private static _tmpQuat;
  44013. private static _tmpMats;
  44014. /**
  44015. * Gets or sets the target mesh
  44016. */
  44017. targetMesh: AbstractMesh;
  44018. /** Gets or sets the mesh used as pole */
  44019. poleTargetMesh: AbstractMesh;
  44020. /**
  44021. * Gets or sets the bone used as pole
  44022. */
  44023. poleTargetBone: Nullable<Bone>;
  44024. /**
  44025. * Gets or sets the target position
  44026. */
  44027. targetPosition: Vector3;
  44028. /**
  44029. * Gets or sets the pole target position
  44030. */
  44031. poleTargetPosition: Vector3;
  44032. /**
  44033. * Gets or sets the pole target local offset
  44034. */
  44035. poleTargetLocalOffset: Vector3;
  44036. /**
  44037. * Gets or sets the pole angle
  44038. */
  44039. poleAngle: number;
  44040. /**
  44041. * Gets or sets the mesh associated with the controller
  44042. */
  44043. mesh: AbstractMesh;
  44044. /**
  44045. * 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)
  44046. */
  44047. slerpAmount: number;
  44048. private _bone1Quat;
  44049. private _bone1Mat;
  44050. private _bone2Ang;
  44051. private _bone1;
  44052. private _bone2;
  44053. private _bone1Length;
  44054. private _bone2Length;
  44055. private _maxAngle;
  44056. private _maxReach;
  44057. private _rightHandedSystem;
  44058. private _bendAxis;
  44059. private _slerping;
  44060. private _adjustRoll;
  44061. /**
  44062. * Gets or sets maximum allowed angle
  44063. */
  44064. get maxAngle(): number;
  44065. set maxAngle(value: number);
  44066. /**
  44067. * Creates a new BoneIKController
  44068. * @param mesh defines the mesh to control
  44069. * @param bone defines the bone to control
  44070. * @param options defines options to set up the controller
  44071. */
  44072. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  44073. targetMesh?: AbstractMesh;
  44074. poleTargetMesh?: AbstractMesh;
  44075. poleTargetBone?: Bone;
  44076. poleTargetLocalOffset?: Vector3;
  44077. poleAngle?: number;
  44078. bendAxis?: Vector3;
  44079. maxAngle?: number;
  44080. slerpAmount?: number;
  44081. });
  44082. private _setMaxAngle;
  44083. /**
  44084. * Force the controller to update the bones
  44085. */
  44086. update(): void;
  44087. }
  44088. }
  44089. declare module "babylonjs/Bones/boneLookController" {
  44090. import { Vector3 } from "babylonjs/Maths/math.vector";
  44091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44092. import { Bone } from "babylonjs/Bones/bone";
  44093. import { Space } from "babylonjs/Maths/math.axis";
  44094. /**
  44095. * Class used to make a bone look toward a point in space
  44096. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  44097. */
  44098. export class BoneLookController {
  44099. private static _tmpVecs;
  44100. private static _tmpQuat;
  44101. private static _tmpMats;
  44102. /**
  44103. * The target Vector3 that the bone will look at
  44104. */
  44105. target: Vector3;
  44106. /**
  44107. * The mesh that the bone is attached to
  44108. */
  44109. mesh: AbstractMesh;
  44110. /**
  44111. * The bone that will be looking to the target
  44112. */
  44113. bone: Bone;
  44114. /**
  44115. * The up axis of the coordinate system that is used when the bone is rotated
  44116. */
  44117. upAxis: Vector3;
  44118. /**
  44119. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  44120. */
  44121. upAxisSpace: Space;
  44122. /**
  44123. * Used to make an adjustment to the yaw of the bone
  44124. */
  44125. adjustYaw: number;
  44126. /**
  44127. * Used to make an adjustment to the pitch of the bone
  44128. */
  44129. adjustPitch: number;
  44130. /**
  44131. * Used to make an adjustment to the roll of the bone
  44132. */
  44133. adjustRoll: number;
  44134. /**
  44135. * 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)
  44136. */
  44137. slerpAmount: number;
  44138. private _minYaw;
  44139. private _maxYaw;
  44140. private _minPitch;
  44141. private _maxPitch;
  44142. private _minYawSin;
  44143. private _minYawCos;
  44144. private _maxYawSin;
  44145. private _maxYawCos;
  44146. private _midYawConstraint;
  44147. private _minPitchTan;
  44148. private _maxPitchTan;
  44149. private _boneQuat;
  44150. private _slerping;
  44151. private _transformYawPitch;
  44152. private _transformYawPitchInv;
  44153. private _firstFrameSkipped;
  44154. private _yawRange;
  44155. private _fowardAxis;
  44156. /**
  44157. * Gets or sets the minimum yaw angle that the bone can look to
  44158. */
  44159. get minYaw(): number;
  44160. set minYaw(value: number);
  44161. /**
  44162. * Gets or sets the maximum yaw angle that the bone can look to
  44163. */
  44164. get maxYaw(): number;
  44165. set maxYaw(value: number);
  44166. /**
  44167. * Gets or sets the minimum pitch angle that the bone can look to
  44168. */
  44169. get minPitch(): number;
  44170. set minPitch(value: number);
  44171. /**
  44172. * Gets or sets the maximum pitch angle that the bone can look to
  44173. */
  44174. get maxPitch(): number;
  44175. set maxPitch(value: number);
  44176. /**
  44177. * Create a BoneLookController
  44178. * @param mesh the mesh that the bone belongs to
  44179. * @param bone the bone that will be looking to the target
  44180. * @param target the target Vector3 to look at
  44181. * @param options optional settings:
  44182. * * maxYaw: the maximum angle the bone will yaw to
  44183. * * minYaw: the minimum angle the bone will yaw to
  44184. * * maxPitch: the maximum angle the bone will pitch to
  44185. * * minPitch: the minimum angle the bone will yaw to
  44186. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44187. * * upAxis: the up axis of the coordinate system
  44188. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44189. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44190. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44191. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44192. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44193. * * adjustRoll: used to make an adjustment to the roll of the bone
  44194. **/
  44195. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44196. maxYaw?: number;
  44197. minYaw?: number;
  44198. maxPitch?: number;
  44199. minPitch?: number;
  44200. slerpAmount?: number;
  44201. upAxis?: Vector3;
  44202. upAxisSpace?: Space;
  44203. yawAxis?: Vector3;
  44204. pitchAxis?: Vector3;
  44205. adjustYaw?: number;
  44206. adjustPitch?: number;
  44207. adjustRoll?: number;
  44208. });
  44209. /**
  44210. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44211. */
  44212. update(): void;
  44213. private _getAngleDiff;
  44214. private _getAngleBetween;
  44215. private _isAngleBetween;
  44216. }
  44217. }
  44218. declare module "babylonjs/Bones/index" {
  44219. export * from "babylonjs/Bones/bone";
  44220. export * from "babylonjs/Bones/boneIKController";
  44221. export * from "babylonjs/Bones/boneLookController";
  44222. export * from "babylonjs/Bones/skeleton";
  44223. }
  44224. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  44225. import { Nullable } from "babylonjs/types";
  44226. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44227. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44228. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  44229. /**
  44230. * Manage the gamepad inputs to control an arc rotate camera.
  44231. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44232. */
  44233. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44234. /**
  44235. * Defines the camera the input is attached to.
  44236. */
  44237. camera: ArcRotateCamera;
  44238. /**
  44239. * Defines the gamepad the input is gathering event from.
  44240. */
  44241. gamepad: Nullable<Gamepad>;
  44242. /**
  44243. * Defines the gamepad rotation sensiblity.
  44244. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44245. */
  44246. gamepadRotationSensibility: number;
  44247. /**
  44248. * Defines the gamepad move sensiblity.
  44249. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44250. */
  44251. gamepadMoveSensibility: number;
  44252. private _yAxisScale;
  44253. /**
  44254. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44255. */
  44256. get invertYAxis(): boolean;
  44257. set invertYAxis(value: boolean);
  44258. private _onGamepadConnectedObserver;
  44259. private _onGamepadDisconnectedObserver;
  44260. /**
  44261. * Attach the input controls to a specific dom element to get the input from.
  44262. * @param element Defines the element the controls should be listened from
  44263. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44264. */
  44265. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44266. /**
  44267. * Detach the current controls from the specified dom element.
  44268. * @param element Defines the element to stop listening the inputs from
  44269. */
  44270. detachControl(element: Nullable<HTMLElement>): void;
  44271. /**
  44272. * Update the current camera state depending on the inputs that have been used this frame.
  44273. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44274. */
  44275. checkInputs(): void;
  44276. /**
  44277. * Gets the class name of the current intput.
  44278. * @returns the class name
  44279. */
  44280. getClassName(): string;
  44281. /**
  44282. * Get the friendly name associated with the input class.
  44283. * @returns the input friendly name
  44284. */
  44285. getSimpleName(): string;
  44286. }
  44287. }
  44288. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  44289. import { Nullable } from "babylonjs/types";
  44290. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44291. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44292. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44293. interface ArcRotateCameraInputsManager {
  44294. /**
  44295. * Add orientation input support to the input manager.
  44296. * @returns the current input manager
  44297. */
  44298. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44299. }
  44300. }
  44301. /**
  44302. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44303. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44304. */
  44305. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44306. /**
  44307. * Defines the camera the input is attached to.
  44308. */
  44309. camera: ArcRotateCamera;
  44310. /**
  44311. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44312. */
  44313. alphaCorrection: number;
  44314. /**
  44315. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44316. */
  44317. gammaCorrection: number;
  44318. private _alpha;
  44319. private _gamma;
  44320. private _dirty;
  44321. private _deviceOrientationHandler;
  44322. /**
  44323. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44324. */
  44325. constructor();
  44326. /**
  44327. * Attach the input controls to a specific dom element to get the input from.
  44328. * @param element Defines the element the controls should be listened from
  44329. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44330. */
  44331. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44332. /** @hidden */
  44333. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44334. /**
  44335. * Update the current camera state depending on the inputs that have been used this frame.
  44336. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44337. */
  44338. checkInputs(): void;
  44339. /**
  44340. * Detach the current controls from the specified dom element.
  44341. * @param element Defines the element to stop listening the inputs from
  44342. */
  44343. detachControl(element: Nullable<HTMLElement>): void;
  44344. /**
  44345. * Gets the class name of the current intput.
  44346. * @returns the class name
  44347. */
  44348. getClassName(): string;
  44349. /**
  44350. * Get the friendly name associated with the input class.
  44351. * @returns the input friendly name
  44352. */
  44353. getSimpleName(): string;
  44354. }
  44355. }
  44356. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  44357. import { Nullable } from "babylonjs/types";
  44358. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44359. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44360. /**
  44361. * Listen to mouse events to control the camera.
  44362. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44363. */
  44364. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44365. /**
  44366. * Defines the camera the input is attached to.
  44367. */
  44368. camera: FlyCamera;
  44369. /**
  44370. * Defines if touch is enabled. (Default is true.)
  44371. */
  44372. touchEnabled: boolean;
  44373. /**
  44374. * Defines the buttons associated with the input to handle camera rotation.
  44375. */
  44376. buttons: number[];
  44377. /**
  44378. * Assign buttons for Yaw control.
  44379. */
  44380. buttonsYaw: number[];
  44381. /**
  44382. * Assign buttons for Pitch control.
  44383. */
  44384. buttonsPitch: number[];
  44385. /**
  44386. * Assign buttons for Roll control.
  44387. */
  44388. buttonsRoll: number[];
  44389. /**
  44390. * Detect if any button is being pressed while mouse is moved.
  44391. * -1 = Mouse locked.
  44392. * 0 = Left button.
  44393. * 1 = Middle Button.
  44394. * 2 = Right Button.
  44395. */
  44396. activeButton: number;
  44397. /**
  44398. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44399. * Higher values reduce its sensitivity.
  44400. */
  44401. angularSensibility: number;
  44402. private _mousemoveCallback;
  44403. private _observer;
  44404. private _rollObserver;
  44405. private previousPosition;
  44406. private noPreventDefault;
  44407. private element;
  44408. /**
  44409. * Listen to mouse events to control the camera.
  44410. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44411. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44412. */
  44413. constructor(touchEnabled?: boolean);
  44414. /**
  44415. * Attach the mouse control to the HTML DOM element.
  44416. * @param element Defines the element that listens to the input events.
  44417. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44418. */
  44419. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44420. /**
  44421. * Detach the current controls from the specified dom element.
  44422. * @param element Defines the element to stop listening the inputs from
  44423. */
  44424. detachControl(element: Nullable<HTMLElement>): void;
  44425. /**
  44426. * Gets the class name of the current input.
  44427. * @returns the class name.
  44428. */
  44429. getClassName(): string;
  44430. /**
  44431. * Get the friendly name associated with the input class.
  44432. * @returns the input's friendly name.
  44433. */
  44434. getSimpleName(): string;
  44435. private _pointerInput;
  44436. private _onMouseMove;
  44437. /**
  44438. * Rotate camera by mouse offset.
  44439. */
  44440. private rotateCamera;
  44441. }
  44442. }
  44443. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  44444. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44445. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44446. /**
  44447. * Default Inputs manager for the FlyCamera.
  44448. * It groups all the default supported inputs for ease of use.
  44449. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44450. */
  44451. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44452. /**
  44453. * Instantiates a new FlyCameraInputsManager.
  44454. * @param camera Defines the camera the inputs belong to.
  44455. */
  44456. constructor(camera: FlyCamera);
  44457. /**
  44458. * Add keyboard input support to the input manager.
  44459. * @returns the new FlyCameraKeyboardMoveInput().
  44460. */
  44461. addKeyboard(): FlyCameraInputsManager;
  44462. /**
  44463. * Add mouse input support to the input manager.
  44464. * @param touchEnabled Enable touch screen support.
  44465. * @returns the new FlyCameraMouseInput().
  44466. */
  44467. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44468. }
  44469. }
  44470. declare module "babylonjs/Cameras/flyCamera" {
  44471. import { Scene } from "babylonjs/scene";
  44472. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  44473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44474. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44475. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  44476. /**
  44477. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44478. * such as in a 3D Space Shooter or a Flight Simulator.
  44479. */
  44480. export class FlyCamera extends TargetCamera {
  44481. /**
  44482. * Define the collision ellipsoid of the camera.
  44483. * This is helpful for simulating a camera body, like a player's body.
  44484. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44485. */
  44486. ellipsoid: Vector3;
  44487. /**
  44488. * Define an offset for the position of the ellipsoid around the camera.
  44489. * This can be helpful if the camera is attached away from the player's body center,
  44490. * such as at its head.
  44491. */
  44492. ellipsoidOffset: Vector3;
  44493. /**
  44494. * Enable or disable collisions of the camera with the rest of the scene objects.
  44495. */
  44496. checkCollisions: boolean;
  44497. /**
  44498. * Enable or disable gravity on the camera.
  44499. */
  44500. applyGravity: boolean;
  44501. /**
  44502. * Define the current direction the camera is moving to.
  44503. */
  44504. cameraDirection: Vector3;
  44505. /**
  44506. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44507. * This overrides and empties cameraRotation.
  44508. */
  44509. rotationQuaternion: Quaternion;
  44510. /**
  44511. * Track Roll to maintain the wanted Rolling when looking around.
  44512. */
  44513. _trackRoll: number;
  44514. /**
  44515. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44516. */
  44517. rollCorrect: number;
  44518. /**
  44519. * Mimic a banked turn, Rolling the camera when Yawing.
  44520. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44521. */
  44522. bankedTurn: boolean;
  44523. /**
  44524. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44525. */
  44526. bankedTurnLimit: number;
  44527. /**
  44528. * Value of 0 disables the banked Roll.
  44529. * Value of 1 is equal to the Yaw angle in radians.
  44530. */
  44531. bankedTurnMultiplier: number;
  44532. /**
  44533. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44534. */
  44535. inputs: FlyCameraInputsManager;
  44536. /**
  44537. * Gets the input sensibility for mouse input.
  44538. * Higher values reduce sensitivity.
  44539. */
  44540. get angularSensibility(): number;
  44541. /**
  44542. * Sets the input sensibility for a mouse input.
  44543. * Higher values reduce sensitivity.
  44544. */
  44545. set angularSensibility(value: number);
  44546. /**
  44547. * Get the keys for camera movement forward.
  44548. */
  44549. get keysForward(): number[];
  44550. /**
  44551. * Set the keys for camera movement forward.
  44552. */
  44553. set keysForward(value: number[]);
  44554. /**
  44555. * Get the keys for camera movement backward.
  44556. */
  44557. get keysBackward(): number[];
  44558. set keysBackward(value: number[]);
  44559. /**
  44560. * Get the keys for camera movement up.
  44561. */
  44562. get keysUp(): number[];
  44563. /**
  44564. * Set the keys for camera movement up.
  44565. */
  44566. set keysUp(value: number[]);
  44567. /**
  44568. * Get the keys for camera movement down.
  44569. */
  44570. get keysDown(): number[];
  44571. /**
  44572. * Set the keys for camera movement down.
  44573. */
  44574. set keysDown(value: number[]);
  44575. /**
  44576. * Get the keys for camera movement left.
  44577. */
  44578. get keysLeft(): number[];
  44579. /**
  44580. * Set the keys for camera movement left.
  44581. */
  44582. set keysLeft(value: number[]);
  44583. /**
  44584. * Set the keys for camera movement right.
  44585. */
  44586. get keysRight(): number[];
  44587. /**
  44588. * Set the keys for camera movement right.
  44589. */
  44590. set keysRight(value: number[]);
  44591. /**
  44592. * Event raised when the camera collides with a mesh in the scene.
  44593. */
  44594. onCollide: (collidedMesh: AbstractMesh) => void;
  44595. private _collider;
  44596. private _needMoveForGravity;
  44597. private _oldPosition;
  44598. private _diffPosition;
  44599. private _newPosition;
  44600. /** @hidden */
  44601. _localDirection: Vector3;
  44602. /** @hidden */
  44603. _transformedDirection: Vector3;
  44604. /**
  44605. * Instantiates a FlyCamera.
  44606. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44607. * such as in a 3D Space Shooter or a Flight Simulator.
  44608. * @param name Define the name of the camera in the scene.
  44609. * @param position Define the starting position of the camera in the scene.
  44610. * @param scene Define the scene the camera belongs to.
  44611. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44612. */
  44613. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44614. /**
  44615. * Attach a control to the HTML DOM element.
  44616. * @param element Defines the element that listens to the input events.
  44617. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44618. */
  44619. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44620. /**
  44621. * Detach a control from the HTML DOM element.
  44622. * The camera will stop reacting to that input.
  44623. * @param element Defines the element that listens to the input events.
  44624. */
  44625. detachControl(element: HTMLElement): void;
  44626. private _collisionMask;
  44627. /**
  44628. * Get the mask that the camera ignores in collision events.
  44629. */
  44630. get collisionMask(): number;
  44631. /**
  44632. * Set the mask that the camera ignores in collision events.
  44633. */
  44634. set collisionMask(mask: number);
  44635. /** @hidden */
  44636. _collideWithWorld(displacement: Vector3): void;
  44637. /** @hidden */
  44638. private _onCollisionPositionChange;
  44639. /** @hidden */
  44640. _checkInputs(): void;
  44641. /** @hidden */
  44642. _decideIfNeedsToMove(): boolean;
  44643. /** @hidden */
  44644. _updatePosition(): void;
  44645. /**
  44646. * Restore the Roll to its target value at the rate specified.
  44647. * @param rate - Higher means slower restoring.
  44648. * @hidden
  44649. */
  44650. restoreRoll(rate: number): void;
  44651. /**
  44652. * Destroy the camera and release the current resources held by it.
  44653. */
  44654. dispose(): void;
  44655. /**
  44656. * Get the current object class name.
  44657. * @returns the class name.
  44658. */
  44659. getClassName(): string;
  44660. }
  44661. }
  44662. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  44663. import { Nullable } from "babylonjs/types";
  44664. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44665. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44666. /**
  44667. * Listen to keyboard events to control the camera.
  44668. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44669. */
  44670. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44671. /**
  44672. * Defines the camera the input is attached to.
  44673. */
  44674. camera: FlyCamera;
  44675. /**
  44676. * The list of keyboard keys used to control the forward move of the camera.
  44677. */
  44678. keysForward: number[];
  44679. /**
  44680. * The list of keyboard keys used to control the backward move of the camera.
  44681. */
  44682. keysBackward: number[];
  44683. /**
  44684. * The list of keyboard keys used to control the forward move of the camera.
  44685. */
  44686. keysUp: number[];
  44687. /**
  44688. * The list of keyboard keys used to control the backward move of the camera.
  44689. */
  44690. keysDown: number[];
  44691. /**
  44692. * The list of keyboard keys used to control the right strafe move of the camera.
  44693. */
  44694. keysRight: number[];
  44695. /**
  44696. * The list of keyboard keys used to control the left strafe move of the camera.
  44697. */
  44698. keysLeft: number[];
  44699. private _keys;
  44700. private _onCanvasBlurObserver;
  44701. private _onKeyboardObserver;
  44702. private _engine;
  44703. private _scene;
  44704. /**
  44705. * Attach the input controls to a specific dom element to get the input from.
  44706. * @param element Defines the element the controls should be listened from
  44707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44708. */
  44709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44710. /**
  44711. * Detach the current controls from the specified dom element.
  44712. * @param element Defines the element to stop listening the inputs from
  44713. */
  44714. detachControl(element: Nullable<HTMLElement>): void;
  44715. /**
  44716. * Gets the class name of the current intput.
  44717. * @returns the class name
  44718. */
  44719. getClassName(): string;
  44720. /** @hidden */
  44721. _onLostFocus(e: FocusEvent): void;
  44722. /**
  44723. * Get the friendly name associated with the input class.
  44724. * @returns the input friendly name
  44725. */
  44726. getSimpleName(): string;
  44727. /**
  44728. * Update the current camera state depending on the inputs that have been used this frame.
  44729. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44730. */
  44731. checkInputs(): void;
  44732. }
  44733. }
  44734. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  44735. import { Nullable } from "babylonjs/types";
  44736. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44737. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44738. /**
  44739. * Manage the mouse wheel inputs to control a follow camera.
  44740. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44741. */
  44742. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44743. /**
  44744. * Defines the camera the input is attached to.
  44745. */
  44746. camera: FollowCamera;
  44747. /**
  44748. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44749. */
  44750. axisControlRadius: boolean;
  44751. /**
  44752. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44753. */
  44754. axisControlHeight: boolean;
  44755. /**
  44756. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44757. */
  44758. axisControlRotation: boolean;
  44759. /**
  44760. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44761. * relation to mouseWheel events.
  44762. */
  44763. wheelPrecision: number;
  44764. /**
  44765. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44766. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44767. */
  44768. wheelDeltaPercentage: number;
  44769. private _wheel;
  44770. private _observer;
  44771. /**
  44772. * Attach the input controls to a specific dom element to get the input from.
  44773. * @param element Defines the element the controls should be listened from
  44774. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44775. */
  44776. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44777. /**
  44778. * Detach the current controls from the specified dom element.
  44779. * @param element Defines the element to stop listening the inputs from
  44780. */
  44781. detachControl(element: Nullable<HTMLElement>): void;
  44782. /**
  44783. * Gets the class name of the current intput.
  44784. * @returns the class name
  44785. */
  44786. getClassName(): string;
  44787. /**
  44788. * Get the friendly name associated with the input class.
  44789. * @returns the input friendly name
  44790. */
  44791. getSimpleName(): string;
  44792. }
  44793. }
  44794. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  44795. import { Nullable } from "babylonjs/types";
  44796. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44797. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44798. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44799. /**
  44800. * Manage the pointers inputs to control an follow camera.
  44801. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44802. */
  44803. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44804. /**
  44805. * Defines the camera the input is attached to.
  44806. */
  44807. camera: FollowCamera;
  44808. /**
  44809. * Gets the class name of the current input.
  44810. * @returns the class name
  44811. */
  44812. getClassName(): string;
  44813. /**
  44814. * Defines the pointer angular sensibility along the X axis or how fast is
  44815. * the camera rotating.
  44816. * A negative number will reverse the axis direction.
  44817. */
  44818. angularSensibilityX: number;
  44819. /**
  44820. * Defines the pointer angular sensibility along the Y axis or how fast is
  44821. * the camera rotating.
  44822. * A negative number will reverse the axis direction.
  44823. */
  44824. angularSensibilityY: number;
  44825. /**
  44826. * Defines the pointer pinch precision or how fast is the camera zooming.
  44827. * A negative number will reverse the axis direction.
  44828. */
  44829. pinchPrecision: number;
  44830. /**
  44831. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44832. * from 0.
  44833. * It defines the percentage of current camera.radius to use as delta when
  44834. * pinch zoom is used.
  44835. */
  44836. pinchDeltaPercentage: number;
  44837. /**
  44838. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44839. */
  44840. axisXControlRadius: boolean;
  44841. /**
  44842. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44843. */
  44844. axisXControlHeight: boolean;
  44845. /**
  44846. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44847. */
  44848. axisXControlRotation: boolean;
  44849. /**
  44850. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44851. */
  44852. axisYControlRadius: boolean;
  44853. /**
  44854. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44855. */
  44856. axisYControlHeight: boolean;
  44857. /**
  44858. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44859. */
  44860. axisYControlRotation: boolean;
  44861. /**
  44862. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44863. */
  44864. axisPinchControlRadius: boolean;
  44865. /**
  44866. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44867. */
  44868. axisPinchControlHeight: boolean;
  44869. /**
  44870. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44871. */
  44872. axisPinchControlRotation: boolean;
  44873. /**
  44874. * Log error messages if basic misconfiguration has occurred.
  44875. */
  44876. warningEnable: boolean;
  44877. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44878. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44879. private _warningCounter;
  44880. private _warning;
  44881. }
  44882. }
  44883. declare module "babylonjs/Cameras/followCameraInputsManager" {
  44884. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44885. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44886. /**
  44887. * Default Inputs manager for the FollowCamera.
  44888. * It groups all the default supported inputs for ease of use.
  44889. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44890. */
  44891. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44892. /**
  44893. * Instantiates a new FollowCameraInputsManager.
  44894. * @param camera Defines the camera the inputs belong to
  44895. */
  44896. constructor(camera: FollowCamera);
  44897. /**
  44898. * Add keyboard input support to the input manager.
  44899. * @returns the current input manager
  44900. */
  44901. addKeyboard(): FollowCameraInputsManager;
  44902. /**
  44903. * Add mouse wheel input support to the input manager.
  44904. * @returns the current input manager
  44905. */
  44906. addMouseWheel(): FollowCameraInputsManager;
  44907. /**
  44908. * Add pointers input support to the input manager.
  44909. * @returns the current input manager
  44910. */
  44911. addPointers(): FollowCameraInputsManager;
  44912. /**
  44913. * Add orientation input support to the input manager.
  44914. * @returns the current input manager
  44915. */
  44916. addVRDeviceOrientation(): FollowCameraInputsManager;
  44917. }
  44918. }
  44919. declare module "babylonjs/Cameras/followCamera" {
  44920. import { Nullable } from "babylonjs/types";
  44921. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44922. import { Scene } from "babylonjs/scene";
  44923. import { Vector3 } from "babylonjs/Maths/math.vector";
  44924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44925. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  44926. /**
  44927. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44928. * an arc rotate version arcFollowCamera are available.
  44929. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  44930. */
  44931. export class FollowCamera extends TargetCamera {
  44932. /**
  44933. * Distance the follow camera should follow an object at
  44934. */
  44935. radius: number;
  44936. /**
  44937. * Minimum allowed distance of the camera to the axis of rotation
  44938. * (The camera can not get closer).
  44939. * This can help limiting how the Camera is able to move in the scene.
  44940. */
  44941. lowerRadiusLimit: Nullable<number>;
  44942. /**
  44943. * Maximum allowed distance of the camera to the axis of rotation
  44944. * (The camera can not get further).
  44945. * This can help limiting how the Camera is able to move in the scene.
  44946. */
  44947. upperRadiusLimit: Nullable<number>;
  44948. /**
  44949. * Define a rotation offset between the camera and the object it follows
  44950. */
  44951. rotationOffset: number;
  44952. /**
  44953. * Minimum allowed angle to camera position relative to target object.
  44954. * This can help limiting how the Camera is able to move in the scene.
  44955. */
  44956. lowerRotationOffsetLimit: Nullable<number>;
  44957. /**
  44958. * Maximum allowed angle to camera position relative to target object.
  44959. * This can help limiting how the Camera is able to move in the scene.
  44960. */
  44961. upperRotationOffsetLimit: Nullable<number>;
  44962. /**
  44963. * Define a height offset between the camera and the object it follows.
  44964. * It can help following an object from the top (like a car chaing a plane)
  44965. */
  44966. heightOffset: number;
  44967. /**
  44968. * Minimum allowed height of camera position relative to target object.
  44969. * This can help limiting how the Camera is able to move in the scene.
  44970. */
  44971. lowerHeightOffsetLimit: Nullable<number>;
  44972. /**
  44973. * Maximum allowed height of camera position relative to target object.
  44974. * This can help limiting how the Camera is able to move in the scene.
  44975. */
  44976. upperHeightOffsetLimit: Nullable<number>;
  44977. /**
  44978. * Define how fast the camera can accelerate to follow it s target.
  44979. */
  44980. cameraAcceleration: number;
  44981. /**
  44982. * Define the speed limit of the camera following an object.
  44983. */
  44984. maxCameraSpeed: number;
  44985. /**
  44986. * Define the target of the camera.
  44987. */
  44988. lockedTarget: Nullable<AbstractMesh>;
  44989. /**
  44990. * Defines the input associated with the camera.
  44991. */
  44992. inputs: FollowCameraInputsManager;
  44993. /**
  44994. * Instantiates the follow camera.
  44995. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  44996. * @param name Define the name of the camera in the scene
  44997. * @param position Define the position of the camera
  44998. * @param scene Define the scene the camera belong to
  44999. * @param lockedTarget Define the target of the camera
  45000. */
  45001. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  45002. private _follow;
  45003. /**
  45004. * Attached controls to the current camera.
  45005. * @param element Defines the element the controls should be listened from
  45006. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45007. */
  45008. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45009. /**
  45010. * Detach the current controls from the camera.
  45011. * The camera will stop reacting to inputs.
  45012. * @param element Defines the element to stop listening the inputs from
  45013. */
  45014. detachControl(element: HTMLElement): void;
  45015. /** @hidden */
  45016. _checkInputs(): void;
  45017. private _checkLimits;
  45018. /**
  45019. * Gets the camera class name.
  45020. * @returns the class name
  45021. */
  45022. getClassName(): string;
  45023. }
  45024. /**
  45025. * Arc Rotate version of the follow camera.
  45026. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  45027. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45028. */
  45029. export class ArcFollowCamera extends TargetCamera {
  45030. /** The longitudinal angle of the camera */
  45031. alpha: number;
  45032. /** The latitudinal angle of the camera */
  45033. beta: number;
  45034. /** The radius of the camera from its target */
  45035. radius: number;
  45036. /** Define the camera target (the messh it should follow) */
  45037. target: Nullable<AbstractMesh>;
  45038. private _cartesianCoordinates;
  45039. /**
  45040. * Instantiates a new ArcFollowCamera
  45041. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45042. * @param name Define the name of the camera
  45043. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  45044. * @param beta Define the rotation angle of the camera around the elevation axis
  45045. * @param radius Define the radius of the camera from its target point
  45046. * @param target Define the target of the camera
  45047. * @param scene Define the scene the camera belongs to
  45048. */
  45049. constructor(name: string,
  45050. /** The longitudinal angle of the camera */
  45051. alpha: number,
  45052. /** The latitudinal angle of the camera */
  45053. beta: number,
  45054. /** The radius of the camera from its target */
  45055. radius: number,
  45056. /** Define the camera target (the messh it should follow) */
  45057. target: Nullable<AbstractMesh>, scene: Scene);
  45058. private _follow;
  45059. /** @hidden */
  45060. _checkInputs(): void;
  45061. /**
  45062. * Returns the class name of the object.
  45063. * It is mostly used internally for serialization purposes.
  45064. */
  45065. getClassName(): string;
  45066. }
  45067. }
  45068. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  45069. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45070. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45071. import { Nullable } from "babylonjs/types";
  45072. /**
  45073. * Manage the keyboard inputs to control the movement of a follow camera.
  45074. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45075. */
  45076. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  45077. /**
  45078. * Defines the camera the input is attached to.
  45079. */
  45080. camera: FollowCamera;
  45081. /**
  45082. * Defines the list of key codes associated with the up action (increase heightOffset)
  45083. */
  45084. keysHeightOffsetIncr: number[];
  45085. /**
  45086. * Defines the list of key codes associated with the down action (decrease heightOffset)
  45087. */
  45088. keysHeightOffsetDecr: number[];
  45089. /**
  45090. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  45091. */
  45092. keysHeightOffsetModifierAlt: boolean;
  45093. /**
  45094. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  45095. */
  45096. keysHeightOffsetModifierCtrl: boolean;
  45097. /**
  45098. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  45099. */
  45100. keysHeightOffsetModifierShift: boolean;
  45101. /**
  45102. * Defines the list of key codes associated with the left action (increase rotationOffset)
  45103. */
  45104. keysRotationOffsetIncr: number[];
  45105. /**
  45106. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  45107. */
  45108. keysRotationOffsetDecr: number[];
  45109. /**
  45110. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  45111. */
  45112. keysRotationOffsetModifierAlt: boolean;
  45113. /**
  45114. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  45115. */
  45116. keysRotationOffsetModifierCtrl: boolean;
  45117. /**
  45118. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  45119. */
  45120. keysRotationOffsetModifierShift: boolean;
  45121. /**
  45122. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  45123. */
  45124. keysRadiusIncr: number[];
  45125. /**
  45126. * Defines the list of key codes associated with the zoom-out action (increase radius)
  45127. */
  45128. keysRadiusDecr: number[];
  45129. /**
  45130. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  45131. */
  45132. keysRadiusModifierAlt: boolean;
  45133. /**
  45134. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  45135. */
  45136. keysRadiusModifierCtrl: boolean;
  45137. /**
  45138. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  45139. */
  45140. keysRadiusModifierShift: boolean;
  45141. /**
  45142. * Defines the rate of change of heightOffset.
  45143. */
  45144. heightSensibility: number;
  45145. /**
  45146. * Defines the rate of change of rotationOffset.
  45147. */
  45148. rotationSensibility: number;
  45149. /**
  45150. * Defines the rate of change of radius.
  45151. */
  45152. radiusSensibility: number;
  45153. private _keys;
  45154. private _ctrlPressed;
  45155. private _altPressed;
  45156. private _shiftPressed;
  45157. private _onCanvasBlurObserver;
  45158. private _onKeyboardObserver;
  45159. private _engine;
  45160. private _scene;
  45161. /**
  45162. * Attach the input controls to a specific dom element to get the input from.
  45163. * @param element Defines the element the controls should be listened from
  45164. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45165. */
  45166. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45167. /**
  45168. * Detach the current controls from the specified dom element.
  45169. * @param element Defines the element to stop listening the inputs from
  45170. */
  45171. detachControl(element: Nullable<HTMLElement>): void;
  45172. /**
  45173. * Update the current camera state depending on the inputs that have been used this frame.
  45174. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45175. */
  45176. checkInputs(): void;
  45177. /**
  45178. * Gets the class name of the current input.
  45179. * @returns the class name
  45180. */
  45181. getClassName(): string;
  45182. /**
  45183. * Get the friendly name associated with the input class.
  45184. * @returns the input friendly name
  45185. */
  45186. getSimpleName(): string;
  45187. /**
  45188. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45189. * allow modification of the heightOffset value.
  45190. */
  45191. private _modifierHeightOffset;
  45192. /**
  45193. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45194. * allow modification of the rotationOffset value.
  45195. */
  45196. private _modifierRotationOffset;
  45197. /**
  45198. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45199. * allow modification of the radius value.
  45200. */
  45201. private _modifierRadius;
  45202. }
  45203. }
  45204. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  45205. import { Nullable } from "babylonjs/types";
  45206. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45207. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45208. import { Observable } from "babylonjs/Misc/observable";
  45209. module "babylonjs/Cameras/freeCameraInputsManager" {
  45210. interface FreeCameraInputsManager {
  45211. /**
  45212. * @hidden
  45213. */
  45214. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  45215. /**
  45216. * Add orientation input support to the input manager.
  45217. * @returns the current input manager
  45218. */
  45219. addDeviceOrientation(): FreeCameraInputsManager;
  45220. }
  45221. }
  45222. /**
  45223. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45224. * Screen rotation is taken into account.
  45225. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45226. */
  45227. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45228. private _camera;
  45229. private _screenOrientationAngle;
  45230. private _constantTranform;
  45231. private _screenQuaternion;
  45232. private _alpha;
  45233. private _beta;
  45234. private _gamma;
  45235. /**
  45236. * Can be used to detect if a device orientation sensor is available on a device
  45237. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45238. * @returns a promise that will resolve on orientation change
  45239. */
  45240. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45241. /**
  45242. * @hidden
  45243. */
  45244. _onDeviceOrientationChangedObservable: Observable<void>;
  45245. /**
  45246. * Instantiates a new input
  45247. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45248. */
  45249. constructor();
  45250. /**
  45251. * Define the camera controlled by the input.
  45252. */
  45253. get camera(): FreeCamera;
  45254. set camera(camera: FreeCamera);
  45255. /**
  45256. * Attach the input controls to a specific dom element to get the input from.
  45257. * @param element Defines the element the controls should be listened from
  45258. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45259. */
  45260. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45261. private _orientationChanged;
  45262. private _deviceOrientation;
  45263. /**
  45264. * Detach the current controls from the specified dom element.
  45265. * @param element Defines the element to stop listening the inputs from
  45266. */
  45267. detachControl(element: Nullable<HTMLElement>): void;
  45268. /**
  45269. * Update the current camera state depending on the inputs that have been used this frame.
  45270. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45271. */
  45272. checkInputs(): void;
  45273. /**
  45274. * Gets the class name of the current intput.
  45275. * @returns the class name
  45276. */
  45277. getClassName(): string;
  45278. /**
  45279. * Get the friendly name associated with the input class.
  45280. * @returns the input friendly name
  45281. */
  45282. getSimpleName(): string;
  45283. }
  45284. }
  45285. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  45286. import { Nullable } from "babylonjs/types";
  45287. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45288. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45289. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45290. /**
  45291. * Manage the gamepad inputs to control a free camera.
  45292. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45293. */
  45294. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45295. /**
  45296. * Define the camera the input is attached to.
  45297. */
  45298. camera: FreeCamera;
  45299. /**
  45300. * Define the Gamepad controlling the input
  45301. */
  45302. gamepad: Nullable<Gamepad>;
  45303. /**
  45304. * Defines the gamepad rotation sensiblity.
  45305. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45306. */
  45307. gamepadAngularSensibility: number;
  45308. /**
  45309. * Defines the gamepad move sensiblity.
  45310. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45311. */
  45312. gamepadMoveSensibility: number;
  45313. private _yAxisScale;
  45314. /**
  45315. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45316. */
  45317. get invertYAxis(): boolean;
  45318. set invertYAxis(value: boolean);
  45319. private _onGamepadConnectedObserver;
  45320. private _onGamepadDisconnectedObserver;
  45321. private _cameraTransform;
  45322. private _deltaTransform;
  45323. private _vector3;
  45324. private _vector2;
  45325. /**
  45326. * Attach the input controls to a specific dom element to get the input from.
  45327. * @param element Defines the element the controls should be listened from
  45328. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45329. */
  45330. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45331. /**
  45332. * Detach the current controls from the specified dom element.
  45333. * @param element Defines the element to stop listening the inputs from
  45334. */
  45335. detachControl(element: Nullable<HTMLElement>): void;
  45336. /**
  45337. * Update the current camera state depending on the inputs that have been used this frame.
  45338. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45339. */
  45340. checkInputs(): void;
  45341. /**
  45342. * Gets the class name of the current intput.
  45343. * @returns the class name
  45344. */
  45345. getClassName(): string;
  45346. /**
  45347. * Get the friendly name associated with the input class.
  45348. * @returns the input friendly name
  45349. */
  45350. getSimpleName(): string;
  45351. }
  45352. }
  45353. declare module "babylonjs/Misc/virtualJoystick" {
  45354. import { Nullable } from "babylonjs/types";
  45355. import { Vector3 } from "babylonjs/Maths/math.vector";
  45356. /**
  45357. * Defines the potential axis of a Joystick
  45358. */
  45359. export enum JoystickAxis {
  45360. /** X axis */
  45361. X = 0,
  45362. /** Y axis */
  45363. Y = 1,
  45364. /** Z axis */
  45365. Z = 2
  45366. }
  45367. /**
  45368. * Class used to define virtual joystick (used in touch mode)
  45369. */
  45370. export class VirtualJoystick {
  45371. /**
  45372. * Gets or sets a boolean indicating that left and right values must be inverted
  45373. */
  45374. reverseLeftRight: boolean;
  45375. /**
  45376. * Gets or sets a boolean indicating that up and down values must be inverted
  45377. */
  45378. reverseUpDown: boolean;
  45379. /**
  45380. * Gets the offset value for the position (ie. the change of the position value)
  45381. */
  45382. deltaPosition: Vector3;
  45383. /**
  45384. * Gets a boolean indicating if the virtual joystick was pressed
  45385. */
  45386. pressed: boolean;
  45387. /**
  45388. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45389. */
  45390. static Canvas: Nullable<HTMLCanvasElement>;
  45391. private static _globalJoystickIndex;
  45392. private static vjCanvasContext;
  45393. private static vjCanvasWidth;
  45394. private static vjCanvasHeight;
  45395. private static halfWidth;
  45396. private _action;
  45397. private _axisTargetedByLeftAndRight;
  45398. private _axisTargetedByUpAndDown;
  45399. private _joystickSensibility;
  45400. private _inversedSensibility;
  45401. private _joystickPointerID;
  45402. private _joystickColor;
  45403. private _joystickPointerPos;
  45404. private _joystickPreviousPointerPos;
  45405. private _joystickPointerStartPos;
  45406. private _deltaJoystickVector;
  45407. private _leftJoystick;
  45408. private _touches;
  45409. private _onPointerDownHandlerRef;
  45410. private _onPointerMoveHandlerRef;
  45411. private _onPointerUpHandlerRef;
  45412. private _onResize;
  45413. /**
  45414. * Creates a new virtual joystick
  45415. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45416. */
  45417. constructor(leftJoystick?: boolean);
  45418. /**
  45419. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45420. * @param newJoystickSensibility defines the new sensibility
  45421. */
  45422. setJoystickSensibility(newJoystickSensibility: number): void;
  45423. private _onPointerDown;
  45424. private _onPointerMove;
  45425. private _onPointerUp;
  45426. /**
  45427. * Change the color of the virtual joystick
  45428. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45429. */
  45430. setJoystickColor(newColor: string): void;
  45431. /**
  45432. * Defines a callback to call when the joystick is touched
  45433. * @param action defines the callback
  45434. */
  45435. setActionOnTouch(action: () => any): void;
  45436. /**
  45437. * Defines which axis you'd like to control for left & right
  45438. * @param axis defines the axis to use
  45439. */
  45440. setAxisForLeftRight(axis: JoystickAxis): void;
  45441. /**
  45442. * Defines which axis you'd like to control for up & down
  45443. * @param axis defines the axis to use
  45444. */
  45445. setAxisForUpDown(axis: JoystickAxis): void;
  45446. private _drawVirtualJoystick;
  45447. /**
  45448. * Release internal HTML canvas
  45449. */
  45450. releaseCanvas(): void;
  45451. }
  45452. }
  45453. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  45454. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  45455. import { Nullable } from "babylonjs/types";
  45456. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45457. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45458. module "babylonjs/Cameras/freeCameraInputsManager" {
  45459. interface FreeCameraInputsManager {
  45460. /**
  45461. * Add virtual joystick input support to the input manager.
  45462. * @returns the current input manager
  45463. */
  45464. addVirtualJoystick(): FreeCameraInputsManager;
  45465. }
  45466. }
  45467. /**
  45468. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45469. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45470. */
  45471. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45472. /**
  45473. * Defines the camera the input is attached to.
  45474. */
  45475. camera: FreeCamera;
  45476. private _leftjoystick;
  45477. private _rightjoystick;
  45478. /**
  45479. * Gets the left stick of the virtual joystick.
  45480. * @returns The virtual Joystick
  45481. */
  45482. getLeftJoystick(): VirtualJoystick;
  45483. /**
  45484. * Gets the right stick of the virtual joystick.
  45485. * @returns The virtual Joystick
  45486. */
  45487. getRightJoystick(): VirtualJoystick;
  45488. /**
  45489. * Update the current camera state depending on the inputs that have been used this frame.
  45490. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45491. */
  45492. checkInputs(): void;
  45493. /**
  45494. * Attach the input controls to a specific dom element to get the input from.
  45495. * @param element Defines the element the controls should be listened from
  45496. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45497. */
  45498. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45499. /**
  45500. * Detach the current controls from the specified dom element.
  45501. * @param element Defines the element to stop listening the inputs from
  45502. */
  45503. detachControl(element: Nullable<HTMLElement>): void;
  45504. /**
  45505. * Gets the class name of the current intput.
  45506. * @returns the class name
  45507. */
  45508. getClassName(): string;
  45509. /**
  45510. * Get the friendly name associated with the input class.
  45511. * @returns the input friendly name
  45512. */
  45513. getSimpleName(): string;
  45514. }
  45515. }
  45516. declare module "babylonjs/Cameras/Inputs/index" {
  45517. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  45518. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  45519. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  45520. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  45521. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  45522. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  45523. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  45524. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  45525. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  45526. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  45527. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45528. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  45529. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  45530. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  45531. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  45532. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  45533. }
  45534. declare module "babylonjs/Cameras/touchCamera" {
  45535. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45536. import { Scene } from "babylonjs/scene";
  45537. import { Vector3 } from "babylonjs/Maths/math.vector";
  45538. /**
  45539. * This represents a FPS type of camera controlled by touch.
  45540. * This is like a universal camera minus the Gamepad controls.
  45541. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  45542. */
  45543. export class TouchCamera extends FreeCamera {
  45544. /**
  45545. * Defines the touch sensibility for rotation.
  45546. * The higher the faster.
  45547. */
  45548. get touchAngularSensibility(): number;
  45549. set touchAngularSensibility(value: number);
  45550. /**
  45551. * Defines the touch sensibility for move.
  45552. * The higher the faster.
  45553. */
  45554. get touchMoveSensibility(): number;
  45555. set touchMoveSensibility(value: number);
  45556. /**
  45557. * Instantiates a new touch camera.
  45558. * This represents a FPS type of camera controlled by touch.
  45559. * This is like a universal camera minus the Gamepad controls.
  45560. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  45561. * @param name Define the name of the camera in the scene
  45562. * @param position Define the start position of the camera in the scene
  45563. * @param scene Define the scene the camera belongs to
  45564. */
  45565. constructor(name: string, position: Vector3, scene: Scene);
  45566. /**
  45567. * Gets the current object class name.
  45568. * @return the class name
  45569. */
  45570. getClassName(): string;
  45571. /** @hidden */
  45572. _setupInputs(): void;
  45573. }
  45574. }
  45575. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  45576. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45577. import { Scene } from "babylonjs/scene";
  45578. import { Vector3 } from "babylonjs/Maths/math.vector";
  45579. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45580. import { Axis } from "babylonjs/Maths/math.axis";
  45581. /**
  45582. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45583. * being tilted forward or back and left or right.
  45584. */
  45585. export class DeviceOrientationCamera extends FreeCamera {
  45586. private _initialQuaternion;
  45587. private _quaternionCache;
  45588. private _tmpDragQuaternion;
  45589. private _disablePointerInputWhenUsingDeviceOrientation;
  45590. /**
  45591. * Creates a new device orientation camera
  45592. * @param name The name of the camera
  45593. * @param position The start position camera
  45594. * @param scene The scene the camera belongs to
  45595. */
  45596. constructor(name: string, position: Vector3, scene: Scene);
  45597. /**
  45598. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45599. */
  45600. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45601. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45602. private _dragFactor;
  45603. /**
  45604. * Enabled turning on the y axis when the orientation sensor is active
  45605. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45606. */
  45607. enableHorizontalDragging(dragFactor?: number): void;
  45608. /**
  45609. * Gets the current instance class name ("DeviceOrientationCamera").
  45610. * This helps avoiding instanceof at run time.
  45611. * @returns the class name
  45612. */
  45613. getClassName(): string;
  45614. /**
  45615. * @hidden
  45616. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45617. */
  45618. _checkInputs(): void;
  45619. /**
  45620. * Reset the camera to its default orientation on the specified axis only.
  45621. * @param axis The axis to reset
  45622. */
  45623. resetToCurrentRotation(axis?: Axis): void;
  45624. }
  45625. }
  45626. declare module "babylonjs/Gamepads/xboxGamepad" {
  45627. import { Observable } from "babylonjs/Misc/observable";
  45628. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45629. /**
  45630. * Defines supported buttons for XBox360 compatible gamepads
  45631. */
  45632. export enum Xbox360Button {
  45633. /** A */
  45634. A = 0,
  45635. /** B */
  45636. B = 1,
  45637. /** X */
  45638. X = 2,
  45639. /** Y */
  45640. Y = 3,
  45641. /** Left button */
  45642. LB = 4,
  45643. /** Right button */
  45644. RB = 5,
  45645. /** Back */
  45646. Back = 8,
  45647. /** Start */
  45648. Start = 9,
  45649. /** Left stick */
  45650. LeftStick = 10,
  45651. /** Right stick */
  45652. RightStick = 11
  45653. }
  45654. /** Defines values for XBox360 DPad */
  45655. export enum Xbox360Dpad {
  45656. /** Up */
  45657. Up = 12,
  45658. /** Down */
  45659. Down = 13,
  45660. /** Left */
  45661. Left = 14,
  45662. /** Right */
  45663. Right = 15
  45664. }
  45665. /**
  45666. * Defines a XBox360 gamepad
  45667. */
  45668. export class Xbox360Pad extends Gamepad {
  45669. private _leftTrigger;
  45670. private _rightTrigger;
  45671. private _onlefttriggerchanged;
  45672. private _onrighttriggerchanged;
  45673. private _onbuttondown;
  45674. private _onbuttonup;
  45675. private _ondpaddown;
  45676. private _ondpadup;
  45677. /** Observable raised when a button is pressed */
  45678. onButtonDownObservable: Observable<Xbox360Button>;
  45679. /** Observable raised when a button is released */
  45680. onButtonUpObservable: Observable<Xbox360Button>;
  45681. /** Observable raised when a pad is pressed */
  45682. onPadDownObservable: Observable<Xbox360Dpad>;
  45683. /** Observable raised when a pad is released */
  45684. onPadUpObservable: Observable<Xbox360Dpad>;
  45685. private _buttonA;
  45686. private _buttonB;
  45687. private _buttonX;
  45688. private _buttonY;
  45689. private _buttonBack;
  45690. private _buttonStart;
  45691. private _buttonLB;
  45692. private _buttonRB;
  45693. private _buttonLeftStick;
  45694. private _buttonRightStick;
  45695. private _dPadUp;
  45696. private _dPadDown;
  45697. private _dPadLeft;
  45698. private _dPadRight;
  45699. private _isXboxOnePad;
  45700. /**
  45701. * Creates a new XBox360 gamepad object
  45702. * @param id defines the id of this gamepad
  45703. * @param index defines its index
  45704. * @param gamepad defines the internal HTML gamepad object
  45705. * @param xboxOne defines if it is a XBox One gamepad
  45706. */
  45707. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45708. /**
  45709. * Defines the callback to call when left trigger is pressed
  45710. * @param callback defines the callback to use
  45711. */
  45712. onlefttriggerchanged(callback: (value: number) => void): void;
  45713. /**
  45714. * Defines the callback to call when right trigger is pressed
  45715. * @param callback defines the callback to use
  45716. */
  45717. onrighttriggerchanged(callback: (value: number) => void): void;
  45718. /**
  45719. * Gets the left trigger value
  45720. */
  45721. get leftTrigger(): number;
  45722. /**
  45723. * Sets the left trigger value
  45724. */
  45725. set leftTrigger(newValue: number);
  45726. /**
  45727. * Gets the right trigger value
  45728. */
  45729. get rightTrigger(): number;
  45730. /**
  45731. * Sets the right trigger value
  45732. */
  45733. set rightTrigger(newValue: number);
  45734. /**
  45735. * Defines the callback to call when a button is pressed
  45736. * @param callback defines the callback to use
  45737. */
  45738. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45739. /**
  45740. * Defines the callback to call when a button is released
  45741. * @param callback defines the callback to use
  45742. */
  45743. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45744. /**
  45745. * Defines the callback to call when a pad is pressed
  45746. * @param callback defines the callback to use
  45747. */
  45748. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45749. /**
  45750. * Defines the callback to call when a pad is released
  45751. * @param callback defines the callback to use
  45752. */
  45753. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45754. private _setButtonValue;
  45755. private _setDPadValue;
  45756. /**
  45757. * Gets the value of the `A` button
  45758. */
  45759. get buttonA(): number;
  45760. /**
  45761. * Sets the value of the `A` button
  45762. */
  45763. set buttonA(value: number);
  45764. /**
  45765. * Gets the value of the `B` button
  45766. */
  45767. get buttonB(): number;
  45768. /**
  45769. * Sets the value of the `B` button
  45770. */
  45771. set buttonB(value: number);
  45772. /**
  45773. * Gets the value of the `X` button
  45774. */
  45775. get buttonX(): number;
  45776. /**
  45777. * Sets the value of the `X` button
  45778. */
  45779. set buttonX(value: number);
  45780. /**
  45781. * Gets the value of the `Y` button
  45782. */
  45783. get buttonY(): number;
  45784. /**
  45785. * Sets the value of the `Y` button
  45786. */
  45787. set buttonY(value: number);
  45788. /**
  45789. * Gets the value of the `Start` button
  45790. */
  45791. get buttonStart(): number;
  45792. /**
  45793. * Sets the value of the `Start` button
  45794. */
  45795. set buttonStart(value: number);
  45796. /**
  45797. * Gets the value of the `Back` button
  45798. */
  45799. get buttonBack(): number;
  45800. /**
  45801. * Sets the value of the `Back` button
  45802. */
  45803. set buttonBack(value: number);
  45804. /**
  45805. * Gets the value of the `Left` button
  45806. */
  45807. get buttonLB(): number;
  45808. /**
  45809. * Sets the value of the `Left` button
  45810. */
  45811. set buttonLB(value: number);
  45812. /**
  45813. * Gets the value of the `Right` button
  45814. */
  45815. get buttonRB(): number;
  45816. /**
  45817. * Sets the value of the `Right` button
  45818. */
  45819. set buttonRB(value: number);
  45820. /**
  45821. * Gets the value of the Left joystick
  45822. */
  45823. get buttonLeftStick(): number;
  45824. /**
  45825. * Sets the value of the Left joystick
  45826. */
  45827. set buttonLeftStick(value: number);
  45828. /**
  45829. * Gets the value of the Right joystick
  45830. */
  45831. get buttonRightStick(): number;
  45832. /**
  45833. * Sets the value of the Right joystick
  45834. */
  45835. set buttonRightStick(value: number);
  45836. /**
  45837. * Gets the value of D-pad up
  45838. */
  45839. get dPadUp(): number;
  45840. /**
  45841. * Sets the value of D-pad up
  45842. */
  45843. set dPadUp(value: number);
  45844. /**
  45845. * Gets the value of D-pad down
  45846. */
  45847. get dPadDown(): number;
  45848. /**
  45849. * Sets the value of D-pad down
  45850. */
  45851. set dPadDown(value: number);
  45852. /**
  45853. * Gets the value of D-pad left
  45854. */
  45855. get dPadLeft(): number;
  45856. /**
  45857. * Sets the value of D-pad left
  45858. */
  45859. set dPadLeft(value: number);
  45860. /**
  45861. * Gets the value of D-pad right
  45862. */
  45863. get dPadRight(): number;
  45864. /**
  45865. * Sets the value of D-pad right
  45866. */
  45867. set dPadRight(value: number);
  45868. /**
  45869. * Force the gamepad to synchronize with device values
  45870. */
  45871. update(): void;
  45872. /**
  45873. * Disposes the gamepad
  45874. */
  45875. dispose(): void;
  45876. }
  45877. }
  45878. declare module "babylonjs/Gamepads/dualShockGamepad" {
  45879. import { Observable } from "babylonjs/Misc/observable";
  45880. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45881. /**
  45882. * Defines supported buttons for DualShock compatible gamepads
  45883. */
  45884. export enum DualShockButton {
  45885. /** Cross */
  45886. Cross = 0,
  45887. /** Circle */
  45888. Circle = 1,
  45889. /** Square */
  45890. Square = 2,
  45891. /** Triangle */
  45892. Triangle = 3,
  45893. /** L1 */
  45894. L1 = 4,
  45895. /** R1 */
  45896. R1 = 5,
  45897. /** Share */
  45898. Share = 8,
  45899. /** Options */
  45900. Options = 9,
  45901. /** Left stick */
  45902. LeftStick = 10,
  45903. /** Right stick */
  45904. RightStick = 11
  45905. }
  45906. /** Defines values for DualShock DPad */
  45907. export enum DualShockDpad {
  45908. /** Up */
  45909. Up = 12,
  45910. /** Down */
  45911. Down = 13,
  45912. /** Left */
  45913. Left = 14,
  45914. /** Right */
  45915. Right = 15
  45916. }
  45917. /**
  45918. * Defines a DualShock gamepad
  45919. */
  45920. export class DualShockPad extends Gamepad {
  45921. private _leftTrigger;
  45922. private _rightTrigger;
  45923. private _onlefttriggerchanged;
  45924. private _onrighttriggerchanged;
  45925. private _onbuttondown;
  45926. private _onbuttonup;
  45927. private _ondpaddown;
  45928. private _ondpadup;
  45929. /** Observable raised when a button is pressed */
  45930. onButtonDownObservable: Observable<DualShockButton>;
  45931. /** Observable raised when a button is released */
  45932. onButtonUpObservable: Observable<DualShockButton>;
  45933. /** Observable raised when a pad is pressed */
  45934. onPadDownObservable: Observable<DualShockDpad>;
  45935. /** Observable raised when a pad is released */
  45936. onPadUpObservable: Observable<DualShockDpad>;
  45937. private _buttonCross;
  45938. private _buttonCircle;
  45939. private _buttonSquare;
  45940. private _buttonTriangle;
  45941. private _buttonShare;
  45942. private _buttonOptions;
  45943. private _buttonL1;
  45944. private _buttonR1;
  45945. private _buttonLeftStick;
  45946. private _buttonRightStick;
  45947. private _dPadUp;
  45948. private _dPadDown;
  45949. private _dPadLeft;
  45950. private _dPadRight;
  45951. /**
  45952. * Creates a new DualShock gamepad object
  45953. * @param id defines the id of this gamepad
  45954. * @param index defines its index
  45955. * @param gamepad defines the internal HTML gamepad object
  45956. */
  45957. constructor(id: string, index: number, gamepad: any);
  45958. /**
  45959. * Defines the callback to call when left trigger is pressed
  45960. * @param callback defines the callback to use
  45961. */
  45962. onlefttriggerchanged(callback: (value: number) => void): void;
  45963. /**
  45964. * Defines the callback to call when right trigger is pressed
  45965. * @param callback defines the callback to use
  45966. */
  45967. onrighttriggerchanged(callback: (value: number) => void): void;
  45968. /**
  45969. * Gets the left trigger value
  45970. */
  45971. get leftTrigger(): number;
  45972. /**
  45973. * Sets the left trigger value
  45974. */
  45975. set leftTrigger(newValue: number);
  45976. /**
  45977. * Gets the right trigger value
  45978. */
  45979. get rightTrigger(): number;
  45980. /**
  45981. * Sets the right trigger value
  45982. */
  45983. set rightTrigger(newValue: number);
  45984. /**
  45985. * Defines the callback to call when a button is pressed
  45986. * @param callback defines the callback to use
  45987. */
  45988. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45989. /**
  45990. * Defines the callback to call when a button is released
  45991. * @param callback defines the callback to use
  45992. */
  45993. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45994. /**
  45995. * Defines the callback to call when a pad is pressed
  45996. * @param callback defines the callback to use
  45997. */
  45998. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45999. /**
  46000. * Defines the callback to call when a pad is released
  46001. * @param callback defines the callback to use
  46002. */
  46003. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  46004. private _setButtonValue;
  46005. private _setDPadValue;
  46006. /**
  46007. * Gets the value of the `Cross` button
  46008. */
  46009. get buttonCross(): number;
  46010. /**
  46011. * Sets the value of the `Cross` button
  46012. */
  46013. set buttonCross(value: number);
  46014. /**
  46015. * Gets the value of the `Circle` button
  46016. */
  46017. get buttonCircle(): number;
  46018. /**
  46019. * Sets the value of the `Circle` button
  46020. */
  46021. set buttonCircle(value: number);
  46022. /**
  46023. * Gets the value of the `Square` button
  46024. */
  46025. get buttonSquare(): number;
  46026. /**
  46027. * Sets the value of the `Square` button
  46028. */
  46029. set buttonSquare(value: number);
  46030. /**
  46031. * Gets the value of the `Triangle` button
  46032. */
  46033. get buttonTriangle(): number;
  46034. /**
  46035. * Sets the value of the `Triangle` button
  46036. */
  46037. set buttonTriangle(value: number);
  46038. /**
  46039. * Gets the value of the `Options` button
  46040. */
  46041. get buttonOptions(): number;
  46042. /**
  46043. * Sets the value of the `Options` button
  46044. */
  46045. set buttonOptions(value: number);
  46046. /**
  46047. * Gets the value of the `Share` button
  46048. */
  46049. get buttonShare(): number;
  46050. /**
  46051. * Sets the value of the `Share` button
  46052. */
  46053. set buttonShare(value: number);
  46054. /**
  46055. * Gets the value of the `L1` button
  46056. */
  46057. get buttonL1(): number;
  46058. /**
  46059. * Sets the value of the `L1` button
  46060. */
  46061. set buttonL1(value: number);
  46062. /**
  46063. * Gets the value of the `R1` button
  46064. */
  46065. get buttonR1(): number;
  46066. /**
  46067. * Sets the value of the `R1` button
  46068. */
  46069. set buttonR1(value: number);
  46070. /**
  46071. * Gets the value of the Left joystick
  46072. */
  46073. get buttonLeftStick(): number;
  46074. /**
  46075. * Sets the value of the Left joystick
  46076. */
  46077. set buttonLeftStick(value: number);
  46078. /**
  46079. * Gets the value of the Right joystick
  46080. */
  46081. get buttonRightStick(): number;
  46082. /**
  46083. * Sets the value of the Right joystick
  46084. */
  46085. set buttonRightStick(value: number);
  46086. /**
  46087. * Gets the value of D-pad up
  46088. */
  46089. get dPadUp(): number;
  46090. /**
  46091. * Sets the value of D-pad up
  46092. */
  46093. set dPadUp(value: number);
  46094. /**
  46095. * Gets the value of D-pad down
  46096. */
  46097. get dPadDown(): number;
  46098. /**
  46099. * Sets the value of D-pad down
  46100. */
  46101. set dPadDown(value: number);
  46102. /**
  46103. * Gets the value of D-pad left
  46104. */
  46105. get dPadLeft(): number;
  46106. /**
  46107. * Sets the value of D-pad left
  46108. */
  46109. set dPadLeft(value: number);
  46110. /**
  46111. * Gets the value of D-pad right
  46112. */
  46113. get dPadRight(): number;
  46114. /**
  46115. * Sets the value of D-pad right
  46116. */
  46117. set dPadRight(value: number);
  46118. /**
  46119. * Force the gamepad to synchronize with device values
  46120. */
  46121. update(): void;
  46122. /**
  46123. * Disposes the gamepad
  46124. */
  46125. dispose(): void;
  46126. }
  46127. }
  46128. declare module "babylonjs/Gamepads/gamepadManager" {
  46129. import { Observable } from "babylonjs/Misc/observable";
  46130. import { Nullable } from "babylonjs/types";
  46131. import { Scene } from "babylonjs/scene";
  46132. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46133. /**
  46134. * Manager for handling gamepads
  46135. */
  46136. export class GamepadManager {
  46137. private _scene?;
  46138. private _babylonGamepads;
  46139. private _oneGamepadConnected;
  46140. /** @hidden */
  46141. _isMonitoring: boolean;
  46142. private _gamepadEventSupported;
  46143. private _gamepadSupport?;
  46144. /**
  46145. * observable to be triggered when the gamepad controller has been connected
  46146. */
  46147. onGamepadConnectedObservable: Observable<Gamepad>;
  46148. /**
  46149. * observable to be triggered when the gamepad controller has been disconnected
  46150. */
  46151. onGamepadDisconnectedObservable: Observable<Gamepad>;
  46152. private _onGamepadConnectedEvent;
  46153. private _onGamepadDisconnectedEvent;
  46154. /**
  46155. * Initializes the gamepad manager
  46156. * @param _scene BabylonJS scene
  46157. */
  46158. constructor(_scene?: Scene | undefined);
  46159. /**
  46160. * The gamepads in the game pad manager
  46161. */
  46162. get gamepads(): Gamepad[];
  46163. /**
  46164. * Get the gamepad controllers based on type
  46165. * @param type The type of gamepad controller
  46166. * @returns Nullable gamepad
  46167. */
  46168. getGamepadByType(type?: number): Nullable<Gamepad>;
  46169. /**
  46170. * Disposes the gamepad manager
  46171. */
  46172. dispose(): void;
  46173. private _addNewGamepad;
  46174. private _startMonitoringGamepads;
  46175. private _stopMonitoringGamepads;
  46176. /** @hidden */
  46177. _checkGamepadsStatus(): void;
  46178. private _updateGamepadObjects;
  46179. }
  46180. }
  46181. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  46182. import { Nullable } from "babylonjs/types";
  46183. import { Scene } from "babylonjs/scene";
  46184. import { ISceneComponent } from "babylonjs/sceneComponent";
  46185. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  46186. module "babylonjs/scene" {
  46187. interface Scene {
  46188. /** @hidden */
  46189. _gamepadManager: Nullable<GamepadManager>;
  46190. /**
  46191. * Gets the gamepad manager associated with the scene
  46192. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  46193. */
  46194. gamepadManager: GamepadManager;
  46195. }
  46196. }
  46197. module "babylonjs/Cameras/freeCameraInputsManager" {
  46198. /**
  46199. * Interface representing a free camera inputs manager
  46200. */
  46201. interface FreeCameraInputsManager {
  46202. /**
  46203. * Adds gamepad input support to the FreeCameraInputsManager.
  46204. * @returns the FreeCameraInputsManager
  46205. */
  46206. addGamepad(): FreeCameraInputsManager;
  46207. }
  46208. }
  46209. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  46210. /**
  46211. * Interface representing an arc rotate camera inputs manager
  46212. */
  46213. interface ArcRotateCameraInputsManager {
  46214. /**
  46215. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46216. * @returns the camera inputs manager
  46217. */
  46218. addGamepad(): ArcRotateCameraInputsManager;
  46219. }
  46220. }
  46221. /**
  46222. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46223. */
  46224. export class GamepadSystemSceneComponent implements ISceneComponent {
  46225. /**
  46226. * The component name helpfull to identify the component in the list of scene components.
  46227. */
  46228. readonly name: string;
  46229. /**
  46230. * The scene the component belongs to.
  46231. */
  46232. scene: Scene;
  46233. /**
  46234. * Creates a new instance of the component for the given scene
  46235. * @param scene Defines the scene to register the component in
  46236. */
  46237. constructor(scene: Scene);
  46238. /**
  46239. * Registers the component in a given scene
  46240. */
  46241. register(): void;
  46242. /**
  46243. * Rebuilds the elements related to this component in case of
  46244. * context lost for instance.
  46245. */
  46246. rebuild(): void;
  46247. /**
  46248. * Disposes the component and the associated ressources
  46249. */
  46250. dispose(): void;
  46251. private _beforeCameraUpdate;
  46252. }
  46253. }
  46254. declare module "babylonjs/Cameras/universalCamera" {
  46255. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  46256. import { Scene } from "babylonjs/scene";
  46257. import { Vector3 } from "babylonjs/Maths/math.vector";
  46258. import "babylonjs/Gamepads/gamepadSceneComponent";
  46259. /**
  46260. * 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,
  46261. * which still works and will still be found in many Playgrounds.
  46262. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46263. */
  46264. export class UniversalCamera extends TouchCamera {
  46265. /**
  46266. * Defines the gamepad rotation sensiblity.
  46267. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46268. */
  46269. get gamepadAngularSensibility(): number;
  46270. set gamepadAngularSensibility(value: number);
  46271. /**
  46272. * Defines the gamepad move sensiblity.
  46273. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46274. */
  46275. get gamepadMoveSensibility(): number;
  46276. set gamepadMoveSensibility(value: number);
  46277. /**
  46278. * 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,
  46279. * which still works and will still be found in many Playgrounds.
  46280. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46281. * @param name Define the name of the camera in the scene
  46282. * @param position Define the start position of the camera in the scene
  46283. * @param scene Define the scene the camera belongs to
  46284. */
  46285. constructor(name: string, position: Vector3, scene: Scene);
  46286. /**
  46287. * Gets the current object class name.
  46288. * @return the class name
  46289. */
  46290. getClassName(): string;
  46291. }
  46292. }
  46293. declare module "babylonjs/Cameras/gamepadCamera" {
  46294. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46295. import { Scene } from "babylonjs/scene";
  46296. import { Vector3 } from "babylonjs/Maths/math.vector";
  46297. /**
  46298. * This represents a FPS type of camera. This is only here for back compat purpose.
  46299. * Please use the UniversalCamera instead as both are identical.
  46300. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46301. */
  46302. export class GamepadCamera extends UniversalCamera {
  46303. /**
  46304. * Instantiates a new Gamepad Camera
  46305. * This represents a FPS type of camera. This is only here for back compat purpose.
  46306. * Please use the UniversalCamera instead as both are identical.
  46307. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46308. * @param name Define the name of the camera in the scene
  46309. * @param position Define the start position of the camera in the scene
  46310. * @param scene Define the scene the camera belongs to
  46311. */
  46312. constructor(name: string, position: Vector3, scene: Scene);
  46313. /**
  46314. * Gets the current object class name.
  46315. * @return the class name
  46316. */
  46317. getClassName(): string;
  46318. }
  46319. }
  46320. declare module "babylonjs/Shaders/pass.fragment" {
  46321. /** @hidden */
  46322. export var passPixelShader: {
  46323. name: string;
  46324. shader: string;
  46325. };
  46326. }
  46327. declare module "babylonjs/Shaders/passCube.fragment" {
  46328. /** @hidden */
  46329. export var passCubePixelShader: {
  46330. name: string;
  46331. shader: string;
  46332. };
  46333. }
  46334. declare module "babylonjs/PostProcesses/passPostProcess" {
  46335. import { Nullable } from "babylonjs/types";
  46336. import { Camera } from "babylonjs/Cameras/camera";
  46337. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46338. import { Engine } from "babylonjs/Engines/engine";
  46339. import "babylonjs/Shaders/pass.fragment";
  46340. import "babylonjs/Shaders/passCube.fragment";
  46341. /**
  46342. * PassPostProcess which produces an output the same as it's input
  46343. */
  46344. export class PassPostProcess extends PostProcess {
  46345. /**
  46346. * Creates the PassPostProcess
  46347. * @param name The name of the effect.
  46348. * @param options The required width/height ratio to downsize to before computing the render pass.
  46349. * @param camera The camera to apply the render pass to.
  46350. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46351. * @param engine The engine which the post process will be applied. (default: current engine)
  46352. * @param reusable If the post process can be reused on the same frame. (default: false)
  46353. * @param textureType The type of texture to be used when performing the post processing.
  46354. * @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)
  46355. */
  46356. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46357. }
  46358. /**
  46359. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46360. */
  46361. export class PassCubePostProcess extends PostProcess {
  46362. private _face;
  46363. /**
  46364. * Gets or sets the cube face to display.
  46365. * * 0 is +X
  46366. * * 1 is -X
  46367. * * 2 is +Y
  46368. * * 3 is -Y
  46369. * * 4 is +Z
  46370. * * 5 is -Z
  46371. */
  46372. get face(): number;
  46373. set face(value: number);
  46374. /**
  46375. * Creates the PassCubePostProcess
  46376. * @param name The name of the effect.
  46377. * @param options The required width/height ratio to downsize to before computing the render pass.
  46378. * @param camera The camera to apply the render pass to.
  46379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46380. * @param engine The engine which the post process will be applied. (default: current engine)
  46381. * @param reusable If the post process can be reused on the same frame. (default: false)
  46382. * @param textureType The type of texture to be used when performing the post processing.
  46383. * @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)
  46384. */
  46385. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46386. }
  46387. }
  46388. declare module "babylonjs/Shaders/anaglyph.fragment" {
  46389. /** @hidden */
  46390. export var anaglyphPixelShader: {
  46391. name: string;
  46392. shader: string;
  46393. };
  46394. }
  46395. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  46396. import { Engine } from "babylonjs/Engines/engine";
  46397. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46398. import { Camera } from "babylonjs/Cameras/camera";
  46399. import "babylonjs/Shaders/anaglyph.fragment";
  46400. /**
  46401. * Postprocess used to generate anaglyphic rendering
  46402. */
  46403. export class AnaglyphPostProcess extends PostProcess {
  46404. private _passedProcess;
  46405. /**
  46406. * Creates a new AnaglyphPostProcess
  46407. * @param name defines postprocess name
  46408. * @param options defines creation options or target ratio scale
  46409. * @param rigCameras defines cameras using this postprocess
  46410. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46411. * @param engine defines hosting engine
  46412. * @param reusable defines if the postprocess will be reused multiple times per frame
  46413. */
  46414. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46415. }
  46416. }
  46417. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  46418. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  46419. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46420. import { Scene } from "babylonjs/scene";
  46421. import { Vector3 } from "babylonjs/Maths/math.vector";
  46422. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46423. /**
  46424. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46425. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46426. */
  46427. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46428. /**
  46429. * Creates a new AnaglyphArcRotateCamera
  46430. * @param name defines camera name
  46431. * @param alpha defines alpha angle (in radians)
  46432. * @param beta defines beta angle (in radians)
  46433. * @param radius defines radius
  46434. * @param target defines camera target
  46435. * @param interaxialDistance defines distance between each color axis
  46436. * @param scene defines the hosting scene
  46437. */
  46438. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46439. /**
  46440. * Gets camera class name
  46441. * @returns AnaglyphArcRotateCamera
  46442. */
  46443. getClassName(): string;
  46444. }
  46445. }
  46446. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  46447. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46448. import { Scene } from "babylonjs/scene";
  46449. import { Vector3 } from "babylonjs/Maths/math.vector";
  46450. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46451. /**
  46452. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46453. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46454. */
  46455. export class AnaglyphFreeCamera extends FreeCamera {
  46456. /**
  46457. * Creates a new AnaglyphFreeCamera
  46458. * @param name defines camera name
  46459. * @param position defines initial position
  46460. * @param interaxialDistance defines distance between each color axis
  46461. * @param scene defines the hosting scene
  46462. */
  46463. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46464. /**
  46465. * Gets camera class name
  46466. * @returns AnaglyphFreeCamera
  46467. */
  46468. getClassName(): string;
  46469. }
  46470. }
  46471. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  46472. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46473. import { Scene } from "babylonjs/scene";
  46474. import { Vector3 } from "babylonjs/Maths/math.vector";
  46475. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46476. /**
  46477. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46478. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46479. */
  46480. export class AnaglyphGamepadCamera extends GamepadCamera {
  46481. /**
  46482. * Creates a new AnaglyphGamepadCamera
  46483. * @param name defines camera name
  46484. * @param position defines initial position
  46485. * @param interaxialDistance defines distance between each color axis
  46486. * @param scene defines the hosting scene
  46487. */
  46488. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46489. /**
  46490. * Gets camera class name
  46491. * @returns AnaglyphGamepadCamera
  46492. */
  46493. getClassName(): string;
  46494. }
  46495. }
  46496. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  46497. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46498. import { Scene } from "babylonjs/scene";
  46499. import { Vector3 } from "babylonjs/Maths/math.vector";
  46500. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46501. /**
  46502. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46503. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46504. */
  46505. export class AnaglyphUniversalCamera extends UniversalCamera {
  46506. /**
  46507. * Creates a new AnaglyphUniversalCamera
  46508. * @param name defines camera name
  46509. * @param position defines initial position
  46510. * @param interaxialDistance defines distance between each color axis
  46511. * @param scene defines the hosting scene
  46512. */
  46513. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46514. /**
  46515. * Gets camera class name
  46516. * @returns AnaglyphUniversalCamera
  46517. */
  46518. getClassName(): string;
  46519. }
  46520. }
  46521. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  46522. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  46523. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46524. import { Scene } from "babylonjs/scene";
  46525. import { Vector3 } from "babylonjs/Maths/math.vector";
  46526. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46527. /**
  46528. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46529. * @see http://doc.babylonjs.com/features/cameras
  46530. */
  46531. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46532. /**
  46533. * Creates a new StereoscopicArcRotateCamera
  46534. * @param name defines camera name
  46535. * @param alpha defines alpha angle (in radians)
  46536. * @param beta defines beta angle (in radians)
  46537. * @param radius defines radius
  46538. * @param target defines camera target
  46539. * @param interaxialDistance defines distance between each color axis
  46540. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46541. * @param scene defines the hosting scene
  46542. */
  46543. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46544. /**
  46545. * Gets camera class name
  46546. * @returns StereoscopicArcRotateCamera
  46547. */
  46548. getClassName(): string;
  46549. }
  46550. }
  46551. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  46552. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46553. import { Scene } from "babylonjs/scene";
  46554. import { Vector3 } from "babylonjs/Maths/math.vector";
  46555. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46556. /**
  46557. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46558. * @see http://doc.babylonjs.com/features/cameras
  46559. */
  46560. export class StereoscopicFreeCamera extends FreeCamera {
  46561. /**
  46562. * Creates a new StereoscopicFreeCamera
  46563. * @param name defines camera name
  46564. * @param position defines initial position
  46565. * @param interaxialDistance defines distance between each color axis
  46566. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46567. * @param scene defines the hosting scene
  46568. */
  46569. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46570. /**
  46571. * Gets camera class name
  46572. * @returns StereoscopicFreeCamera
  46573. */
  46574. getClassName(): string;
  46575. }
  46576. }
  46577. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  46578. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46579. import { Scene } from "babylonjs/scene";
  46580. import { Vector3 } from "babylonjs/Maths/math.vector";
  46581. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46582. /**
  46583. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46584. * @see http://doc.babylonjs.com/features/cameras
  46585. */
  46586. export class StereoscopicGamepadCamera extends GamepadCamera {
  46587. /**
  46588. * Creates a new StereoscopicGamepadCamera
  46589. * @param name defines camera name
  46590. * @param position defines initial position
  46591. * @param interaxialDistance defines distance between each color axis
  46592. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46593. * @param scene defines the hosting scene
  46594. */
  46595. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46596. /**
  46597. * Gets camera class name
  46598. * @returns StereoscopicGamepadCamera
  46599. */
  46600. getClassName(): string;
  46601. }
  46602. }
  46603. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  46604. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46605. import { Scene } from "babylonjs/scene";
  46606. import { Vector3 } from "babylonjs/Maths/math.vector";
  46607. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46608. /**
  46609. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46610. * @see http://doc.babylonjs.com/features/cameras
  46611. */
  46612. export class StereoscopicUniversalCamera extends UniversalCamera {
  46613. /**
  46614. * Creates a new StereoscopicUniversalCamera
  46615. * @param name defines camera name
  46616. * @param position defines initial position
  46617. * @param interaxialDistance defines distance between each color axis
  46618. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46619. * @param scene defines the hosting scene
  46620. */
  46621. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46622. /**
  46623. * Gets camera class name
  46624. * @returns StereoscopicUniversalCamera
  46625. */
  46626. getClassName(): string;
  46627. }
  46628. }
  46629. declare module "babylonjs/Cameras/Stereoscopic/index" {
  46630. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  46631. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  46632. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  46633. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  46634. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  46635. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  46636. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  46637. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  46638. }
  46639. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  46640. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46641. import { Scene } from "babylonjs/scene";
  46642. import { Vector3 } from "babylonjs/Maths/math.vector";
  46643. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46644. /**
  46645. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46646. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46647. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46648. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46649. */
  46650. export class VirtualJoysticksCamera extends FreeCamera {
  46651. /**
  46652. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46653. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46654. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46655. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46656. * @param name Define the name of the camera in the scene
  46657. * @param position Define the start position of the camera in the scene
  46658. * @param scene Define the scene the camera belongs to
  46659. */
  46660. constructor(name: string, position: Vector3, scene: Scene);
  46661. /**
  46662. * Gets the current object class name.
  46663. * @return the class name
  46664. */
  46665. getClassName(): string;
  46666. }
  46667. }
  46668. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  46669. import { Matrix } from "babylonjs/Maths/math.vector";
  46670. /**
  46671. * This represents all the required metrics to create a VR camera.
  46672. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46673. */
  46674. export class VRCameraMetrics {
  46675. /**
  46676. * Define the horizontal resolution off the screen.
  46677. */
  46678. hResolution: number;
  46679. /**
  46680. * Define the vertical resolution off the screen.
  46681. */
  46682. vResolution: number;
  46683. /**
  46684. * Define the horizontal screen size.
  46685. */
  46686. hScreenSize: number;
  46687. /**
  46688. * Define the vertical screen size.
  46689. */
  46690. vScreenSize: number;
  46691. /**
  46692. * Define the vertical screen center position.
  46693. */
  46694. vScreenCenter: number;
  46695. /**
  46696. * Define the distance of the eyes to the screen.
  46697. */
  46698. eyeToScreenDistance: number;
  46699. /**
  46700. * Define the distance between both lenses
  46701. */
  46702. lensSeparationDistance: number;
  46703. /**
  46704. * Define the distance between both viewer's eyes.
  46705. */
  46706. interpupillaryDistance: number;
  46707. /**
  46708. * Define the distortion factor of the VR postprocess.
  46709. * Please, touch with care.
  46710. */
  46711. distortionK: number[];
  46712. /**
  46713. * Define the chromatic aberration correction factors for the VR post process.
  46714. */
  46715. chromaAbCorrection: number[];
  46716. /**
  46717. * Define the scale factor of the post process.
  46718. * The smaller the better but the slower.
  46719. */
  46720. postProcessScaleFactor: number;
  46721. /**
  46722. * Define an offset for the lens center.
  46723. */
  46724. lensCenterOffset: number;
  46725. /**
  46726. * Define if the current vr camera should compensate the distortion of the lense or not.
  46727. */
  46728. compensateDistortion: boolean;
  46729. /**
  46730. * Defines if multiview should be enabled when rendering (Default: false)
  46731. */
  46732. multiviewEnabled: boolean;
  46733. /**
  46734. * Gets the rendering aspect ratio based on the provided resolutions.
  46735. */
  46736. get aspectRatio(): number;
  46737. /**
  46738. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46739. */
  46740. get aspectRatioFov(): number;
  46741. /**
  46742. * @hidden
  46743. */
  46744. get leftHMatrix(): Matrix;
  46745. /**
  46746. * @hidden
  46747. */
  46748. get rightHMatrix(): Matrix;
  46749. /**
  46750. * @hidden
  46751. */
  46752. get leftPreViewMatrix(): Matrix;
  46753. /**
  46754. * @hidden
  46755. */
  46756. get rightPreViewMatrix(): Matrix;
  46757. /**
  46758. * Get the default VRMetrics based on the most generic setup.
  46759. * @returns the default vr metrics
  46760. */
  46761. static GetDefault(): VRCameraMetrics;
  46762. }
  46763. }
  46764. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  46765. /** @hidden */
  46766. export var vrDistortionCorrectionPixelShader: {
  46767. name: string;
  46768. shader: string;
  46769. };
  46770. }
  46771. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  46772. import { Camera } from "babylonjs/Cameras/camera";
  46773. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46774. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  46775. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  46776. /**
  46777. * VRDistortionCorrectionPostProcess used for mobile VR
  46778. */
  46779. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46780. private _isRightEye;
  46781. private _distortionFactors;
  46782. private _postProcessScaleFactor;
  46783. private _lensCenterOffset;
  46784. private _scaleIn;
  46785. private _scaleFactor;
  46786. private _lensCenter;
  46787. /**
  46788. * Initializes the VRDistortionCorrectionPostProcess
  46789. * @param name The name of the effect.
  46790. * @param camera The camera to apply the render pass to.
  46791. * @param isRightEye If this is for the right eye distortion
  46792. * @param vrMetrics All the required metrics for the VR camera
  46793. */
  46794. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46795. }
  46796. }
  46797. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  46798. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  46799. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46800. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46801. import { Scene } from "babylonjs/scene";
  46802. import { Vector3 } from "babylonjs/Maths/math.vector";
  46803. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  46804. import "babylonjs/Cameras/RigModes/vrRigMode";
  46805. /**
  46806. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46807. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46808. */
  46809. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46810. /**
  46811. * Creates a new VRDeviceOrientationArcRotateCamera
  46812. * @param name defines camera name
  46813. * @param alpha defines the camera rotation along the logitudinal axis
  46814. * @param beta defines the camera rotation along the latitudinal axis
  46815. * @param radius defines the camera distance from its target
  46816. * @param target defines the camera target
  46817. * @param scene defines the scene the camera belongs to
  46818. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46819. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46820. */
  46821. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46822. /**
  46823. * Gets camera class name
  46824. * @returns VRDeviceOrientationArcRotateCamera
  46825. */
  46826. getClassName(): string;
  46827. }
  46828. }
  46829. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  46830. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46831. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46832. import { Scene } from "babylonjs/scene";
  46833. import { Vector3 } from "babylonjs/Maths/math.vector";
  46834. import "babylonjs/Cameras/RigModes/vrRigMode";
  46835. /**
  46836. * Camera used to simulate VR rendering (based on FreeCamera)
  46837. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46838. */
  46839. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46840. /**
  46841. * Creates a new VRDeviceOrientationFreeCamera
  46842. * @param name defines camera name
  46843. * @param position defines the start position of the camera
  46844. * @param scene defines the scene the camera belongs to
  46845. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46846. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46847. */
  46848. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46849. /**
  46850. * Gets camera class name
  46851. * @returns VRDeviceOrientationFreeCamera
  46852. */
  46853. getClassName(): string;
  46854. }
  46855. }
  46856. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  46857. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46858. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46859. import { Scene } from "babylonjs/scene";
  46860. import { Vector3 } from "babylonjs/Maths/math.vector";
  46861. import "babylonjs/Gamepads/gamepadSceneComponent";
  46862. /**
  46863. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46864. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46865. */
  46866. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46867. /**
  46868. * Creates a new VRDeviceOrientationGamepadCamera
  46869. * @param name defines camera name
  46870. * @param position defines the start position of the camera
  46871. * @param scene defines the scene the camera belongs to
  46872. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46873. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46874. */
  46875. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46876. /**
  46877. * Gets camera class name
  46878. * @returns VRDeviceOrientationGamepadCamera
  46879. */
  46880. getClassName(): string;
  46881. }
  46882. }
  46883. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  46884. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46885. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46886. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46887. /** @hidden */
  46888. export var imageProcessingPixelShader: {
  46889. name: string;
  46890. shader: string;
  46891. };
  46892. }
  46893. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  46894. import { Nullable } from "babylonjs/types";
  46895. import { Color4 } from "babylonjs/Maths/math.color";
  46896. import { Camera } from "babylonjs/Cameras/camera";
  46897. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46898. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46899. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46900. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46901. import { Engine } from "babylonjs/Engines/engine";
  46902. import "babylonjs/Shaders/imageProcessing.fragment";
  46903. import "babylonjs/Shaders/postprocess.vertex";
  46904. /**
  46905. * ImageProcessingPostProcess
  46906. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  46907. */
  46908. export class ImageProcessingPostProcess extends PostProcess {
  46909. /**
  46910. * Default configuration related to image processing available in the PBR Material.
  46911. */
  46912. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46913. /**
  46914. * Gets the image processing configuration used either in this material.
  46915. */
  46916. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  46917. /**
  46918. * Sets the Default image processing configuration used either in the this material.
  46919. *
  46920. * If sets to null, the scene one is in use.
  46921. */
  46922. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  46923. /**
  46924. * Keep track of the image processing observer to allow dispose and replace.
  46925. */
  46926. private _imageProcessingObserver;
  46927. /**
  46928. * Attaches a new image processing configuration to the PBR Material.
  46929. * @param configuration
  46930. */
  46931. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  46932. /**
  46933. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  46934. */
  46935. get colorCurves(): Nullable<ColorCurves>;
  46936. /**
  46937. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  46938. */
  46939. set colorCurves(value: Nullable<ColorCurves>);
  46940. /**
  46941. * Gets wether the color curves effect is enabled.
  46942. */
  46943. get colorCurvesEnabled(): boolean;
  46944. /**
  46945. * Sets wether the color curves effect is enabled.
  46946. */
  46947. set colorCurvesEnabled(value: boolean);
  46948. /**
  46949. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  46950. */
  46951. get colorGradingTexture(): Nullable<BaseTexture>;
  46952. /**
  46953. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  46954. */
  46955. set colorGradingTexture(value: Nullable<BaseTexture>);
  46956. /**
  46957. * Gets wether the color grading effect is enabled.
  46958. */
  46959. get colorGradingEnabled(): boolean;
  46960. /**
  46961. * Gets wether the color grading effect is enabled.
  46962. */
  46963. set colorGradingEnabled(value: boolean);
  46964. /**
  46965. * Gets exposure used in the effect.
  46966. */
  46967. get exposure(): number;
  46968. /**
  46969. * Sets exposure used in the effect.
  46970. */
  46971. set exposure(value: number);
  46972. /**
  46973. * Gets wether tonemapping is enabled or not.
  46974. */
  46975. get toneMappingEnabled(): boolean;
  46976. /**
  46977. * Sets wether tonemapping is enabled or not
  46978. */
  46979. set toneMappingEnabled(value: boolean);
  46980. /**
  46981. * Gets the type of tone mapping effect.
  46982. */
  46983. get toneMappingType(): number;
  46984. /**
  46985. * Sets the type of tone mapping effect.
  46986. */
  46987. set toneMappingType(value: number);
  46988. /**
  46989. * Gets contrast used in the effect.
  46990. */
  46991. get contrast(): number;
  46992. /**
  46993. * Sets contrast used in the effect.
  46994. */
  46995. set contrast(value: number);
  46996. /**
  46997. * Gets Vignette stretch size.
  46998. */
  46999. get vignetteStretch(): number;
  47000. /**
  47001. * Sets Vignette stretch size.
  47002. */
  47003. set vignetteStretch(value: number);
  47004. /**
  47005. * Gets Vignette centre X Offset.
  47006. */
  47007. get vignetteCentreX(): number;
  47008. /**
  47009. * Sets Vignette centre X Offset.
  47010. */
  47011. set vignetteCentreX(value: number);
  47012. /**
  47013. * Gets Vignette centre Y Offset.
  47014. */
  47015. get vignetteCentreY(): number;
  47016. /**
  47017. * Sets Vignette centre Y Offset.
  47018. */
  47019. set vignetteCentreY(value: number);
  47020. /**
  47021. * Gets Vignette weight or intensity of the vignette effect.
  47022. */
  47023. get vignetteWeight(): number;
  47024. /**
  47025. * Sets Vignette weight or intensity of the vignette effect.
  47026. */
  47027. set vignetteWeight(value: number);
  47028. /**
  47029. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47030. * if vignetteEnabled is set to true.
  47031. */
  47032. get vignetteColor(): Color4;
  47033. /**
  47034. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47035. * if vignetteEnabled is set to true.
  47036. */
  47037. set vignetteColor(value: Color4);
  47038. /**
  47039. * Gets Camera field of view used by the Vignette effect.
  47040. */
  47041. get vignetteCameraFov(): number;
  47042. /**
  47043. * Sets Camera field of view used by the Vignette effect.
  47044. */
  47045. set vignetteCameraFov(value: number);
  47046. /**
  47047. * Gets the vignette blend mode allowing different kind of effect.
  47048. */
  47049. get vignetteBlendMode(): number;
  47050. /**
  47051. * Sets the vignette blend mode allowing different kind of effect.
  47052. */
  47053. set vignetteBlendMode(value: number);
  47054. /**
  47055. * Gets wether the vignette effect is enabled.
  47056. */
  47057. get vignetteEnabled(): boolean;
  47058. /**
  47059. * Sets wether the vignette effect is enabled.
  47060. */
  47061. set vignetteEnabled(value: boolean);
  47062. private _fromLinearSpace;
  47063. /**
  47064. * Gets wether the input of the processing is in Gamma or Linear Space.
  47065. */
  47066. get fromLinearSpace(): boolean;
  47067. /**
  47068. * Sets wether the input of the processing is in Gamma or Linear Space.
  47069. */
  47070. set fromLinearSpace(value: boolean);
  47071. /**
  47072. * Defines cache preventing GC.
  47073. */
  47074. private _defines;
  47075. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  47076. /**
  47077. * "ImageProcessingPostProcess"
  47078. * @returns "ImageProcessingPostProcess"
  47079. */
  47080. getClassName(): string;
  47081. protected _updateParameters(): void;
  47082. dispose(camera?: Camera): void;
  47083. }
  47084. }
  47085. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  47086. import { Scene } from "babylonjs/scene";
  47087. import { Color3 } from "babylonjs/Maths/math.color";
  47088. import { Mesh } from "babylonjs/Meshes/mesh";
  47089. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  47090. import { Nullable } from "babylonjs/types";
  47091. /**
  47092. * Class containing static functions to help procedurally build meshes
  47093. */
  47094. export class GroundBuilder {
  47095. /**
  47096. * Creates a ground mesh
  47097. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  47098. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  47099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47100. * @param name defines the name of the mesh
  47101. * @param options defines the options used to create the mesh
  47102. * @param scene defines the hosting scene
  47103. * @returns the ground mesh
  47104. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  47105. */
  47106. static CreateGround(name: string, options: {
  47107. width?: number;
  47108. height?: number;
  47109. subdivisions?: number;
  47110. subdivisionsX?: number;
  47111. subdivisionsY?: number;
  47112. updatable?: boolean;
  47113. }, scene: any): Mesh;
  47114. /**
  47115. * Creates a tiled ground mesh
  47116. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  47117. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  47118. * * 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
  47119. * * 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
  47120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47121. * @param name defines the name of the mesh
  47122. * @param options defines the options used to create the mesh
  47123. * @param scene defines the hosting scene
  47124. * @returns the tiled ground mesh
  47125. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  47126. */
  47127. static CreateTiledGround(name: string, options: {
  47128. xmin: number;
  47129. zmin: number;
  47130. xmax: number;
  47131. zmax: number;
  47132. subdivisions?: {
  47133. w: number;
  47134. h: number;
  47135. };
  47136. precision?: {
  47137. w: number;
  47138. h: number;
  47139. };
  47140. updatable?: boolean;
  47141. }, scene?: Nullable<Scene>): Mesh;
  47142. /**
  47143. * Creates a ground mesh from a height map
  47144. * * The parameter `url` sets the URL of the height map image resource.
  47145. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  47146. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  47147. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  47148. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  47149. * * 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.
  47150. * * 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).
  47151. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  47152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47153. * @param name defines the name of the mesh
  47154. * @param url defines the url to the height map
  47155. * @param options defines the options used to create the mesh
  47156. * @param scene defines the hosting scene
  47157. * @returns the ground mesh
  47158. * @see https://doc.babylonjs.com/babylon101/height_map
  47159. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  47160. */
  47161. static CreateGroundFromHeightMap(name: string, url: string, options: {
  47162. width?: number;
  47163. height?: number;
  47164. subdivisions?: number;
  47165. minHeight?: number;
  47166. maxHeight?: number;
  47167. colorFilter?: Color3;
  47168. alphaFilter?: number;
  47169. updatable?: boolean;
  47170. onReady?: (mesh: GroundMesh) => void;
  47171. }, scene?: Nullable<Scene>): GroundMesh;
  47172. }
  47173. }
  47174. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  47175. import { Vector4 } from "babylonjs/Maths/math.vector";
  47176. import { Mesh } from "babylonjs/Meshes/mesh";
  47177. /**
  47178. * Class containing static functions to help procedurally build meshes
  47179. */
  47180. export class TorusBuilder {
  47181. /**
  47182. * Creates a torus mesh
  47183. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  47184. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  47185. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  47186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47189. * @param name defines the name of the mesh
  47190. * @param options defines the options used to create the mesh
  47191. * @param scene defines the hosting scene
  47192. * @returns the torus mesh
  47193. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  47194. */
  47195. static CreateTorus(name: string, options: {
  47196. diameter?: number;
  47197. thickness?: number;
  47198. tessellation?: number;
  47199. updatable?: boolean;
  47200. sideOrientation?: number;
  47201. frontUVs?: Vector4;
  47202. backUVs?: Vector4;
  47203. }, scene: any): Mesh;
  47204. }
  47205. }
  47206. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  47207. import { Vector4 } from "babylonjs/Maths/math.vector";
  47208. import { Color4 } from "babylonjs/Maths/math.color";
  47209. import { Mesh } from "babylonjs/Meshes/mesh";
  47210. /**
  47211. * Class containing static functions to help procedurally build meshes
  47212. */
  47213. export class CylinderBuilder {
  47214. /**
  47215. * Creates a cylinder or a cone mesh
  47216. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  47217. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  47218. * * 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.
  47219. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  47220. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  47221. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  47222. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  47223. * * 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).
  47224. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  47225. * * 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).
  47226. * * 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
  47227. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  47228. * * 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
  47229. * * 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.
  47230. * * If `enclose` is false, a ring surface is one element.
  47231. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  47232. * * 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
  47233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47234. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47236. * @param name defines the name of the mesh
  47237. * @param options defines the options used to create the mesh
  47238. * @param scene defines the hosting scene
  47239. * @returns the cylinder mesh
  47240. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  47241. */
  47242. static CreateCylinder(name: string, options: {
  47243. height?: number;
  47244. diameterTop?: number;
  47245. diameterBottom?: number;
  47246. diameter?: number;
  47247. tessellation?: number;
  47248. subdivisions?: number;
  47249. arc?: number;
  47250. faceColors?: Color4[];
  47251. faceUV?: Vector4[];
  47252. updatable?: boolean;
  47253. hasRings?: boolean;
  47254. enclose?: boolean;
  47255. cap?: number;
  47256. sideOrientation?: number;
  47257. frontUVs?: Vector4;
  47258. backUVs?: Vector4;
  47259. }, scene: any): Mesh;
  47260. }
  47261. }
  47262. declare module "babylonjs/XR/webXRTypes" {
  47263. import { Nullable } from "babylonjs/types";
  47264. import { IDisposable } from "babylonjs/scene";
  47265. /**
  47266. * States of the webXR experience
  47267. */
  47268. export enum WebXRState {
  47269. /**
  47270. * Transitioning to being in XR mode
  47271. */
  47272. ENTERING_XR = 0,
  47273. /**
  47274. * Transitioning to non XR mode
  47275. */
  47276. EXITING_XR = 1,
  47277. /**
  47278. * In XR mode and presenting
  47279. */
  47280. IN_XR = 2,
  47281. /**
  47282. * Not entered XR mode
  47283. */
  47284. NOT_IN_XR = 3
  47285. }
  47286. /**
  47287. * Abstraction of the XR render target
  47288. */
  47289. export interface WebXRRenderTarget extends IDisposable {
  47290. /**
  47291. * xrpresent context of the canvas which can be used to display/mirror xr content
  47292. */
  47293. canvasContext: WebGLRenderingContext;
  47294. /**
  47295. * xr layer for the canvas
  47296. */
  47297. xrLayer: Nullable<XRWebGLLayer>;
  47298. /**
  47299. * Initializes the xr layer for the session
  47300. * @param xrSession xr session
  47301. * @returns a promise that will resolve once the XR Layer has been created
  47302. */
  47303. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47304. }
  47305. }
  47306. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  47307. import { Nullable } from "babylonjs/types";
  47308. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47309. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47310. /**
  47311. * COnfiguration object for WebXR output canvas
  47312. */
  47313. export class WebXRManagedOutputCanvasOptions {
  47314. /**
  47315. * An optional canvas in case you wish to create it yourself and provide it here.
  47316. * If not provided, a new canvas will be created
  47317. */
  47318. canvasElement?: HTMLCanvasElement;
  47319. /**
  47320. * Options for this XR Layer output
  47321. */
  47322. canvasOptions?: XRWebGLLayerOptions;
  47323. /**
  47324. * CSS styling for a newly created canvas (if not provided)
  47325. */
  47326. newCanvasCssStyle?: string;
  47327. /**
  47328. * Get the default values of the configuration object
  47329. * @returns default values of this configuration object
  47330. */
  47331. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  47332. }
  47333. /**
  47334. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  47335. */
  47336. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  47337. private _options;
  47338. private _canvas;
  47339. private _engine;
  47340. /**
  47341. * Rendering context of the canvas which can be used to display/mirror xr content
  47342. */
  47343. canvasContext: WebGLRenderingContext;
  47344. /**
  47345. * xr layer for the canvas
  47346. */
  47347. xrLayer: Nullable<XRWebGLLayer>;
  47348. /**
  47349. * Initializes the canvas to be added/removed upon entering/exiting xr
  47350. * @param _xrSessionManager The XR Session manager
  47351. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  47352. */
  47353. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  47354. /**
  47355. * Disposes of the object
  47356. */
  47357. dispose(): void;
  47358. /**
  47359. * Initializes the xr layer for the session
  47360. * @param xrSession xr session
  47361. * @returns a promise that will resolve once the XR Layer has been created
  47362. */
  47363. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47364. private _addCanvas;
  47365. private _removeCanvas;
  47366. private _setManagedOutputCanvas;
  47367. }
  47368. }
  47369. declare module "babylonjs/XR/webXRSessionManager" {
  47370. import { Observable } from "babylonjs/Misc/observable";
  47371. import { Nullable } from "babylonjs/types";
  47372. import { IDisposable, Scene } from "babylonjs/scene";
  47373. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47374. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47375. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47376. /**
  47377. * Manages an XRSession to work with Babylon's engine
  47378. * @see https://doc.babylonjs.com/how_to/webxr
  47379. */
  47380. export class WebXRSessionManager implements IDisposable {
  47381. /** The scene which the session should be created for */
  47382. scene: Scene;
  47383. private _referenceSpace;
  47384. private _rttProvider;
  47385. private _sessionEnded;
  47386. private _xrNavigator;
  47387. private baseLayer;
  47388. /**
  47389. * The base reference space from which the session started. good if you want to reset your
  47390. * reference space
  47391. */
  47392. baseReferenceSpace: XRReferenceSpace;
  47393. /**
  47394. * Current XR frame
  47395. */
  47396. currentFrame: Nullable<XRFrame>;
  47397. /** WebXR timestamp updated every frame */
  47398. currentTimestamp: number;
  47399. /**
  47400. * Used just in case of a failure to initialize an immersive session.
  47401. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47402. */
  47403. defaultHeightCompensation: number;
  47404. /**
  47405. * Fires every time a new xrFrame arrives which can be used to update the camera
  47406. */
  47407. onXRFrameObservable: Observable<XRFrame>;
  47408. /**
  47409. * Fires when the reference space changed
  47410. */
  47411. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47412. /**
  47413. * Fires when the xr session is ended either by the device or manually done
  47414. */
  47415. onXRSessionEnded: Observable<any>;
  47416. /**
  47417. * Fires when the xr session is ended either by the device or manually done
  47418. */
  47419. onXRSessionInit: Observable<XRSession>;
  47420. /**
  47421. * Underlying xr session
  47422. */
  47423. session: XRSession;
  47424. /**
  47425. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47426. * or get the offset the player is currently at.
  47427. */
  47428. viewerReferenceSpace: XRReferenceSpace;
  47429. /**
  47430. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47431. * @param scene The scene which the session should be created for
  47432. */
  47433. constructor(
  47434. /** The scene which the session should be created for */
  47435. scene: Scene);
  47436. /**
  47437. * The current reference space used in this session. This reference space can constantly change!
  47438. * It is mainly used to offset the camera's position.
  47439. */
  47440. get referenceSpace(): XRReferenceSpace;
  47441. /**
  47442. * Set a new reference space and triggers the observable
  47443. */
  47444. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47445. /**
  47446. * Disposes of the session manager
  47447. */
  47448. dispose(): void;
  47449. /**
  47450. * Stops the xrSession and restores the render loop
  47451. * @returns Promise which resolves after it exits XR
  47452. */
  47453. exitXRAsync(): Promise<void>;
  47454. /**
  47455. * Gets the correct render target texture to be rendered this frame for this eye
  47456. * @param eye the eye for which to get the render target
  47457. * @returns the render target for the specified eye
  47458. */
  47459. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47460. /**
  47461. * Creates a WebXRRenderTarget object for the XR session
  47462. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47463. * @param options optional options to provide when creating a new render target
  47464. * @returns a WebXR render target to which the session can render
  47465. */
  47466. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47467. /**
  47468. * Initializes the manager
  47469. * After initialization enterXR can be called to start an XR session
  47470. * @returns Promise which resolves after it is initialized
  47471. */
  47472. initializeAsync(): Promise<void>;
  47473. /**
  47474. * Initializes an xr session
  47475. * @param xrSessionMode mode to initialize
  47476. * @param xrSessionInit defines optional and required values to pass to the session builder
  47477. * @returns a promise which will resolve once the session has been initialized
  47478. */
  47479. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47480. /**
  47481. * Checks if a session would be supported for the creation options specified
  47482. * @param sessionMode session mode to check if supported eg. immersive-vr
  47483. * @returns A Promise that resolves to true if supported and false if not
  47484. */
  47485. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47486. /**
  47487. * Resets the reference space to the one started the session
  47488. */
  47489. resetReferenceSpace(): void;
  47490. /**
  47491. * Starts rendering to the xr layer
  47492. */
  47493. runXRRenderLoop(): void;
  47494. /**
  47495. * Sets the reference space on the xr session
  47496. * @param referenceSpaceType space to set
  47497. * @returns a promise that will resolve once the reference space has been set
  47498. */
  47499. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47500. /**
  47501. * Updates the render state of the session
  47502. * @param state state to set
  47503. * @returns a promise that resolves once the render state has been updated
  47504. */
  47505. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47506. /**
  47507. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47508. * @param sessionMode defines the session to test
  47509. * @returns a promise with boolean as final value
  47510. */
  47511. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47512. private _createRenderTargetTexture;
  47513. }
  47514. }
  47515. declare module "babylonjs/XR/webXRCamera" {
  47516. import { Matrix } from "babylonjs/Maths/math.vector";
  47517. import { Scene } from "babylonjs/scene";
  47518. import { Camera } from "babylonjs/Cameras/camera";
  47519. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47520. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47521. /**
  47522. * WebXR Camera which holds the views for the xrSession
  47523. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47524. */
  47525. export class WebXRCamera extends FreeCamera {
  47526. private _xrSessionManager;
  47527. private _firstFrame;
  47528. private _referenceQuaternion;
  47529. private _referencedPosition;
  47530. private _xrInvPositionCache;
  47531. private _xrInvQuaternionCache;
  47532. /**
  47533. * Should position compensation execute on first frame.
  47534. * This is used when copying the position from a native (non XR) camera
  47535. */
  47536. compensateOnFirstFrame: boolean;
  47537. /**
  47538. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47539. * @param name the name of the camera
  47540. * @param scene the scene to add the camera to
  47541. * @param _xrSessionManager a constructed xr session manager
  47542. */
  47543. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47544. /**
  47545. * Return the user's height, unrelated to the current ground.
  47546. * This will be the y position of this camera, when ground level is 0.
  47547. */
  47548. get realWorldHeight(): number;
  47549. /** @hidden */
  47550. _updateForDualEyeDebugging(): void;
  47551. /**
  47552. * Sets this camera's transformation based on a non-vr camera
  47553. * @param otherCamera the non-vr camera to copy the transformation from
  47554. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47555. */
  47556. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47557. /**
  47558. * Gets the current instance class name ("WebXRCamera").
  47559. * @returns the class name
  47560. */
  47561. getClassName(): string;
  47562. /**
  47563. * Overriding the _getViewMatrix function, as it is computed by WebXR
  47564. */
  47565. _getViewMatrix(): Matrix;
  47566. private _updateFromXRSession;
  47567. private _updateNumberOfRigCameras;
  47568. private _updateReferenceSpace;
  47569. private _updateReferenceSpaceOffset;
  47570. }
  47571. }
  47572. declare module "babylonjs/XR/webXRFeaturesManager" {
  47573. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47574. import { IDisposable } from "babylonjs/scene";
  47575. /**
  47576. * Defining the interface required for a (webxr) feature
  47577. */
  47578. export interface IWebXRFeature extends IDisposable {
  47579. /**
  47580. * Is this feature attached
  47581. */
  47582. attached: boolean;
  47583. /**
  47584. * Should auto-attach be disabled?
  47585. */
  47586. disableAutoAttach: boolean;
  47587. /**
  47588. * Attach the feature to the session
  47589. * Will usually be called by the features manager
  47590. *
  47591. * @param force should attachment be forced (even when already attached)
  47592. * @returns true if successful.
  47593. */
  47594. attach(force?: boolean): boolean;
  47595. /**
  47596. * Detach the feature from the session
  47597. * Will usually be called by the features manager
  47598. *
  47599. * @returns true if successful.
  47600. */
  47601. detach(): boolean;
  47602. }
  47603. /**
  47604. * A list of the currently available features without referencing them
  47605. */
  47606. export class WebXRFeatureName {
  47607. /**
  47608. * The name of the anchor system feature
  47609. */
  47610. static ANCHOR_SYSTEM: string;
  47611. /**
  47612. * The name of the background remover feature
  47613. */
  47614. static BACKGROUND_REMOVER: string;
  47615. /**
  47616. * The name of the hit test feature
  47617. */
  47618. static HIT_TEST: string;
  47619. /**
  47620. * physics impostors for xr controllers feature
  47621. */
  47622. static PHYSICS_CONTROLLERS: string;
  47623. /**
  47624. * The name of the plane detection feature
  47625. */
  47626. static PLANE_DETECTION: string;
  47627. /**
  47628. * The name of the pointer selection feature
  47629. */
  47630. static POINTER_SELECTION: string;
  47631. /**
  47632. * The name of the teleportation feature
  47633. */
  47634. static TELEPORTATION: string;
  47635. }
  47636. /**
  47637. * Defining the constructor of a feature. Used to register the modules.
  47638. */
  47639. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  47640. /**
  47641. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47642. * It is mainly used in AR sessions.
  47643. *
  47644. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47645. */
  47646. export class WebXRFeaturesManager implements IDisposable {
  47647. private _xrSessionManager;
  47648. private static readonly _AvailableFeatures;
  47649. private _features;
  47650. /**
  47651. * constructs a new features manages.
  47652. *
  47653. * @param _xrSessionManager an instance of WebXRSessionManager
  47654. */
  47655. constructor(_xrSessionManager: WebXRSessionManager);
  47656. /**
  47657. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47658. * Mainly used internally.
  47659. *
  47660. * @param featureName the name of the feature to register
  47661. * @param constructorFunction the function used to construct the module
  47662. * @param version the (babylon) version of the module
  47663. * @param stable is that a stable version of this module
  47664. */
  47665. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47666. /**
  47667. * Returns a constructor of a specific feature.
  47668. *
  47669. * @param featureName the name of the feature to construct
  47670. * @param version the version of the feature to load
  47671. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47672. * @param options optional options provided to the module.
  47673. * @returns a function that, when called, will return a new instance of this feature
  47674. */
  47675. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  47676. /**
  47677. * Can be used to return the list of features currently registered
  47678. *
  47679. * @returns an Array of available features
  47680. */
  47681. static GetAvailableFeatures(): string[];
  47682. /**
  47683. * Gets the versions available for a specific feature
  47684. * @param featureName the name of the feature
  47685. * @returns an array with the available versions
  47686. */
  47687. static GetAvailableVersions(featureName: string): string[];
  47688. /**
  47689. * Return the latest unstable version of this feature
  47690. * @param featureName the name of the feature to search
  47691. * @returns the version number. if not found will return -1
  47692. */
  47693. static GetLatestVersionOfFeature(featureName: string): number;
  47694. /**
  47695. * Return the latest stable version of this feature
  47696. * @param featureName the name of the feature to search
  47697. * @returns the version number. if not found will return -1
  47698. */
  47699. static GetStableVersionOfFeature(featureName: string): number;
  47700. /**
  47701. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47702. * Can be used during a session to start a feature
  47703. * @param featureName the name of feature to attach
  47704. */
  47705. attachFeature(featureName: string): void;
  47706. /**
  47707. * Can be used inside a session or when the session ends to detach a specific feature
  47708. * @param featureName the name of the feature to detach
  47709. */
  47710. detachFeature(featureName: string): void;
  47711. /**
  47712. * Used to disable an already-enabled feature
  47713. * The feature will be disposed and will be recreated once enabled.
  47714. * @param featureName the feature to disable
  47715. * @returns true if disable was successful
  47716. */
  47717. disableFeature(featureName: string | {
  47718. Name: string;
  47719. }): boolean;
  47720. /**
  47721. * dispose this features manager
  47722. */
  47723. dispose(): void;
  47724. /**
  47725. * 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.
  47726. * 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.
  47727. *
  47728. * @param featureName the name of the feature to load or the class of the feature
  47729. * @param version optional version to load. if not provided the latest version will be enabled
  47730. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47731. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47732. * @returns a new constructed feature or throws an error if feature not found.
  47733. */
  47734. enableFeature(featureName: string | {
  47735. Name: string;
  47736. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  47737. /**
  47738. * get the implementation of an enabled feature.
  47739. * @param featureName the name of the feature to load
  47740. * @returns the feature class, if found
  47741. */
  47742. getEnabledFeature(featureName: string): IWebXRFeature;
  47743. /**
  47744. * Get the list of enabled features
  47745. * @returns an array of enabled features
  47746. */
  47747. getEnabledFeatures(): string[];
  47748. }
  47749. }
  47750. declare module "babylonjs/XR/webXRExperienceHelper" {
  47751. import { Observable } from "babylonjs/Misc/observable";
  47752. import { IDisposable, Scene } from "babylonjs/scene";
  47753. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47754. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  47755. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47756. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  47757. /**
  47758. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47759. * @see https://doc.babylonjs.com/how_to/webxr
  47760. */
  47761. export class WebXRExperienceHelper implements IDisposable {
  47762. private scene;
  47763. private _nonVRCamera;
  47764. private _originalSceneAutoClear;
  47765. private _supported;
  47766. /**
  47767. * Camera used to render xr content
  47768. */
  47769. camera: WebXRCamera;
  47770. /** A features manager for this xr session */
  47771. featuresManager: WebXRFeaturesManager;
  47772. /**
  47773. * Observers registered here will be triggered after the camera's initial transformation is set
  47774. * This can be used to set a different ground level or an extra rotation.
  47775. *
  47776. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47777. * to the position set after this observable is done executing.
  47778. */
  47779. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47780. /**
  47781. * Fires when the state of the experience helper has changed
  47782. */
  47783. onStateChangedObservable: Observable<WebXRState>;
  47784. /** Session manager used to keep track of xr session */
  47785. sessionManager: WebXRSessionManager;
  47786. /**
  47787. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47788. */
  47789. state: WebXRState;
  47790. /**
  47791. * Creates a WebXRExperienceHelper
  47792. * @param scene The scene the helper should be created in
  47793. */
  47794. private constructor();
  47795. /**
  47796. * Creates the experience helper
  47797. * @param scene the scene to attach the experience helper to
  47798. * @returns a promise for the experience helper
  47799. */
  47800. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47801. /**
  47802. * Disposes of the experience helper
  47803. */
  47804. dispose(): void;
  47805. /**
  47806. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47807. * @param sessionMode options for the XR session
  47808. * @param referenceSpaceType frame of reference of the XR session
  47809. * @param renderTarget the output canvas that will be used to enter XR mode
  47810. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47811. * @returns promise that resolves after xr mode has entered
  47812. */
  47813. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47814. /**
  47815. * Exits XR mode and returns the scene to its original state
  47816. * @returns promise that resolves after xr mode has exited
  47817. */
  47818. exitXRAsync(): Promise<void>;
  47819. private _nonXRToXRCamera;
  47820. private _setState;
  47821. }
  47822. }
  47823. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  47824. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  47825. import { Observable } from "babylonjs/Misc/observable";
  47826. import { IDisposable } from "babylonjs/scene";
  47827. /**
  47828. * X-Y values for axes in WebXR
  47829. */
  47830. export interface IWebXRMotionControllerAxesValue {
  47831. /**
  47832. * The value of the x axis
  47833. */
  47834. x: number;
  47835. /**
  47836. * The value of the y-axis
  47837. */
  47838. y: number;
  47839. }
  47840. /**
  47841. * changed / previous values for the values of this component
  47842. */
  47843. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47844. /**
  47845. * current (this frame) value
  47846. */
  47847. current: T;
  47848. /**
  47849. * previous (last change) value
  47850. */
  47851. previous: T;
  47852. }
  47853. /**
  47854. * Represents changes in the component between current frame and last values recorded
  47855. */
  47856. export interface IWebXRMotionControllerComponentChanges {
  47857. /**
  47858. * will be populated with previous and current values if axes changed
  47859. */
  47860. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47861. /**
  47862. * will be populated with previous and current values if pressed changed
  47863. */
  47864. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47865. /**
  47866. * will be populated with previous and current values if touched changed
  47867. */
  47868. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47869. /**
  47870. * will be populated with previous and current values if value changed
  47871. */
  47872. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47873. }
  47874. /**
  47875. * This class represents a single component (for example button or thumbstick) of a motion controller
  47876. */
  47877. export class WebXRControllerComponent implements IDisposable {
  47878. /**
  47879. * the id of this component
  47880. */
  47881. id: string;
  47882. /**
  47883. * the type of the component
  47884. */
  47885. type: MotionControllerComponentType;
  47886. private _buttonIndex;
  47887. private _axesIndices;
  47888. private _axes;
  47889. private _changes;
  47890. private _currentValue;
  47891. private _hasChanges;
  47892. private _pressed;
  47893. private _touched;
  47894. /**
  47895. * button component type
  47896. */
  47897. static BUTTON_TYPE: MotionControllerComponentType;
  47898. /**
  47899. * squeeze component type
  47900. */
  47901. static SQUEEZE_TYPE: MotionControllerComponentType;
  47902. /**
  47903. * Thumbstick component type
  47904. */
  47905. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47906. /**
  47907. * Touchpad component type
  47908. */
  47909. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47910. /**
  47911. * trigger component type
  47912. */
  47913. static TRIGGER_TYPE: MotionControllerComponentType;
  47914. /**
  47915. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47916. * the axes data changes
  47917. */
  47918. onAxisValueChangedObservable: Observable<{
  47919. x: number;
  47920. y: number;
  47921. }>;
  47922. /**
  47923. * Observers registered here will be triggered when the state of a button changes
  47924. * State change is either pressed / touched / value
  47925. */
  47926. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47927. /**
  47928. * Creates a new component for a motion controller.
  47929. * It is created by the motion controller itself
  47930. *
  47931. * @param id the id of this component
  47932. * @param type the type of the component
  47933. * @param _buttonIndex index in the buttons array of the gamepad
  47934. * @param _axesIndices indices of the values in the axes array of the gamepad
  47935. */
  47936. constructor(
  47937. /**
  47938. * the id of this component
  47939. */
  47940. id: string,
  47941. /**
  47942. * the type of the component
  47943. */
  47944. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47945. /**
  47946. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47947. */
  47948. get axes(): IWebXRMotionControllerAxesValue;
  47949. /**
  47950. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47951. */
  47952. get changes(): IWebXRMotionControllerComponentChanges;
  47953. /**
  47954. * Return whether or not the component changed the last frame
  47955. */
  47956. get hasChanges(): boolean;
  47957. /**
  47958. * is the button currently pressed
  47959. */
  47960. get pressed(): boolean;
  47961. /**
  47962. * is the button currently touched
  47963. */
  47964. get touched(): boolean;
  47965. /**
  47966. * Get the current value of this component
  47967. */
  47968. get value(): number;
  47969. /**
  47970. * Dispose this component
  47971. */
  47972. dispose(): void;
  47973. /**
  47974. * Are there axes correlating to this component
  47975. * @return true is axes data is available
  47976. */
  47977. isAxes(): boolean;
  47978. /**
  47979. * Is this component a button (hence - pressable)
  47980. * @returns true if can be pressed
  47981. */
  47982. isButton(): boolean;
  47983. /**
  47984. * update this component using the gamepad object it is in. Called on every frame
  47985. * @param nativeController the native gamepad controller object
  47986. */
  47987. update(nativeController: IMinimalMotionControllerObject): void;
  47988. }
  47989. }
  47990. declare module "babylonjs/Loading/sceneLoader" {
  47991. import { Observable } from "babylonjs/Misc/observable";
  47992. import { Nullable } from "babylonjs/types";
  47993. import { Scene } from "babylonjs/scene";
  47994. import { Engine } from "babylonjs/Engines/engine";
  47995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47996. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  47997. import { AssetContainer } from "babylonjs/assetContainer";
  47998. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  47999. import { Skeleton } from "babylonjs/Bones/skeleton";
  48000. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  48001. import { WebRequest } from "babylonjs/Misc/webRequest";
  48002. /**
  48003. * Class used to represent data loading progression
  48004. */
  48005. export class SceneLoaderProgressEvent {
  48006. /** defines if data length to load can be evaluated */
  48007. readonly lengthComputable: boolean;
  48008. /** defines the loaded data length */
  48009. readonly loaded: number;
  48010. /** defines the data length to load */
  48011. readonly total: number;
  48012. /**
  48013. * Create a new progress event
  48014. * @param lengthComputable defines if data length to load can be evaluated
  48015. * @param loaded defines the loaded data length
  48016. * @param total defines the data length to load
  48017. */
  48018. constructor(
  48019. /** defines if data length to load can be evaluated */
  48020. lengthComputable: boolean,
  48021. /** defines the loaded data length */
  48022. loaded: number,
  48023. /** defines the data length to load */
  48024. total: number);
  48025. /**
  48026. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  48027. * @param event defines the source event
  48028. * @returns a new SceneLoaderProgressEvent
  48029. */
  48030. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  48031. }
  48032. /**
  48033. * Interface used by SceneLoader plugins to define supported file extensions
  48034. */
  48035. export interface ISceneLoaderPluginExtensions {
  48036. /**
  48037. * Defines the list of supported extensions
  48038. */
  48039. [extension: string]: {
  48040. isBinary: boolean;
  48041. };
  48042. }
  48043. /**
  48044. * Interface used by SceneLoader plugin factory
  48045. */
  48046. export interface ISceneLoaderPluginFactory {
  48047. /**
  48048. * Defines the name of the factory
  48049. */
  48050. name: string;
  48051. /**
  48052. * Function called to create a new plugin
  48053. * @return the new plugin
  48054. */
  48055. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  48056. /**
  48057. * The callback that returns true if the data can be directly loaded.
  48058. * @param data string containing the file data
  48059. * @returns if the data can be loaded directly
  48060. */
  48061. canDirectLoad?(data: string): boolean;
  48062. }
  48063. /**
  48064. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  48065. */
  48066. export interface ISceneLoaderPluginBase {
  48067. /**
  48068. * The friendly name of this plugin.
  48069. */
  48070. name: string;
  48071. /**
  48072. * The file extensions supported by this plugin.
  48073. */
  48074. extensions: string | ISceneLoaderPluginExtensions;
  48075. /**
  48076. * The callback called when loading from a url.
  48077. * @param scene scene loading this url
  48078. * @param url url to load
  48079. * @param onSuccess callback called when the file successfully loads
  48080. * @param onProgress callback called while file is loading (if the server supports this mode)
  48081. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  48082. * @param onError callback called when the file fails to load
  48083. * @returns a file request object
  48084. */
  48085. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48086. /**
  48087. * The callback called when loading from a file object.
  48088. * @param scene scene loading this file
  48089. * @param file defines the file to load
  48090. * @param onSuccess defines the callback to call when data is loaded
  48091. * @param onProgress defines the callback to call during loading process
  48092. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  48093. * @param onError defines the callback to call when an error occurs
  48094. * @returns a file request object
  48095. */
  48096. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48097. /**
  48098. * The callback that returns true if the data can be directly loaded.
  48099. * @param data string containing the file data
  48100. * @returns if the data can be loaded directly
  48101. */
  48102. canDirectLoad?(data: string): boolean;
  48103. /**
  48104. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  48105. * @param scene scene loading this data
  48106. * @param data string containing the data
  48107. * @returns data to pass to the plugin
  48108. */
  48109. directLoad?(scene: Scene, data: string): any;
  48110. /**
  48111. * The callback that allows custom handling of the root url based on the response url.
  48112. * @param rootUrl the original root url
  48113. * @param responseURL the response url if available
  48114. * @returns the new root url
  48115. */
  48116. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  48117. }
  48118. /**
  48119. * Interface used to define a SceneLoader plugin
  48120. */
  48121. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  48122. /**
  48123. * Import meshes into a scene.
  48124. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48125. * @param scene The scene to import into
  48126. * @param data The data to import
  48127. * @param rootUrl The root url for scene and resources
  48128. * @param meshes The meshes array to import into
  48129. * @param particleSystems The particle systems array to import into
  48130. * @param skeletons The skeletons array to import into
  48131. * @param onError The callback when import fails
  48132. * @returns True if successful or false otherwise
  48133. */
  48134. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  48135. /**
  48136. * Load into a scene.
  48137. * @param scene The scene to load into
  48138. * @param data The data to import
  48139. * @param rootUrl The root url for scene and resources
  48140. * @param onError The callback when import fails
  48141. * @returns True if successful or false otherwise
  48142. */
  48143. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  48144. /**
  48145. * Load into an asset container.
  48146. * @param scene The scene to load into
  48147. * @param data The data to import
  48148. * @param rootUrl The root url for scene and resources
  48149. * @param onError The callback when import fails
  48150. * @returns The loaded asset container
  48151. */
  48152. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  48153. }
  48154. /**
  48155. * Interface used to define an async SceneLoader plugin
  48156. */
  48157. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  48158. /**
  48159. * Import meshes into a scene.
  48160. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48161. * @param scene The scene to import into
  48162. * @param data The data to import
  48163. * @param rootUrl The root url for scene and resources
  48164. * @param onProgress The callback when the load progresses
  48165. * @param fileName Defines the name of the file to load
  48166. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  48167. */
  48168. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  48169. meshes: AbstractMesh[];
  48170. particleSystems: IParticleSystem[];
  48171. skeletons: Skeleton[];
  48172. animationGroups: AnimationGroup[];
  48173. }>;
  48174. /**
  48175. * Load into a scene.
  48176. * @param scene The scene to load into
  48177. * @param data The data to import
  48178. * @param rootUrl The root url for scene and resources
  48179. * @param onProgress The callback when the load progresses
  48180. * @param fileName Defines the name of the file to load
  48181. * @returns Nothing
  48182. */
  48183. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  48184. /**
  48185. * Load into an asset container.
  48186. * @param scene The scene to load into
  48187. * @param data The data to import
  48188. * @param rootUrl The root url for scene and resources
  48189. * @param onProgress The callback when the load progresses
  48190. * @param fileName Defines the name of the file to load
  48191. * @returns The loaded asset container
  48192. */
  48193. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  48194. }
  48195. /**
  48196. * Mode that determines how to handle old animation groups before loading new ones.
  48197. */
  48198. export enum SceneLoaderAnimationGroupLoadingMode {
  48199. /**
  48200. * Reset all old animations to initial state then dispose them.
  48201. */
  48202. Clean = 0,
  48203. /**
  48204. * Stop all old animations.
  48205. */
  48206. Stop = 1,
  48207. /**
  48208. * Restart old animations from first frame.
  48209. */
  48210. Sync = 2,
  48211. /**
  48212. * Old animations remains untouched.
  48213. */
  48214. NoSync = 3
  48215. }
  48216. /**
  48217. * Class used to load scene from various file formats using registered plugins
  48218. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  48219. */
  48220. export class SceneLoader {
  48221. /**
  48222. * No logging while loading
  48223. */
  48224. static readonly NO_LOGGING: number;
  48225. /**
  48226. * Minimal logging while loading
  48227. */
  48228. static readonly MINIMAL_LOGGING: number;
  48229. /**
  48230. * Summary logging while loading
  48231. */
  48232. static readonly SUMMARY_LOGGING: number;
  48233. /**
  48234. * Detailled logging while loading
  48235. */
  48236. static readonly DETAILED_LOGGING: number;
  48237. /**
  48238. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48239. */
  48240. static get ForceFullSceneLoadingForIncremental(): boolean;
  48241. static set ForceFullSceneLoadingForIncremental(value: boolean);
  48242. /**
  48243. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48244. */
  48245. static get ShowLoadingScreen(): boolean;
  48246. static set ShowLoadingScreen(value: boolean);
  48247. /**
  48248. * Defines the current logging level (while loading the scene)
  48249. * @ignorenaming
  48250. */
  48251. static get loggingLevel(): number;
  48252. static set loggingLevel(value: number);
  48253. /**
  48254. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48255. */
  48256. static get CleanBoneMatrixWeights(): boolean;
  48257. static set CleanBoneMatrixWeights(value: boolean);
  48258. /**
  48259. * Event raised when a plugin is used to load a scene
  48260. */
  48261. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48262. private static _registeredPlugins;
  48263. private static _getDefaultPlugin;
  48264. private static _getPluginForExtension;
  48265. private static _getPluginForDirectLoad;
  48266. private static _getPluginForFilename;
  48267. private static _getDirectLoad;
  48268. private static _loadData;
  48269. private static _getFileInfo;
  48270. /**
  48271. * Gets a plugin that can load the given extension
  48272. * @param extension defines the extension to load
  48273. * @returns a plugin or null if none works
  48274. */
  48275. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  48276. /**
  48277. * Gets a boolean indicating that the given extension can be loaded
  48278. * @param extension defines the extension to load
  48279. * @returns true if the extension is supported
  48280. */
  48281. static IsPluginForExtensionAvailable(extension: string): boolean;
  48282. /**
  48283. * Adds a new plugin to the list of registered plugins
  48284. * @param plugin defines the plugin to add
  48285. */
  48286. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  48287. /**
  48288. * Import meshes into a scene
  48289. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48290. * @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)
  48291. * @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)
  48292. * @param scene the instance of BABYLON.Scene to append to
  48293. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48294. * @param onProgress a callback with a progress event for each file being loaded
  48295. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48296. * @param pluginExtension the extension used to determine the plugin
  48297. * @returns The loaded plugin
  48298. */
  48299. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48300. /**
  48301. * Import meshes into a scene
  48302. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48303. * @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)
  48304. * @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)
  48305. * @param scene the instance of BABYLON.Scene to append to
  48306. * @param onProgress a callback with a progress event for each file being loaded
  48307. * @param pluginExtension the extension used to determine the plugin
  48308. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48309. */
  48310. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  48311. meshes: AbstractMesh[];
  48312. particleSystems: IParticleSystem[];
  48313. skeletons: Skeleton[];
  48314. animationGroups: AnimationGroup[];
  48315. }>;
  48316. /**
  48317. * Load a scene
  48318. * @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)
  48319. * @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)
  48320. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48321. * @param onSuccess a callback with the scene when import succeeds
  48322. * @param onProgress a callback with a progress event for each file being loaded
  48323. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48324. * @param pluginExtension the extension used to determine the plugin
  48325. * @returns The loaded plugin
  48326. */
  48327. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48328. /**
  48329. * Load a scene
  48330. * @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)
  48331. * @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)
  48332. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48333. * @param onProgress a callback with a progress event for each file being loaded
  48334. * @param pluginExtension the extension used to determine the plugin
  48335. * @returns The loaded scene
  48336. */
  48337. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48338. /**
  48339. * Append a scene
  48340. * @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)
  48341. * @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)
  48342. * @param scene is the instance of BABYLON.Scene to append to
  48343. * @param onSuccess a callback with the scene when import succeeds
  48344. * @param onProgress a callback with a progress event for each file being loaded
  48345. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48346. * @param pluginExtension the extension used to determine the plugin
  48347. * @returns The loaded plugin
  48348. */
  48349. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48350. /**
  48351. * Append a scene
  48352. * @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)
  48353. * @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)
  48354. * @param scene is the instance of BABYLON.Scene to append to
  48355. * @param onProgress a callback with a progress event for each file being loaded
  48356. * @param pluginExtension the extension used to determine the plugin
  48357. * @returns The given scene
  48358. */
  48359. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48360. /**
  48361. * Load a scene into an asset container
  48362. * @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)
  48363. * @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)
  48364. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48365. * @param onSuccess a callback with the scene when import succeeds
  48366. * @param onProgress a callback with a progress event for each file being loaded
  48367. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48368. * @param pluginExtension the extension used to determine the plugin
  48369. * @returns The loaded plugin
  48370. */
  48371. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48372. /**
  48373. * Load a scene into an asset container
  48374. * @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)
  48375. * @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)
  48376. * @param scene is the instance of Scene to append to
  48377. * @param onProgress a callback with a progress event for each file being loaded
  48378. * @param pluginExtension the extension used to determine the plugin
  48379. * @returns The loaded asset container
  48380. */
  48381. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48382. /**
  48383. * Import animations from a file into a scene
  48384. * @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)
  48385. * @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)
  48386. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48387. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48388. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48389. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48390. * @param onSuccess a callback with the scene when import succeeds
  48391. * @param onProgress a callback with a progress event for each file being loaded
  48392. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48393. */
  48394. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  48395. /**
  48396. * Import animations from a file into a scene
  48397. * @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)
  48398. * @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)
  48399. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48400. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48401. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48402. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48403. * @param onSuccess a callback with the scene when import succeeds
  48404. * @param onProgress a callback with a progress event for each file being loaded
  48405. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48406. * @returns the updated scene with imported animations
  48407. */
  48408. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  48409. }
  48410. }
  48411. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  48412. import { IDisposable, Scene } from "babylonjs/scene";
  48413. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  48414. import { Observable } from "babylonjs/Misc/observable";
  48415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48416. import { Nullable } from "babylonjs/types";
  48417. /**
  48418. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48419. */
  48420. export type MotionControllerHandedness = "none" | "left" | "right";
  48421. /**
  48422. * The type of components available in motion controllers.
  48423. * This is not the name of the component.
  48424. */
  48425. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48426. /**
  48427. * The state of a controller component
  48428. */
  48429. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48430. /**
  48431. * The schema of motion controller layout.
  48432. * No object will be initialized using this interface
  48433. * This is used just to define the profile.
  48434. */
  48435. export interface IMotionControllerLayout {
  48436. /**
  48437. * Path to load the assets. Usually relative to the base path
  48438. */
  48439. assetPath: string;
  48440. /**
  48441. * Available components (unsorted)
  48442. */
  48443. components: {
  48444. /**
  48445. * A map of component Ids
  48446. */
  48447. [componentId: string]: {
  48448. /**
  48449. * The type of input the component outputs
  48450. */
  48451. type: MotionControllerComponentType;
  48452. /**
  48453. * The indices of this component in the gamepad object
  48454. */
  48455. gamepadIndices: {
  48456. /**
  48457. * Index of button
  48458. */
  48459. button?: number;
  48460. /**
  48461. * If available, index of x-axis
  48462. */
  48463. xAxis?: number;
  48464. /**
  48465. * If available, index of y-axis
  48466. */
  48467. yAxis?: number;
  48468. };
  48469. /**
  48470. * The mesh's root node name
  48471. */
  48472. rootNodeName: string;
  48473. /**
  48474. * Animation definitions for this model
  48475. */
  48476. visualResponses: {
  48477. [stateKey: string]: {
  48478. /**
  48479. * What property will be animated
  48480. */
  48481. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48482. /**
  48483. * What states influence this visual response
  48484. */
  48485. states: MotionControllerComponentStateType[];
  48486. /**
  48487. * Type of animation - movement or visibility
  48488. */
  48489. valueNodeProperty: "transform" | "visibility";
  48490. /**
  48491. * Base node name to move. Its position will be calculated according to the min and max nodes
  48492. */
  48493. valueNodeName?: string;
  48494. /**
  48495. * Minimum movement node
  48496. */
  48497. minNodeName?: string;
  48498. /**
  48499. * Max movement node
  48500. */
  48501. maxNodeName?: string;
  48502. };
  48503. };
  48504. /**
  48505. * If touch enabled, what is the name of node to display user feedback
  48506. */
  48507. touchPointNodeName?: string;
  48508. };
  48509. };
  48510. /**
  48511. * Is it xr standard mapping or not
  48512. */
  48513. gamepadMapping: "" | "xr-standard";
  48514. /**
  48515. * Base root node of this entire model
  48516. */
  48517. rootNodeName: string;
  48518. /**
  48519. * Defines the main button component id
  48520. */
  48521. selectComponentId: string;
  48522. }
  48523. /**
  48524. * A definition for the layout map in the input profile
  48525. */
  48526. export interface IMotionControllerLayoutMap {
  48527. /**
  48528. * Layouts with handedness type as a key
  48529. */
  48530. [handedness: string]: IMotionControllerLayout;
  48531. }
  48532. /**
  48533. * The XR Input profile schema
  48534. * Profiles can be found here:
  48535. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48536. */
  48537. export interface IMotionControllerProfile {
  48538. /**
  48539. * fallback profiles for this profileId
  48540. */
  48541. fallbackProfileIds: string[];
  48542. /**
  48543. * The layout map, with handedness as key
  48544. */
  48545. layouts: IMotionControllerLayoutMap;
  48546. /**
  48547. * The id of this profile
  48548. * correlates to the profile(s) in the xrInput.profiles array
  48549. */
  48550. profileId: string;
  48551. }
  48552. /**
  48553. * A helper-interface for the 3 meshes needed for controller button animation
  48554. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48555. */
  48556. export interface IMotionControllerButtonMeshMap {
  48557. /**
  48558. * the mesh that defines the pressed value mesh position.
  48559. * This is used to find the max-position of this button
  48560. */
  48561. pressedMesh: AbstractMesh;
  48562. /**
  48563. * the mesh that defines the unpressed value mesh position.
  48564. * This is used to find the min (or initial) position of this button
  48565. */
  48566. unpressedMesh: AbstractMesh;
  48567. /**
  48568. * The mesh that will be changed when value changes
  48569. */
  48570. valueMesh: AbstractMesh;
  48571. }
  48572. /**
  48573. * A helper-interface for the 3 meshes needed for controller axis animation.
  48574. * This will be expanded when touchpad animations are fully supported
  48575. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48576. */
  48577. export interface IMotionControllerMeshMap {
  48578. /**
  48579. * the mesh that defines the maximum value mesh position.
  48580. */
  48581. maxMesh?: AbstractMesh;
  48582. /**
  48583. * the mesh that defines the minimum value mesh position.
  48584. */
  48585. minMesh?: AbstractMesh;
  48586. /**
  48587. * The mesh that will be changed when axis value changes
  48588. */
  48589. valueMesh: AbstractMesh;
  48590. }
  48591. /**
  48592. * The elements needed for change-detection of the gamepad objects in motion controllers
  48593. */
  48594. export interface IMinimalMotionControllerObject {
  48595. /**
  48596. * Available axes of this controller
  48597. */
  48598. axes: number[];
  48599. /**
  48600. * An array of available buttons
  48601. */
  48602. buttons: Array<{
  48603. /**
  48604. * Value of the button/trigger
  48605. */
  48606. value: number;
  48607. /**
  48608. * If the button/trigger is currently touched
  48609. */
  48610. touched: boolean;
  48611. /**
  48612. * If the button/trigger is currently pressed
  48613. */
  48614. pressed: boolean;
  48615. }>;
  48616. /**
  48617. * EXPERIMENTAL haptic support.
  48618. */
  48619. hapticActuators?: Array<{
  48620. pulse: (value: number, duration: number) => Promise<boolean>;
  48621. }>;
  48622. }
  48623. /**
  48624. * An Abstract Motion controller
  48625. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48626. * Each component has an observable to check for changes in value and state
  48627. */
  48628. export abstract class WebXRAbstractMotionController implements IDisposable {
  48629. protected scene: Scene;
  48630. protected layout: IMotionControllerLayout;
  48631. /**
  48632. * The gamepad object correlating to this controller
  48633. */
  48634. gamepadObject: IMinimalMotionControllerObject;
  48635. /**
  48636. * handedness (left/right/none) of this controller
  48637. */
  48638. handedness: MotionControllerHandedness;
  48639. private _initComponent;
  48640. private _modelReady;
  48641. /**
  48642. * A map of components (WebXRControllerComponent) in this motion controller
  48643. * Components have a ComponentType and can also have both button and axis definitions
  48644. */
  48645. readonly components: {
  48646. [id: string]: WebXRControllerComponent;
  48647. };
  48648. /**
  48649. * Disable the model's animation. Can be set at any time.
  48650. */
  48651. disableAnimation: boolean;
  48652. /**
  48653. * Observers registered here will be triggered when the model of this controller is done loading
  48654. */
  48655. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48656. /**
  48657. * The profile id of this motion controller
  48658. */
  48659. abstract profileId: string;
  48660. /**
  48661. * The root mesh of the model. It is null if the model was not yet initialized
  48662. */
  48663. rootMesh: Nullable<AbstractMesh>;
  48664. /**
  48665. * constructs a new abstract motion controller
  48666. * @param scene the scene to which the model of the controller will be added
  48667. * @param layout The profile layout to load
  48668. * @param gamepadObject The gamepad object correlating to this controller
  48669. * @param handedness handedness (left/right/none) of this controller
  48670. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48671. */
  48672. constructor(scene: Scene, layout: IMotionControllerLayout,
  48673. /**
  48674. * The gamepad object correlating to this controller
  48675. */
  48676. gamepadObject: IMinimalMotionControllerObject,
  48677. /**
  48678. * handedness (left/right/none) of this controller
  48679. */
  48680. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48681. /**
  48682. * Dispose this controller, the model mesh and all its components
  48683. */
  48684. dispose(): void;
  48685. /**
  48686. * Returns all components of specific type
  48687. * @param type the type to search for
  48688. * @return an array of components with this type
  48689. */
  48690. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48691. /**
  48692. * get a component based an its component id as defined in layout.components
  48693. * @param id the id of the component
  48694. * @returns the component correlates to the id or undefined if not found
  48695. */
  48696. getComponent(id: string): WebXRControllerComponent;
  48697. /**
  48698. * Get the list of components available in this motion controller
  48699. * @returns an array of strings correlating to available components
  48700. */
  48701. getComponentIds(): string[];
  48702. /**
  48703. * Get the first component of specific type
  48704. * @param type type of component to find
  48705. * @return a controller component or null if not found
  48706. */
  48707. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48708. /**
  48709. * Get the main (Select) component of this controller as defined in the layout
  48710. * @returns the main component of this controller
  48711. */
  48712. getMainComponent(): WebXRControllerComponent;
  48713. /**
  48714. * Loads the model correlating to this controller
  48715. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48716. * @returns A promise fulfilled with the result of the model loading
  48717. */
  48718. loadModel(): Promise<boolean>;
  48719. /**
  48720. * Update this model using the current XRFrame
  48721. * @param xrFrame the current xr frame to use and update the model
  48722. */
  48723. updateFromXRFrame(xrFrame: XRFrame): void;
  48724. /**
  48725. * Backwards compatibility due to a deeply-integrated typo
  48726. */
  48727. get handness(): XREye;
  48728. /**
  48729. * Pulse (vibrate) this controller
  48730. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48731. * Consecutive calls to this function will cancel the last pulse call
  48732. *
  48733. * @param value the strength of the pulse in 0.0...1.0 range
  48734. * @param duration Duration of the pulse in milliseconds
  48735. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48736. * @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
  48737. */
  48738. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48739. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48740. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48741. /**
  48742. * Moves the axis on the controller mesh based on its current state
  48743. * @param axis the index of the axis
  48744. * @param axisValue the value of the axis which determines the meshes new position
  48745. * @hidden
  48746. */
  48747. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48748. /**
  48749. * Update the model itself with the current frame data
  48750. * @param xrFrame the frame to use for updating the model mesh
  48751. */
  48752. protected updateModel(xrFrame: XRFrame): void;
  48753. /**
  48754. * Get the filename and path for this controller's model
  48755. * @returns a map of filename and path
  48756. */
  48757. protected abstract _getFilenameAndPath(): {
  48758. filename: string;
  48759. path: string;
  48760. };
  48761. /**
  48762. * This function is called before the mesh is loaded. It checks for loading constraints.
  48763. * For example, this function can check if the GLB loader is available
  48764. * If this function returns false, the generic controller will be loaded instead
  48765. * @returns Is the client ready to load the mesh
  48766. */
  48767. protected abstract _getModelLoadingConstraints(): boolean;
  48768. /**
  48769. * This function will be called after the model was successfully loaded and can be used
  48770. * for mesh transformations before it is available for the user
  48771. * @param meshes the loaded meshes
  48772. */
  48773. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48774. /**
  48775. * Set the root mesh for this controller. Important for the WebXR controller class
  48776. * @param meshes the loaded meshes
  48777. */
  48778. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48779. /**
  48780. * A function executed each frame that updates the mesh (if needed)
  48781. * @param xrFrame the current xrFrame
  48782. */
  48783. protected abstract _updateModel(xrFrame: XRFrame): void;
  48784. private _getGenericFilenameAndPath;
  48785. private _getGenericParentMesh;
  48786. }
  48787. }
  48788. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  48789. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48791. import { Scene } from "babylonjs/scene";
  48792. /**
  48793. * A generic trigger-only motion controller for WebXR
  48794. */
  48795. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48796. /**
  48797. * Static version of the profile id of this controller
  48798. */
  48799. static ProfileId: string;
  48800. profileId: string;
  48801. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48802. protected _getFilenameAndPath(): {
  48803. filename: string;
  48804. path: string;
  48805. };
  48806. protected _getModelLoadingConstraints(): boolean;
  48807. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48808. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48809. protected _updateModel(): void;
  48810. }
  48811. }
  48812. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  48813. import { Vector4 } from "babylonjs/Maths/math.vector";
  48814. import { Mesh } from "babylonjs/Meshes/mesh";
  48815. import { Scene } from "babylonjs/scene";
  48816. import { Nullable } from "babylonjs/types";
  48817. /**
  48818. * Class containing static functions to help procedurally build meshes
  48819. */
  48820. export class SphereBuilder {
  48821. /**
  48822. * Creates a sphere mesh
  48823. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48824. * * 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`)
  48825. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48826. * * 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
  48827. * * 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)
  48828. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48829. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48831. * @param name defines the name of the mesh
  48832. * @param options defines the options used to create the mesh
  48833. * @param scene defines the hosting scene
  48834. * @returns the sphere mesh
  48835. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48836. */
  48837. static CreateSphere(name: string, options: {
  48838. segments?: number;
  48839. diameter?: number;
  48840. diameterX?: number;
  48841. diameterY?: number;
  48842. diameterZ?: number;
  48843. arc?: number;
  48844. slice?: number;
  48845. sideOrientation?: number;
  48846. frontUVs?: Vector4;
  48847. backUVs?: Vector4;
  48848. updatable?: boolean;
  48849. }, scene?: Nullable<Scene>): Mesh;
  48850. }
  48851. }
  48852. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  48853. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48854. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48855. import { Scene } from "babylonjs/scene";
  48856. /**
  48857. * A profiled motion controller has its profile loaded from an online repository.
  48858. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48859. */
  48860. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48861. private _repositoryUrl;
  48862. private _buttonMeshMapping;
  48863. private _touchDots;
  48864. /**
  48865. * The profile ID of this controller. Will be populated when the controller initializes.
  48866. */
  48867. profileId: string;
  48868. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48869. dispose(): void;
  48870. protected _getFilenameAndPath(): {
  48871. filename: string;
  48872. path: string;
  48873. };
  48874. protected _getModelLoadingConstraints(): boolean;
  48875. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48876. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48877. protected _updateModel(_xrFrame: XRFrame): void;
  48878. }
  48879. }
  48880. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  48881. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48882. import { Scene } from "babylonjs/scene";
  48883. /**
  48884. * A construction function type to create a new controller based on an xrInput object
  48885. */
  48886. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48887. /**
  48888. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48889. *
  48890. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48891. * it should be replaced with auto-loaded controllers.
  48892. *
  48893. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48894. */
  48895. export class WebXRMotionControllerManager {
  48896. private static _AvailableControllers;
  48897. private static _Fallbacks;
  48898. private static _ProfileLoadingPromises;
  48899. private static _ProfilesList;
  48900. /**
  48901. * The base URL of the online controller repository. Can be changed at any time.
  48902. */
  48903. static BaseRepositoryUrl: string;
  48904. /**
  48905. * Which repository gets priority - local or online
  48906. */
  48907. static PrioritizeOnlineRepository: boolean;
  48908. /**
  48909. * Use the online repository, or use only locally-defined controllers
  48910. */
  48911. static UseOnlineRepository: boolean;
  48912. /**
  48913. * Clear the cache used for profile loading and reload when requested again
  48914. */
  48915. static ClearProfilesCache(): void;
  48916. /**
  48917. * Register the default fallbacks.
  48918. * This function is called automatically when this file is imported.
  48919. */
  48920. static DefaultFallbacks(): void;
  48921. /**
  48922. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48923. * @param profileId the profile to which a fallback needs to be found
  48924. * @return an array with corresponding fallback profiles
  48925. */
  48926. static FindFallbackWithProfileId(profileId: string): string[];
  48927. /**
  48928. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48929. * The order of search:
  48930. *
  48931. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48932. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48933. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48934. * 4) return the generic trigger controller if none were found
  48935. *
  48936. * @param xrInput the xrInput to which a new controller is initialized
  48937. * @param scene the scene to which the model will be added
  48938. * @param forceProfile force a certain profile for this controller
  48939. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48940. */
  48941. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48942. /**
  48943. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48944. *
  48945. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48946. *
  48947. * @param type the profile type to register
  48948. * @param constructFunction the function to be called when loading this profile
  48949. */
  48950. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48951. /**
  48952. * Register a fallback to a specific profile.
  48953. * @param profileId the profileId that will receive the fallbacks
  48954. * @param fallbacks A list of fallback profiles
  48955. */
  48956. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48957. /**
  48958. * Will update the list of profiles available in the repository
  48959. * @return a promise that resolves to a map of profiles available online
  48960. */
  48961. static UpdateProfilesList(): Promise<{
  48962. [profile: string]: string;
  48963. }>;
  48964. private static _LoadProfileFromRepository;
  48965. private static _LoadProfilesFromAvailableControllers;
  48966. }
  48967. }
  48968. declare module "babylonjs/XR/webXRInputSource" {
  48969. import { Observable } from "babylonjs/Misc/observable";
  48970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48971. import { Ray } from "babylonjs/Culling/ray";
  48972. import { Scene } from "babylonjs/scene";
  48973. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48974. /**
  48975. * Configuration options for the WebXR controller creation
  48976. */
  48977. export interface IWebXRControllerOptions {
  48978. /**
  48979. * Should the controller mesh be animated when a user interacts with it
  48980. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48981. */
  48982. disableMotionControllerAnimation?: boolean;
  48983. /**
  48984. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48985. */
  48986. doNotLoadControllerMesh?: boolean;
  48987. /**
  48988. * Force a specific controller type for this controller.
  48989. * This can be used when creating your own profile or when testing different controllers
  48990. */
  48991. forceControllerProfile?: string;
  48992. /**
  48993. * Defines a rendering group ID for meshes that will be loaded.
  48994. * This is for the default controllers only.
  48995. */
  48996. renderingGroupId?: number;
  48997. }
  48998. /**
  48999. * Represents an XR controller
  49000. */
  49001. export class WebXRInputSource {
  49002. private _scene;
  49003. /** The underlying input source for the controller */
  49004. inputSource: XRInputSource;
  49005. private _options;
  49006. private _tmpVector;
  49007. private _uniqueId;
  49008. /**
  49009. * 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
  49010. */
  49011. grip?: AbstractMesh;
  49012. /**
  49013. * If available, this is the gamepad object related to this controller.
  49014. * Using this object it is possible to get click events and trackpad changes of the
  49015. * webxr controller that is currently being used.
  49016. */
  49017. motionController?: WebXRAbstractMotionController;
  49018. /**
  49019. * Event that fires when the controller is removed/disposed.
  49020. * The object provided as event data is this controller, after associated assets were disposed.
  49021. * uniqueId is still available.
  49022. */
  49023. onDisposeObservable: Observable<WebXRInputSource>;
  49024. /**
  49025. * Will be triggered when the mesh associated with the motion controller is done loading.
  49026. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  49027. * A shortened version of controller -> motion controller -> on mesh loaded.
  49028. */
  49029. onMeshLoadedObservable: Observable<AbstractMesh>;
  49030. /**
  49031. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  49032. */
  49033. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  49034. /**
  49035. * Pointer which can be used to select objects or attach a visible laser to
  49036. */
  49037. pointer: AbstractMesh;
  49038. /**
  49039. * Creates the controller
  49040. * @see https://doc.babylonjs.com/how_to/webxr
  49041. * @param _scene the scene which the controller should be associated to
  49042. * @param inputSource the underlying input source for the controller
  49043. * @param _options options for this controller creation
  49044. */
  49045. constructor(_scene: Scene,
  49046. /** The underlying input source for the controller */
  49047. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  49048. /**
  49049. * Get this controllers unique id
  49050. */
  49051. get uniqueId(): string;
  49052. /**
  49053. * Disposes of the object
  49054. */
  49055. dispose(): void;
  49056. /**
  49057. * Gets a world space ray coming from the pointer or grip
  49058. * @param result the resulting ray
  49059. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  49060. */
  49061. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  49062. /**
  49063. * Updates the controller pose based on the given XRFrame
  49064. * @param xrFrame xr frame to update the pose with
  49065. * @param referenceSpace reference space to use
  49066. */
  49067. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  49068. }
  49069. }
  49070. declare module "babylonjs/XR/webXRInput" {
  49071. import { Observable } from "babylonjs/Misc/observable";
  49072. import { IDisposable } from "babylonjs/scene";
  49073. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  49074. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49075. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49076. /**
  49077. * The schema for initialization options of the XR Input class
  49078. */
  49079. export interface IWebXRInputOptions {
  49080. /**
  49081. * If set to true no model will be automatically loaded
  49082. */
  49083. doNotLoadControllerMeshes?: boolean;
  49084. /**
  49085. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  49086. * If not found, the xr input profile data will be used.
  49087. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  49088. */
  49089. forceInputProfile?: string;
  49090. /**
  49091. * Do not send a request to the controller repository to load the profile.
  49092. *
  49093. * Instead, use the controllers available in babylon itself.
  49094. */
  49095. disableOnlineControllerRepository?: boolean;
  49096. /**
  49097. * A custom URL for the controllers repository
  49098. */
  49099. customControllersRepositoryURL?: string;
  49100. /**
  49101. * Should the controller model's components not move according to the user input
  49102. */
  49103. disableControllerAnimation?: boolean;
  49104. /**
  49105. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  49106. */
  49107. controllerOptions?: IWebXRControllerOptions;
  49108. }
  49109. /**
  49110. * XR input used to track XR inputs such as controllers/rays
  49111. */
  49112. export class WebXRInput implements IDisposable {
  49113. /**
  49114. * the xr session manager for this session
  49115. */
  49116. xrSessionManager: WebXRSessionManager;
  49117. /**
  49118. * the WebXR camera for this session. Mainly used for teleportation
  49119. */
  49120. xrCamera: WebXRCamera;
  49121. private readonly options;
  49122. /**
  49123. * XR controllers being tracked
  49124. */
  49125. controllers: Array<WebXRInputSource>;
  49126. private _frameObserver;
  49127. private _sessionEndedObserver;
  49128. private _sessionInitObserver;
  49129. /**
  49130. * Event when a controller has been connected/added
  49131. */
  49132. onControllerAddedObservable: Observable<WebXRInputSource>;
  49133. /**
  49134. * Event when a controller has been removed/disconnected
  49135. */
  49136. onControllerRemovedObservable: Observable<WebXRInputSource>;
  49137. /**
  49138. * Initializes the WebXRInput
  49139. * @param xrSessionManager the xr session manager for this session
  49140. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  49141. * @param options = initialization options for this xr input
  49142. */
  49143. constructor(
  49144. /**
  49145. * the xr session manager for this session
  49146. */
  49147. xrSessionManager: WebXRSessionManager,
  49148. /**
  49149. * the WebXR camera for this session. Mainly used for teleportation
  49150. */
  49151. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  49152. private _onInputSourcesChange;
  49153. private _addAndRemoveControllers;
  49154. /**
  49155. * Disposes of the object
  49156. */
  49157. dispose(): void;
  49158. }
  49159. }
  49160. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  49161. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49162. import { Observable, EventState } from "babylonjs/Misc/observable";
  49163. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49164. /**
  49165. * This is the base class for all WebXR features.
  49166. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  49167. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  49168. */
  49169. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  49170. protected _xrSessionManager: WebXRSessionManager;
  49171. private _attached;
  49172. private _removeOnDetach;
  49173. /**
  49174. * Should auto-attach be disabled?
  49175. */
  49176. disableAutoAttach: boolean;
  49177. /**
  49178. * Construct a new (abstract) WebXR feature
  49179. * @param _xrSessionManager the xr session manager for this feature
  49180. */
  49181. constructor(_xrSessionManager: WebXRSessionManager);
  49182. /**
  49183. * Is this feature attached
  49184. */
  49185. get attached(): boolean;
  49186. /**
  49187. * attach this feature
  49188. *
  49189. * @param force should attachment be forced (even when already attached)
  49190. * @returns true if successful, false is failed or already attached
  49191. */
  49192. attach(force?: boolean): boolean;
  49193. /**
  49194. * detach this feature.
  49195. *
  49196. * @returns true if successful, false if failed or already detached
  49197. */
  49198. detach(): boolean;
  49199. /**
  49200. * Dispose this feature and all of the resources attached
  49201. */
  49202. dispose(): void;
  49203. /**
  49204. * This is used to register callbacks that will automatically be removed when detach is called.
  49205. * @param observable the observable to which the observer will be attached
  49206. * @param callback the callback to register
  49207. */
  49208. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  49209. /**
  49210. * Code in this function will be executed on each xrFrame received from the browser.
  49211. * This function will not execute after the feature is detached.
  49212. * @param _xrFrame the current frame
  49213. */
  49214. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  49215. }
  49216. }
  49217. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  49218. import { IDisposable, Scene } from "babylonjs/scene";
  49219. import { Nullable } from "babylonjs/types";
  49220. import { Observable } from "babylonjs/Misc/observable";
  49221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49222. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  49223. import { Camera } from "babylonjs/Cameras/camera";
  49224. /**
  49225. * Renders a layer on top of an existing scene
  49226. */
  49227. export class UtilityLayerRenderer implements IDisposable {
  49228. /** the original scene that will be rendered on top of */
  49229. originalScene: Scene;
  49230. private _pointerCaptures;
  49231. private _lastPointerEvents;
  49232. private static _DefaultUtilityLayer;
  49233. private static _DefaultKeepDepthUtilityLayer;
  49234. private _sharedGizmoLight;
  49235. private _renderCamera;
  49236. /**
  49237. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  49238. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  49239. * @returns the camera that is used when rendering the utility layer
  49240. */
  49241. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  49242. /**
  49243. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  49244. * @param cam the camera that should be used when rendering the utility layer
  49245. */
  49246. setRenderCamera(cam: Nullable<Camera>): void;
  49247. /**
  49248. * @hidden
  49249. * Light which used by gizmos to get light shading
  49250. */
  49251. _getSharedGizmoLight(): HemisphericLight;
  49252. /**
  49253. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  49254. */
  49255. pickUtilitySceneFirst: boolean;
  49256. /**
  49257. * 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)
  49258. */
  49259. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  49260. /**
  49261. * 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)
  49262. */
  49263. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  49264. /**
  49265. * The scene that is rendered on top of the original scene
  49266. */
  49267. utilityLayerScene: Scene;
  49268. /**
  49269. * If the utility layer should automatically be rendered on top of existing scene
  49270. */
  49271. shouldRender: boolean;
  49272. /**
  49273. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  49274. */
  49275. onlyCheckPointerDownEvents: boolean;
  49276. /**
  49277. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  49278. */
  49279. processAllEvents: boolean;
  49280. /**
  49281. * Observable raised when the pointer move from the utility layer scene to the main scene
  49282. */
  49283. onPointerOutObservable: Observable<number>;
  49284. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  49285. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  49286. private _afterRenderObserver;
  49287. private _sceneDisposeObserver;
  49288. private _originalPointerObserver;
  49289. /**
  49290. * Instantiates a UtilityLayerRenderer
  49291. * @param originalScene the original scene that will be rendered on top of
  49292. * @param handleEvents boolean indicating if the utility layer should handle events
  49293. */
  49294. constructor(
  49295. /** the original scene that will be rendered on top of */
  49296. originalScene: Scene, handleEvents?: boolean);
  49297. private _notifyObservers;
  49298. /**
  49299. * Renders the utility layers scene on top of the original scene
  49300. */
  49301. render(): void;
  49302. /**
  49303. * Disposes of the renderer
  49304. */
  49305. dispose(): void;
  49306. private _updateCamera;
  49307. }
  49308. }
  49309. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  49310. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49312. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49313. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  49314. import { Scene } from "babylonjs/scene";
  49315. import { Nullable } from "babylonjs/types";
  49316. import { Color3 } from "babylonjs/Maths/math.color";
  49317. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49318. /**
  49319. * Options interface for the pointer selection module
  49320. */
  49321. export interface IWebXRControllerPointerSelectionOptions {
  49322. /**
  49323. * if provided, this scene will be used to render meshes.
  49324. */
  49325. customUtilityLayerScene?: Scene;
  49326. /**
  49327. * 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)
  49328. * If not disabled, the last picked point will be used to execute a pointer up event
  49329. * If disabled, pointer up event will be triggered right after the pointer down event.
  49330. * Used in screen and gaze target ray mode only
  49331. */
  49332. disablePointerUpOnTouchOut: boolean;
  49333. /**
  49334. * For gaze mode (time to select instead of press)
  49335. */
  49336. forceGazeMode: boolean;
  49337. /**
  49338. * 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
  49339. * to start a new countdown to the pointer down event.
  49340. * Defaults to 1.
  49341. */
  49342. gazeModePointerMovedFactor?: number;
  49343. /**
  49344. * Different button type to use instead of the main component
  49345. */
  49346. overrideButtonId?: string;
  49347. /**
  49348. * use this rendering group id for the meshes (optional)
  49349. */
  49350. renderingGroupId?: number;
  49351. /**
  49352. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  49353. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  49354. * 3000 means 3 seconds between pointing at something and selecting it
  49355. */
  49356. timeToSelect?: number;
  49357. /**
  49358. * Should meshes created here be added to a utility layer or the main scene
  49359. */
  49360. useUtilityLayer?: boolean;
  49361. /**
  49362. * the xr input to use with this pointer selection
  49363. */
  49364. xrInput: WebXRInput;
  49365. }
  49366. /**
  49367. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49368. */
  49369. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49370. private readonly _options;
  49371. private static _idCounter;
  49372. private _attachController;
  49373. private _controllers;
  49374. private _scene;
  49375. private _tmpVectorForPickCompare;
  49376. /**
  49377. * The module's name
  49378. */
  49379. static readonly Name: string;
  49380. /**
  49381. * The (Babylon) version of this module.
  49382. * This is an integer representing the implementation version.
  49383. * This number does not correspond to the WebXR specs version
  49384. */
  49385. static readonly Version: number;
  49386. /**
  49387. * Disable lighting on the laser pointer (so it will always be visible)
  49388. */
  49389. disablePointerLighting: boolean;
  49390. /**
  49391. * Disable lighting on the selection mesh (so it will always be visible)
  49392. */
  49393. disableSelectionMeshLighting: boolean;
  49394. /**
  49395. * Should the laser pointer be displayed
  49396. */
  49397. displayLaserPointer: boolean;
  49398. /**
  49399. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49400. */
  49401. displaySelectionMesh: boolean;
  49402. /**
  49403. * This color will be set to the laser pointer when selection is triggered
  49404. */
  49405. laserPointerPickedColor: Color3;
  49406. /**
  49407. * Default color of the laser pointer
  49408. */
  49409. lasterPointerDefaultColor: Color3;
  49410. /**
  49411. * default color of the selection ring
  49412. */
  49413. selectionMeshDefaultColor: Color3;
  49414. /**
  49415. * This color will be applied to the selection ring when selection is triggered
  49416. */
  49417. selectionMeshPickedColor: Color3;
  49418. /**
  49419. * Optional filter to be used for ray selection. This predicate shares behavior with
  49420. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49421. */
  49422. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49423. /**
  49424. * constructs a new background remover module
  49425. * @param _xrSessionManager the session manager for this module
  49426. * @param _options read-only options to be used in this module
  49427. */
  49428. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49429. /**
  49430. * attach this feature
  49431. * Will usually be called by the features manager
  49432. *
  49433. * @returns true if successful.
  49434. */
  49435. attach(): boolean;
  49436. /**
  49437. * detach this feature.
  49438. * Will usually be called by the features manager
  49439. *
  49440. * @returns true if successful.
  49441. */
  49442. detach(): boolean;
  49443. /**
  49444. * Will get the mesh under a specific pointer.
  49445. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49446. * @param controllerId the controllerId to check
  49447. * @returns The mesh under pointer or null if no mesh is under the pointer
  49448. */
  49449. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49450. /**
  49451. * Get the xr controller that correlates to the pointer id in the pointer event
  49452. *
  49453. * @param id the pointer id to search for
  49454. * @returns the controller that correlates to this id or null if not found
  49455. */
  49456. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49457. protected _onXRFrame(_xrFrame: XRFrame): void;
  49458. private _attachGazeMode;
  49459. private _attachScreenRayMode;
  49460. private _attachTrackedPointerRayMode;
  49461. private _convertNormalToDirectionOfRay;
  49462. private _detachController;
  49463. private _generateNewMeshPair;
  49464. private _pickingMoved;
  49465. private _updatePointerDistance;
  49466. }
  49467. }
  49468. declare module "babylonjs/XR/webXREnterExitUI" {
  49469. import { Nullable } from "babylonjs/types";
  49470. import { Observable } from "babylonjs/Misc/observable";
  49471. import { IDisposable, Scene } from "babylonjs/scene";
  49472. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  49473. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49474. /**
  49475. * Button which can be used to enter a different mode of XR
  49476. */
  49477. export class WebXREnterExitUIButton {
  49478. /** button element */
  49479. element: HTMLElement;
  49480. /** XR initialization options for the button */
  49481. sessionMode: XRSessionMode;
  49482. /** Reference space type */
  49483. referenceSpaceType: XRReferenceSpaceType;
  49484. /**
  49485. * Creates a WebXREnterExitUIButton
  49486. * @param element button element
  49487. * @param sessionMode XR initialization session mode
  49488. * @param referenceSpaceType the type of reference space to be used
  49489. */
  49490. constructor(
  49491. /** button element */
  49492. element: HTMLElement,
  49493. /** XR initialization options for the button */
  49494. sessionMode: XRSessionMode,
  49495. /** Reference space type */
  49496. referenceSpaceType: XRReferenceSpaceType);
  49497. /**
  49498. * Extendable function which can be used to update the button's visuals when the state changes
  49499. * @param activeButton the current active button in the UI
  49500. */
  49501. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49502. }
  49503. /**
  49504. * Options to create the webXR UI
  49505. */
  49506. export class WebXREnterExitUIOptions {
  49507. /**
  49508. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49509. */
  49510. customButtons?: Array<WebXREnterExitUIButton>;
  49511. /**
  49512. * A reference space type to use when creating the default button.
  49513. * Default is local-floor
  49514. */
  49515. referenceSpaceType?: XRReferenceSpaceType;
  49516. /**
  49517. * Context to enter xr with
  49518. */
  49519. renderTarget?: Nullable<WebXRRenderTarget>;
  49520. /**
  49521. * A session mode to use when creating the default button.
  49522. * Default is immersive-vr
  49523. */
  49524. sessionMode?: XRSessionMode;
  49525. /**
  49526. * A list of optional features to init the session with
  49527. */
  49528. optionalFeatures?: string[];
  49529. }
  49530. /**
  49531. * UI to allow the user to enter/exit XR mode
  49532. */
  49533. export class WebXREnterExitUI implements IDisposable {
  49534. private scene;
  49535. /** version of the options passed to this UI */
  49536. options: WebXREnterExitUIOptions;
  49537. private _activeButton;
  49538. private _buttons;
  49539. private _overlay;
  49540. /**
  49541. * Fired every time the active button is changed.
  49542. *
  49543. * When xr is entered via a button that launches xr that button will be the callback parameter
  49544. *
  49545. * When exiting xr the callback parameter will be null)
  49546. */
  49547. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49548. /**
  49549. *
  49550. * @param scene babylon scene object to use
  49551. * @param options (read-only) version of the options passed to this UI
  49552. */
  49553. private constructor();
  49554. /**
  49555. * Creates UI to allow the user to enter/exit XR mode
  49556. * @param scene the scene to add the ui to
  49557. * @param helper the xr experience helper to enter/exit xr with
  49558. * @param options options to configure the UI
  49559. * @returns the created ui
  49560. */
  49561. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49562. /**
  49563. * Disposes of the XR UI component
  49564. */
  49565. dispose(): void;
  49566. private _updateButtons;
  49567. }
  49568. }
  49569. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  49570. import { Vector3 } from "babylonjs/Maths/math.vector";
  49571. import { Color4 } from "babylonjs/Maths/math.color";
  49572. import { Nullable } from "babylonjs/types";
  49573. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49574. import { Scene } from "babylonjs/scene";
  49575. /**
  49576. * Class containing static functions to help procedurally build meshes
  49577. */
  49578. export class LinesBuilder {
  49579. /**
  49580. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49581. * * 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
  49582. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49583. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49584. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49585. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49586. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49587. * * 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
  49588. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49590. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49591. * @param name defines the name of the new line system
  49592. * @param options defines the options used to create the line system
  49593. * @param scene defines the hosting scene
  49594. * @returns a new line system mesh
  49595. */
  49596. static CreateLineSystem(name: string, options: {
  49597. lines: Vector3[][];
  49598. updatable?: boolean;
  49599. instance?: Nullable<LinesMesh>;
  49600. colors?: Nullable<Color4[][]>;
  49601. useVertexAlpha?: boolean;
  49602. }, scene: Nullable<Scene>): LinesMesh;
  49603. /**
  49604. * Creates a line mesh
  49605. * 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
  49606. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49607. * * The parameter `points` is an array successive Vector3
  49608. * * 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
  49609. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49610. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49611. * * When updating an instance, remember that only point positions can change, not the number of points
  49612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49613. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49614. * @param name defines the name of the new line system
  49615. * @param options defines the options used to create the line system
  49616. * @param scene defines the hosting scene
  49617. * @returns a new line mesh
  49618. */
  49619. static CreateLines(name: string, options: {
  49620. points: Vector3[];
  49621. updatable?: boolean;
  49622. instance?: Nullable<LinesMesh>;
  49623. colors?: Color4[];
  49624. useVertexAlpha?: boolean;
  49625. }, scene?: Nullable<Scene>): LinesMesh;
  49626. /**
  49627. * Creates a dashed line mesh
  49628. * * 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
  49629. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49630. * * The parameter `points` is an array successive Vector3
  49631. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49632. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49633. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49634. * * 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
  49635. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49636. * * When updating an instance, remember that only point positions can change, not the number of points
  49637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49638. * @param name defines the name of the mesh
  49639. * @param options defines the options used to create the mesh
  49640. * @param scene defines the hosting scene
  49641. * @returns the dashed line mesh
  49642. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49643. */
  49644. static CreateDashedLines(name: string, options: {
  49645. points: Vector3[];
  49646. dashSize?: number;
  49647. gapSize?: number;
  49648. dashNb?: number;
  49649. updatable?: boolean;
  49650. instance?: LinesMesh;
  49651. useVertexAlpha?: boolean;
  49652. }, scene?: Nullable<Scene>): LinesMesh;
  49653. }
  49654. }
  49655. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  49656. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49657. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49658. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49660. import { Vector3 } from "babylonjs/Maths/math.vector";
  49661. import { Material } from "babylonjs/Materials/material";
  49662. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49663. import { Scene } from "babylonjs/scene";
  49664. /**
  49665. * The options container for the teleportation module
  49666. */
  49667. export interface IWebXRTeleportationOptions {
  49668. /**
  49669. * if provided, this scene will be used to render meshes.
  49670. */
  49671. customUtilityLayerScene?: Scene;
  49672. /**
  49673. * Values to configure the default target mesh
  49674. */
  49675. defaultTargetMeshOptions?: {
  49676. /**
  49677. * Fill color of the teleportation area
  49678. */
  49679. teleportationFillColor?: string;
  49680. /**
  49681. * Border color for the teleportation area
  49682. */
  49683. teleportationBorderColor?: string;
  49684. /**
  49685. * Disable the mesh's animation sequence
  49686. */
  49687. disableAnimation?: boolean;
  49688. /**
  49689. * Disable lighting on the material or the ring and arrow
  49690. */
  49691. disableLighting?: boolean;
  49692. /**
  49693. * Override the default material of the torus and arrow
  49694. */
  49695. torusArrowMaterial?: Material;
  49696. };
  49697. /**
  49698. * A list of meshes to use as floor meshes.
  49699. * Meshes can be added and removed after initializing the feature using the
  49700. * addFloorMesh and removeFloorMesh functions
  49701. * If empty, rotation will still work
  49702. */
  49703. floorMeshes?: AbstractMesh[];
  49704. /**
  49705. * use this rendering group id for the meshes (optional)
  49706. */
  49707. renderingGroupId?: number;
  49708. /**
  49709. * Should teleportation move only to snap points
  49710. */
  49711. snapPointsOnly?: boolean;
  49712. /**
  49713. * An array of points to which the teleportation will snap to.
  49714. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49715. */
  49716. snapPositions?: Vector3[];
  49717. /**
  49718. * How close should the teleportation ray be in order to snap to position.
  49719. * Default to 0.8 units (meters)
  49720. */
  49721. snapToPositionRadius?: number;
  49722. /**
  49723. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49724. * If you want to support rotation, make sure your mesh has a direction indicator.
  49725. *
  49726. * When left untouched, the default mesh will be initialized.
  49727. */
  49728. teleportationTargetMesh?: AbstractMesh;
  49729. /**
  49730. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49731. */
  49732. timeToTeleport?: number;
  49733. /**
  49734. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49735. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49736. */
  49737. useMainComponentOnly?: boolean;
  49738. /**
  49739. * Should meshes created here be added to a utility layer or the main scene
  49740. */
  49741. useUtilityLayer?: boolean;
  49742. /**
  49743. * Babylon XR Input class for controller
  49744. */
  49745. xrInput: WebXRInput;
  49746. }
  49747. /**
  49748. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49749. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49750. * the input of the attached controllers.
  49751. */
  49752. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49753. private _options;
  49754. private _controllers;
  49755. private _currentTeleportationControllerId;
  49756. private _floorMeshes;
  49757. private _quadraticBezierCurve;
  49758. private _selectionFeature;
  49759. private _snapToPositions;
  49760. private _snappedToPoint;
  49761. private _teleportationRingMaterial?;
  49762. private _tmpRay;
  49763. private _tmpVector;
  49764. /**
  49765. * The module's name
  49766. */
  49767. static readonly Name: string;
  49768. /**
  49769. * The (Babylon) version of this module.
  49770. * This is an integer representing the implementation version.
  49771. * This number does not correspond to the webxr specs version
  49772. */
  49773. static readonly Version: number;
  49774. /**
  49775. * Is movement backwards enabled
  49776. */
  49777. backwardsMovementEnabled: boolean;
  49778. /**
  49779. * Distance to travel when moving backwards
  49780. */
  49781. backwardsTeleportationDistance: number;
  49782. /**
  49783. * The distance from the user to the inspection point in the direction of the controller
  49784. * A higher number will allow the user to move further
  49785. * defaults to 5 (meters, in xr units)
  49786. */
  49787. parabolicCheckRadius: number;
  49788. /**
  49789. * Should the module support parabolic ray on top of direct ray
  49790. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49791. * Very helpful when moving between floors / different heights
  49792. */
  49793. parabolicRayEnabled: boolean;
  49794. /**
  49795. * How much rotation should be applied when rotating right and left
  49796. */
  49797. rotationAngle: number;
  49798. /**
  49799. * Is rotation enabled when moving forward?
  49800. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49801. */
  49802. rotationEnabled: boolean;
  49803. /**
  49804. * constructs a new anchor system
  49805. * @param _xrSessionManager an instance of WebXRSessionManager
  49806. * @param _options configuration object for this feature
  49807. */
  49808. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49809. /**
  49810. * Get the snapPointsOnly flag
  49811. */
  49812. get snapPointsOnly(): boolean;
  49813. /**
  49814. * Sets the snapPointsOnly flag
  49815. * @param snapToPoints should teleportation be exclusively to snap points
  49816. */
  49817. set snapPointsOnly(snapToPoints: boolean);
  49818. /**
  49819. * Add a new mesh to the floor meshes array
  49820. * @param mesh the mesh to use as floor mesh
  49821. */
  49822. addFloorMesh(mesh: AbstractMesh): void;
  49823. /**
  49824. * Add a new snap-to point to fix teleportation to this position
  49825. * @param newSnapPoint The new Snap-To point
  49826. */
  49827. addSnapPoint(newSnapPoint: Vector3): void;
  49828. attach(): boolean;
  49829. detach(): boolean;
  49830. dispose(): void;
  49831. /**
  49832. * Remove a mesh from the floor meshes array
  49833. * @param mesh the mesh to remove
  49834. */
  49835. removeFloorMesh(mesh: AbstractMesh): void;
  49836. /**
  49837. * Remove a mesh from the floor meshes array using its name
  49838. * @param name the mesh name to remove
  49839. */
  49840. removeFloorMeshByName(name: string): void;
  49841. /**
  49842. * 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
  49843. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49844. * @returns was the point found and removed or not
  49845. */
  49846. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49847. /**
  49848. * This function sets a selection feature that will be disabled when
  49849. * the forward ray is shown and will be reattached when hidden.
  49850. * This is used to remove the selection rays when moving.
  49851. * @param selectionFeature the feature to disable when forward movement is enabled
  49852. */
  49853. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  49854. protected _onXRFrame(_xrFrame: XRFrame): void;
  49855. private _attachController;
  49856. private _createDefaultTargetMesh;
  49857. private _detachController;
  49858. private _findClosestSnapPointWithRadius;
  49859. private _setTargetMeshPosition;
  49860. private _setTargetMeshVisibility;
  49861. private _showParabolicPath;
  49862. private _teleportForward;
  49863. }
  49864. }
  49865. declare module "babylonjs/XR/webXRDefaultExperience" {
  49866. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  49867. import { Scene } from "babylonjs/scene";
  49868. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  49869. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  49870. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49871. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  49872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49873. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  49874. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  49875. /**
  49876. * Options for the default xr helper
  49877. */
  49878. export class WebXRDefaultExperienceOptions {
  49879. /**
  49880. * Enable or disable default UI to enter XR
  49881. */
  49882. disableDefaultUI?: boolean;
  49883. /**
  49884. * Should teleportation not initialize. defaults to false.
  49885. */
  49886. disableTeleportation?: boolean;
  49887. /**
  49888. * Floor meshes that will be used for teleport
  49889. */
  49890. floorMeshes?: Array<AbstractMesh>;
  49891. /**
  49892. * If set to true, the first frame will not be used to reset position
  49893. * The first frame is mainly used when copying transformation from the old camera
  49894. * Mainly used in AR
  49895. */
  49896. ignoreNativeCameraTransformation?: boolean;
  49897. /**
  49898. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49899. */
  49900. inputOptions?: IWebXRInputOptions;
  49901. /**
  49902. * optional configuration for the output canvas
  49903. */
  49904. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49905. /**
  49906. * optional UI options. This can be used among other to change session mode and reference space type
  49907. */
  49908. uiOptions?: WebXREnterExitUIOptions;
  49909. /**
  49910. * When loading teleportation and pointer select, use stable versions instead of latest.
  49911. */
  49912. useStablePlugins?: boolean;
  49913. /**
  49914. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49915. */
  49916. renderingGroupId?: number;
  49917. /**
  49918. * A list of optional features to init the session with
  49919. * If set to true, all features we support will be added
  49920. */
  49921. optionalFeatures?: boolean | string[];
  49922. }
  49923. /**
  49924. * Default experience which provides a similar setup to the previous webVRExperience
  49925. */
  49926. export class WebXRDefaultExperience {
  49927. /**
  49928. * Base experience
  49929. */
  49930. baseExperience: WebXRExperienceHelper;
  49931. /**
  49932. * Enables ui for entering/exiting xr
  49933. */
  49934. enterExitUI: WebXREnterExitUI;
  49935. /**
  49936. * Input experience extension
  49937. */
  49938. input: WebXRInput;
  49939. /**
  49940. * Enables laser pointer and selection
  49941. */
  49942. pointerSelection: WebXRControllerPointerSelection;
  49943. /**
  49944. * Default target xr should render to
  49945. */
  49946. renderTarget: WebXRRenderTarget;
  49947. /**
  49948. * Enables teleportation
  49949. */
  49950. teleportation: WebXRMotionControllerTeleportation;
  49951. private constructor();
  49952. /**
  49953. * Creates the default xr experience
  49954. * @param scene scene
  49955. * @param options options for basic configuration
  49956. * @returns resulting WebXRDefaultExperience
  49957. */
  49958. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49959. /**
  49960. * DIsposes of the experience helper
  49961. */
  49962. dispose(): void;
  49963. }
  49964. }
  49965. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  49966. import { Observable } from "babylonjs/Misc/observable";
  49967. import { Nullable } from "babylonjs/types";
  49968. import { Camera } from "babylonjs/Cameras/camera";
  49969. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  49970. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  49971. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  49972. import { Scene } from "babylonjs/scene";
  49973. import { Vector3 } from "babylonjs/Maths/math.vector";
  49974. import { Color3 } from "babylonjs/Maths/math.color";
  49975. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49977. import { Mesh } from "babylonjs/Meshes/mesh";
  49978. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  49979. import { EasingFunction } from "babylonjs/Animations/easing";
  49980. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  49981. import "babylonjs/Meshes/Builders/groundBuilder";
  49982. import "babylonjs/Meshes/Builders/torusBuilder";
  49983. import "babylonjs/Meshes/Builders/cylinderBuilder";
  49984. import "babylonjs/Gamepads/gamepadSceneComponent";
  49985. import "babylonjs/Animations/animatable";
  49986. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  49987. /**
  49988. * Options to modify the vr teleportation behavior.
  49989. */
  49990. export interface VRTeleportationOptions {
  49991. /**
  49992. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49993. */
  49994. floorMeshName?: string;
  49995. /**
  49996. * A list of meshes to be used as the teleportation floor. (default: empty)
  49997. */
  49998. floorMeshes?: Mesh[];
  49999. /**
  50000. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  50001. */
  50002. teleportationMode?: number;
  50003. /**
  50004. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  50005. */
  50006. teleportationTime?: number;
  50007. /**
  50008. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  50009. */
  50010. teleportationSpeed?: number;
  50011. /**
  50012. * The easing function used in the animation or null for Linear. (default CircleEase)
  50013. */
  50014. easingFunction?: EasingFunction;
  50015. }
  50016. /**
  50017. * Options to modify the vr experience helper's behavior.
  50018. */
  50019. export interface VRExperienceHelperOptions extends WebVROptions {
  50020. /**
  50021. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  50022. */
  50023. createDeviceOrientationCamera?: boolean;
  50024. /**
  50025. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  50026. */
  50027. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  50028. /**
  50029. * Uses the main button on the controller to toggle the laser casted. (default: true)
  50030. */
  50031. laserToggle?: boolean;
  50032. /**
  50033. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  50034. */
  50035. floorMeshes?: Mesh[];
  50036. /**
  50037. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  50038. */
  50039. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  50040. /**
  50041. * Defines if WebXR should be used instead of WebVR (if available)
  50042. */
  50043. useXR?: boolean;
  50044. }
  50045. /**
  50046. * Event containing information after VR has been entered
  50047. */
  50048. export class OnAfterEnteringVRObservableEvent {
  50049. /**
  50050. * If entering vr was successful
  50051. */
  50052. success: boolean;
  50053. }
  50054. /**
  50055. * Helps to quickly add VR support to an existing scene.
  50056. * See http://doc.babylonjs.com/how_to/webvr_helper
  50057. */
  50058. export class VRExperienceHelper {
  50059. /** Options to modify the vr experience helper's behavior. */
  50060. webVROptions: VRExperienceHelperOptions;
  50061. private _scene;
  50062. private _position;
  50063. private _btnVR;
  50064. private _btnVRDisplayed;
  50065. private _webVRsupported;
  50066. private _webVRready;
  50067. private _webVRrequesting;
  50068. private _webVRpresenting;
  50069. private _hasEnteredVR;
  50070. private _fullscreenVRpresenting;
  50071. private _inputElement;
  50072. private _webVRCamera;
  50073. private _vrDeviceOrientationCamera;
  50074. private _deviceOrientationCamera;
  50075. private _existingCamera;
  50076. private _onKeyDown;
  50077. private _onVrDisplayPresentChange;
  50078. private _onVRDisplayChanged;
  50079. private _onVRRequestPresentStart;
  50080. private _onVRRequestPresentComplete;
  50081. /**
  50082. * 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)
  50083. */
  50084. enableGazeEvenWhenNoPointerLock: boolean;
  50085. /**
  50086. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  50087. */
  50088. exitVROnDoubleTap: boolean;
  50089. /**
  50090. * Observable raised right before entering VR.
  50091. */
  50092. onEnteringVRObservable: Observable<VRExperienceHelper>;
  50093. /**
  50094. * Observable raised when entering VR has completed.
  50095. */
  50096. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  50097. /**
  50098. * Observable raised when exiting VR.
  50099. */
  50100. onExitingVRObservable: Observable<VRExperienceHelper>;
  50101. /**
  50102. * Observable raised when controller mesh is loaded.
  50103. */
  50104. onControllerMeshLoadedObservable: Observable<WebVRController>;
  50105. /** Return this.onEnteringVRObservable
  50106. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  50107. */
  50108. get onEnteringVR(): Observable<VRExperienceHelper>;
  50109. /** Return this.onExitingVRObservable
  50110. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  50111. */
  50112. get onExitingVR(): Observable<VRExperienceHelper>;
  50113. /** Return this.onControllerMeshLoadedObservable
  50114. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  50115. */
  50116. get onControllerMeshLoaded(): Observable<WebVRController>;
  50117. private _rayLength;
  50118. private _useCustomVRButton;
  50119. private _teleportationRequested;
  50120. private _teleportActive;
  50121. private _floorMeshName;
  50122. private _floorMeshesCollection;
  50123. private _teleportationMode;
  50124. private _teleportationTime;
  50125. private _teleportationSpeed;
  50126. private _teleportationEasing;
  50127. private _rotationAllowed;
  50128. private _teleportBackwardsVector;
  50129. private _teleportationTarget;
  50130. private _isDefaultTeleportationTarget;
  50131. private _postProcessMove;
  50132. private _teleportationFillColor;
  50133. private _teleportationBorderColor;
  50134. private _rotationAngle;
  50135. private _haloCenter;
  50136. private _cameraGazer;
  50137. private _padSensibilityUp;
  50138. private _padSensibilityDown;
  50139. private _leftController;
  50140. private _rightController;
  50141. private _gazeColor;
  50142. private _laserColor;
  50143. private _pickedLaserColor;
  50144. private _pickedGazeColor;
  50145. /**
  50146. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  50147. */
  50148. onNewMeshSelected: Observable<AbstractMesh>;
  50149. /**
  50150. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  50151. * This observable will provide the mesh and the controller used to select the mesh
  50152. */
  50153. onMeshSelectedWithController: Observable<{
  50154. mesh: AbstractMesh;
  50155. controller: WebVRController;
  50156. }>;
  50157. /**
  50158. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  50159. */
  50160. onNewMeshPicked: Observable<PickingInfo>;
  50161. private _circleEase;
  50162. /**
  50163. * Observable raised before camera teleportation
  50164. */
  50165. onBeforeCameraTeleport: Observable<Vector3>;
  50166. /**
  50167. * Observable raised after camera teleportation
  50168. */
  50169. onAfterCameraTeleport: Observable<Vector3>;
  50170. /**
  50171. * Observable raised when current selected mesh gets unselected
  50172. */
  50173. onSelectedMeshUnselected: Observable<AbstractMesh>;
  50174. private _raySelectionPredicate;
  50175. /**
  50176. * To be optionaly changed by user to define custom ray selection
  50177. */
  50178. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50179. /**
  50180. * To be optionaly changed by user to define custom selection logic (after ray selection)
  50181. */
  50182. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50183. /**
  50184. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  50185. */
  50186. teleportationEnabled: boolean;
  50187. private _defaultHeight;
  50188. private _teleportationInitialized;
  50189. private _interactionsEnabled;
  50190. private _interactionsRequested;
  50191. private _displayGaze;
  50192. private _displayLaserPointer;
  50193. /**
  50194. * The mesh used to display where the user is going to teleport.
  50195. */
  50196. get teleportationTarget(): Mesh;
  50197. /**
  50198. * Sets the mesh to be used to display where the user is going to teleport.
  50199. */
  50200. set teleportationTarget(value: Mesh);
  50201. /**
  50202. * 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
  50203. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  50204. * See http://doc.babylonjs.com/resources/baking_transformations
  50205. */
  50206. get gazeTrackerMesh(): Mesh;
  50207. set gazeTrackerMesh(value: Mesh);
  50208. /**
  50209. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  50210. */
  50211. updateGazeTrackerScale: boolean;
  50212. /**
  50213. * If the gaze trackers color should be updated when selecting meshes
  50214. */
  50215. updateGazeTrackerColor: boolean;
  50216. /**
  50217. * If the controller laser color should be updated when selecting meshes
  50218. */
  50219. updateControllerLaserColor: boolean;
  50220. /**
  50221. * The gaze tracking mesh corresponding to the left controller
  50222. */
  50223. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  50224. /**
  50225. * The gaze tracking mesh corresponding to the right controller
  50226. */
  50227. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  50228. /**
  50229. * If the ray of the gaze should be displayed.
  50230. */
  50231. get displayGaze(): boolean;
  50232. /**
  50233. * Sets if the ray of the gaze should be displayed.
  50234. */
  50235. set displayGaze(value: boolean);
  50236. /**
  50237. * If the ray of the LaserPointer should be displayed.
  50238. */
  50239. get displayLaserPointer(): boolean;
  50240. /**
  50241. * Sets if the ray of the LaserPointer should be displayed.
  50242. */
  50243. set displayLaserPointer(value: boolean);
  50244. /**
  50245. * The deviceOrientationCamera used as the camera when not in VR.
  50246. */
  50247. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  50248. /**
  50249. * Based on the current WebVR support, returns the current VR camera used.
  50250. */
  50251. get currentVRCamera(): Nullable<Camera>;
  50252. /**
  50253. * The webVRCamera which is used when in VR.
  50254. */
  50255. get webVRCamera(): WebVRFreeCamera;
  50256. /**
  50257. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50258. */
  50259. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50260. /**
  50261. * The html button that is used to trigger entering into VR.
  50262. */
  50263. get vrButton(): Nullable<HTMLButtonElement>;
  50264. private get _teleportationRequestInitiated();
  50265. /**
  50266. * Defines whether or not Pointer lock should be requested when switching to
  50267. * full screen.
  50268. */
  50269. requestPointerLockOnFullScreen: boolean;
  50270. /**
  50271. * If asking to force XR, this will be populated with the default xr experience
  50272. */
  50273. xr: WebXRDefaultExperience;
  50274. /**
  50275. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50276. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50277. */
  50278. xrTestDone: boolean;
  50279. /**
  50280. * Instantiates a VRExperienceHelper.
  50281. * Helps to quickly add VR support to an existing scene.
  50282. * @param scene The scene the VRExperienceHelper belongs to.
  50283. * @param webVROptions Options to modify the vr experience helper's behavior.
  50284. */
  50285. constructor(scene: Scene,
  50286. /** Options to modify the vr experience helper's behavior. */
  50287. webVROptions?: VRExperienceHelperOptions);
  50288. private completeVRInit;
  50289. private _onDefaultMeshLoaded;
  50290. private _onResize;
  50291. private _onFullscreenChange;
  50292. /**
  50293. * Gets a value indicating if we are currently in VR mode.
  50294. */
  50295. get isInVRMode(): boolean;
  50296. private onVrDisplayPresentChange;
  50297. private onVRDisplayChanged;
  50298. private moveButtonToBottomRight;
  50299. private displayVRButton;
  50300. private updateButtonVisibility;
  50301. private _cachedAngularSensibility;
  50302. /**
  50303. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50304. * Otherwise, will use the fullscreen API.
  50305. */
  50306. enterVR(): void;
  50307. /**
  50308. * Attempt to exit VR, or fullscreen.
  50309. */
  50310. exitVR(): void;
  50311. /**
  50312. * The position of the vr experience helper.
  50313. */
  50314. get position(): Vector3;
  50315. /**
  50316. * Sets the position of the vr experience helper.
  50317. */
  50318. set position(value: Vector3);
  50319. /**
  50320. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50321. */
  50322. enableInteractions(): void;
  50323. private get _noControllerIsActive();
  50324. private beforeRender;
  50325. private _isTeleportationFloor;
  50326. /**
  50327. * Adds a floor mesh to be used for teleportation.
  50328. * @param floorMesh the mesh to be used for teleportation.
  50329. */
  50330. addFloorMesh(floorMesh: Mesh): void;
  50331. /**
  50332. * Removes a floor mesh from being used for teleportation.
  50333. * @param floorMesh the mesh to be removed.
  50334. */
  50335. removeFloorMesh(floorMesh: Mesh): void;
  50336. /**
  50337. * Enables interactions and teleportation using the VR controllers and gaze.
  50338. * @param vrTeleportationOptions options to modify teleportation behavior.
  50339. */
  50340. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50341. private _onNewGamepadConnected;
  50342. private _tryEnableInteractionOnController;
  50343. private _onNewGamepadDisconnected;
  50344. private _enableInteractionOnController;
  50345. private _checkTeleportWithRay;
  50346. private _checkRotate;
  50347. private _checkTeleportBackwards;
  50348. private _enableTeleportationOnController;
  50349. private _createTeleportationCircles;
  50350. private _displayTeleportationTarget;
  50351. private _hideTeleportationTarget;
  50352. private _rotateCamera;
  50353. private _moveTeleportationSelectorTo;
  50354. private _workingVector;
  50355. private _workingQuaternion;
  50356. private _workingMatrix;
  50357. /**
  50358. * Time Constant Teleportation Mode
  50359. */
  50360. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50361. /**
  50362. * Speed Constant Teleportation Mode
  50363. */
  50364. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50365. /**
  50366. * Teleports the users feet to the desired location
  50367. * @param location The location where the user's feet should be placed
  50368. */
  50369. teleportCamera(location: Vector3): void;
  50370. private _convertNormalToDirectionOfRay;
  50371. private _castRayAndSelectObject;
  50372. private _notifySelectedMeshUnselected;
  50373. /**
  50374. * Permanently set new colors for the laser pointer
  50375. * @param color the new laser color
  50376. * @param pickedColor the new laser color when picked mesh detected
  50377. */
  50378. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50379. /**
  50380. * Set lighting enabled / disabled on the laser pointer of both controllers
  50381. * @param enabled should the lighting be enabled on the laser pointer
  50382. */
  50383. setLaserLightingState(enabled?: boolean): void;
  50384. /**
  50385. * Permanently set new colors for the gaze pointer
  50386. * @param color the new gaze color
  50387. * @param pickedColor the new gaze color when picked mesh detected
  50388. */
  50389. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50390. /**
  50391. * Sets the color of the laser ray from the vr controllers.
  50392. * @param color new color for the ray.
  50393. */
  50394. changeLaserColor(color: Color3): void;
  50395. /**
  50396. * Sets the color of the ray from the vr headsets gaze.
  50397. * @param color new color for the ray.
  50398. */
  50399. changeGazeColor(color: Color3): void;
  50400. /**
  50401. * Exits VR and disposes of the vr experience helper
  50402. */
  50403. dispose(): void;
  50404. /**
  50405. * Gets the name of the VRExperienceHelper class
  50406. * @returns "VRExperienceHelper"
  50407. */
  50408. getClassName(): string;
  50409. }
  50410. }
  50411. declare module "babylonjs/Cameras/VR/index" {
  50412. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  50413. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  50414. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50415. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  50416. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  50417. export * from "babylonjs/Cameras/VR/webVRCamera";
  50418. }
  50419. declare module "babylonjs/Cameras/RigModes/index" {
  50420. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  50421. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  50422. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  50423. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  50424. }
  50425. declare module "babylonjs/Cameras/index" {
  50426. export * from "babylonjs/Cameras/Inputs/index";
  50427. export * from "babylonjs/Cameras/cameraInputsManager";
  50428. export * from "babylonjs/Cameras/camera";
  50429. export * from "babylonjs/Cameras/targetCamera";
  50430. export * from "babylonjs/Cameras/freeCamera";
  50431. export * from "babylonjs/Cameras/freeCameraInputsManager";
  50432. export * from "babylonjs/Cameras/touchCamera";
  50433. export * from "babylonjs/Cameras/arcRotateCamera";
  50434. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  50435. export * from "babylonjs/Cameras/deviceOrientationCamera";
  50436. export * from "babylonjs/Cameras/flyCamera";
  50437. export * from "babylonjs/Cameras/flyCameraInputsManager";
  50438. export * from "babylonjs/Cameras/followCamera";
  50439. export * from "babylonjs/Cameras/followCameraInputsManager";
  50440. export * from "babylonjs/Cameras/gamepadCamera";
  50441. export * from "babylonjs/Cameras/Stereoscopic/index";
  50442. export * from "babylonjs/Cameras/universalCamera";
  50443. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  50444. export * from "babylonjs/Cameras/VR/index";
  50445. export * from "babylonjs/Cameras/RigModes/index";
  50446. }
  50447. declare module "babylonjs/Collisions/index" {
  50448. export * from "babylonjs/Collisions/collider";
  50449. export * from "babylonjs/Collisions/collisionCoordinator";
  50450. export * from "babylonjs/Collisions/pickingInfo";
  50451. export * from "babylonjs/Collisions/intersectionInfo";
  50452. export * from "babylonjs/Collisions/meshCollisionData";
  50453. }
  50454. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  50455. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  50456. import { Vector3 } from "babylonjs/Maths/math.vector";
  50457. import { Ray } from "babylonjs/Culling/ray";
  50458. import { Plane } from "babylonjs/Maths/math.plane";
  50459. /**
  50460. * Contains an array of blocks representing the octree
  50461. */
  50462. export interface IOctreeContainer<T> {
  50463. /**
  50464. * Blocks within the octree
  50465. */
  50466. blocks: Array<OctreeBlock<T>>;
  50467. }
  50468. /**
  50469. * Class used to store a cell in an octree
  50470. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50471. */
  50472. export class OctreeBlock<T> {
  50473. /**
  50474. * Gets the content of the current block
  50475. */
  50476. entries: T[];
  50477. /**
  50478. * Gets the list of block children
  50479. */
  50480. blocks: Array<OctreeBlock<T>>;
  50481. private _depth;
  50482. private _maxDepth;
  50483. private _capacity;
  50484. private _minPoint;
  50485. private _maxPoint;
  50486. private _boundingVectors;
  50487. private _creationFunc;
  50488. /**
  50489. * Creates a new block
  50490. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50491. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50492. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50493. * @param depth defines the current depth of this block in the octree
  50494. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50495. * @param creationFunc defines a callback to call when an element is added to the block
  50496. */
  50497. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50498. /**
  50499. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50500. */
  50501. get capacity(): number;
  50502. /**
  50503. * Gets the minimum vector (in world space) of the block's bounding box
  50504. */
  50505. get minPoint(): Vector3;
  50506. /**
  50507. * Gets the maximum vector (in world space) of the block's bounding box
  50508. */
  50509. get maxPoint(): Vector3;
  50510. /**
  50511. * Add a new element to this block
  50512. * @param entry defines the element to add
  50513. */
  50514. addEntry(entry: T): void;
  50515. /**
  50516. * Remove an element from this block
  50517. * @param entry defines the element to remove
  50518. */
  50519. removeEntry(entry: T): void;
  50520. /**
  50521. * Add an array of elements to this block
  50522. * @param entries defines the array of elements to add
  50523. */
  50524. addEntries(entries: T[]): void;
  50525. /**
  50526. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50527. * @param frustumPlanes defines the frustum planes to test
  50528. * @param selection defines the array to store current content if selection is positive
  50529. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50530. */
  50531. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50532. /**
  50533. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50534. * @param sphereCenter defines the bounding sphere center
  50535. * @param sphereRadius defines the bounding sphere radius
  50536. * @param selection defines the array to store current content if selection is positive
  50537. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50538. */
  50539. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50540. /**
  50541. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50542. * @param ray defines the ray to test with
  50543. * @param selection defines the array to store current content if selection is positive
  50544. */
  50545. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50546. /**
  50547. * Subdivide the content into child blocks (this block will then be empty)
  50548. */
  50549. createInnerBlocks(): void;
  50550. /**
  50551. * @hidden
  50552. */
  50553. 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;
  50554. }
  50555. }
  50556. declare module "babylonjs/Culling/Octrees/octree" {
  50557. import { SmartArray } from "babylonjs/Misc/smartArray";
  50558. import { Vector3 } from "babylonjs/Maths/math.vector";
  50559. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50561. import { Ray } from "babylonjs/Culling/ray";
  50562. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  50563. import { Plane } from "babylonjs/Maths/math.plane";
  50564. /**
  50565. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50566. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50567. */
  50568. export class Octree<T> {
  50569. /** 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.) */
  50570. maxDepth: number;
  50571. /**
  50572. * Blocks within the octree containing objects
  50573. */
  50574. blocks: Array<OctreeBlock<T>>;
  50575. /**
  50576. * Content stored in the octree
  50577. */
  50578. dynamicContent: T[];
  50579. private _maxBlockCapacity;
  50580. private _selectionContent;
  50581. private _creationFunc;
  50582. /**
  50583. * Creates a octree
  50584. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50585. * @param creationFunc function to be used to instatiate the octree
  50586. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50587. * @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.)
  50588. */
  50589. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50590. /** 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.) */
  50591. maxDepth?: number);
  50592. /**
  50593. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50594. * @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);
  50595. * @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);
  50596. * @param entries meshes to be added to the octree blocks
  50597. */
  50598. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50599. /**
  50600. * Adds a mesh to the octree
  50601. * @param entry Mesh to add to the octree
  50602. */
  50603. addMesh(entry: T): void;
  50604. /**
  50605. * Remove an element from the octree
  50606. * @param entry defines the element to remove
  50607. */
  50608. removeMesh(entry: T): void;
  50609. /**
  50610. * Selects an array of meshes within the frustum
  50611. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50612. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50613. * @returns array of meshes within the frustum
  50614. */
  50615. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50616. /**
  50617. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50618. * @param sphereCenter defines the bounding sphere center
  50619. * @param sphereRadius defines the bounding sphere radius
  50620. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50621. * @returns an array of objects that intersect the sphere
  50622. */
  50623. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50624. /**
  50625. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50626. * @param ray defines the ray to test with
  50627. * @returns array of intersected objects
  50628. */
  50629. intersectsRay(ray: Ray): SmartArray<T>;
  50630. /**
  50631. * Adds a mesh into the octree block if it intersects the block
  50632. */
  50633. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50634. /**
  50635. * Adds a submesh into the octree block if it intersects the block
  50636. */
  50637. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50638. }
  50639. }
  50640. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  50641. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  50642. import { Scene } from "babylonjs/scene";
  50643. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50645. import { Ray } from "babylonjs/Culling/ray";
  50646. import { Octree } from "babylonjs/Culling/Octrees/octree";
  50647. import { Collider } from "babylonjs/Collisions/collider";
  50648. module "babylonjs/scene" {
  50649. interface Scene {
  50650. /**
  50651. * @hidden
  50652. * Backing Filed
  50653. */
  50654. _selectionOctree: Octree<AbstractMesh>;
  50655. /**
  50656. * Gets the octree used to boost mesh selection (picking)
  50657. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50658. */
  50659. selectionOctree: Octree<AbstractMesh>;
  50660. /**
  50661. * Creates or updates the octree used to boost selection (picking)
  50662. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50663. * @param maxCapacity defines the maximum capacity per leaf
  50664. * @param maxDepth defines the maximum depth of the octree
  50665. * @returns an octree of AbstractMesh
  50666. */
  50667. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50668. }
  50669. }
  50670. module "babylonjs/Meshes/abstractMesh" {
  50671. interface AbstractMesh {
  50672. /**
  50673. * @hidden
  50674. * Backing Field
  50675. */
  50676. _submeshesOctree: Octree<SubMesh>;
  50677. /**
  50678. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50679. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50680. * @param maxCapacity defines the maximum size of each block (64 by default)
  50681. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50682. * @returns the new octree
  50683. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50684. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50685. */
  50686. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50687. }
  50688. }
  50689. /**
  50690. * Defines the octree scene component responsible to manage any octrees
  50691. * in a given scene.
  50692. */
  50693. export class OctreeSceneComponent {
  50694. /**
  50695. * The component name help to identify the component in the list of scene components.
  50696. */
  50697. readonly name: string;
  50698. /**
  50699. * The scene the component belongs to.
  50700. */
  50701. scene: Scene;
  50702. /**
  50703. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50704. */
  50705. readonly checksIsEnabled: boolean;
  50706. /**
  50707. * Creates a new instance of the component for the given scene
  50708. * @param scene Defines the scene to register the component in
  50709. */
  50710. constructor(scene: Scene);
  50711. /**
  50712. * Registers the component in a given scene
  50713. */
  50714. register(): void;
  50715. /**
  50716. * Return the list of active meshes
  50717. * @returns the list of active meshes
  50718. */
  50719. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50720. /**
  50721. * Return the list of active sub meshes
  50722. * @param mesh The mesh to get the candidates sub meshes from
  50723. * @returns the list of active sub meshes
  50724. */
  50725. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50726. private _tempRay;
  50727. /**
  50728. * Return the list of sub meshes intersecting with a given local ray
  50729. * @param mesh defines the mesh to find the submesh for
  50730. * @param localRay defines the ray in local space
  50731. * @returns the list of intersecting sub meshes
  50732. */
  50733. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50734. /**
  50735. * Return the list of sub meshes colliding with a collider
  50736. * @param mesh defines the mesh to find the submesh for
  50737. * @param collider defines the collider to evaluate the collision against
  50738. * @returns the list of colliding sub meshes
  50739. */
  50740. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50741. /**
  50742. * Rebuilds the elements related to this component in case of
  50743. * context lost for instance.
  50744. */
  50745. rebuild(): void;
  50746. /**
  50747. * Disposes the component and the associated ressources.
  50748. */
  50749. dispose(): void;
  50750. }
  50751. }
  50752. declare module "babylonjs/Culling/Octrees/index" {
  50753. export * from "babylonjs/Culling/Octrees/octree";
  50754. export * from "babylonjs/Culling/Octrees/octreeBlock";
  50755. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  50756. }
  50757. declare module "babylonjs/Culling/index" {
  50758. export * from "babylonjs/Culling/boundingBox";
  50759. export * from "babylonjs/Culling/boundingInfo";
  50760. export * from "babylonjs/Culling/boundingSphere";
  50761. export * from "babylonjs/Culling/Octrees/index";
  50762. export * from "babylonjs/Culling/ray";
  50763. }
  50764. declare module "babylonjs/Gizmos/gizmo" {
  50765. import { Nullable } from "babylonjs/types";
  50766. import { IDisposable } from "babylonjs/scene";
  50767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50768. import { Mesh } from "babylonjs/Meshes/mesh";
  50769. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50770. /**
  50771. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50772. */
  50773. export class Gizmo implements IDisposable {
  50774. /** The utility layer the gizmo will be added to */
  50775. gizmoLayer: UtilityLayerRenderer;
  50776. /**
  50777. * The root mesh of the gizmo
  50778. */
  50779. _rootMesh: Mesh;
  50780. private _attachedMesh;
  50781. /**
  50782. * Ratio for the scale of the gizmo (Default: 1)
  50783. */
  50784. scaleRatio: number;
  50785. /**
  50786. * If a custom mesh has been set (Default: false)
  50787. */
  50788. protected _customMeshSet: boolean;
  50789. /**
  50790. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50791. * * When set, interactions will be enabled
  50792. */
  50793. get attachedMesh(): Nullable<AbstractMesh>;
  50794. set attachedMesh(value: Nullable<AbstractMesh>);
  50795. /**
  50796. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50797. * @param mesh The mesh to replace the default mesh of the gizmo
  50798. */
  50799. setCustomMesh(mesh: Mesh): void;
  50800. /**
  50801. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50802. */
  50803. updateGizmoRotationToMatchAttachedMesh: boolean;
  50804. /**
  50805. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50806. */
  50807. updateGizmoPositionToMatchAttachedMesh: boolean;
  50808. /**
  50809. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50810. */
  50811. updateScale: boolean;
  50812. protected _interactionsEnabled: boolean;
  50813. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50814. private _beforeRenderObserver;
  50815. private _tempVector;
  50816. /**
  50817. * Creates a gizmo
  50818. * @param gizmoLayer The utility layer the gizmo will be added to
  50819. */
  50820. constructor(
  50821. /** The utility layer the gizmo will be added to */
  50822. gizmoLayer?: UtilityLayerRenderer);
  50823. /**
  50824. * Updates the gizmo to match the attached mesh's position/rotation
  50825. */
  50826. protected _update(): void;
  50827. /**
  50828. * Disposes of the gizmo
  50829. */
  50830. dispose(): void;
  50831. }
  50832. }
  50833. declare module "babylonjs/Gizmos/planeDragGizmo" {
  50834. import { Observable } from "babylonjs/Misc/observable";
  50835. import { Nullable } from "babylonjs/types";
  50836. import { Vector3 } from "babylonjs/Maths/math.vector";
  50837. import { Color3 } from "babylonjs/Maths/math.color";
  50838. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50840. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50841. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50842. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50843. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  50844. import { Scene } from "babylonjs/scene";
  50845. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50846. /**
  50847. * Single plane drag gizmo
  50848. */
  50849. export class PlaneDragGizmo extends Gizmo {
  50850. /**
  50851. * Drag behavior responsible for the gizmos dragging interactions
  50852. */
  50853. dragBehavior: PointerDragBehavior;
  50854. private _pointerObserver;
  50855. /**
  50856. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50857. */
  50858. snapDistance: number;
  50859. /**
  50860. * Event that fires each time the gizmo snaps to a new location.
  50861. * * snapDistance is the the change in distance
  50862. */
  50863. onSnapObservable: Observable<{
  50864. snapDistance: number;
  50865. }>;
  50866. private _plane;
  50867. private _coloredMaterial;
  50868. private _hoverMaterial;
  50869. private _isEnabled;
  50870. private _parent;
  50871. /** @hidden */
  50872. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50873. /** @hidden */
  50874. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50875. /**
  50876. * Creates a PlaneDragGizmo
  50877. * @param gizmoLayer The utility layer the gizmo will be added to
  50878. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50879. * @param color The color of the gizmo
  50880. */
  50881. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50882. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50883. /**
  50884. * If the gizmo is enabled
  50885. */
  50886. set isEnabled(value: boolean);
  50887. get isEnabled(): boolean;
  50888. /**
  50889. * Disposes of the gizmo
  50890. */
  50891. dispose(): void;
  50892. }
  50893. }
  50894. declare module "babylonjs/Gizmos/positionGizmo" {
  50895. import { Observable } from "babylonjs/Misc/observable";
  50896. import { Nullable } from "babylonjs/types";
  50897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50898. import { Mesh } from "babylonjs/Meshes/mesh";
  50899. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50900. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  50901. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  50902. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50903. /**
  50904. * Gizmo that enables dragging a mesh along 3 axis
  50905. */
  50906. export class PositionGizmo extends Gizmo {
  50907. /**
  50908. * Internal gizmo used for interactions on the x axis
  50909. */
  50910. xGizmo: AxisDragGizmo;
  50911. /**
  50912. * Internal gizmo used for interactions on the y axis
  50913. */
  50914. yGizmo: AxisDragGizmo;
  50915. /**
  50916. * Internal gizmo used for interactions on the z axis
  50917. */
  50918. zGizmo: AxisDragGizmo;
  50919. /**
  50920. * Internal gizmo used for interactions on the yz plane
  50921. */
  50922. xPlaneGizmo: PlaneDragGizmo;
  50923. /**
  50924. * Internal gizmo used for interactions on the xz plane
  50925. */
  50926. yPlaneGizmo: PlaneDragGizmo;
  50927. /**
  50928. * Internal gizmo used for interactions on the xy plane
  50929. */
  50930. zPlaneGizmo: PlaneDragGizmo;
  50931. /**
  50932. * private variables
  50933. */
  50934. private _meshAttached;
  50935. private _updateGizmoRotationToMatchAttachedMesh;
  50936. private _snapDistance;
  50937. private _scaleRatio;
  50938. /** Fires an event when any of it's sub gizmos are dragged */
  50939. onDragStartObservable: Observable<unknown>;
  50940. /** Fires an event when any of it's sub gizmos are released from dragging */
  50941. onDragEndObservable: Observable<unknown>;
  50942. /**
  50943. * If set to true, planar drag is enabled
  50944. */
  50945. private _planarGizmoEnabled;
  50946. get attachedMesh(): Nullable<AbstractMesh>;
  50947. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50948. /**
  50949. * Creates a PositionGizmo
  50950. * @param gizmoLayer The utility layer the gizmo will be added to
  50951. */
  50952. constructor(gizmoLayer?: UtilityLayerRenderer);
  50953. /**
  50954. * If the planar drag gizmo is enabled
  50955. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50956. */
  50957. set planarGizmoEnabled(value: boolean);
  50958. get planarGizmoEnabled(): boolean;
  50959. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50960. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50961. /**
  50962. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50963. */
  50964. set snapDistance(value: number);
  50965. get snapDistance(): number;
  50966. /**
  50967. * Ratio for the scale of the gizmo (Default: 1)
  50968. */
  50969. set scaleRatio(value: number);
  50970. get scaleRatio(): number;
  50971. /**
  50972. * Disposes of the gizmo
  50973. */
  50974. dispose(): void;
  50975. /**
  50976. * CustomMeshes are not supported by this gizmo
  50977. * @param mesh The mesh to replace the default mesh of the gizmo
  50978. */
  50979. setCustomMesh(mesh: Mesh): void;
  50980. }
  50981. }
  50982. declare module "babylonjs/Gizmos/axisDragGizmo" {
  50983. import { Observable } from "babylonjs/Misc/observable";
  50984. import { Nullable } from "babylonjs/types";
  50985. import { Vector3 } from "babylonjs/Maths/math.vector";
  50986. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50988. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50989. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50990. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50991. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  50992. import { Scene } from "babylonjs/scene";
  50993. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50994. import { Color3 } from "babylonjs/Maths/math.color";
  50995. /**
  50996. * Single axis drag gizmo
  50997. */
  50998. export class AxisDragGizmo extends Gizmo {
  50999. /**
  51000. * Drag behavior responsible for the gizmos dragging interactions
  51001. */
  51002. dragBehavior: PointerDragBehavior;
  51003. private _pointerObserver;
  51004. /**
  51005. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51006. */
  51007. snapDistance: number;
  51008. /**
  51009. * Event that fires each time the gizmo snaps to a new location.
  51010. * * snapDistance is the the change in distance
  51011. */
  51012. onSnapObservable: Observable<{
  51013. snapDistance: number;
  51014. }>;
  51015. private _isEnabled;
  51016. private _parent;
  51017. private _arrow;
  51018. private _coloredMaterial;
  51019. private _hoverMaterial;
  51020. /** @hidden */
  51021. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  51022. /** @hidden */
  51023. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51024. /**
  51025. * Creates an AxisDragGizmo
  51026. * @param gizmoLayer The utility layer the gizmo will be added to
  51027. * @param dragAxis The axis which the gizmo will be able to drag on
  51028. * @param color The color of the gizmo
  51029. */
  51030. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51031. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51032. /**
  51033. * If the gizmo is enabled
  51034. */
  51035. set isEnabled(value: boolean);
  51036. get isEnabled(): boolean;
  51037. /**
  51038. * Disposes of the gizmo
  51039. */
  51040. dispose(): void;
  51041. }
  51042. }
  51043. declare module "babylonjs/Debug/axesViewer" {
  51044. import { Vector3 } from "babylonjs/Maths/math.vector";
  51045. import { Nullable } from "babylonjs/types";
  51046. import { Scene } from "babylonjs/scene";
  51047. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51048. /**
  51049. * The Axes viewer will show 3 axes in a specific point in space
  51050. */
  51051. export class AxesViewer {
  51052. private _xAxis;
  51053. private _yAxis;
  51054. private _zAxis;
  51055. private _scaleLinesFactor;
  51056. private _instanced;
  51057. /**
  51058. * Gets the hosting scene
  51059. */
  51060. scene: Scene;
  51061. /**
  51062. * Gets or sets a number used to scale line length
  51063. */
  51064. scaleLines: number;
  51065. /** Gets the node hierarchy used to render x-axis */
  51066. get xAxis(): TransformNode;
  51067. /** Gets the node hierarchy used to render y-axis */
  51068. get yAxis(): TransformNode;
  51069. /** Gets the node hierarchy used to render z-axis */
  51070. get zAxis(): TransformNode;
  51071. /**
  51072. * Creates a new AxesViewer
  51073. * @param scene defines the hosting scene
  51074. * @param scaleLines defines a number used to scale line length (1 by default)
  51075. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  51076. * @param xAxis defines the node hierarchy used to render the x-axis
  51077. * @param yAxis defines the node hierarchy used to render the y-axis
  51078. * @param zAxis defines the node hierarchy used to render the z-axis
  51079. */
  51080. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  51081. /**
  51082. * Force the viewer to update
  51083. * @param position defines the position of the viewer
  51084. * @param xaxis defines the x axis of the viewer
  51085. * @param yaxis defines the y axis of the viewer
  51086. * @param zaxis defines the z axis of the viewer
  51087. */
  51088. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  51089. /**
  51090. * Creates an instance of this axes viewer.
  51091. * @returns a new axes viewer with instanced meshes
  51092. */
  51093. createInstance(): AxesViewer;
  51094. /** Releases resources */
  51095. dispose(): void;
  51096. private static _SetRenderingGroupId;
  51097. }
  51098. }
  51099. declare module "babylonjs/Debug/boneAxesViewer" {
  51100. import { Nullable } from "babylonjs/types";
  51101. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  51102. import { Vector3 } from "babylonjs/Maths/math.vector";
  51103. import { Mesh } from "babylonjs/Meshes/mesh";
  51104. import { Bone } from "babylonjs/Bones/bone";
  51105. import { Scene } from "babylonjs/scene";
  51106. /**
  51107. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  51108. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  51109. */
  51110. export class BoneAxesViewer extends AxesViewer {
  51111. /**
  51112. * Gets or sets the target mesh where to display the axes viewer
  51113. */
  51114. mesh: Nullable<Mesh>;
  51115. /**
  51116. * Gets or sets the target bone where to display the axes viewer
  51117. */
  51118. bone: Nullable<Bone>;
  51119. /** Gets current position */
  51120. pos: Vector3;
  51121. /** Gets direction of X axis */
  51122. xaxis: Vector3;
  51123. /** Gets direction of Y axis */
  51124. yaxis: Vector3;
  51125. /** Gets direction of Z axis */
  51126. zaxis: Vector3;
  51127. /**
  51128. * Creates a new BoneAxesViewer
  51129. * @param scene defines the hosting scene
  51130. * @param bone defines the target bone
  51131. * @param mesh defines the target mesh
  51132. * @param scaleLines defines a scaling factor for line length (1 by default)
  51133. */
  51134. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  51135. /**
  51136. * Force the viewer to update
  51137. */
  51138. update(): void;
  51139. /** Releases resources */
  51140. dispose(): void;
  51141. }
  51142. }
  51143. declare module "babylonjs/Debug/debugLayer" {
  51144. import { Scene } from "babylonjs/scene";
  51145. /**
  51146. * Interface used to define scene explorer extensibility option
  51147. */
  51148. export interface IExplorerExtensibilityOption {
  51149. /**
  51150. * Define the option label
  51151. */
  51152. label: string;
  51153. /**
  51154. * Defines the action to execute on click
  51155. */
  51156. action: (entity: any) => void;
  51157. }
  51158. /**
  51159. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  51160. */
  51161. export interface IExplorerExtensibilityGroup {
  51162. /**
  51163. * Defines a predicate to test if a given type mut be extended
  51164. */
  51165. predicate: (entity: any) => boolean;
  51166. /**
  51167. * Gets the list of options added to a type
  51168. */
  51169. entries: IExplorerExtensibilityOption[];
  51170. }
  51171. /**
  51172. * Interface used to define the options to use to create the Inspector
  51173. */
  51174. export interface IInspectorOptions {
  51175. /**
  51176. * Display in overlay mode (default: false)
  51177. */
  51178. overlay?: boolean;
  51179. /**
  51180. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  51181. */
  51182. globalRoot?: HTMLElement;
  51183. /**
  51184. * Display the Scene explorer
  51185. */
  51186. showExplorer?: boolean;
  51187. /**
  51188. * Display the property inspector
  51189. */
  51190. showInspector?: boolean;
  51191. /**
  51192. * Display in embed mode (both panes on the right)
  51193. */
  51194. embedMode?: boolean;
  51195. /**
  51196. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  51197. */
  51198. handleResize?: boolean;
  51199. /**
  51200. * Allow the panes to popup (default: true)
  51201. */
  51202. enablePopup?: boolean;
  51203. /**
  51204. * Allow the panes to be closed by users (default: true)
  51205. */
  51206. enableClose?: boolean;
  51207. /**
  51208. * Optional list of extensibility entries
  51209. */
  51210. explorerExtensibility?: IExplorerExtensibilityGroup[];
  51211. /**
  51212. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  51213. */
  51214. inspectorURL?: string;
  51215. /**
  51216. * Optional initial tab (default to DebugLayerTab.Properties)
  51217. */
  51218. initialTab?: DebugLayerTab;
  51219. }
  51220. module "babylonjs/scene" {
  51221. interface Scene {
  51222. /**
  51223. * @hidden
  51224. * Backing field
  51225. */
  51226. _debugLayer: DebugLayer;
  51227. /**
  51228. * Gets the debug layer (aka Inspector) associated with the scene
  51229. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51230. */
  51231. debugLayer: DebugLayer;
  51232. }
  51233. }
  51234. /**
  51235. * Enum of inspector action tab
  51236. */
  51237. export enum DebugLayerTab {
  51238. /**
  51239. * Properties tag (default)
  51240. */
  51241. Properties = 0,
  51242. /**
  51243. * Debug tab
  51244. */
  51245. Debug = 1,
  51246. /**
  51247. * Statistics tab
  51248. */
  51249. Statistics = 2,
  51250. /**
  51251. * Tools tab
  51252. */
  51253. Tools = 3,
  51254. /**
  51255. * Settings tab
  51256. */
  51257. Settings = 4
  51258. }
  51259. /**
  51260. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51261. * what is happening in your scene
  51262. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51263. */
  51264. export class DebugLayer {
  51265. /**
  51266. * Define the url to get the inspector script from.
  51267. * By default it uses the babylonjs CDN.
  51268. * @ignoreNaming
  51269. */
  51270. static InspectorURL: string;
  51271. private _scene;
  51272. private BJSINSPECTOR;
  51273. private _onPropertyChangedObservable?;
  51274. /**
  51275. * Observable triggered when a property is changed through the inspector.
  51276. */
  51277. get onPropertyChangedObservable(): any;
  51278. /**
  51279. * Instantiates a new debug layer.
  51280. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51281. * what is happening in your scene
  51282. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51283. * @param scene Defines the scene to inspect
  51284. */
  51285. constructor(scene: Scene);
  51286. /** Creates the inspector window. */
  51287. private _createInspector;
  51288. /**
  51289. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  51290. * @param entity defines the entity to select
  51291. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  51292. */
  51293. select(entity: any, lineContainerTitles?: string | string[]): void;
  51294. /** Get the inspector from bundle or global */
  51295. private _getGlobalInspector;
  51296. /**
  51297. * Get if the inspector is visible or not.
  51298. * @returns true if visible otherwise, false
  51299. */
  51300. isVisible(): boolean;
  51301. /**
  51302. * Hide the inspector and close its window.
  51303. */
  51304. hide(): void;
  51305. /**
  51306. * Update the scene in the inspector
  51307. */
  51308. setAsActiveScene(): void;
  51309. /**
  51310. * Launch the debugLayer.
  51311. * @param config Define the configuration of the inspector
  51312. * @return a promise fulfilled when the debug layer is visible
  51313. */
  51314. show(config?: IInspectorOptions): Promise<DebugLayer>;
  51315. }
  51316. }
  51317. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  51318. import { Nullable } from "babylonjs/types";
  51319. import { Scene } from "babylonjs/scene";
  51320. import { Vector4 } from "babylonjs/Maths/math.vector";
  51321. import { Color4 } from "babylonjs/Maths/math.color";
  51322. import { Mesh } from "babylonjs/Meshes/mesh";
  51323. /**
  51324. * Class containing static functions to help procedurally build meshes
  51325. */
  51326. export class BoxBuilder {
  51327. /**
  51328. * Creates a box mesh
  51329. * * The parameter `size` sets the size (float) of each box side (default 1)
  51330. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51331. * * 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)
  51332. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51334. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51336. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51337. * @param name defines the name of the mesh
  51338. * @param options defines the options used to create the mesh
  51339. * @param scene defines the hosting scene
  51340. * @returns the box mesh
  51341. */
  51342. static CreateBox(name: string, options: {
  51343. size?: number;
  51344. width?: number;
  51345. height?: number;
  51346. depth?: number;
  51347. faceUV?: Vector4[];
  51348. faceColors?: Color4[];
  51349. sideOrientation?: number;
  51350. frontUVs?: Vector4;
  51351. backUVs?: Vector4;
  51352. wrap?: boolean;
  51353. topBaseAt?: number;
  51354. bottomBaseAt?: number;
  51355. updatable?: boolean;
  51356. }, scene?: Nullable<Scene>): Mesh;
  51357. }
  51358. }
  51359. declare module "babylonjs/Debug/physicsViewer" {
  51360. import { Nullable } from "babylonjs/types";
  51361. import { Scene } from "babylonjs/scene";
  51362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51363. import { Mesh } from "babylonjs/Meshes/mesh";
  51364. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51365. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51366. /**
  51367. * Used to show the physics impostor around the specific mesh
  51368. */
  51369. export class PhysicsViewer {
  51370. /** @hidden */
  51371. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  51372. /** @hidden */
  51373. protected _meshes: Array<Nullable<AbstractMesh>>;
  51374. /** @hidden */
  51375. protected _scene: Nullable<Scene>;
  51376. /** @hidden */
  51377. protected _numMeshes: number;
  51378. /** @hidden */
  51379. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  51380. private _renderFunction;
  51381. private _utilityLayer;
  51382. private _debugBoxMesh;
  51383. private _debugSphereMesh;
  51384. private _debugCylinderMesh;
  51385. private _debugMaterial;
  51386. private _debugMeshMeshes;
  51387. /**
  51388. * Creates a new PhysicsViewer
  51389. * @param scene defines the hosting scene
  51390. */
  51391. constructor(scene: Scene);
  51392. /** @hidden */
  51393. protected _updateDebugMeshes(): void;
  51394. /**
  51395. * Renders a specified physic impostor
  51396. * @param impostor defines the impostor to render
  51397. * @param targetMesh defines the mesh represented by the impostor
  51398. * @returns the new debug mesh used to render the impostor
  51399. */
  51400. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  51401. /**
  51402. * Hides a specified physic impostor
  51403. * @param impostor defines the impostor to hide
  51404. */
  51405. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  51406. private _getDebugMaterial;
  51407. private _getDebugBoxMesh;
  51408. private _getDebugSphereMesh;
  51409. private _getDebugCylinderMesh;
  51410. private _getDebugMeshMesh;
  51411. private _getDebugMesh;
  51412. /** Releases all resources */
  51413. dispose(): void;
  51414. }
  51415. }
  51416. declare module "babylonjs/Debug/rayHelper" {
  51417. import { Nullable } from "babylonjs/types";
  51418. import { Ray } from "babylonjs/Culling/ray";
  51419. import { Vector3 } from "babylonjs/Maths/math.vector";
  51420. import { Color3 } from "babylonjs/Maths/math.color";
  51421. import { Scene } from "babylonjs/scene";
  51422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51423. import "babylonjs/Meshes/Builders/linesBuilder";
  51424. /**
  51425. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51426. * in order to better appreciate the issue one might have.
  51427. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  51428. */
  51429. export class RayHelper {
  51430. /**
  51431. * Defines the ray we are currently tryin to visualize.
  51432. */
  51433. ray: Nullable<Ray>;
  51434. private _renderPoints;
  51435. private _renderLine;
  51436. private _renderFunction;
  51437. private _scene;
  51438. private _updateToMeshFunction;
  51439. private _attachedToMesh;
  51440. private _meshSpaceDirection;
  51441. private _meshSpaceOrigin;
  51442. /**
  51443. * Helper function to create a colored helper in a scene in one line.
  51444. * @param ray Defines the ray we are currently tryin to visualize
  51445. * @param scene Defines the scene the ray is used in
  51446. * @param color Defines the color we want to see the ray in
  51447. * @returns The newly created ray helper.
  51448. */
  51449. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  51450. /**
  51451. * Instantiate a new ray helper.
  51452. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51453. * in order to better appreciate the issue one might have.
  51454. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  51455. * @param ray Defines the ray we are currently tryin to visualize
  51456. */
  51457. constructor(ray: Ray);
  51458. /**
  51459. * Shows the ray we are willing to debug.
  51460. * @param scene Defines the scene the ray needs to be rendered in
  51461. * @param color Defines the color the ray needs to be rendered in
  51462. */
  51463. show(scene: Scene, color?: Color3): void;
  51464. /**
  51465. * Hides the ray we are debugging.
  51466. */
  51467. hide(): void;
  51468. private _render;
  51469. /**
  51470. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  51471. * @param mesh Defines the mesh we want the helper attached to
  51472. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  51473. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  51474. * @param length Defines the length of the ray
  51475. */
  51476. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  51477. /**
  51478. * Detach the ray helper from the mesh it has previously been attached to.
  51479. */
  51480. detachFromMesh(): void;
  51481. private _updateToMesh;
  51482. /**
  51483. * Dispose the helper and release its associated resources.
  51484. */
  51485. dispose(): void;
  51486. }
  51487. }
  51488. declare module "babylonjs/Debug/skeletonViewer" {
  51489. import { Color3 } from "babylonjs/Maths/math.color";
  51490. import { Scene } from "babylonjs/scene";
  51491. import { Nullable } from "babylonjs/types";
  51492. import { Skeleton } from "babylonjs/Bones/skeleton";
  51493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51494. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51495. /**
  51496. * Class used to render a debug view of a given skeleton
  51497. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51498. */
  51499. export class SkeletonViewer {
  51500. /** defines the skeleton to render */
  51501. skeleton: Skeleton;
  51502. /** defines the mesh attached to the skeleton */
  51503. mesh: AbstractMesh;
  51504. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51505. autoUpdateBonesMatrices: boolean;
  51506. /** defines the rendering group id to use with the viewer */
  51507. renderingGroupId: number;
  51508. /** Gets or sets the color used to render the skeleton */
  51509. color: Color3;
  51510. private _scene;
  51511. private _debugLines;
  51512. private _debugMesh;
  51513. private _isEnabled;
  51514. private _renderFunction;
  51515. private _utilityLayer;
  51516. /**
  51517. * Returns the mesh used to render the bones
  51518. */
  51519. get debugMesh(): Nullable<LinesMesh>;
  51520. /**
  51521. * Creates a new SkeletonViewer
  51522. * @param skeleton defines the skeleton to render
  51523. * @param mesh defines the mesh attached to the skeleton
  51524. * @param scene defines the hosting scene
  51525. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51526. * @param renderingGroupId defines the rendering group id to use with the viewer
  51527. */
  51528. constructor(
  51529. /** defines the skeleton to render */
  51530. skeleton: Skeleton,
  51531. /** defines the mesh attached to the skeleton */
  51532. mesh: AbstractMesh, scene: Scene,
  51533. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51534. autoUpdateBonesMatrices?: boolean,
  51535. /** defines the rendering group id to use with the viewer */
  51536. renderingGroupId?: number);
  51537. /** Gets or sets a boolean indicating if the viewer is enabled */
  51538. set isEnabled(value: boolean);
  51539. get isEnabled(): boolean;
  51540. private _getBonePosition;
  51541. private _getLinesForBonesWithLength;
  51542. private _getLinesForBonesNoLength;
  51543. /** Update the viewer to sync with current skeleton state */
  51544. update(): void;
  51545. /** Release associated resources */
  51546. dispose(): void;
  51547. }
  51548. }
  51549. declare module "babylonjs/Debug/index" {
  51550. export * from "babylonjs/Debug/axesViewer";
  51551. export * from "babylonjs/Debug/boneAxesViewer";
  51552. export * from "babylonjs/Debug/debugLayer";
  51553. export * from "babylonjs/Debug/physicsViewer";
  51554. export * from "babylonjs/Debug/rayHelper";
  51555. export * from "babylonjs/Debug/skeletonViewer";
  51556. }
  51557. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  51558. /**
  51559. * Enum for Device Types
  51560. */
  51561. export enum DeviceType {
  51562. /** Generic */
  51563. Generic = 0,
  51564. /** Keyboard */
  51565. Keyboard = 1,
  51566. /** Mouse */
  51567. Mouse = 2,
  51568. /** Touch Pointers */
  51569. Touch = 3,
  51570. /** PS4 Dual Shock */
  51571. DualShock = 4,
  51572. /** Xbox */
  51573. Xbox = 5,
  51574. /** Switch Controller */
  51575. Switch = 6
  51576. }
  51577. /**
  51578. * Enum for All Pointers (Touch/Mouse)
  51579. */
  51580. export enum PointerInput {
  51581. /** Horizontal Axis */
  51582. Horizontal = 0,
  51583. /** Vertical Axis */
  51584. Vertical = 1,
  51585. /** Left Click or Touch */
  51586. LeftClick = 2,
  51587. /** Middle Click */
  51588. MiddleClick = 3,
  51589. /** Right Click */
  51590. RightClick = 4,
  51591. /** Browser Back */
  51592. BrowserBack = 5,
  51593. /** Browser Forward */
  51594. BrowserForward = 6
  51595. }
  51596. /**
  51597. * Enum for Dual Shock Gamepad
  51598. */
  51599. export enum DualShockInput {
  51600. /** Cross */
  51601. Cross = 0,
  51602. /** Circle */
  51603. Circle = 1,
  51604. /** Square */
  51605. Square = 2,
  51606. /** Triangle */
  51607. Triangle = 3,
  51608. /** L1 */
  51609. L1 = 4,
  51610. /** R1 */
  51611. R1 = 5,
  51612. /** L2 */
  51613. L2 = 6,
  51614. /** R2 */
  51615. R2 = 7,
  51616. /** Share */
  51617. Share = 8,
  51618. /** Options */
  51619. Options = 9,
  51620. /** L3 */
  51621. L3 = 10,
  51622. /** R3 */
  51623. R3 = 11,
  51624. /** DPadUp */
  51625. DPadUp = 12,
  51626. /** DPadDown */
  51627. DPadDown = 13,
  51628. /** DPadLeft */
  51629. DPadLeft = 14,
  51630. /** DRight */
  51631. DPadRight = 15,
  51632. /** Home */
  51633. Home = 16,
  51634. /** TouchPad */
  51635. TouchPad = 17,
  51636. /** LStickXAxis */
  51637. LStickXAxis = 18,
  51638. /** LStickYAxis */
  51639. LStickYAxis = 19,
  51640. /** RStickXAxis */
  51641. RStickXAxis = 20,
  51642. /** RStickYAxis */
  51643. RStickYAxis = 21
  51644. }
  51645. /**
  51646. * Enum for Xbox Gamepad
  51647. */
  51648. export enum XboxInput {
  51649. /** A */
  51650. A = 0,
  51651. /** B */
  51652. B = 1,
  51653. /** X */
  51654. X = 2,
  51655. /** Y */
  51656. Y = 3,
  51657. /** LB */
  51658. LB = 4,
  51659. /** RB */
  51660. RB = 5,
  51661. /** LT */
  51662. LT = 6,
  51663. /** RT */
  51664. RT = 7,
  51665. /** Back */
  51666. Back = 8,
  51667. /** Start */
  51668. Start = 9,
  51669. /** LS */
  51670. LS = 10,
  51671. /** RS */
  51672. RS = 11,
  51673. /** DPadUp */
  51674. DPadUp = 12,
  51675. /** DPadDown */
  51676. DPadDown = 13,
  51677. /** DPadLeft */
  51678. DPadLeft = 14,
  51679. /** DRight */
  51680. DPadRight = 15,
  51681. /** Home */
  51682. Home = 16,
  51683. /** LStickXAxis */
  51684. LStickXAxis = 17,
  51685. /** LStickYAxis */
  51686. LStickYAxis = 18,
  51687. /** RStickXAxis */
  51688. RStickXAxis = 19,
  51689. /** RStickYAxis */
  51690. RStickYAxis = 20
  51691. }
  51692. /**
  51693. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51694. */
  51695. export enum SwitchInput {
  51696. /** B */
  51697. B = 0,
  51698. /** A */
  51699. A = 1,
  51700. /** Y */
  51701. Y = 2,
  51702. /** X */
  51703. X = 3,
  51704. /** L */
  51705. L = 4,
  51706. /** R */
  51707. R = 5,
  51708. /** ZL */
  51709. ZL = 6,
  51710. /** ZR */
  51711. ZR = 7,
  51712. /** Minus */
  51713. Minus = 8,
  51714. /** Plus */
  51715. Plus = 9,
  51716. /** LS */
  51717. LS = 10,
  51718. /** RS */
  51719. RS = 11,
  51720. /** DPadUp */
  51721. DPadUp = 12,
  51722. /** DPadDown */
  51723. DPadDown = 13,
  51724. /** DPadLeft */
  51725. DPadLeft = 14,
  51726. /** DRight */
  51727. DPadRight = 15,
  51728. /** Home */
  51729. Home = 16,
  51730. /** Capture */
  51731. Capture = 17,
  51732. /** LStickXAxis */
  51733. LStickXAxis = 18,
  51734. /** LStickYAxis */
  51735. LStickYAxis = 19,
  51736. /** RStickXAxis */
  51737. RStickXAxis = 20,
  51738. /** RStickYAxis */
  51739. RStickYAxis = 21
  51740. }
  51741. }
  51742. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  51743. import { Engine } from "babylonjs/Engines/engine";
  51744. import { IDisposable } from "babylonjs/scene";
  51745. import { Nullable } from "babylonjs/types";
  51746. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  51747. /**
  51748. * This class will take all inputs from Keyboard, Pointer, and
  51749. * any Gamepads and provide a polling system that all devices
  51750. * will use. This class assumes that there will only be one
  51751. * pointer device and one keyboard.
  51752. */
  51753. export class DeviceInputSystem implements IDisposable {
  51754. /**
  51755. * Callback to be triggered when a device is connected
  51756. */
  51757. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51758. /**
  51759. * Callback to be triggered when a device is disconnected
  51760. */
  51761. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51762. /**
  51763. * Callback to be triggered when event driven input is updated
  51764. */
  51765. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51766. private _inputs;
  51767. private _gamepads;
  51768. private _keyboardActive;
  51769. private _pointerActive;
  51770. private _elementToAttachTo;
  51771. private _keyboardDownEvent;
  51772. private _keyboardUpEvent;
  51773. private _pointerMoveEvent;
  51774. private _pointerDownEvent;
  51775. private _pointerUpEvent;
  51776. private _gamepadConnectedEvent;
  51777. private _gamepadDisconnectedEvent;
  51778. private static _MAX_KEYCODES;
  51779. private static _MAX_POINTER_INPUTS;
  51780. private constructor();
  51781. /**
  51782. * Creates a new DeviceInputSystem instance
  51783. * @param engine Engine to pull input element from
  51784. * @returns The new instance
  51785. */
  51786. static Create(engine: Engine): DeviceInputSystem;
  51787. /**
  51788. * Checks for current device input value, given an id and input index
  51789. * @param deviceName Id of connected device
  51790. * @param inputIndex Index of device input
  51791. * @returns Current value of input
  51792. */
  51793. /**
  51794. * Checks for current device input value, given an id and input index
  51795. * @param deviceType Enum specifiying device type
  51796. * @param deviceSlot "Slot" or index that device is referenced in
  51797. * @param inputIndex Id of input to be checked
  51798. * @returns Current value of input
  51799. */
  51800. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  51801. /**
  51802. * Dispose of all the eventlisteners
  51803. */
  51804. dispose(): void;
  51805. /**
  51806. * Add device and inputs to device array
  51807. * @param deviceType Enum specifiying device type
  51808. * @param deviceSlot "Slot" or index that device is referenced in
  51809. * @param numberOfInputs Number of input entries to create for given device
  51810. */
  51811. private _registerDevice;
  51812. /**
  51813. * Given a specific device name, remove that device from the device map
  51814. * @param deviceType Enum specifiying device type
  51815. * @param deviceSlot "Slot" or index that device is referenced in
  51816. */
  51817. private _unregisterDevice;
  51818. /**
  51819. * Handle all actions that come from keyboard interaction
  51820. */
  51821. private _handleKeyActions;
  51822. /**
  51823. * Handle all actions that come from pointer interaction
  51824. */
  51825. private _handlePointerActions;
  51826. /**
  51827. * Handle all actions that come from gamepad interaction
  51828. */
  51829. private _handleGamepadActions;
  51830. /**
  51831. * Update all non-event based devices with each frame
  51832. * @param deviceType Enum specifiying device type
  51833. * @param deviceSlot "Slot" or index that device is referenced in
  51834. * @param inputIndex Id of input to be checked
  51835. */
  51836. private _updateDevice;
  51837. /**
  51838. * Gets DeviceType from the device name
  51839. * @param deviceName Name of Device from DeviceInputSystem
  51840. * @returns DeviceType enum value
  51841. */
  51842. private _getGamepadDeviceType;
  51843. }
  51844. }
  51845. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  51846. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  51847. /**
  51848. * Type to handle enforcement of inputs
  51849. */
  51850. 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;
  51851. }
  51852. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  51853. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  51854. import { Engine } from "babylonjs/Engines/engine";
  51855. import { IDisposable } from "babylonjs/scene";
  51856. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  51857. import { Nullable } from "babylonjs/types";
  51858. import { Observable } from "babylonjs/Misc/observable";
  51859. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  51860. /**
  51861. * Class that handles all input for a specific device
  51862. */
  51863. export class DeviceSource<T extends DeviceType> {
  51864. /** Type of device */
  51865. readonly deviceType: DeviceType;
  51866. /** "Slot" or index that device is referenced in */
  51867. readonly deviceSlot: number;
  51868. /**
  51869. * Observable to handle device input changes per device
  51870. */
  51871. readonly onInputChangedObservable: Observable<{
  51872. inputIndex: DeviceInput<T>;
  51873. previousState: Nullable<number>;
  51874. currentState: Nullable<number>;
  51875. }>;
  51876. private readonly _deviceInputSystem;
  51877. /**
  51878. * Default Constructor
  51879. * @param deviceInputSystem Reference to DeviceInputSystem
  51880. * @param deviceType Type of device
  51881. * @param deviceSlot "Slot" or index that device is referenced in
  51882. */
  51883. constructor(deviceInputSystem: DeviceInputSystem,
  51884. /** Type of device */
  51885. deviceType: DeviceType,
  51886. /** "Slot" or index that device is referenced in */
  51887. deviceSlot?: number);
  51888. /**
  51889. * Get input for specific input
  51890. * @param inputIndex index of specific input on device
  51891. * @returns Input value from DeviceInputSystem
  51892. */
  51893. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  51894. }
  51895. /**
  51896. * Class to keep track of devices
  51897. */
  51898. export class DeviceSourceManager implements IDisposable {
  51899. /**
  51900. * Observable to be triggered when before a device is connected
  51901. */
  51902. readonly onBeforeDeviceConnectedObservable: Observable<{
  51903. deviceType: DeviceType;
  51904. deviceSlot: number;
  51905. }>;
  51906. /**
  51907. * Observable to be triggered when before a device is disconnected
  51908. */
  51909. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51910. deviceType: DeviceType;
  51911. deviceSlot: number;
  51912. }>;
  51913. /**
  51914. * Observable to be triggered when after a device is connected
  51915. */
  51916. readonly onAfterDeviceConnectedObservable: Observable<{
  51917. deviceType: DeviceType;
  51918. deviceSlot: number;
  51919. }>;
  51920. /**
  51921. * Observable to be triggered when after a device is disconnected
  51922. */
  51923. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51924. deviceType: DeviceType;
  51925. deviceSlot: number;
  51926. }>;
  51927. private readonly _devices;
  51928. private readonly _firstDevice;
  51929. private readonly _deviceInputSystem;
  51930. /**
  51931. * Default Constructor
  51932. * @param engine engine to pull input element from
  51933. */
  51934. constructor(engine: Engine);
  51935. /**
  51936. * Gets a DeviceSource, given a type and slot
  51937. * @param deviceType Enum specifying device type
  51938. * @param deviceSlot "Slot" or index that device is referenced in
  51939. * @returns DeviceSource object
  51940. */
  51941. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51942. /**
  51943. * Gets an array of DeviceSource objects for a given device type
  51944. * @param deviceType Enum specifying device type
  51945. * @returns Array of DeviceSource objects
  51946. */
  51947. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51948. /**
  51949. * Dispose of DeviceInputSystem and other parts
  51950. */
  51951. dispose(): void;
  51952. /**
  51953. * Function to add device name to device list
  51954. * @param deviceType Enum specifying device type
  51955. * @param deviceSlot "Slot" or index that device is referenced in
  51956. */
  51957. private _addDevice;
  51958. /**
  51959. * Function to remove device name to device list
  51960. * @param deviceType Enum specifying device type
  51961. * @param deviceSlot "Slot" or index that device is referenced in
  51962. */
  51963. private _removeDevice;
  51964. /**
  51965. * Updates array storing first connected device of each type
  51966. * @param type Type of Device
  51967. */
  51968. private _updateFirstDevices;
  51969. }
  51970. }
  51971. declare module "babylonjs/DeviceInput/index" {
  51972. export * from "babylonjs/DeviceInput/deviceInputSystem";
  51973. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  51974. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  51975. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  51976. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  51977. }
  51978. declare module "babylonjs/Engines/nullEngine" {
  51979. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  51980. import { Engine } from "babylonjs/Engines/engine";
  51981. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  51982. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  51983. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51984. import { Effect } from "babylonjs/Materials/effect";
  51985. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  51986. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  51987. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  51988. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  51989. /**
  51990. * Options to create the null engine
  51991. */
  51992. export class NullEngineOptions {
  51993. /**
  51994. * Render width (Default: 512)
  51995. */
  51996. renderWidth: number;
  51997. /**
  51998. * Render height (Default: 256)
  51999. */
  52000. renderHeight: number;
  52001. /**
  52002. * Texture size (Default: 512)
  52003. */
  52004. textureSize: number;
  52005. /**
  52006. * If delta time between frames should be constant
  52007. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52008. */
  52009. deterministicLockstep: boolean;
  52010. /**
  52011. * Maximum about of steps between frames (Default: 4)
  52012. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52013. */
  52014. lockstepMaxSteps: number;
  52015. }
  52016. /**
  52017. * The null engine class provides support for headless version of babylon.js.
  52018. * This can be used in server side scenario or for testing purposes
  52019. */
  52020. export class NullEngine extends Engine {
  52021. private _options;
  52022. /**
  52023. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  52024. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52025. * @returns true if engine is in deterministic lock step mode
  52026. */
  52027. isDeterministicLockStep(): boolean;
  52028. /**
  52029. * Gets the max steps when engine is running in deterministic lock step
  52030. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52031. * @returns the max steps
  52032. */
  52033. getLockstepMaxSteps(): number;
  52034. /**
  52035. * Gets the current hardware scaling level.
  52036. * By default the hardware scaling level is computed from the window device ratio.
  52037. * 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.
  52038. * @returns a number indicating the current hardware scaling level
  52039. */
  52040. getHardwareScalingLevel(): number;
  52041. constructor(options?: NullEngineOptions);
  52042. /**
  52043. * Creates a vertex buffer
  52044. * @param vertices the data for the vertex buffer
  52045. * @returns the new WebGL static buffer
  52046. */
  52047. createVertexBuffer(vertices: FloatArray): DataBuffer;
  52048. /**
  52049. * Creates a new index buffer
  52050. * @param indices defines the content of the index buffer
  52051. * @param updatable defines if the index buffer must be updatable
  52052. * @returns a new webGL buffer
  52053. */
  52054. createIndexBuffer(indices: IndicesArray): DataBuffer;
  52055. /**
  52056. * Clear the current render buffer or the current render target (if any is set up)
  52057. * @param color defines the color to use
  52058. * @param backBuffer defines if the back buffer must be cleared
  52059. * @param depth defines if the depth buffer must be cleared
  52060. * @param stencil defines if the stencil buffer must be cleared
  52061. */
  52062. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52063. /**
  52064. * Gets the current render width
  52065. * @param useScreen defines if screen size must be used (or the current render target if any)
  52066. * @returns a number defining the current render width
  52067. */
  52068. getRenderWidth(useScreen?: boolean): number;
  52069. /**
  52070. * Gets the current render height
  52071. * @param useScreen defines if screen size must be used (or the current render target if any)
  52072. * @returns a number defining the current render height
  52073. */
  52074. getRenderHeight(useScreen?: boolean): number;
  52075. /**
  52076. * Set the WebGL's viewport
  52077. * @param viewport defines the viewport element to be used
  52078. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  52079. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  52080. */
  52081. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  52082. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  52083. /**
  52084. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  52085. * @param pipelineContext defines the pipeline context to use
  52086. * @param uniformsNames defines the list of uniform names
  52087. * @returns an array of webGL uniform locations
  52088. */
  52089. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  52090. /**
  52091. * Gets the lsit of active attributes for a given webGL program
  52092. * @param pipelineContext defines the pipeline context to use
  52093. * @param attributesNames defines the list of attribute names to get
  52094. * @returns an array of indices indicating the offset of each attribute
  52095. */
  52096. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52097. /**
  52098. * Binds an effect to the webGL context
  52099. * @param effect defines the effect to bind
  52100. */
  52101. bindSamplers(effect: Effect): void;
  52102. /**
  52103. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  52104. * @param effect defines the effect to activate
  52105. */
  52106. enableEffect(effect: Effect): void;
  52107. /**
  52108. * Set various states to the webGL context
  52109. * @param culling defines backface culling state
  52110. * @param zOffset defines the value to apply to zOffset (0 by default)
  52111. * @param force defines if states must be applied even if cache is up to date
  52112. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52113. */
  52114. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52115. /**
  52116. * Set the value of an uniform to an array of int32
  52117. * @param uniform defines the webGL uniform location where to store the value
  52118. * @param array defines the array of int32 to store
  52119. */
  52120. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52121. /**
  52122. * Set the value of an uniform to an array of int32 (stored as vec2)
  52123. * @param uniform defines the webGL uniform location where to store the value
  52124. * @param array defines the array of int32 to store
  52125. */
  52126. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52127. /**
  52128. * Set the value of an uniform to an array of int32 (stored as vec3)
  52129. * @param uniform defines the webGL uniform location where to store the value
  52130. * @param array defines the array of int32 to store
  52131. */
  52132. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52133. /**
  52134. * Set the value of an uniform to an array of int32 (stored as vec4)
  52135. * @param uniform defines the webGL uniform location where to store the value
  52136. * @param array defines the array of int32 to store
  52137. */
  52138. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52139. /**
  52140. * Set the value of an uniform to an array of float32
  52141. * @param uniform defines the webGL uniform location where to store the value
  52142. * @param array defines the array of float32 to store
  52143. */
  52144. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52145. /**
  52146. * Set the value of an uniform to an array of float32 (stored as vec2)
  52147. * @param uniform defines the webGL uniform location where to store the value
  52148. * @param array defines the array of float32 to store
  52149. */
  52150. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52151. /**
  52152. * Set the value of an uniform to an array of float32 (stored as vec3)
  52153. * @param uniform defines the webGL uniform location where to store the value
  52154. * @param array defines the array of float32 to store
  52155. */
  52156. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52157. /**
  52158. * Set the value of an uniform to an array of float32 (stored as vec4)
  52159. * @param uniform defines the webGL uniform location where to store the value
  52160. * @param array defines the array of float32 to store
  52161. */
  52162. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52163. /**
  52164. * Set the value of an uniform to an array of number
  52165. * @param uniform defines the webGL uniform location where to store the value
  52166. * @param array defines the array of number to store
  52167. */
  52168. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52169. /**
  52170. * Set the value of an uniform to an array of number (stored as vec2)
  52171. * @param uniform defines the webGL uniform location where to store the value
  52172. * @param array defines the array of number to store
  52173. */
  52174. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52175. /**
  52176. * Set the value of an uniform to an array of number (stored as vec3)
  52177. * @param uniform defines the webGL uniform location where to store the value
  52178. * @param array defines the array of number to store
  52179. */
  52180. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52181. /**
  52182. * Set the value of an uniform to an array of number (stored as vec4)
  52183. * @param uniform defines the webGL uniform location where to store the value
  52184. * @param array defines the array of number to store
  52185. */
  52186. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52187. /**
  52188. * Set the value of an uniform to an array of float32 (stored as matrices)
  52189. * @param uniform defines the webGL uniform location where to store the value
  52190. * @param matrices defines the array of float32 to store
  52191. */
  52192. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52193. /**
  52194. * Set the value of an uniform to a matrix (3x3)
  52195. * @param uniform defines the webGL uniform location where to store the value
  52196. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52197. */
  52198. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52199. /**
  52200. * Set the value of an uniform to a matrix (2x2)
  52201. * @param uniform defines the webGL uniform location where to store the value
  52202. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52203. */
  52204. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52205. /**
  52206. * Set the value of an uniform to a number (float)
  52207. * @param uniform defines the webGL uniform location where to store the value
  52208. * @param value defines the float number to store
  52209. */
  52210. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52211. /**
  52212. * Set the value of an uniform to a vec2
  52213. * @param uniform defines the webGL uniform location where to store the value
  52214. * @param x defines the 1st component of the value
  52215. * @param y defines the 2nd component of the value
  52216. */
  52217. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52218. /**
  52219. * Set the value of an uniform to a vec3
  52220. * @param uniform defines the webGL uniform location where to store the value
  52221. * @param x defines the 1st component of the value
  52222. * @param y defines the 2nd component of the value
  52223. * @param z defines the 3rd component of the value
  52224. */
  52225. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52226. /**
  52227. * Set the value of an uniform to a boolean
  52228. * @param uniform defines the webGL uniform location where to store the value
  52229. * @param bool defines the boolean to store
  52230. */
  52231. setBool(uniform: WebGLUniformLocation, bool: number): void;
  52232. /**
  52233. * Set the value of an uniform to a vec4
  52234. * @param uniform defines the webGL uniform location where to store the value
  52235. * @param x defines the 1st component of the value
  52236. * @param y defines the 2nd component of the value
  52237. * @param z defines the 3rd component of the value
  52238. * @param w defines the 4th component of the value
  52239. */
  52240. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52241. /**
  52242. * Sets the current alpha mode
  52243. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52244. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52245. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52246. */
  52247. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52248. /**
  52249. * Bind webGl buffers directly to the webGL context
  52250. * @param vertexBuffers defines the vertex buffer to bind
  52251. * @param indexBuffer defines the index buffer to bind
  52252. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52253. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52254. * @param effect defines the effect associated with the vertex buffer
  52255. */
  52256. bindBuffers(vertexBuffers: {
  52257. [key: string]: VertexBuffer;
  52258. }, indexBuffer: DataBuffer, effect: Effect): void;
  52259. /**
  52260. * Force the entire cache to be cleared
  52261. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52262. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52263. */
  52264. wipeCaches(bruteForce?: boolean): void;
  52265. /**
  52266. * Send a draw order
  52267. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52268. * @param indexStart defines the starting index
  52269. * @param indexCount defines the number of index to draw
  52270. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52271. */
  52272. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52273. /**
  52274. * Draw a list of indexed primitives
  52275. * @param fillMode defines the primitive to use
  52276. * @param indexStart defines the starting index
  52277. * @param indexCount defines the number of index to draw
  52278. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52279. */
  52280. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52281. /**
  52282. * Draw a list of unindexed primitives
  52283. * @param fillMode defines the primitive to use
  52284. * @param verticesStart defines the index of first vertex to draw
  52285. * @param verticesCount defines the count of vertices to draw
  52286. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52287. */
  52288. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52289. /** @hidden */
  52290. _createTexture(): WebGLTexture;
  52291. /** @hidden */
  52292. _releaseTexture(texture: InternalTexture): void;
  52293. /**
  52294. * Usually called from Texture.ts.
  52295. * Passed information to create a WebGLTexture
  52296. * @param urlArg defines a value which contains one of the following:
  52297. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52298. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52299. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52300. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52301. * @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)
  52302. * @param scene needed for loading to the correct scene
  52303. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52304. * @param onLoad optional callback to be called upon successful completion
  52305. * @param onError optional callback to be called upon failure
  52306. * @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
  52307. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52308. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52309. * @param forcedExtension defines the extension to use to pick the right loader
  52310. * @param mimeType defines an optional mime type
  52311. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52312. */
  52313. 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;
  52314. /**
  52315. * Creates a new render target texture
  52316. * @param size defines the size of the texture
  52317. * @param options defines the options used to create the texture
  52318. * @returns a new render target texture stored in an InternalTexture
  52319. */
  52320. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52321. /**
  52322. * Update the sampling mode of a given texture
  52323. * @param samplingMode defines the required sampling mode
  52324. * @param texture defines the texture to update
  52325. */
  52326. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52327. /**
  52328. * Binds the frame buffer to the specified texture.
  52329. * @param texture The texture to render to or null for the default canvas
  52330. * @param faceIndex The face of the texture to render to in case of cube texture
  52331. * @param requiredWidth The width of the target to render to
  52332. * @param requiredHeight The height of the target to render to
  52333. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52334. * @param lodLevel defines le lod level to bind to the frame buffer
  52335. */
  52336. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52337. /**
  52338. * Unbind the current render target texture from the webGL context
  52339. * @param texture defines the render target texture to unbind
  52340. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52341. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52342. */
  52343. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52344. /**
  52345. * Creates a dynamic vertex buffer
  52346. * @param vertices the data for the dynamic vertex buffer
  52347. * @returns the new WebGL dynamic buffer
  52348. */
  52349. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52350. /**
  52351. * Update the content of a dynamic texture
  52352. * @param texture defines the texture to update
  52353. * @param canvas defines the canvas containing the source
  52354. * @param invertY defines if data must be stored with Y axis inverted
  52355. * @param premulAlpha defines if alpha is stored as premultiplied
  52356. * @param format defines the format of the data
  52357. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52358. */
  52359. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52360. /**
  52361. * Gets a boolean indicating if all created effects are ready
  52362. * @returns true if all effects are ready
  52363. */
  52364. areAllEffectsReady(): boolean;
  52365. /**
  52366. * @hidden
  52367. * Get the current error code of the webGL context
  52368. * @returns the error code
  52369. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52370. */
  52371. getError(): number;
  52372. /** @hidden */
  52373. _getUnpackAlignement(): number;
  52374. /** @hidden */
  52375. _unpackFlipY(value: boolean): void;
  52376. /**
  52377. * Update a dynamic index buffer
  52378. * @param indexBuffer defines the target index buffer
  52379. * @param indices defines the data to update
  52380. * @param offset defines the offset in the target index buffer where update should start
  52381. */
  52382. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52383. /**
  52384. * Updates a dynamic vertex buffer.
  52385. * @param vertexBuffer the vertex buffer to update
  52386. * @param vertices the data used to update the vertex buffer
  52387. * @param byteOffset the byte offset of the data (optional)
  52388. * @param byteLength the byte length of the data (optional)
  52389. */
  52390. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52391. /** @hidden */
  52392. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52393. /** @hidden */
  52394. _bindTexture(channel: number, texture: InternalTexture): void;
  52395. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52396. /**
  52397. * 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
  52398. */
  52399. releaseEffects(): void;
  52400. displayLoadingUI(): void;
  52401. hideLoadingUI(): void;
  52402. /** @hidden */
  52403. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52404. /** @hidden */
  52405. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52406. /** @hidden */
  52407. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52408. /** @hidden */
  52409. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52410. }
  52411. }
  52412. declare module "babylonjs/Instrumentation/timeToken" {
  52413. import { Nullable } from "babylonjs/types";
  52414. /**
  52415. * @hidden
  52416. **/
  52417. export class _TimeToken {
  52418. _startTimeQuery: Nullable<WebGLQuery>;
  52419. _endTimeQuery: Nullable<WebGLQuery>;
  52420. _timeElapsedQuery: Nullable<WebGLQuery>;
  52421. _timeElapsedQueryEnded: boolean;
  52422. }
  52423. }
  52424. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  52425. import { Nullable, int } from "babylonjs/types";
  52426. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  52427. /** @hidden */
  52428. export class _OcclusionDataStorage {
  52429. /** @hidden */
  52430. occlusionInternalRetryCounter: number;
  52431. /** @hidden */
  52432. isOcclusionQueryInProgress: boolean;
  52433. /** @hidden */
  52434. isOccluded: boolean;
  52435. /** @hidden */
  52436. occlusionRetryCount: number;
  52437. /** @hidden */
  52438. occlusionType: number;
  52439. /** @hidden */
  52440. occlusionQueryAlgorithmType: number;
  52441. }
  52442. module "babylonjs/Engines/engine" {
  52443. interface Engine {
  52444. /**
  52445. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52446. * @return the new query
  52447. */
  52448. createQuery(): WebGLQuery;
  52449. /**
  52450. * Delete and release a webGL query
  52451. * @param query defines the query to delete
  52452. * @return the current engine
  52453. */
  52454. deleteQuery(query: WebGLQuery): Engine;
  52455. /**
  52456. * Check if a given query has resolved and got its value
  52457. * @param query defines the query to check
  52458. * @returns true if the query got its value
  52459. */
  52460. isQueryResultAvailable(query: WebGLQuery): boolean;
  52461. /**
  52462. * Gets the value of a given query
  52463. * @param query defines the query to check
  52464. * @returns the value of the query
  52465. */
  52466. getQueryResult(query: WebGLQuery): number;
  52467. /**
  52468. * Initiates an occlusion query
  52469. * @param algorithmType defines the algorithm to use
  52470. * @param query defines the query to use
  52471. * @returns the current engine
  52472. * @see http://doc.babylonjs.com/features/occlusionquery
  52473. */
  52474. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52475. /**
  52476. * Ends an occlusion query
  52477. * @see http://doc.babylonjs.com/features/occlusionquery
  52478. * @param algorithmType defines the algorithm to use
  52479. * @returns the current engine
  52480. */
  52481. endOcclusionQuery(algorithmType: number): Engine;
  52482. /**
  52483. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52484. * Please note that only one query can be issued at a time
  52485. * @returns a time token used to track the time span
  52486. */
  52487. startTimeQuery(): Nullable<_TimeToken>;
  52488. /**
  52489. * Ends a time query
  52490. * @param token defines the token used to measure the time span
  52491. * @returns the time spent (in ns)
  52492. */
  52493. endTimeQuery(token: _TimeToken): int;
  52494. /** @hidden */
  52495. _currentNonTimestampToken: Nullable<_TimeToken>;
  52496. /** @hidden */
  52497. _createTimeQuery(): WebGLQuery;
  52498. /** @hidden */
  52499. _deleteTimeQuery(query: WebGLQuery): void;
  52500. /** @hidden */
  52501. _getGlAlgorithmType(algorithmType: number): number;
  52502. /** @hidden */
  52503. _getTimeQueryResult(query: WebGLQuery): any;
  52504. /** @hidden */
  52505. _getTimeQueryAvailability(query: WebGLQuery): any;
  52506. }
  52507. }
  52508. module "babylonjs/Meshes/abstractMesh" {
  52509. interface AbstractMesh {
  52510. /**
  52511. * Backing filed
  52512. * @hidden
  52513. */
  52514. __occlusionDataStorage: _OcclusionDataStorage;
  52515. /**
  52516. * Access property
  52517. * @hidden
  52518. */
  52519. _occlusionDataStorage: _OcclusionDataStorage;
  52520. /**
  52521. * 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.
  52522. * The default value is -1 which means don't break the query and wait till the result
  52523. * @see http://doc.babylonjs.com/features/occlusionquery
  52524. */
  52525. occlusionRetryCount: number;
  52526. /**
  52527. * 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:
  52528. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52529. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52530. * * 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.
  52531. * @see http://doc.babylonjs.com/features/occlusionquery
  52532. */
  52533. occlusionType: number;
  52534. /**
  52535. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52536. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52537. * * 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.
  52538. * @see http://doc.babylonjs.com/features/occlusionquery
  52539. */
  52540. occlusionQueryAlgorithmType: number;
  52541. /**
  52542. * 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
  52543. * @see http://doc.babylonjs.com/features/occlusionquery
  52544. */
  52545. isOccluded: boolean;
  52546. /**
  52547. * Flag to check the progress status of the query
  52548. * @see http://doc.babylonjs.com/features/occlusionquery
  52549. */
  52550. isOcclusionQueryInProgress: boolean;
  52551. }
  52552. }
  52553. }
  52554. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  52555. import { Nullable } from "babylonjs/types";
  52556. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  52557. /** @hidden */
  52558. export var _forceTransformFeedbackToBundle: boolean;
  52559. module "babylonjs/Engines/engine" {
  52560. interface Engine {
  52561. /**
  52562. * Creates a webGL transform feedback object
  52563. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52564. * @returns the webGL transform feedback object
  52565. */
  52566. createTransformFeedback(): WebGLTransformFeedback;
  52567. /**
  52568. * Delete a webGL transform feedback object
  52569. * @param value defines the webGL transform feedback object to delete
  52570. */
  52571. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52572. /**
  52573. * Bind a webGL transform feedback object to the webgl context
  52574. * @param value defines the webGL transform feedback object to bind
  52575. */
  52576. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52577. /**
  52578. * Begins a transform feedback operation
  52579. * @param usePoints defines if points or triangles must be used
  52580. */
  52581. beginTransformFeedback(usePoints: boolean): void;
  52582. /**
  52583. * Ends a transform feedback operation
  52584. */
  52585. endTransformFeedback(): void;
  52586. /**
  52587. * Specify the varyings to use with transform feedback
  52588. * @param program defines the associated webGL program
  52589. * @param value defines the list of strings representing the varying names
  52590. */
  52591. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52592. /**
  52593. * Bind a webGL buffer for a transform feedback operation
  52594. * @param value defines the webGL buffer to bind
  52595. */
  52596. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52597. }
  52598. }
  52599. }
  52600. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  52601. import { Scene } from "babylonjs/scene";
  52602. import { Engine } from "babylonjs/Engines/engine";
  52603. import { Texture } from "babylonjs/Materials/Textures/texture";
  52604. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52605. import "babylonjs/Engines/Extensions/engine.multiRender";
  52606. /**
  52607. * Creation options of the multi render target texture.
  52608. */
  52609. export interface IMultiRenderTargetOptions {
  52610. /**
  52611. * Define if the texture needs to create mip maps after render.
  52612. */
  52613. generateMipMaps?: boolean;
  52614. /**
  52615. * Define the types of all the draw buffers we want to create
  52616. */
  52617. types?: number[];
  52618. /**
  52619. * Define the sampling modes of all the draw buffers we want to create
  52620. */
  52621. samplingModes?: number[];
  52622. /**
  52623. * Define if a depth buffer is required
  52624. */
  52625. generateDepthBuffer?: boolean;
  52626. /**
  52627. * Define if a stencil buffer is required
  52628. */
  52629. generateStencilBuffer?: boolean;
  52630. /**
  52631. * Define if a depth texture is required instead of a depth buffer
  52632. */
  52633. generateDepthTexture?: boolean;
  52634. /**
  52635. * Define the number of desired draw buffers
  52636. */
  52637. textureCount?: number;
  52638. /**
  52639. * Define if aspect ratio should be adapted to the texture or stay the scene one
  52640. */
  52641. doNotChangeAspectRatio?: boolean;
  52642. /**
  52643. * Define the default type of the buffers we are creating
  52644. */
  52645. defaultType?: number;
  52646. }
  52647. /**
  52648. * A multi render target, like a render target provides the ability to render to a texture.
  52649. * Unlike the render target, it can render to several draw buffers in one draw.
  52650. * This is specially interesting in deferred rendering or for any effects requiring more than
  52651. * just one color from a single pass.
  52652. */
  52653. export class MultiRenderTarget extends RenderTargetTexture {
  52654. private _internalTextures;
  52655. private _textures;
  52656. private _multiRenderTargetOptions;
  52657. /**
  52658. * Get if draw buffers are currently supported by the used hardware and browser.
  52659. */
  52660. get isSupported(): boolean;
  52661. /**
  52662. * Get the list of textures generated by the multi render target.
  52663. */
  52664. get textures(): Texture[];
  52665. /**
  52666. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  52667. */
  52668. get depthTexture(): Texture;
  52669. /**
  52670. * Set the wrapping mode on U of all the textures we are rendering to.
  52671. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  52672. */
  52673. set wrapU(wrap: number);
  52674. /**
  52675. * Set the wrapping mode on V of all the textures we are rendering to.
  52676. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  52677. */
  52678. set wrapV(wrap: number);
  52679. /**
  52680. * Instantiate a new multi render target texture.
  52681. * A multi render target, like a render target provides the ability to render to a texture.
  52682. * Unlike the render target, it can render to several draw buffers in one draw.
  52683. * This is specially interesting in deferred rendering or for any effects requiring more than
  52684. * just one color from a single pass.
  52685. * @param name Define the name of the texture
  52686. * @param size Define the size of the buffers to render to
  52687. * @param count Define the number of target we are rendering into
  52688. * @param scene Define the scene the texture belongs to
  52689. * @param options Define the options used to create the multi render target
  52690. */
  52691. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  52692. /** @hidden */
  52693. _rebuild(): void;
  52694. private _createInternalTextures;
  52695. private _createTextures;
  52696. /**
  52697. * Define the number of samples used if MSAA is enabled.
  52698. */
  52699. get samples(): number;
  52700. set samples(value: number);
  52701. /**
  52702. * Resize all the textures in the multi render target.
  52703. * Be carrefull as it will recreate all the data in the new texture.
  52704. * @param size Define the new size
  52705. */
  52706. resize(size: any): void;
  52707. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  52708. /**
  52709. * Dispose the render targets and their associated resources
  52710. */
  52711. dispose(): void;
  52712. /**
  52713. * Release all the underlying texture used as draw buffers.
  52714. */
  52715. releaseInternalTextures(): void;
  52716. }
  52717. }
  52718. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  52719. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52720. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  52721. import { Nullable } from "babylonjs/types";
  52722. module "babylonjs/Engines/thinEngine" {
  52723. interface ThinEngine {
  52724. /**
  52725. * Unbind a list of render target textures from the webGL context
  52726. * This is used only when drawBuffer extension or webGL2 are active
  52727. * @param textures defines the render target textures to unbind
  52728. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52729. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52730. */
  52731. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  52732. /**
  52733. * Create a multi render target texture
  52734. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  52735. * @param size defines the size of the texture
  52736. * @param options defines the creation options
  52737. * @returns the cube texture as an InternalTexture
  52738. */
  52739. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  52740. /**
  52741. * Update the sample count for a given multiple render target texture
  52742. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  52743. * @param textures defines the textures to update
  52744. * @param samples defines the sample count to set
  52745. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  52746. */
  52747. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  52748. }
  52749. }
  52750. }
  52751. declare module "babylonjs/Engines/Extensions/engine.views" {
  52752. import { Camera } from "babylonjs/Cameras/camera";
  52753. import { Nullable } from "babylonjs/types";
  52754. /**
  52755. * Class used to define an additional view for the engine
  52756. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52757. */
  52758. export class EngineView {
  52759. /** Defines the canvas where to render the view */
  52760. target: HTMLCanvasElement;
  52761. /** Defines an optional camera used to render the view (will use active camera else) */
  52762. camera?: Camera;
  52763. }
  52764. module "babylonjs/Engines/engine" {
  52765. interface Engine {
  52766. /**
  52767. * Gets or sets the HTML element to use for attaching events
  52768. */
  52769. inputElement: Nullable<HTMLElement>;
  52770. /**
  52771. * Gets the current engine view
  52772. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52773. */
  52774. activeView: Nullable<EngineView>;
  52775. /** Gets or sets the list of views */
  52776. views: EngineView[];
  52777. /**
  52778. * Register a new child canvas
  52779. * @param canvas defines the canvas to register
  52780. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52781. * @returns the associated view
  52782. */
  52783. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52784. /**
  52785. * Remove a registered child canvas
  52786. * @param canvas defines the canvas to remove
  52787. * @returns the current engine
  52788. */
  52789. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52790. }
  52791. }
  52792. }
  52793. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  52794. import { Nullable } from "babylonjs/types";
  52795. module "babylonjs/Engines/engine" {
  52796. interface Engine {
  52797. /** @hidden */
  52798. _excludedCompressedTextures: string[];
  52799. /** @hidden */
  52800. _textureFormatInUse: string;
  52801. /**
  52802. * Gets the list of texture formats supported
  52803. */
  52804. readonly texturesSupported: Array<string>;
  52805. /**
  52806. * Gets the texture format in use
  52807. */
  52808. readonly textureFormatInUse: Nullable<string>;
  52809. /**
  52810. * Set the compressed texture extensions or file names to skip.
  52811. *
  52812. * @param skippedFiles defines the list of those texture files you want to skip
  52813. * Example: [".dds", ".env", "myfile.png"]
  52814. */
  52815. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52816. /**
  52817. * Set the compressed texture format to use, based on the formats you have, and the formats
  52818. * supported by the hardware / browser.
  52819. *
  52820. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52821. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52822. * to API arguments needed to compressed textures. This puts the burden on the container
  52823. * generator to house the arcane code for determining these for current & future formats.
  52824. *
  52825. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52826. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52827. *
  52828. * Note: The result of this call is not taken into account when a texture is base64.
  52829. *
  52830. * @param formatsAvailable defines the list of those format families you have created
  52831. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52832. *
  52833. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52834. * @returns The extension selected.
  52835. */
  52836. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52837. }
  52838. }
  52839. }
  52840. declare module "babylonjs/Engines/Extensions/index" {
  52841. export * from "babylonjs/Engines/Extensions/engine.alpha";
  52842. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  52843. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  52844. export * from "babylonjs/Engines/Extensions/engine.multiview";
  52845. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  52846. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  52847. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  52848. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  52849. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  52850. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  52851. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  52852. export * from "babylonjs/Engines/Extensions/engine.webVR";
  52853. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  52854. export * from "babylonjs/Engines/Extensions/engine.views";
  52855. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  52856. import "babylonjs/Engines/Extensions/engine.textureSelector";
  52857. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  52858. }
  52859. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  52860. import { Nullable } from "babylonjs/types";
  52861. /**
  52862. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52863. */
  52864. export interface CubeMapInfo {
  52865. /**
  52866. * The pixel array for the front face.
  52867. * This is stored in format, left to right, up to down format.
  52868. */
  52869. front: Nullable<ArrayBufferView>;
  52870. /**
  52871. * The pixel array for the back face.
  52872. * This is stored in format, left to right, up to down format.
  52873. */
  52874. back: Nullable<ArrayBufferView>;
  52875. /**
  52876. * The pixel array for the left face.
  52877. * This is stored in format, left to right, up to down format.
  52878. */
  52879. left: Nullable<ArrayBufferView>;
  52880. /**
  52881. * The pixel array for the right face.
  52882. * This is stored in format, left to right, up to down format.
  52883. */
  52884. right: Nullable<ArrayBufferView>;
  52885. /**
  52886. * The pixel array for the up face.
  52887. * This is stored in format, left to right, up to down format.
  52888. */
  52889. up: Nullable<ArrayBufferView>;
  52890. /**
  52891. * The pixel array for the down face.
  52892. * This is stored in format, left to right, up to down format.
  52893. */
  52894. down: Nullable<ArrayBufferView>;
  52895. /**
  52896. * The size of the cubemap stored.
  52897. *
  52898. * Each faces will be size * size pixels.
  52899. */
  52900. size: number;
  52901. /**
  52902. * The format of the texture.
  52903. *
  52904. * RGBA, RGB.
  52905. */
  52906. format: number;
  52907. /**
  52908. * The type of the texture data.
  52909. *
  52910. * UNSIGNED_INT, FLOAT.
  52911. */
  52912. type: number;
  52913. /**
  52914. * Specifies whether the texture is in gamma space.
  52915. */
  52916. gammaSpace: boolean;
  52917. }
  52918. /**
  52919. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52920. */
  52921. export class PanoramaToCubeMapTools {
  52922. private static FACE_LEFT;
  52923. private static FACE_RIGHT;
  52924. private static FACE_FRONT;
  52925. private static FACE_BACK;
  52926. private static FACE_DOWN;
  52927. private static FACE_UP;
  52928. /**
  52929. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52930. *
  52931. * @param float32Array The source data.
  52932. * @param inputWidth The width of the input panorama.
  52933. * @param inputHeight The height of the input panorama.
  52934. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52935. * @return The cubemap data
  52936. */
  52937. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52938. private static CreateCubemapTexture;
  52939. private static CalcProjectionSpherical;
  52940. }
  52941. }
  52942. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  52943. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52944. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52945. import { Nullable } from "babylonjs/types";
  52946. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52947. /**
  52948. * Helper class dealing with the extraction of spherical polynomial dataArray
  52949. * from a cube map.
  52950. */
  52951. export class CubeMapToSphericalPolynomialTools {
  52952. private static FileFaces;
  52953. /**
  52954. * Converts a texture to the according Spherical Polynomial data.
  52955. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52956. *
  52957. * @param texture The texture to extract the information from.
  52958. * @return The Spherical Polynomial data.
  52959. */
  52960. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52961. /**
  52962. * Converts a cubemap to the according Spherical Polynomial data.
  52963. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52964. *
  52965. * @param cubeInfo The Cube map to extract the information from.
  52966. * @return The Spherical Polynomial data.
  52967. */
  52968. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52969. }
  52970. }
  52971. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  52972. import { Nullable } from "babylonjs/types";
  52973. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52974. module "babylonjs/Materials/Textures/baseTexture" {
  52975. interface BaseTexture {
  52976. /**
  52977. * Get the polynomial representation of the texture data.
  52978. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52979. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52980. */
  52981. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52982. }
  52983. }
  52984. }
  52985. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  52986. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52987. /** @hidden */
  52988. export var rgbdEncodePixelShader: {
  52989. name: string;
  52990. shader: string;
  52991. };
  52992. }
  52993. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  52994. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52995. /** @hidden */
  52996. export var rgbdDecodePixelShader: {
  52997. name: string;
  52998. shader: string;
  52999. };
  53000. }
  53001. declare module "babylonjs/Misc/environmentTextureTools" {
  53002. import { Nullable } from "babylonjs/types";
  53003. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53004. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53005. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53006. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53007. import "babylonjs/Engines/Extensions/engine.readTexture";
  53008. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53009. import "babylonjs/Shaders/rgbdEncode.fragment";
  53010. import "babylonjs/Shaders/rgbdDecode.fragment";
  53011. /**
  53012. * Raw texture data and descriptor sufficient for WebGL texture upload
  53013. */
  53014. export interface EnvironmentTextureInfo {
  53015. /**
  53016. * Version of the environment map
  53017. */
  53018. version: number;
  53019. /**
  53020. * Width of image
  53021. */
  53022. width: number;
  53023. /**
  53024. * Irradiance information stored in the file.
  53025. */
  53026. irradiance: any;
  53027. /**
  53028. * Specular information stored in the file.
  53029. */
  53030. specular: any;
  53031. }
  53032. /**
  53033. * Defines One Image in the file. It requires only the position in the file
  53034. * as well as the length.
  53035. */
  53036. interface BufferImageData {
  53037. /**
  53038. * Length of the image data.
  53039. */
  53040. length: number;
  53041. /**
  53042. * Position of the data from the null terminator delimiting the end of the JSON.
  53043. */
  53044. position: number;
  53045. }
  53046. /**
  53047. * Defines the specular data enclosed in the file.
  53048. * This corresponds to the version 1 of the data.
  53049. */
  53050. export interface EnvironmentTextureSpecularInfoV1 {
  53051. /**
  53052. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  53053. */
  53054. specularDataPosition?: number;
  53055. /**
  53056. * This contains all the images data needed to reconstruct the cubemap.
  53057. */
  53058. mipmaps: Array<BufferImageData>;
  53059. /**
  53060. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  53061. */
  53062. lodGenerationScale: number;
  53063. }
  53064. /**
  53065. * Sets of helpers addressing the serialization and deserialization of environment texture
  53066. * stored in a BabylonJS env file.
  53067. * Those files are usually stored as .env files.
  53068. */
  53069. export class EnvironmentTextureTools {
  53070. /**
  53071. * Magic number identifying the env file.
  53072. */
  53073. private static _MagicBytes;
  53074. /**
  53075. * Gets the environment info from an env file.
  53076. * @param data The array buffer containing the .env bytes.
  53077. * @returns the environment file info (the json header) if successfully parsed.
  53078. */
  53079. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  53080. /**
  53081. * Creates an environment texture from a loaded cube texture.
  53082. * @param texture defines the cube texture to convert in env file
  53083. * @return a promise containing the environment data if succesfull.
  53084. */
  53085. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  53086. /**
  53087. * Creates a JSON representation of the spherical data.
  53088. * @param texture defines the texture containing the polynomials
  53089. * @return the JSON representation of the spherical info
  53090. */
  53091. private static _CreateEnvTextureIrradiance;
  53092. /**
  53093. * Creates the ArrayBufferViews used for initializing environment texture image data.
  53094. * @param data the image data
  53095. * @param info parameters that determine what views will be created for accessing the underlying buffer
  53096. * @return the views described by info providing access to the underlying buffer
  53097. */
  53098. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  53099. /**
  53100. * Uploads the texture info contained in the env file to the GPU.
  53101. * @param texture defines the internal texture to upload to
  53102. * @param data defines the data to load
  53103. * @param info defines the texture info retrieved through the GetEnvInfo method
  53104. * @returns a promise
  53105. */
  53106. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  53107. private static _OnImageReadyAsync;
  53108. /**
  53109. * Uploads the levels of image data to the GPU.
  53110. * @param texture defines the internal texture to upload to
  53111. * @param imageData defines the array buffer views of image data [mipmap][face]
  53112. * @returns a promise
  53113. */
  53114. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  53115. /**
  53116. * Uploads spherical polynomials information to the texture.
  53117. * @param texture defines the texture we are trying to upload the information to
  53118. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  53119. */
  53120. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  53121. /** @hidden */
  53122. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53123. }
  53124. }
  53125. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  53126. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  53127. /** @hidden */
  53128. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  53129. private _genericAttributeLocation;
  53130. private _varyingLocationCount;
  53131. private _varyingLocationMap;
  53132. private _replacements;
  53133. private _textureCount;
  53134. private _uniforms;
  53135. lineProcessor(line: string): string;
  53136. attributeProcessor(attribute: string): string;
  53137. varyingProcessor(varying: string, isFragment: boolean): string;
  53138. uniformProcessor(uniform: string): string;
  53139. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  53140. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  53141. }
  53142. }
  53143. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  53144. /**
  53145. * Class used to inline functions in shader code
  53146. */
  53147. export class ShaderCodeInliner {
  53148. private static readonly _RegexpFindFunctionNameAndType;
  53149. private _sourceCode;
  53150. private _functionDescr;
  53151. private _numMaxIterations;
  53152. /** Gets or sets the token used to mark the functions to inline */
  53153. inlineToken: string;
  53154. /** Gets or sets the debug mode */
  53155. debug: boolean;
  53156. /** Gets the code after the inlining process */
  53157. get code(): string;
  53158. /**
  53159. * Initializes the inliner
  53160. * @param sourceCode shader code source to inline
  53161. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  53162. */
  53163. constructor(sourceCode: string, numMaxIterations?: number);
  53164. /**
  53165. * Start the processing of the shader code
  53166. */
  53167. processCode(): void;
  53168. private _collectFunctions;
  53169. private _processInlining;
  53170. private _extractBetweenMarkers;
  53171. private _skipWhitespaces;
  53172. private _removeComments;
  53173. private _replaceFunctionCallsByCode;
  53174. private _findBackward;
  53175. private _escapeRegExp;
  53176. private _replaceNames;
  53177. }
  53178. }
  53179. declare module "babylonjs/Engines/nativeEngine" {
  53180. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  53181. import { Engine } from "babylonjs/Engines/engine";
  53182. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53183. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53184. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53185. import { Effect } from "babylonjs/Materials/effect";
  53186. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53187. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  53188. import { IColor4Like } from "babylonjs/Maths/math.like";
  53189. import { Scene } from "babylonjs/scene";
  53190. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53191. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53192. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53193. /**
  53194. * Container for accessors for natively-stored mesh data buffers.
  53195. */
  53196. class NativeDataBuffer extends DataBuffer {
  53197. /**
  53198. * Accessor value used to identify/retrieve a natively-stored index buffer.
  53199. */
  53200. nativeIndexBuffer?: any;
  53201. /**
  53202. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  53203. */
  53204. nativeVertexBuffer?: any;
  53205. }
  53206. /** @hidden */
  53207. class NativeTexture extends InternalTexture {
  53208. getInternalTexture(): InternalTexture;
  53209. getViewCount(): number;
  53210. }
  53211. /** @hidden */
  53212. export class NativeEngine extends Engine {
  53213. private readonly _native;
  53214. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  53215. private readonly INVALID_HANDLE;
  53216. getHardwareScalingLevel(): number;
  53217. constructor();
  53218. dispose(): void;
  53219. /**
  53220. * Can be used to override the current requestAnimationFrame requester.
  53221. * @hidden
  53222. */
  53223. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  53224. /**
  53225. * Override default engine behavior.
  53226. * @param color
  53227. * @param backBuffer
  53228. * @param depth
  53229. * @param stencil
  53230. */
  53231. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  53232. /**
  53233. * Gets host document
  53234. * @returns the host document object
  53235. */
  53236. getHostDocument(): Nullable<Document>;
  53237. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53238. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  53239. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  53240. recordVertexArrayObject(vertexBuffers: {
  53241. [key: string]: VertexBuffer;
  53242. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  53243. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53244. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53245. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53246. /**
  53247. * Draw a list of indexed primitives
  53248. * @param fillMode defines the primitive to use
  53249. * @param indexStart defines the starting index
  53250. * @param indexCount defines the number of index to draw
  53251. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53252. */
  53253. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53254. /**
  53255. * Draw a list of unindexed primitives
  53256. * @param fillMode defines the primitive to use
  53257. * @param verticesStart defines the index of first vertex to draw
  53258. * @param verticesCount defines the count of vertices to draw
  53259. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53260. */
  53261. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53262. createPipelineContext(): IPipelineContext;
  53263. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  53264. /** @hidden */
  53265. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  53266. /** @hidden */
  53267. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  53268. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53269. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53270. protected _setProgram(program: WebGLProgram): void;
  53271. _releaseEffect(effect: Effect): void;
  53272. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  53273. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  53274. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  53275. bindSamplers(effect: Effect): void;
  53276. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  53277. getRenderWidth(useScreen?: boolean): number;
  53278. getRenderHeight(useScreen?: boolean): number;
  53279. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  53280. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53281. /**
  53282. * Set the z offset to apply to current rendering
  53283. * @param value defines the offset to apply
  53284. */
  53285. setZOffset(value: number): void;
  53286. /**
  53287. * Gets the current value of the zOffset
  53288. * @returns the current zOffset state
  53289. */
  53290. getZOffset(): number;
  53291. /**
  53292. * Enable or disable depth buffering
  53293. * @param enable defines the state to set
  53294. */
  53295. setDepthBuffer(enable: boolean): void;
  53296. /**
  53297. * Gets a boolean indicating if depth writing is enabled
  53298. * @returns the current depth writing state
  53299. */
  53300. getDepthWrite(): boolean;
  53301. /**
  53302. * Enable or disable depth writing
  53303. * @param enable defines the state to set
  53304. */
  53305. setDepthWrite(enable: boolean): void;
  53306. /**
  53307. * Enable or disable color writing
  53308. * @param enable defines the state to set
  53309. */
  53310. setColorWrite(enable: boolean): void;
  53311. /**
  53312. * Gets a boolean indicating if color writing is enabled
  53313. * @returns the current color writing state
  53314. */
  53315. getColorWrite(): boolean;
  53316. /**
  53317. * Sets alpha constants used by some alpha blending modes
  53318. * @param r defines the red component
  53319. * @param g defines the green component
  53320. * @param b defines the blue component
  53321. * @param a defines the alpha component
  53322. */
  53323. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  53324. /**
  53325. * Sets the current alpha mode
  53326. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  53327. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53328. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53329. */
  53330. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53331. /**
  53332. * Gets the current alpha mode
  53333. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53334. * @returns the current alpha mode
  53335. */
  53336. getAlphaMode(): number;
  53337. setInt(uniform: WebGLUniformLocation, int: number): void;
  53338. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53339. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53340. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53341. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53342. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53343. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53344. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53345. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53346. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53347. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53348. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53349. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53350. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53351. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53352. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53353. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53354. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53355. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53356. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53357. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  53358. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  53359. wipeCaches(bruteForce?: boolean): void;
  53360. _createTexture(): WebGLTexture;
  53361. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  53362. /**
  53363. * Usually called from Texture.ts.
  53364. * Passed information to create a WebGLTexture
  53365. * @param url defines a value which contains one of the following:
  53366. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53367. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53368. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53369. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53370. * @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)
  53371. * @param scene needed for loading to the correct scene
  53372. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53373. * @param onLoad optional callback to be called upon successful completion
  53374. * @param onError optional callback to be called upon failure
  53375. * @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
  53376. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53377. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53378. * @param forcedExtension defines the extension to use to pick the right loader
  53379. * @param mimeType defines an optional mime type
  53380. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53381. */
  53382. 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;
  53383. /**
  53384. * Creates a cube texture
  53385. * @param rootUrl defines the url where the files to load is located
  53386. * @param scene defines the current scene
  53387. * @param files defines the list of files to load (1 per face)
  53388. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  53389. * @param onLoad defines an optional callback raised when the texture is loaded
  53390. * @param onError defines an optional callback raised if there is an issue to load the texture
  53391. * @param format defines the format of the data
  53392. * @param forcedExtension defines the extension to use to pick the right loader
  53393. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  53394. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53395. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53396. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  53397. * @returns the cube texture as an InternalTexture
  53398. */
  53399. 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;
  53400. private _getSamplingFilter;
  53401. private static _GetNativeTextureFormat;
  53402. createRenderTargetTexture(size: number | {
  53403. width: number;
  53404. height: number;
  53405. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  53406. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53407. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53408. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53409. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  53410. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  53411. /**
  53412. * Updates a dynamic vertex buffer.
  53413. * @param vertexBuffer the vertex buffer to update
  53414. * @param data the data used to update the vertex buffer
  53415. * @param byteOffset the byte offset of the data (optional)
  53416. * @param byteLength the byte length of the data (optional)
  53417. */
  53418. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  53419. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  53420. private _updateAnisotropicLevel;
  53421. private _getAddressMode;
  53422. /** @hidden */
  53423. _bindTexture(channel: number, texture: InternalTexture): void;
  53424. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53425. releaseEffects(): void;
  53426. /** @hidden */
  53427. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53428. /** @hidden */
  53429. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53430. /** @hidden */
  53431. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53432. /** @hidden */
  53433. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53434. }
  53435. }
  53436. declare module "babylonjs/Engines/index" {
  53437. export * from "babylonjs/Engines/constants";
  53438. export * from "babylonjs/Engines/engineCapabilities";
  53439. export * from "babylonjs/Engines/instancingAttributeInfo";
  53440. export * from "babylonjs/Engines/thinEngine";
  53441. export * from "babylonjs/Engines/engine";
  53442. export * from "babylonjs/Engines/engineStore";
  53443. export * from "babylonjs/Engines/nullEngine";
  53444. export * from "babylonjs/Engines/Extensions/index";
  53445. export * from "babylonjs/Engines/IPipelineContext";
  53446. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  53447. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  53448. export * from "babylonjs/Engines/nativeEngine";
  53449. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  53450. }
  53451. declare module "babylonjs/Events/clipboardEvents" {
  53452. /**
  53453. * Gather the list of clipboard event types as constants.
  53454. */
  53455. export class ClipboardEventTypes {
  53456. /**
  53457. * The clipboard event is fired when a copy command is active (pressed).
  53458. */
  53459. static readonly COPY: number;
  53460. /**
  53461. * The clipboard event is fired when a cut command is active (pressed).
  53462. */
  53463. static readonly CUT: number;
  53464. /**
  53465. * The clipboard event is fired when a paste command is active (pressed).
  53466. */
  53467. static readonly PASTE: number;
  53468. }
  53469. /**
  53470. * This class is used to store clipboard related info for the onClipboardObservable event.
  53471. */
  53472. export class ClipboardInfo {
  53473. /**
  53474. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53475. */
  53476. type: number;
  53477. /**
  53478. * Defines the related dom event
  53479. */
  53480. event: ClipboardEvent;
  53481. /**
  53482. *Creates an instance of ClipboardInfo.
  53483. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  53484. * @param event Defines the related dom event
  53485. */
  53486. constructor(
  53487. /**
  53488. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53489. */
  53490. type: number,
  53491. /**
  53492. * Defines the related dom event
  53493. */
  53494. event: ClipboardEvent);
  53495. /**
  53496. * Get the clipboard event's type from the keycode.
  53497. * @param keyCode Defines the keyCode for the current keyboard event.
  53498. * @return {number}
  53499. */
  53500. static GetTypeFromCharacter(keyCode: number): number;
  53501. }
  53502. }
  53503. declare module "babylonjs/Events/index" {
  53504. export * from "babylonjs/Events/keyboardEvents";
  53505. export * from "babylonjs/Events/pointerEvents";
  53506. export * from "babylonjs/Events/clipboardEvents";
  53507. }
  53508. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  53509. import { Scene } from "babylonjs/scene";
  53510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53511. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53512. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53513. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53514. /**
  53515. * Google Daydream controller
  53516. */
  53517. export class DaydreamController extends WebVRController {
  53518. /**
  53519. * Base Url for the controller model.
  53520. */
  53521. static MODEL_BASE_URL: string;
  53522. /**
  53523. * File name for the controller model.
  53524. */
  53525. static MODEL_FILENAME: string;
  53526. /**
  53527. * Gamepad Id prefix used to identify Daydream Controller.
  53528. */
  53529. static readonly GAMEPAD_ID_PREFIX: string;
  53530. /**
  53531. * Creates a new DaydreamController from a gamepad
  53532. * @param vrGamepad the gamepad that the controller should be created from
  53533. */
  53534. constructor(vrGamepad: any);
  53535. /**
  53536. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53537. * @param scene scene in which to add meshes
  53538. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53539. */
  53540. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53541. /**
  53542. * Called once for each button that changed state since the last frame
  53543. * @param buttonIdx Which button index changed
  53544. * @param state New state of the button
  53545. * @param changes Which properties on the state changed since last frame
  53546. */
  53547. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53548. }
  53549. }
  53550. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  53551. import { Scene } from "babylonjs/scene";
  53552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53553. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53554. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53555. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53556. /**
  53557. * Gear VR Controller
  53558. */
  53559. export class GearVRController extends WebVRController {
  53560. /**
  53561. * Base Url for the controller model.
  53562. */
  53563. static MODEL_BASE_URL: string;
  53564. /**
  53565. * File name for the controller model.
  53566. */
  53567. static MODEL_FILENAME: string;
  53568. /**
  53569. * Gamepad Id prefix used to identify this controller.
  53570. */
  53571. static readonly GAMEPAD_ID_PREFIX: string;
  53572. private readonly _buttonIndexToObservableNameMap;
  53573. /**
  53574. * Creates a new GearVRController from a gamepad
  53575. * @param vrGamepad the gamepad that the controller should be created from
  53576. */
  53577. constructor(vrGamepad: any);
  53578. /**
  53579. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53580. * @param scene scene in which to add meshes
  53581. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53582. */
  53583. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53584. /**
  53585. * Called once for each button that changed state since the last frame
  53586. * @param buttonIdx Which button index changed
  53587. * @param state New state of the button
  53588. * @param changes Which properties on the state changed since last frame
  53589. */
  53590. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53591. }
  53592. }
  53593. declare module "babylonjs/Gamepads/Controllers/genericController" {
  53594. import { Scene } from "babylonjs/scene";
  53595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53596. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53597. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53598. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53599. /**
  53600. * Generic Controller
  53601. */
  53602. export class GenericController extends WebVRController {
  53603. /**
  53604. * Base Url for the controller model.
  53605. */
  53606. static readonly MODEL_BASE_URL: string;
  53607. /**
  53608. * File name for the controller model.
  53609. */
  53610. static readonly MODEL_FILENAME: string;
  53611. /**
  53612. * Creates a new GenericController from a gamepad
  53613. * @param vrGamepad the gamepad that the controller should be created from
  53614. */
  53615. constructor(vrGamepad: any);
  53616. /**
  53617. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53618. * @param scene scene in which to add meshes
  53619. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53620. */
  53621. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53622. /**
  53623. * Called once for each button that changed state since the last frame
  53624. * @param buttonIdx Which button index changed
  53625. * @param state New state of the button
  53626. * @param changes Which properties on the state changed since last frame
  53627. */
  53628. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53629. }
  53630. }
  53631. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  53632. import { Observable } from "babylonjs/Misc/observable";
  53633. import { Scene } from "babylonjs/scene";
  53634. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53635. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53636. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53637. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53638. /**
  53639. * Oculus Touch Controller
  53640. */
  53641. export class OculusTouchController extends WebVRController {
  53642. /**
  53643. * Base Url for the controller model.
  53644. */
  53645. static MODEL_BASE_URL: string;
  53646. /**
  53647. * File name for the left controller model.
  53648. */
  53649. static MODEL_LEFT_FILENAME: string;
  53650. /**
  53651. * File name for the right controller model.
  53652. */
  53653. static MODEL_RIGHT_FILENAME: string;
  53654. /**
  53655. * Base Url for the Quest controller model.
  53656. */
  53657. static QUEST_MODEL_BASE_URL: string;
  53658. /**
  53659. * @hidden
  53660. * If the controllers are running on a device that needs the updated Quest controller models
  53661. */
  53662. static _IsQuest: boolean;
  53663. /**
  53664. * Fired when the secondary trigger on this controller is modified
  53665. */
  53666. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  53667. /**
  53668. * Fired when the thumb rest on this controller is modified
  53669. */
  53670. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  53671. /**
  53672. * Creates a new OculusTouchController from a gamepad
  53673. * @param vrGamepad the gamepad that the controller should be created from
  53674. */
  53675. constructor(vrGamepad: any);
  53676. /**
  53677. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53678. * @param scene scene in which to add meshes
  53679. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53680. */
  53681. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53682. /**
  53683. * Fired when the A button on this controller is modified
  53684. */
  53685. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53686. /**
  53687. * Fired when the B button on this controller is modified
  53688. */
  53689. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53690. /**
  53691. * Fired when the X button on this controller is modified
  53692. */
  53693. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53694. /**
  53695. * Fired when the Y button on this controller is modified
  53696. */
  53697. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53698. /**
  53699. * Called once for each button that changed state since the last frame
  53700. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  53701. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  53702. * 2) secondary trigger (same)
  53703. * 3) A (right) X (left), touch, pressed = value
  53704. * 4) B / Y
  53705. * 5) thumb rest
  53706. * @param buttonIdx Which button index changed
  53707. * @param state New state of the button
  53708. * @param changes Which properties on the state changed since last frame
  53709. */
  53710. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53711. }
  53712. }
  53713. declare module "babylonjs/Gamepads/Controllers/viveController" {
  53714. import { Scene } from "babylonjs/scene";
  53715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53716. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53717. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53718. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53719. import { Observable } from "babylonjs/Misc/observable";
  53720. /**
  53721. * Vive Controller
  53722. */
  53723. export class ViveController extends WebVRController {
  53724. /**
  53725. * Base Url for the controller model.
  53726. */
  53727. static MODEL_BASE_URL: string;
  53728. /**
  53729. * File name for the controller model.
  53730. */
  53731. static MODEL_FILENAME: string;
  53732. /**
  53733. * Creates a new ViveController from a gamepad
  53734. * @param vrGamepad the gamepad that the controller should be created from
  53735. */
  53736. constructor(vrGamepad: any);
  53737. /**
  53738. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53739. * @param scene scene in which to add meshes
  53740. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53741. */
  53742. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53743. /**
  53744. * Fired when the left button on this controller is modified
  53745. */
  53746. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53747. /**
  53748. * Fired when the right button on this controller is modified
  53749. */
  53750. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53751. /**
  53752. * Fired when the menu button on this controller is modified
  53753. */
  53754. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53755. /**
  53756. * Called once for each button that changed state since the last frame
  53757. * Vive mapping:
  53758. * 0: touchpad
  53759. * 1: trigger
  53760. * 2: left AND right buttons
  53761. * 3: menu button
  53762. * @param buttonIdx Which button index changed
  53763. * @param state New state of the button
  53764. * @param changes Which properties on the state changed since last frame
  53765. */
  53766. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53767. }
  53768. }
  53769. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  53770. import { Observable } from "babylonjs/Misc/observable";
  53771. import { Scene } from "babylonjs/scene";
  53772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53773. import { Ray } from "babylonjs/Culling/ray";
  53774. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53775. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53776. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53777. /**
  53778. * Defines the WindowsMotionController object that the state of the windows motion controller
  53779. */
  53780. export class WindowsMotionController extends WebVRController {
  53781. /**
  53782. * The base url used to load the left and right controller models
  53783. */
  53784. static MODEL_BASE_URL: string;
  53785. /**
  53786. * The name of the left controller model file
  53787. */
  53788. static MODEL_LEFT_FILENAME: string;
  53789. /**
  53790. * The name of the right controller model file
  53791. */
  53792. static MODEL_RIGHT_FILENAME: string;
  53793. /**
  53794. * The controller name prefix for this controller type
  53795. */
  53796. static readonly GAMEPAD_ID_PREFIX: string;
  53797. /**
  53798. * The controller id pattern for this controller type
  53799. */
  53800. private static readonly GAMEPAD_ID_PATTERN;
  53801. private _loadedMeshInfo;
  53802. protected readonly _mapping: {
  53803. buttons: string[];
  53804. buttonMeshNames: {
  53805. trigger: string;
  53806. menu: string;
  53807. grip: string;
  53808. thumbstick: string;
  53809. trackpad: string;
  53810. };
  53811. buttonObservableNames: {
  53812. trigger: string;
  53813. menu: string;
  53814. grip: string;
  53815. thumbstick: string;
  53816. trackpad: string;
  53817. };
  53818. axisMeshNames: string[];
  53819. pointingPoseMeshName: string;
  53820. };
  53821. /**
  53822. * Fired when the trackpad on this controller is clicked
  53823. */
  53824. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53825. /**
  53826. * Fired when the trackpad on this controller is modified
  53827. */
  53828. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53829. /**
  53830. * The current x and y values of this controller's trackpad
  53831. */
  53832. trackpad: StickValues;
  53833. /**
  53834. * Creates a new WindowsMotionController from a gamepad
  53835. * @param vrGamepad the gamepad that the controller should be created from
  53836. */
  53837. constructor(vrGamepad: any);
  53838. /**
  53839. * Fired when the trigger on this controller is modified
  53840. */
  53841. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53842. /**
  53843. * Fired when the menu button on this controller is modified
  53844. */
  53845. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53846. /**
  53847. * Fired when the grip button on this controller is modified
  53848. */
  53849. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53850. /**
  53851. * Fired when the thumbstick button on this controller is modified
  53852. */
  53853. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53854. /**
  53855. * Fired when the touchpad button on this controller is modified
  53856. */
  53857. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53858. /**
  53859. * Fired when the touchpad values on this controller are modified
  53860. */
  53861. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53862. protected _updateTrackpad(): void;
  53863. /**
  53864. * Called once per frame by the engine.
  53865. */
  53866. update(): void;
  53867. /**
  53868. * Called once for each button that changed state since the last frame
  53869. * @param buttonIdx Which button index changed
  53870. * @param state New state of the button
  53871. * @param changes Which properties on the state changed since last frame
  53872. */
  53873. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53874. /**
  53875. * Moves the buttons on the controller mesh based on their current state
  53876. * @param buttonName the name of the button to move
  53877. * @param buttonValue the value of the button which determines the buttons new position
  53878. */
  53879. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53880. /**
  53881. * Moves the axis on the controller mesh based on its current state
  53882. * @param axis the index of the axis
  53883. * @param axisValue the value of the axis which determines the meshes new position
  53884. * @hidden
  53885. */
  53886. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53887. /**
  53888. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53889. * @param scene scene in which to add meshes
  53890. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53891. */
  53892. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53893. /**
  53894. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53895. * can be transformed by button presses and axes values, based on this._mapping.
  53896. *
  53897. * @param scene scene in which the meshes exist
  53898. * @param meshes list of meshes that make up the controller model to process
  53899. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53900. */
  53901. private processModel;
  53902. private createMeshInfo;
  53903. /**
  53904. * Gets the ray of the controller in the direction the controller is pointing
  53905. * @param length the length the resulting ray should be
  53906. * @returns a ray in the direction the controller is pointing
  53907. */
  53908. getForwardRay(length?: number): Ray;
  53909. /**
  53910. * Disposes of the controller
  53911. */
  53912. dispose(): void;
  53913. }
  53914. /**
  53915. * This class represents a new windows motion controller in XR.
  53916. */
  53917. export class XRWindowsMotionController extends WindowsMotionController {
  53918. /**
  53919. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53920. */
  53921. protected readonly _mapping: {
  53922. buttons: string[];
  53923. buttonMeshNames: {
  53924. trigger: string;
  53925. menu: string;
  53926. grip: string;
  53927. thumbstick: string;
  53928. trackpad: string;
  53929. };
  53930. buttonObservableNames: {
  53931. trigger: string;
  53932. menu: string;
  53933. grip: string;
  53934. thumbstick: string;
  53935. trackpad: string;
  53936. };
  53937. axisMeshNames: string[];
  53938. pointingPoseMeshName: string;
  53939. };
  53940. /**
  53941. * Construct a new XR-Based windows motion controller
  53942. *
  53943. * @param gamepadInfo the gamepad object from the browser
  53944. */
  53945. constructor(gamepadInfo: any);
  53946. /**
  53947. * holds the thumbstick values (X,Y)
  53948. */
  53949. thumbstickValues: StickValues;
  53950. /**
  53951. * Fired when the thumbstick on this controller is clicked
  53952. */
  53953. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53954. /**
  53955. * Fired when the thumbstick on this controller is modified
  53956. */
  53957. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53958. /**
  53959. * Fired when the touchpad button on this controller is modified
  53960. */
  53961. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53962. /**
  53963. * Fired when the touchpad values on this controller are modified
  53964. */
  53965. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53966. /**
  53967. * Fired when the thumbstick button on this controller is modified
  53968. * here to prevent breaking changes
  53969. */
  53970. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53971. /**
  53972. * updating the thumbstick(!) and not the trackpad.
  53973. * This is named this way due to the difference between WebVR and XR and to avoid
  53974. * changing the parent class.
  53975. */
  53976. protected _updateTrackpad(): void;
  53977. /**
  53978. * Disposes the class with joy
  53979. */
  53980. dispose(): void;
  53981. }
  53982. }
  53983. declare module "babylonjs/Gamepads/Controllers/index" {
  53984. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  53985. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  53986. export * from "babylonjs/Gamepads/Controllers/genericController";
  53987. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  53988. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53989. export * from "babylonjs/Gamepads/Controllers/viveController";
  53990. export * from "babylonjs/Gamepads/Controllers/webVRController";
  53991. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  53992. }
  53993. declare module "babylonjs/Gamepads/index" {
  53994. export * from "babylonjs/Gamepads/Controllers/index";
  53995. export * from "babylonjs/Gamepads/gamepad";
  53996. export * from "babylonjs/Gamepads/gamepadManager";
  53997. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  53998. export * from "babylonjs/Gamepads/xboxGamepad";
  53999. export * from "babylonjs/Gamepads/dualShockGamepad";
  54000. }
  54001. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  54002. import { Scene } from "babylonjs/scene";
  54003. import { Vector4 } from "babylonjs/Maths/math.vector";
  54004. import { Color4 } from "babylonjs/Maths/math.color";
  54005. import { Mesh } from "babylonjs/Meshes/mesh";
  54006. import { Nullable } from "babylonjs/types";
  54007. /**
  54008. * Class containing static functions to help procedurally build meshes
  54009. */
  54010. export class PolyhedronBuilder {
  54011. /**
  54012. * Creates a polyhedron mesh
  54013. * * 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
  54014. * * The parameter `size` (positive float, default 1) sets the polygon size
  54015. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54016. * * 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`
  54017. * * 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
  54018. * * 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)`)
  54019. * * 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
  54020. * * 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
  54021. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54022. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54024. * @param name defines the name of the mesh
  54025. * @param options defines the options used to create the mesh
  54026. * @param scene defines the hosting scene
  54027. * @returns the polyhedron mesh
  54028. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54029. */
  54030. static CreatePolyhedron(name: string, options: {
  54031. type?: number;
  54032. size?: number;
  54033. sizeX?: number;
  54034. sizeY?: number;
  54035. sizeZ?: number;
  54036. custom?: any;
  54037. faceUV?: Vector4[];
  54038. faceColors?: Color4[];
  54039. flat?: boolean;
  54040. updatable?: boolean;
  54041. sideOrientation?: number;
  54042. frontUVs?: Vector4;
  54043. backUVs?: Vector4;
  54044. }, scene?: Nullable<Scene>): Mesh;
  54045. }
  54046. }
  54047. declare module "babylonjs/Gizmos/scaleGizmo" {
  54048. import { Observable } from "babylonjs/Misc/observable";
  54049. import { Nullable } from "babylonjs/types";
  54050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54051. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54052. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  54053. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54054. /**
  54055. * Gizmo that enables scaling a mesh along 3 axis
  54056. */
  54057. export class ScaleGizmo extends Gizmo {
  54058. /**
  54059. * Internal gizmo used for interactions on the x axis
  54060. */
  54061. xGizmo: AxisScaleGizmo;
  54062. /**
  54063. * Internal gizmo used for interactions on the y axis
  54064. */
  54065. yGizmo: AxisScaleGizmo;
  54066. /**
  54067. * Internal gizmo used for interactions on the z axis
  54068. */
  54069. zGizmo: AxisScaleGizmo;
  54070. /**
  54071. * Internal gizmo used to scale all axis equally
  54072. */
  54073. uniformScaleGizmo: AxisScaleGizmo;
  54074. private _meshAttached;
  54075. private _updateGizmoRotationToMatchAttachedMesh;
  54076. private _snapDistance;
  54077. private _scaleRatio;
  54078. private _uniformScalingMesh;
  54079. private _octahedron;
  54080. private _sensitivity;
  54081. /** Fires an event when any of it's sub gizmos are dragged */
  54082. onDragStartObservable: Observable<unknown>;
  54083. /** Fires an event when any of it's sub gizmos are released from dragging */
  54084. onDragEndObservable: Observable<unknown>;
  54085. get attachedMesh(): Nullable<AbstractMesh>;
  54086. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54087. /**
  54088. * Creates a ScaleGizmo
  54089. * @param gizmoLayer The utility layer the gizmo will be added to
  54090. */
  54091. constructor(gizmoLayer?: UtilityLayerRenderer);
  54092. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54093. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54094. /**
  54095. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54096. */
  54097. set snapDistance(value: number);
  54098. get snapDistance(): number;
  54099. /**
  54100. * Ratio for the scale of the gizmo (Default: 1)
  54101. */
  54102. set scaleRatio(value: number);
  54103. get scaleRatio(): number;
  54104. /**
  54105. * Sensitivity factor for dragging (Default: 1)
  54106. */
  54107. set sensitivity(value: number);
  54108. get sensitivity(): number;
  54109. /**
  54110. * Disposes of the gizmo
  54111. */
  54112. dispose(): void;
  54113. }
  54114. }
  54115. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  54116. import { Observable } from "babylonjs/Misc/observable";
  54117. import { Nullable } from "babylonjs/types";
  54118. import { Vector3 } from "babylonjs/Maths/math.vector";
  54119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54120. import { Mesh } from "babylonjs/Meshes/mesh";
  54121. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54122. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54123. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54124. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54125. import { Color3 } from "babylonjs/Maths/math.color";
  54126. /**
  54127. * Single axis scale gizmo
  54128. */
  54129. export class AxisScaleGizmo extends Gizmo {
  54130. /**
  54131. * Drag behavior responsible for the gizmos dragging interactions
  54132. */
  54133. dragBehavior: PointerDragBehavior;
  54134. private _pointerObserver;
  54135. /**
  54136. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54137. */
  54138. snapDistance: number;
  54139. /**
  54140. * Event that fires each time the gizmo snaps to a new location.
  54141. * * snapDistance is the the change in distance
  54142. */
  54143. onSnapObservable: Observable<{
  54144. snapDistance: number;
  54145. }>;
  54146. /**
  54147. * If the scaling operation should be done on all axis (default: false)
  54148. */
  54149. uniformScaling: boolean;
  54150. /**
  54151. * Custom sensitivity value for the drag strength
  54152. */
  54153. sensitivity: number;
  54154. private _isEnabled;
  54155. private _parent;
  54156. private _arrow;
  54157. private _coloredMaterial;
  54158. private _hoverMaterial;
  54159. /**
  54160. * Creates an AxisScaleGizmo
  54161. * @param gizmoLayer The utility layer the gizmo will be added to
  54162. * @param dragAxis The axis which the gizmo will be able to scale on
  54163. * @param color The color of the gizmo
  54164. */
  54165. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  54166. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54167. /**
  54168. * If the gizmo is enabled
  54169. */
  54170. set isEnabled(value: boolean);
  54171. get isEnabled(): boolean;
  54172. /**
  54173. * Disposes of the gizmo
  54174. */
  54175. dispose(): void;
  54176. /**
  54177. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54178. * @param mesh The mesh to replace the default mesh of the gizmo
  54179. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54180. */
  54181. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54182. }
  54183. }
  54184. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  54185. import { Observable } from "babylonjs/Misc/observable";
  54186. import { Nullable } from "babylonjs/types";
  54187. import { Vector3 } from "babylonjs/Maths/math.vector";
  54188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54189. import { Mesh } from "babylonjs/Meshes/mesh";
  54190. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54191. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54192. import { Color3 } from "babylonjs/Maths/math.color";
  54193. import "babylonjs/Meshes/Builders/boxBuilder";
  54194. /**
  54195. * Bounding box gizmo
  54196. */
  54197. export class BoundingBoxGizmo extends Gizmo {
  54198. private _lineBoundingBox;
  54199. private _rotateSpheresParent;
  54200. private _scaleBoxesParent;
  54201. private _boundingDimensions;
  54202. private _renderObserver;
  54203. private _pointerObserver;
  54204. private _scaleDragSpeed;
  54205. private _tmpQuaternion;
  54206. private _tmpVector;
  54207. private _tmpRotationMatrix;
  54208. /**
  54209. * 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)
  54210. */
  54211. ignoreChildren: boolean;
  54212. /**
  54213. * 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)
  54214. */
  54215. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54216. /**
  54217. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54218. */
  54219. rotationSphereSize: number;
  54220. /**
  54221. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54222. */
  54223. scaleBoxSize: number;
  54224. /**
  54225. * 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)
  54226. */
  54227. fixedDragMeshScreenSize: boolean;
  54228. /**
  54229. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54230. */
  54231. fixedDragMeshScreenSizeDistanceFactor: number;
  54232. /**
  54233. * Fired when a rotation sphere or scale box is dragged
  54234. */
  54235. onDragStartObservable: Observable<{}>;
  54236. /**
  54237. * Fired when a scale box is dragged
  54238. */
  54239. onScaleBoxDragObservable: Observable<{}>;
  54240. /**
  54241. * Fired when a scale box drag is ended
  54242. */
  54243. onScaleBoxDragEndObservable: Observable<{}>;
  54244. /**
  54245. * Fired when a rotation sphere is dragged
  54246. */
  54247. onRotationSphereDragObservable: Observable<{}>;
  54248. /**
  54249. * Fired when a rotation sphere drag is ended
  54250. */
  54251. onRotationSphereDragEndObservable: Observable<{}>;
  54252. /**
  54253. * 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)
  54254. */
  54255. scalePivot: Nullable<Vector3>;
  54256. /**
  54257. * Mesh used as a pivot to rotate the attached mesh
  54258. */
  54259. private _anchorMesh;
  54260. private _existingMeshScale;
  54261. private _dragMesh;
  54262. private pointerDragBehavior;
  54263. private coloredMaterial;
  54264. private hoverColoredMaterial;
  54265. /**
  54266. * Sets the color of the bounding box gizmo
  54267. * @param color the color to set
  54268. */
  54269. setColor(color: Color3): void;
  54270. /**
  54271. * Creates an BoundingBoxGizmo
  54272. * @param gizmoLayer The utility layer the gizmo will be added to
  54273. * @param color The color of the gizmo
  54274. */
  54275. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54276. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54277. private _selectNode;
  54278. /**
  54279. * Updates the bounding box information for the Gizmo
  54280. */
  54281. updateBoundingBox(): void;
  54282. private _updateRotationSpheres;
  54283. private _updateScaleBoxes;
  54284. /**
  54285. * Enables rotation on the specified axis and disables rotation on the others
  54286. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54287. */
  54288. setEnabledRotationAxis(axis: string): void;
  54289. /**
  54290. * Enables/disables scaling
  54291. * @param enable if scaling should be enabled
  54292. * @param homogeneousScaling defines if scaling should only be homogeneous
  54293. */
  54294. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54295. private _updateDummy;
  54296. /**
  54297. * Enables a pointer drag behavior on the bounding box of the gizmo
  54298. */
  54299. enableDragBehavior(): void;
  54300. /**
  54301. * Disposes of the gizmo
  54302. */
  54303. dispose(): void;
  54304. /**
  54305. * 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)
  54306. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54307. * @returns the bounding box mesh with the passed in mesh as a child
  54308. */
  54309. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54310. /**
  54311. * CustomMeshes are not supported by this gizmo
  54312. * @param mesh The mesh to replace the default mesh of the gizmo
  54313. */
  54314. setCustomMesh(mesh: Mesh): void;
  54315. }
  54316. }
  54317. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  54318. import { Observable } from "babylonjs/Misc/observable";
  54319. import { Nullable } from "babylonjs/types";
  54320. import { Vector3 } from "babylonjs/Maths/math.vector";
  54321. import { Color3 } from "babylonjs/Maths/math.color";
  54322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54323. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54324. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54325. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54326. import "babylonjs/Meshes/Builders/linesBuilder";
  54327. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54328. /**
  54329. * Single plane rotation gizmo
  54330. */
  54331. export class PlaneRotationGizmo extends Gizmo {
  54332. /**
  54333. * Drag behavior responsible for the gizmos dragging interactions
  54334. */
  54335. dragBehavior: PointerDragBehavior;
  54336. private _pointerObserver;
  54337. /**
  54338. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54339. */
  54340. snapDistance: number;
  54341. /**
  54342. * Event that fires each time the gizmo snaps to a new location.
  54343. * * snapDistance is the the change in distance
  54344. */
  54345. onSnapObservable: Observable<{
  54346. snapDistance: number;
  54347. }>;
  54348. private _isEnabled;
  54349. private _parent;
  54350. /**
  54351. * Creates a PlaneRotationGizmo
  54352. * @param gizmoLayer The utility layer the gizmo will be added to
  54353. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54354. * @param color The color of the gizmo
  54355. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54356. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54357. */
  54358. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  54359. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54360. /**
  54361. * If the gizmo is enabled
  54362. */
  54363. set isEnabled(value: boolean);
  54364. get isEnabled(): boolean;
  54365. /**
  54366. * Disposes of the gizmo
  54367. */
  54368. dispose(): void;
  54369. }
  54370. }
  54371. declare module "babylonjs/Gizmos/rotationGizmo" {
  54372. import { Observable } from "babylonjs/Misc/observable";
  54373. import { Nullable } from "babylonjs/types";
  54374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54375. import { Mesh } from "babylonjs/Meshes/mesh";
  54376. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54377. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  54378. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54379. /**
  54380. * Gizmo that enables rotating a mesh along 3 axis
  54381. */
  54382. export class RotationGizmo extends Gizmo {
  54383. /**
  54384. * Internal gizmo used for interactions on the x axis
  54385. */
  54386. xGizmo: PlaneRotationGizmo;
  54387. /**
  54388. * Internal gizmo used for interactions on the y axis
  54389. */
  54390. yGizmo: PlaneRotationGizmo;
  54391. /**
  54392. * Internal gizmo used for interactions on the z axis
  54393. */
  54394. zGizmo: PlaneRotationGizmo;
  54395. /** Fires an event when any of it's sub gizmos are dragged */
  54396. onDragStartObservable: Observable<unknown>;
  54397. /** Fires an event when any of it's sub gizmos are released from dragging */
  54398. onDragEndObservable: Observable<unknown>;
  54399. private _meshAttached;
  54400. get attachedMesh(): Nullable<AbstractMesh>;
  54401. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54402. /**
  54403. * Creates a RotationGizmo
  54404. * @param gizmoLayer The utility layer the gizmo will be added to
  54405. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54406. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54407. */
  54408. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  54409. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54410. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54411. /**
  54412. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54413. */
  54414. set snapDistance(value: number);
  54415. get snapDistance(): number;
  54416. /**
  54417. * Ratio for the scale of the gizmo (Default: 1)
  54418. */
  54419. set scaleRatio(value: number);
  54420. get scaleRatio(): number;
  54421. /**
  54422. * Disposes of the gizmo
  54423. */
  54424. dispose(): void;
  54425. /**
  54426. * CustomMeshes are not supported by this gizmo
  54427. * @param mesh The mesh to replace the default mesh of the gizmo
  54428. */
  54429. setCustomMesh(mesh: Mesh): void;
  54430. }
  54431. }
  54432. declare module "babylonjs/Gizmos/gizmoManager" {
  54433. import { Observable } from "babylonjs/Misc/observable";
  54434. import { Nullable } from "babylonjs/types";
  54435. import { Scene, IDisposable } from "babylonjs/scene";
  54436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54437. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54438. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  54439. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54440. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  54441. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54442. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  54443. /**
  54444. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  54445. */
  54446. export class GizmoManager implements IDisposable {
  54447. private scene;
  54448. /**
  54449. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54450. */
  54451. gizmos: {
  54452. positionGizmo: Nullable<PositionGizmo>;
  54453. rotationGizmo: Nullable<RotationGizmo>;
  54454. scaleGizmo: Nullable<ScaleGizmo>;
  54455. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54456. };
  54457. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54458. clearGizmoOnEmptyPointerEvent: boolean;
  54459. /** Fires an event when the manager is attached to a mesh */
  54460. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54461. private _gizmosEnabled;
  54462. private _pointerObserver;
  54463. private _attachedMesh;
  54464. private _boundingBoxColor;
  54465. private _defaultUtilityLayer;
  54466. private _defaultKeepDepthUtilityLayer;
  54467. /**
  54468. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54469. */
  54470. boundingBoxDragBehavior: SixDofDragBehavior;
  54471. /**
  54472. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54473. */
  54474. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54475. /**
  54476. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  54477. */
  54478. usePointerToAttachGizmos: boolean;
  54479. /**
  54480. * Utility layer that the bounding box gizmo belongs to
  54481. */
  54482. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54483. /**
  54484. * Utility layer that all gizmos besides bounding box belong to
  54485. */
  54486. get utilityLayer(): UtilityLayerRenderer;
  54487. /**
  54488. * Instatiates a gizmo manager
  54489. * @param scene the scene to overlay the gizmos on top of
  54490. */
  54491. constructor(scene: Scene);
  54492. /**
  54493. * Attaches a set of gizmos to the specified mesh
  54494. * @param mesh The mesh the gizmo's should be attached to
  54495. */
  54496. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54497. /**
  54498. * If the position gizmo is enabled
  54499. */
  54500. set positionGizmoEnabled(value: boolean);
  54501. get positionGizmoEnabled(): boolean;
  54502. /**
  54503. * If the rotation gizmo is enabled
  54504. */
  54505. set rotationGizmoEnabled(value: boolean);
  54506. get rotationGizmoEnabled(): boolean;
  54507. /**
  54508. * If the scale gizmo is enabled
  54509. */
  54510. set scaleGizmoEnabled(value: boolean);
  54511. get scaleGizmoEnabled(): boolean;
  54512. /**
  54513. * If the boundingBox gizmo is enabled
  54514. */
  54515. set boundingBoxGizmoEnabled(value: boolean);
  54516. get boundingBoxGizmoEnabled(): boolean;
  54517. /**
  54518. * Disposes of the gizmo manager
  54519. */
  54520. dispose(): void;
  54521. }
  54522. }
  54523. declare module "babylonjs/Lights/directionalLight" {
  54524. import { Camera } from "babylonjs/Cameras/camera";
  54525. import { Scene } from "babylonjs/scene";
  54526. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54528. import { Light } from "babylonjs/Lights/light";
  54529. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54530. import { Effect } from "babylonjs/Materials/effect";
  54531. /**
  54532. * A directional light is defined by a direction (what a surprise!).
  54533. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  54534. * 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.
  54535. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54536. */
  54537. export class DirectionalLight extends ShadowLight {
  54538. private _shadowFrustumSize;
  54539. /**
  54540. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  54541. */
  54542. get shadowFrustumSize(): number;
  54543. /**
  54544. * Specifies a fix frustum size for the shadow generation.
  54545. */
  54546. set shadowFrustumSize(value: number);
  54547. private _shadowOrthoScale;
  54548. /**
  54549. * Gets the shadow projection scale against the optimal computed one.
  54550. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54551. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54552. */
  54553. get shadowOrthoScale(): number;
  54554. /**
  54555. * Sets the shadow projection scale against the optimal computed one.
  54556. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54557. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54558. */
  54559. set shadowOrthoScale(value: number);
  54560. /**
  54561. * Automatically compute the projection matrix to best fit (including all the casters)
  54562. * on each frame.
  54563. */
  54564. autoUpdateExtends: boolean;
  54565. /**
  54566. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  54567. * on each frame. autoUpdateExtends must be set to true for this to work
  54568. */
  54569. autoCalcShadowZBounds: boolean;
  54570. private _orthoLeft;
  54571. private _orthoRight;
  54572. private _orthoTop;
  54573. private _orthoBottom;
  54574. /**
  54575. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  54576. * The directional light is emitted from everywhere in the given direction.
  54577. * It can cast shadows.
  54578. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54579. * @param name The friendly name of the light
  54580. * @param direction The direction of the light
  54581. * @param scene The scene the light belongs to
  54582. */
  54583. constructor(name: string, direction: Vector3, scene: Scene);
  54584. /**
  54585. * Returns the string "DirectionalLight".
  54586. * @return The class name
  54587. */
  54588. getClassName(): string;
  54589. /**
  54590. * Returns the integer 1.
  54591. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54592. */
  54593. getTypeID(): number;
  54594. /**
  54595. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  54596. * Returns the DirectionalLight Shadow projection matrix.
  54597. */
  54598. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54599. /**
  54600. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  54601. * Returns the DirectionalLight Shadow projection matrix.
  54602. */
  54603. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  54604. /**
  54605. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  54606. * Returns the DirectionalLight Shadow projection matrix.
  54607. */
  54608. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54609. protected _buildUniformLayout(): void;
  54610. /**
  54611. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  54612. * @param effect The effect to update
  54613. * @param lightIndex The index of the light in the effect to update
  54614. * @returns The directional light
  54615. */
  54616. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  54617. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  54618. /**
  54619. * Gets the minZ used for shadow according to both the scene and the light.
  54620. *
  54621. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54622. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54623. * @param activeCamera The camera we are returning the min for
  54624. * @returns the depth min z
  54625. */
  54626. getDepthMinZ(activeCamera: Camera): number;
  54627. /**
  54628. * Gets the maxZ used for shadow according to both the scene and the light.
  54629. *
  54630. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54631. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54632. * @param activeCamera The camera we are returning the max for
  54633. * @returns the depth max z
  54634. */
  54635. getDepthMaxZ(activeCamera: Camera): number;
  54636. /**
  54637. * Prepares the list of defines specific to the light type.
  54638. * @param defines the list of defines
  54639. * @param lightIndex defines the index of the light for the effect
  54640. */
  54641. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54642. }
  54643. }
  54644. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  54645. import { Mesh } from "babylonjs/Meshes/mesh";
  54646. /**
  54647. * Class containing static functions to help procedurally build meshes
  54648. */
  54649. export class HemisphereBuilder {
  54650. /**
  54651. * Creates a hemisphere mesh
  54652. * @param name defines the name of the mesh
  54653. * @param options defines the options used to create the mesh
  54654. * @param scene defines the hosting scene
  54655. * @returns the hemisphere mesh
  54656. */
  54657. static CreateHemisphere(name: string, options: {
  54658. segments?: number;
  54659. diameter?: number;
  54660. sideOrientation?: number;
  54661. }, scene: any): Mesh;
  54662. }
  54663. }
  54664. declare module "babylonjs/Lights/spotLight" {
  54665. import { Nullable } from "babylonjs/types";
  54666. import { Scene } from "babylonjs/scene";
  54667. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54668. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54669. import { Effect } from "babylonjs/Materials/effect";
  54670. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54671. import { Light } from "babylonjs/Lights/light";
  54672. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54673. /**
  54674. * A spot light is defined by a position, a direction, an angle, and an exponent.
  54675. * These values define a cone of light starting from the position, emitting toward the direction.
  54676. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  54677. * and the exponent defines the speed of the decay of the light with distance (reach).
  54678. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54679. */
  54680. export class SpotLight extends ShadowLight {
  54681. private _angle;
  54682. private _innerAngle;
  54683. private _cosHalfAngle;
  54684. private _lightAngleScale;
  54685. private _lightAngleOffset;
  54686. /**
  54687. * Gets the cone angle of the spot light in Radians.
  54688. */
  54689. get angle(): number;
  54690. /**
  54691. * Sets the cone angle of the spot light in Radians.
  54692. */
  54693. set angle(value: number);
  54694. /**
  54695. * Only used in gltf falloff mode, this defines the angle where
  54696. * the directional falloff will start before cutting at angle which could be seen
  54697. * as outer angle.
  54698. */
  54699. get innerAngle(): number;
  54700. /**
  54701. * Only used in gltf falloff mode, this defines the angle where
  54702. * the directional falloff will start before cutting at angle which could be seen
  54703. * as outer angle.
  54704. */
  54705. set innerAngle(value: number);
  54706. private _shadowAngleScale;
  54707. /**
  54708. * Allows scaling the angle of the light for shadow generation only.
  54709. */
  54710. get shadowAngleScale(): number;
  54711. /**
  54712. * Allows scaling the angle of the light for shadow generation only.
  54713. */
  54714. set shadowAngleScale(value: number);
  54715. /**
  54716. * The light decay speed with the distance from the emission spot.
  54717. */
  54718. exponent: number;
  54719. private _projectionTextureMatrix;
  54720. /**
  54721. * Allows reading the projecton texture
  54722. */
  54723. get projectionTextureMatrix(): Matrix;
  54724. protected _projectionTextureLightNear: number;
  54725. /**
  54726. * Gets the near clip of the Spotlight for texture projection.
  54727. */
  54728. get projectionTextureLightNear(): number;
  54729. /**
  54730. * Sets the near clip of the Spotlight for texture projection.
  54731. */
  54732. set projectionTextureLightNear(value: number);
  54733. protected _projectionTextureLightFar: number;
  54734. /**
  54735. * Gets the far clip of the Spotlight for texture projection.
  54736. */
  54737. get projectionTextureLightFar(): number;
  54738. /**
  54739. * Sets the far clip of the Spotlight for texture projection.
  54740. */
  54741. set projectionTextureLightFar(value: number);
  54742. protected _projectionTextureUpDirection: Vector3;
  54743. /**
  54744. * Gets the Up vector of the Spotlight for texture projection.
  54745. */
  54746. get projectionTextureUpDirection(): Vector3;
  54747. /**
  54748. * Sets the Up vector of the Spotlight for texture projection.
  54749. */
  54750. set projectionTextureUpDirection(value: Vector3);
  54751. private _projectionTexture;
  54752. /**
  54753. * Gets the projection texture of the light.
  54754. */
  54755. get projectionTexture(): Nullable<BaseTexture>;
  54756. /**
  54757. * Sets the projection texture of the light.
  54758. */
  54759. set projectionTexture(value: Nullable<BaseTexture>);
  54760. private _projectionTextureViewLightDirty;
  54761. private _projectionTextureProjectionLightDirty;
  54762. private _projectionTextureDirty;
  54763. private _projectionTextureViewTargetVector;
  54764. private _projectionTextureViewLightMatrix;
  54765. private _projectionTextureProjectionLightMatrix;
  54766. private _projectionTextureScalingMatrix;
  54767. /**
  54768. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  54769. * It can cast shadows.
  54770. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54771. * @param name The light friendly name
  54772. * @param position The position of the spot light in the scene
  54773. * @param direction The direction of the light in the scene
  54774. * @param angle The cone angle of the light in Radians
  54775. * @param exponent The light decay speed with the distance from the emission spot
  54776. * @param scene The scene the lights belongs to
  54777. */
  54778. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  54779. /**
  54780. * Returns the string "SpotLight".
  54781. * @returns the class name
  54782. */
  54783. getClassName(): string;
  54784. /**
  54785. * Returns the integer 2.
  54786. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54787. */
  54788. getTypeID(): number;
  54789. /**
  54790. * Overrides the direction setter to recompute the projection texture view light Matrix.
  54791. */
  54792. protected _setDirection(value: Vector3): void;
  54793. /**
  54794. * Overrides the position setter to recompute the projection texture view light Matrix.
  54795. */
  54796. protected _setPosition(value: Vector3): void;
  54797. /**
  54798. * 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.
  54799. * Returns the SpotLight.
  54800. */
  54801. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54802. protected _computeProjectionTextureViewLightMatrix(): void;
  54803. protected _computeProjectionTextureProjectionLightMatrix(): void;
  54804. /**
  54805. * Main function for light texture projection matrix computing.
  54806. */
  54807. protected _computeProjectionTextureMatrix(): void;
  54808. protected _buildUniformLayout(): void;
  54809. private _computeAngleValues;
  54810. /**
  54811. * Sets the passed Effect "effect" with the Light textures.
  54812. * @param effect The effect to update
  54813. * @param lightIndex The index of the light in the effect to update
  54814. * @returns The light
  54815. */
  54816. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  54817. /**
  54818. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  54819. * @param effect The effect to update
  54820. * @param lightIndex The index of the light in the effect to update
  54821. * @returns The spot light
  54822. */
  54823. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  54824. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54825. /**
  54826. * Disposes the light and the associated resources.
  54827. */
  54828. dispose(): void;
  54829. /**
  54830. * Prepares the list of defines specific to the light type.
  54831. * @param defines the list of defines
  54832. * @param lightIndex defines the index of the light for the effect
  54833. */
  54834. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54835. }
  54836. }
  54837. declare module "babylonjs/Gizmos/lightGizmo" {
  54838. import { Nullable } from "babylonjs/types";
  54839. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54840. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54841. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  54842. import { Light } from "babylonjs/Lights/light";
  54843. /**
  54844. * Gizmo that enables viewing a light
  54845. */
  54846. export class LightGizmo extends Gizmo {
  54847. private _lightMesh;
  54848. private _material;
  54849. private _cachedPosition;
  54850. private _cachedForward;
  54851. private _attachedMeshParent;
  54852. /**
  54853. * Creates a LightGizmo
  54854. * @param gizmoLayer The utility layer the gizmo will be added to
  54855. */
  54856. constructor(gizmoLayer?: UtilityLayerRenderer);
  54857. private _light;
  54858. /**
  54859. * The light that the gizmo is attached to
  54860. */
  54861. set light(light: Nullable<Light>);
  54862. get light(): Nullable<Light>;
  54863. /**
  54864. * Gets the material used to render the light gizmo
  54865. */
  54866. get material(): StandardMaterial;
  54867. /**
  54868. * @hidden
  54869. * Updates the gizmo to match the attached mesh's position/rotation
  54870. */
  54871. protected _update(): void;
  54872. private static _Scale;
  54873. /**
  54874. * Creates the lines for a light mesh
  54875. */
  54876. private static _CreateLightLines;
  54877. /**
  54878. * Disposes of the light gizmo
  54879. */
  54880. dispose(): void;
  54881. private static _CreateHemisphericLightMesh;
  54882. private static _CreatePointLightMesh;
  54883. private static _CreateSpotLightMesh;
  54884. private static _CreateDirectionalLightMesh;
  54885. }
  54886. }
  54887. declare module "babylonjs/Gizmos/index" {
  54888. export * from "babylonjs/Gizmos/axisDragGizmo";
  54889. export * from "babylonjs/Gizmos/axisScaleGizmo";
  54890. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  54891. export * from "babylonjs/Gizmos/gizmo";
  54892. export * from "babylonjs/Gizmos/gizmoManager";
  54893. export * from "babylonjs/Gizmos/planeRotationGizmo";
  54894. export * from "babylonjs/Gizmos/positionGizmo";
  54895. export * from "babylonjs/Gizmos/rotationGizmo";
  54896. export * from "babylonjs/Gizmos/scaleGizmo";
  54897. export * from "babylonjs/Gizmos/lightGizmo";
  54898. export * from "babylonjs/Gizmos/planeDragGizmo";
  54899. }
  54900. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  54901. /** @hidden */
  54902. export var backgroundFragmentDeclaration: {
  54903. name: string;
  54904. shader: string;
  54905. };
  54906. }
  54907. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  54908. /** @hidden */
  54909. export var backgroundUboDeclaration: {
  54910. name: string;
  54911. shader: string;
  54912. };
  54913. }
  54914. declare module "babylonjs/Shaders/background.fragment" {
  54915. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  54916. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  54917. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  54918. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  54919. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  54920. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  54921. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54922. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  54923. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  54924. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  54925. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  54926. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  54927. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  54928. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  54929. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  54930. /** @hidden */
  54931. export var backgroundPixelShader: {
  54932. name: string;
  54933. shader: string;
  54934. };
  54935. }
  54936. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  54937. /** @hidden */
  54938. export var backgroundVertexDeclaration: {
  54939. name: string;
  54940. shader: string;
  54941. };
  54942. }
  54943. declare module "babylonjs/Shaders/background.vertex" {
  54944. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  54945. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  54946. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54947. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54948. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54949. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  54950. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  54951. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  54952. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  54953. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54954. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54955. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  54956. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  54957. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  54958. /** @hidden */
  54959. export var backgroundVertexShader: {
  54960. name: string;
  54961. shader: string;
  54962. };
  54963. }
  54964. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  54965. import { Nullable, int, float } from "babylonjs/types";
  54966. import { Scene } from "babylonjs/scene";
  54967. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54968. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54970. import { Mesh } from "babylonjs/Meshes/mesh";
  54971. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54972. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  54973. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  54974. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54975. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  54976. import { Color3 } from "babylonjs/Maths/math.color";
  54977. import "babylonjs/Shaders/background.fragment";
  54978. import "babylonjs/Shaders/background.vertex";
  54979. /**
  54980. * Background material used to create an efficient environement around your scene.
  54981. */
  54982. export class BackgroundMaterial extends PushMaterial {
  54983. /**
  54984. * Standard reflectance value at parallel view angle.
  54985. */
  54986. static StandardReflectance0: number;
  54987. /**
  54988. * Standard reflectance value at grazing angle.
  54989. */
  54990. static StandardReflectance90: number;
  54991. protected _primaryColor: Color3;
  54992. /**
  54993. * Key light Color (multiply against the environement texture)
  54994. */
  54995. primaryColor: Color3;
  54996. protected __perceptualColor: Nullable<Color3>;
  54997. /**
  54998. * Experimental Internal Use Only.
  54999. *
  55000. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  55001. * This acts as a helper to set the primary color to a more "human friendly" value.
  55002. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  55003. * output color as close as possible from the chosen value.
  55004. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  55005. * part of lighting setup.)
  55006. */
  55007. get _perceptualColor(): Nullable<Color3>;
  55008. set _perceptualColor(value: Nullable<Color3>);
  55009. protected _primaryColorShadowLevel: float;
  55010. /**
  55011. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  55012. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  55013. */
  55014. get primaryColorShadowLevel(): float;
  55015. set primaryColorShadowLevel(value: float);
  55016. protected _primaryColorHighlightLevel: float;
  55017. /**
  55018. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  55019. * The primary color is used at the level chosen to define what the white area would look.
  55020. */
  55021. get primaryColorHighlightLevel(): float;
  55022. set primaryColorHighlightLevel(value: float);
  55023. protected _reflectionTexture: Nullable<BaseTexture>;
  55024. /**
  55025. * Reflection Texture used in the material.
  55026. * Should be author in a specific way for the best result (refer to the documentation).
  55027. */
  55028. reflectionTexture: Nullable<BaseTexture>;
  55029. protected _reflectionBlur: float;
  55030. /**
  55031. * Reflection Texture level of blur.
  55032. *
  55033. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  55034. * texture twice.
  55035. */
  55036. reflectionBlur: float;
  55037. protected _diffuseTexture: Nullable<BaseTexture>;
  55038. /**
  55039. * Diffuse Texture used in the material.
  55040. * Should be author in a specific way for the best result (refer to the documentation).
  55041. */
  55042. diffuseTexture: Nullable<BaseTexture>;
  55043. protected _shadowLights: Nullable<IShadowLight[]>;
  55044. /**
  55045. * Specify the list of lights casting shadow on the material.
  55046. * All scene shadow lights will be included if null.
  55047. */
  55048. shadowLights: Nullable<IShadowLight[]>;
  55049. protected _shadowLevel: float;
  55050. /**
  55051. * Helps adjusting the shadow to a softer level if required.
  55052. * 0 means black shadows and 1 means no shadows.
  55053. */
  55054. shadowLevel: float;
  55055. protected _sceneCenter: Vector3;
  55056. /**
  55057. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  55058. * It is usually zero but might be interesting to modify according to your setup.
  55059. */
  55060. sceneCenter: Vector3;
  55061. protected _opacityFresnel: boolean;
  55062. /**
  55063. * This helps specifying that the material is falling off to the sky box at grazing angle.
  55064. * This helps ensuring a nice transition when the camera goes under the ground.
  55065. */
  55066. opacityFresnel: boolean;
  55067. protected _reflectionFresnel: boolean;
  55068. /**
  55069. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  55070. * This helps adding a mirror texture on the ground.
  55071. */
  55072. reflectionFresnel: boolean;
  55073. protected _reflectionFalloffDistance: number;
  55074. /**
  55075. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  55076. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  55077. */
  55078. reflectionFalloffDistance: number;
  55079. protected _reflectionAmount: number;
  55080. /**
  55081. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  55082. */
  55083. reflectionAmount: number;
  55084. protected _reflectionReflectance0: number;
  55085. /**
  55086. * This specifies the weight of the reflection at grazing angle.
  55087. */
  55088. reflectionReflectance0: number;
  55089. protected _reflectionReflectance90: number;
  55090. /**
  55091. * This specifies the weight of the reflection at a perpendicular point of view.
  55092. */
  55093. reflectionReflectance90: number;
  55094. /**
  55095. * Sets the reflection reflectance fresnel values according to the default standard
  55096. * empirically know to work well :-)
  55097. */
  55098. set reflectionStandardFresnelWeight(value: number);
  55099. protected _useRGBColor: boolean;
  55100. /**
  55101. * Helps to directly use the maps channels instead of their level.
  55102. */
  55103. useRGBColor: boolean;
  55104. protected _enableNoise: boolean;
  55105. /**
  55106. * This helps reducing the banding effect that could occur on the background.
  55107. */
  55108. enableNoise: boolean;
  55109. /**
  55110. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55111. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  55112. * Recommended to be keep at 1.0 except for special cases.
  55113. */
  55114. get fovMultiplier(): number;
  55115. set fovMultiplier(value: number);
  55116. private _fovMultiplier;
  55117. /**
  55118. * Enable the FOV adjustment feature controlled by fovMultiplier.
  55119. */
  55120. useEquirectangularFOV: boolean;
  55121. private _maxSimultaneousLights;
  55122. /**
  55123. * Number of Simultaneous lights allowed on the material.
  55124. */
  55125. maxSimultaneousLights: int;
  55126. /**
  55127. * Default configuration related to image processing available in the Background Material.
  55128. */
  55129. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55130. /**
  55131. * Keep track of the image processing observer to allow dispose and replace.
  55132. */
  55133. private _imageProcessingObserver;
  55134. /**
  55135. * Attaches a new image processing configuration to the PBR Material.
  55136. * @param configuration (if null the scene configuration will be use)
  55137. */
  55138. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55139. /**
  55140. * Gets the image processing configuration used either in this material.
  55141. */
  55142. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  55143. /**
  55144. * Sets the Default image processing configuration used either in the this material.
  55145. *
  55146. * If sets to null, the scene one is in use.
  55147. */
  55148. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  55149. /**
  55150. * Gets wether the color curves effect is enabled.
  55151. */
  55152. get cameraColorCurvesEnabled(): boolean;
  55153. /**
  55154. * Sets wether the color curves effect is enabled.
  55155. */
  55156. set cameraColorCurvesEnabled(value: boolean);
  55157. /**
  55158. * Gets wether the color grading effect is enabled.
  55159. */
  55160. get cameraColorGradingEnabled(): boolean;
  55161. /**
  55162. * Gets wether the color grading effect is enabled.
  55163. */
  55164. set cameraColorGradingEnabled(value: boolean);
  55165. /**
  55166. * Gets wether tonemapping is enabled or not.
  55167. */
  55168. get cameraToneMappingEnabled(): boolean;
  55169. /**
  55170. * Sets wether tonemapping is enabled or not
  55171. */
  55172. set cameraToneMappingEnabled(value: boolean);
  55173. /**
  55174. * The camera exposure used on this material.
  55175. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55176. * This corresponds to a photographic exposure.
  55177. */
  55178. get cameraExposure(): float;
  55179. /**
  55180. * The camera exposure used on this material.
  55181. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55182. * This corresponds to a photographic exposure.
  55183. */
  55184. set cameraExposure(value: float);
  55185. /**
  55186. * Gets The camera contrast used on this material.
  55187. */
  55188. get cameraContrast(): float;
  55189. /**
  55190. * Sets The camera contrast used on this material.
  55191. */
  55192. set cameraContrast(value: float);
  55193. /**
  55194. * Gets the Color Grading 2D Lookup Texture.
  55195. */
  55196. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55197. /**
  55198. * Sets the Color Grading 2D Lookup Texture.
  55199. */
  55200. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55201. /**
  55202. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55203. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55204. * 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;
  55205. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55206. */
  55207. get cameraColorCurves(): Nullable<ColorCurves>;
  55208. /**
  55209. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55210. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55211. * 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;
  55212. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55213. */
  55214. set cameraColorCurves(value: Nullable<ColorCurves>);
  55215. /**
  55216. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  55217. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  55218. */
  55219. switchToBGR: boolean;
  55220. private _renderTargets;
  55221. private _reflectionControls;
  55222. private _white;
  55223. private _primaryShadowColor;
  55224. private _primaryHighlightColor;
  55225. /**
  55226. * Instantiates a Background Material in the given scene
  55227. * @param name The friendly name of the material
  55228. * @param scene The scene to add the material to
  55229. */
  55230. constructor(name: string, scene: Scene);
  55231. /**
  55232. * Gets a boolean indicating that current material needs to register RTT
  55233. */
  55234. get hasRenderTargetTextures(): boolean;
  55235. /**
  55236. * The entire material has been created in order to prevent overdraw.
  55237. * @returns false
  55238. */
  55239. needAlphaTesting(): boolean;
  55240. /**
  55241. * The entire material has been created in order to prevent overdraw.
  55242. * @returns true if blending is enable
  55243. */
  55244. needAlphaBlending(): boolean;
  55245. /**
  55246. * Checks wether the material is ready to be rendered for a given mesh.
  55247. * @param mesh The mesh to render
  55248. * @param subMesh The submesh to check against
  55249. * @param useInstances Specify wether or not the material is used with instances
  55250. * @returns true if all the dependencies are ready (Textures, Effects...)
  55251. */
  55252. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55253. /**
  55254. * Compute the primary color according to the chosen perceptual color.
  55255. */
  55256. private _computePrimaryColorFromPerceptualColor;
  55257. /**
  55258. * Compute the highlights and shadow colors according to their chosen levels.
  55259. */
  55260. private _computePrimaryColors;
  55261. /**
  55262. * Build the uniform buffer used in the material.
  55263. */
  55264. buildUniformLayout(): void;
  55265. /**
  55266. * Unbind the material.
  55267. */
  55268. unbind(): void;
  55269. /**
  55270. * Bind only the world matrix to the material.
  55271. * @param world The world matrix to bind.
  55272. */
  55273. bindOnlyWorldMatrix(world: Matrix): void;
  55274. /**
  55275. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  55276. * @param world The world matrix to bind.
  55277. * @param subMesh The submesh to bind for.
  55278. */
  55279. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55280. /**
  55281. * Checks to see if a texture is used in the material.
  55282. * @param texture - Base texture to use.
  55283. * @returns - Boolean specifying if a texture is used in the material.
  55284. */
  55285. hasTexture(texture: BaseTexture): boolean;
  55286. /**
  55287. * Dispose the material.
  55288. * @param forceDisposeEffect Force disposal of the associated effect.
  55289. * @param forceDisposeTextures Force disposal of the associated textures.
  55290. */
  55291. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55292. /**
  55293. * Clones the material.
  55294. * @param name The cloned name.
  55295. * @returns The cloned material.
  55296. */
  55297. clone(name: string): BackgroundMaterial;
  55298. /**
  55299. * Serializes the current material to its JSON representation.
  55300. * @returns The JSON representation.
  55301. */
  55302. serialize(): any;
  55303. /**
  55304. * Gets the class name of the material
  55305. * @returns "BackgroundMaterial"
  55306. */
  55307. getClassName(): string;
  55308. /**
  55309. * Parse a JSON input to create back a background material.
  55310. * @param source The JSON data to parse
  55311. * @param scene The scene to create the parsed material in
  55312. * @param rootUrl The root url of the assets the material depends upon
  55313. * @returns the instantiated BackgroundMaterial.
  55314. */
  55315. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  55316. }
  55317. }
  55318. declare module "babylonjs/Helpers/environmentHelper" {
  55319. import { Observable } from "babylonjs/Misc/observable";
  55320. import { Nullable } from "babylonjs/types";
  55321. import { Scene } from "babylonjs/scene";
  55322. import { Vector3 } from "babylonjs/Maths/math.vector";
  55323. import { Color3 } from "babylonjs/Maths/math.color";
  55324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55325. import { Mesh } from "babylonjs/Meshes/mesh";
  55326. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55327. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  55328. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55329. import "babylonjs/Meshes/Builders/planeBuilder";
  55330. import "babylonjs/Meshes/Builders/boxBuilder";
  55331. /**
  55332. * Represents the different options available during the creation of
  55333. * a Environment helper.
  55334. *
  55335. * This can control the default ground, skybox and image processing setup of your scene.
  55336. */
  55337. export interface IEnvironmentHelperOptions {
  55338. /**
  55339. * Specifies whether or not to create a ground.
  55340. * True by default.
  55341. */
  55342. createGround: boolean;
  55343. /**
  55344. * Specifies the ground size.
  55345. * 15 by default.
  55346. */
  55347. groundSize: number;
  55348. /**
  55349. * The texture used on the ground for the main color.
  55350. * Comes from the BabylonJS CDN by default.
  55351. *
  55352. * Remarks: Can be either a texture or a url.
  55353. */
  55354. groundTexture: string | BaseTexture;
  55355. /**
  55356. * The color mixed in the ground texture by default.
  55357. * BabylonJS clearColor by default.
  55358. */
  55359. groundColor: Color3;
  55360. /**
  55361. * Specifies the ground opacity.
  55362. * 1 by default.
  55363. */
  55364. groundOpacity: number;
  55365. /**
  55366. * Enables the ground to receive shadows.
  55367. * True by default.
  55368. */
  55369. enableGroundShadow: boolean;
  55370. /**
  55371. * Helps preventing the shadow to be fully black on the ground.
  55372. * 0.5 by default.
  55373. */
  55374. groundShadowLevel: number;
  55375. /**
  55376. * Creates a mirror texture attach to the ground.
  55377. * false by default.
  55378. */
  55379. enableGroundMirror: boolean;
  55380. /**
  55381. * Specifies the ground mirror size ratio.
  55382. * 0.3 by default as the default kernel is 64.
  55383. */
  55384. groundMirrorSizeRatio: number;
  55385. /**
  55386. * Specifies the ground mirror blur kernel size.
  55387. * 64 by default.
  55388. */
  55389. groundMirrorBlurKernel: number;
  55390. /**
  55391. * Specifies the ground mirror visibility amount.
  55392. * 1 by default
  55393. */
  55394. groundMirrorAmount: number;
  55395. /**
  55396. * Specifies the ground mirror reflectance weight.
  55397. * This uses the standard weight of the background material to setup the fresnel effect
  55398. * of the mirror.
  55399. * 1 by default.
  55400. */
  55401. groundMirrorFresnelWeight: number;
  55402. /**
  55403. * Specifies the ground mirror Falloff distance.
  55404. * This can helps reducing the size of the reflection.
  55405. * 0 by Default.
  55406. */
  55407. groundMirrorFallOffDistance: number;
  55408. /**
  55409. * Specifies the ground mirror texture type.
  55410. * Unsigned Int by Default.
  55411. */
  55412. groundMirrorTextureType: number;
  55413. /**
  55414. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  55415. * the shown objects.
  55416. */
  55417. groundYBias: number;
  55418. /**
  55419. * Specifies whether or not to create a skybox.
  55420. * True by default.
  55421. */
  55422. createSkybox: boolean;
  55423. /**
  55424. * Specifies the skybox size.
  55425. * 20 by default.
  55426. */
  55427. skyboxSize: number;
  55428. /**
  55429. * The texture used on the skybox for the main color.
  55430. * Comes from the BabylonJS CDN by default.
  55431. *
  55432. * Remarks: Can be either a texture or a url.
  55433. */
  55434. skyboxTexture: string | BaseTexture;
  55435. /**
  55436. * The color mixed in the skybox texture by default.
  55437. * BabylonJS clearColor by default.
  55438. */
  55439. skyboxColor: Color3;
  55440. /**
  55441. * The background rotation around the Y axis of the scene.
  55442. * This helps aligning the key lights of your scene with the background.
  55443. * 0 by default.
  55444. */
  55445. backgroundYRotation: number;
  55446. /**
  55447. * Compute automatically the size of the elements to best fit with the scene.
  55448. */
  55449. sizeAuto: boolean;
  55450. /**
  55451. * Default position of the rootMesh if autoSize is not true.
  55452. */
  55453. rootPosition: Vector3;
  55454. /**
  55455. * Sets up the image processing in the scene.
  55456. * true by default.
  55457. */
  55458. setupImageProcessing: boolean;
  55459. /**
  55460. * The texture used as your environment texture in the scene.
  55461. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  55462. *
  55463. * Remarks: Can be either a texture or a url.
  55464. */
  55465. environmentTexture: string | BaseTexture;
  55466. /**
  55467. * The value of the exposure to apply to the scene.
  55468. * 0.6 by default if setupImageProcessing is true.
  55469. */
  55470. cameraExposure: number;
  55471. /**
  55472. * The value of the contrast to apply to the scene.
  55473. * 1.6 by default if setupImageProcessing is true.
  55474. */
  55475. cameraContrast: number;
  55476. /**
  55477. * Specifies whether or not tonemapping should be enabled in the scene.
  55478. * true by default if setupImageProcessing is true.
  55479. */
  55480. toneMappingEnabled: boolean;
  55481. }
  55482. /**
  55483. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  55484. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  55485. * It also helps with the default setup of your imageProcessing configuration.
  55486. */
  55487. export class EnvironmentHelper {
  55488. /**
  55489. * Default ground texture URL.
  55490. */
  55491. private static _groundTextureCDNUrl;
  55492. /**
  55493. * Default skybox texture URL.
  55494. */
  55495. private static _skyboxTextureCDNUrl;
  55496. /**
  55497. * Default environment texture URL.
  55498. */
  55499. private static _environmentTextureCDNUrl;
  55500. /**
  55501. * Creates the default options for the helper.
  55502. */
  55503. private static _getDefaultOptions;
  55504. private _rootMesh;
  55505. /**
  55506. * Gets the root mesh created by the helper.
  55507. */
  55508. get rootMesh(): Mesh;
  55509. private _skybox;
  55510. /**
  55511. * Gets the skybox created by the helper.
  55512. */
  55513. get skybox(): Nullable<Mesh>;
  55514. private _skyboxTexture;
  55515. /**
  55516. * Gets the skybox texture created by the helper.
  55517. */
  55518. get skyboxTexture(): Nullable<BaseTexture>;
  55519. private _skyboxMaterial;
  55520. /**
  55521. * Gets the skybox material created by the helper.
  55522. */
  55523. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  55524. private _ground;
  55525. /**
  55526. * Gets the ground mesh created by the helper.
  55527. */
  55528. get ground(): Nullable<Mesh>;
  55529. private _groundTexture;
  55530. /**
  55531. * Gets the ground texture created by the helper.
  55532. */
  55533. get groundTexture(): Nullable<BaseTexture>;
  55534. private _groundMirror;
  55535. /**
  55536. * Gets the ground mirror created by the helper.
  55537. */
  55538. get groundMirror(): Nullable<MirrorTexture>;
  55539. /**
  55540. * Gets the ground mirror render list to helps pushing the meshes
  55541. * you wish in the ground reflection.
  55542. */
  55543. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  55544. private _groundMaterial;
  55545. /**
  55546. * Gets the ground material created by the helper.
  55547. */
  55548. get groundMaterial(): Nullable<BackgroundMaterial>;
  55549. /**
  55550. * Stores the creation options.
  55551. */
  55552. private readonly _scene;
  55553. private _options;
  55554. /**
  55555. * This observable will be notified with any error during the creation of the environment,
  55556. * mainly texture creation errors.
  55557. */
  55558. onErrorObservable: Observable<{
  55559. message?: string;
  55560. exception?: any;
  55561. }>;
  55562. /**
  55563. * constructor
  55564. * @param options Defines the options we want to customize the helper
  55565. * @param scene The scene to add the material to
  55566. */
  55567. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  55568. /**
  55569. * Updates the background according to the new options
  55570. * @param options
  55571. */
  55572. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  55573. /**
  55574. * Sets the primary color of all the available elements.
  55575. * @param color the main color to affect to the ground and the background
  55576. */
  55577. setMainColor(color: Color3): void;
  55578. /**
  55579. * Setup the image processing according to the specified options.
  55580. */
  55581. private _setupImageProcessing;
  55582. /**
  55583. * Setup the environment texture according to the specified options.
  55584. */
  55585. private _setupEnvironmentTexture;
  55586. /**
  55587. * Setup the background according to the specified options.
  55588. */
  55589. private _setupBackground;
  55590. /**
  55591. * Get the scene sizes according to the setup.
  55592. */
  55593. private _getSceneSize;
  55594. /**
  55595. * Setup the ground according to the specified options.
  55596. */
  55597. private _setupGround;
  55598. /**
  55599. * Setup the ground material according to the specified options.
  55600. */
  55601. private _setupGroundMaterial;
  55602. /**
  55603. * Setup the ground diffuse texture according to the specified options.
  55604. */
  55605. private _setupGroundDiffuseTexture;
  55606. /**
  55607. * Setup the ground mirror texture according to the specified options.
  55608. */
  55609. private _setupGroundMirrorTexture;
  55610. /**
  55611. * Setup the ground to receive the mirror texture.
  55612. */
  55613. private _setupMirrorInGroundMaterial;
  55614. /**
  55615. * Setup the skybox according to the specified options.
  55616. */
  55617. private _setupSkybox;
  55618. /**
  55619. * Setup the skybox material according to the specified options.
  55620. */
  55621. private _setupSkyboxMaterial;
  55622. /**
  55623. * Setup the skybox reflection texture according to the specified options.
  55624. */
  55625. private _setupSkyboxReflectionTexture;
  55626. private _errorHandler;
  55627. /**
  55628. * Dispose all the elements created by the Helper.
  55629. */
  55630. dispose(): void;
  55631. }
  55632. }
  55633. declare module "babylonjs/Helpers/photoDome" {
  55634. import { Observable } from "babylonjs/Misc/observable";
  55635. import { Nullable } from "babylonjs/types";
  55636. import { Scene } from "babylonjs/scene";
  55637. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55638. import { Mesh } from "babylonjs/Meshes/mesh";
  55639. import { Texture } from "babylonjs/Materials/Textures/texture";
  55640. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55641. import "babylonjs/Meshes/Builders/sphereBuilder";
  55642. /**
  55643. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  55644. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  55645. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55646. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55647. */
  55648. export class PhotoDome extends TransformNode {
  55649. /**
  55650. * Define the image as a Monoscopic panoramic 360 image.
  55651. */
  55652. static readonly MODE_MONOSCOPIC: number;
  55653. /**
  55654. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55655. */
  55656. static readonly MODE_TOPBOTTOM: number;
  55657. /**
  55658. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55659. */
  55660. static readonly MODE_SIDEBYSIDE: number;
  55661. private _useDirectMapping;
  55662. /**
  55663. * The texture being displayed on the sphere
  55664. */
  55665. protected _photoTexture: Texture;
  55666. /**
  55667. * Gets or sets the texture being displayed on the sphere
  55668. */
  55669. get photoTexture(): Texture;
  55670. set photoTexture(value: Texture);
  55671. /**
  55672. * Observable raised when an error occured while loading the 360 image
  55673. */
  55674. onLoadErrorObservable: Observable<string>;
  55675. /**
  55676. * The skybox material
  55677. */
  55678. protected _material: BackgroundMaterial;
  55679. /**
  55680. * The surface used for the skybox
  55681. */
  55682. protected _mesh: Mesh;
  55683. /**
  55684. * Gets the mesh used for the skybox.
  55685. */
  55686. get mesh(): Mesh;
  55687. /**
  55688. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55689. * Also see the options.resolution property.
  55690. */
  55691. get fovMultiplier(): number;
  55692. set fovMultiplier(value: number);
  55693. private _imageMode;
  55694. /**
  55695. * Gets or set the current video mode for the video. It can be:
  55696. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  55697. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55698. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55699. */
  55700. get imageMode(): number;
  55701. set imageMode(value: number);
  55702. /**
  55703. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  55704. * @param name Element's name, child elements will append suffixes for their own names.
  55705. * @param urlsOfPhoto defines the url of the photo to display
  55706. * @param options defines an object containing optional or exposed sub element properties
  55707. * @param onError defines a callback called when an error occured while loading the texture
  55708. */
  55709. constructor(name: string, urlOfPhoto: string, options: {
  55710. resolution?: number;
  55711. size?: number;
  55712. useDirectMapping?: boolean;
  55713. faceForward?: boolean;
  55714. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  55715. private _onBeforeCameraRenderObserver;
  55716. private _changeImageMode;
  55717. /**
  55718. * Releases resources associated with this node.
  55719. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55720. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55721. */
  55722. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55723. }
  55724. }
  55725. declare module "babylonjs/Misc/rgbdTextureTools" {
  55726. import "babylonjs/Shaders/rgbdDecode.fragment";
  55727. import "babylonjs/Engines/Extensions/engine.renderTarget";
  55728. import { Texture } from "babylonjs/Materials/Textures/texture";
  55729. /**
  55730. * Class used to host RGBD texture specific utilities
  55731. */
  55732. export class RGBDTextureTools {
  55733. /**
  55734. * Expand the RGBD Texture from RGBD to Half Float if possible.
  55735. * @param texture the texture to expand.
  55736. */
  55737. static ExpandRGBDTexture(texture: Texture): void;
  55738. }
  55739. }
  55740. declare module "babylonjs/Misc/brdfTextureTools" {
  55741. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55742. import { Scene } from "babylonjs/scene";
  55743. /**
  55744. * Class used to host texture specific utilities
  55745. */
  55746. export class BRDFTextureTools {
  55747. /**
  55748. * Prevents texture cache collision
  55749. */
  55750. private static _instanceNumber;
  55751. /**
  55752. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  55753. * @param scene defines the hosting scene
  55754. * @returns the environment BRDF texture
  55755. */
  55756. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  55757. private static _environmentBRDFBase64Texture;
  55758. }
  55759. }
  55760. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  55761. import { Nullable } from "babylonjs/types";
  55762. import { Color3 } from "babylonjs/Maths/math.color";
  55763. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55764. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  55765. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  55766. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55767. import { Engine } from "babylonjs/Engines/engine";
  55768. import { Scene } from "babylonjs/scene";
  55769. /**
  55770. * @hidden
  55771. */
  55772. export interface IMaterialClearCoatDefines {
  55773. CLEARCOAT: boolean;
  55774. CLEARCOAT_DEFAULTIOR: boolean;
  55775. CLEARCOAT_TEXTURE: boolean;
  55776. CLEARCOAT_TEXTUREDIRECTUV: number;
  55777. CLEARCOAT_BUMP: boolean;
  55778. CLEARCOAT_BUMPDIRECTUV: number;
  55779. CLEARCOAT_TINT: boolean;
  55780. CLEARCOAT_TINT_TEXTURE: boolean;
  55781. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55782. /** @hidden */
  55783. _areTexturesDirty: boolean;
  55784. }
  55785. /**
  55786. * Define the code related to the clear coat parameters of the pbr material.
  55787. */
  55788. export class PBRClearCoatConfiguration {
  55789. /**
  55790. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55791. * The default fits with a polyurethane material.
  55792. */
  55793. private static readonly _DefaultIndexOfRefraction;
  55794. private _isEnabled;
  55795. /**
  55796. * Defines if the clear coat is enabled in the material.
  55797. */
  55798. isEnabled: boolean;
  55799. /**
  55800. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  55801. */
  55802. intensity: number;
  55803. /**
  55804. * Defines the clear coat layer roughness.
  55805. */
  55806. roughness: number;
  55807. private _indexOfRefraction;
  55808. /**
  55809. * Defines the index of refraction of the clear coat.
  55810. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55811. * The default fits with a polyurethane material.
  55812. * Changing the default value is more performance intensive.
  55813. */
  55814. indexOfRefraction: number;
  55815. private _texture;
  55816. /**
  55817. * Stores the clear coat values in a texture.
  55818. */
  55819. texture: Nullable<BaseTexture>;
  55820. private _bumpTexture;
  55821. /**
  55822. * Define the clear coat specific bump texture.
  55823. */
  55824. bumpTexture: Nullable<BaseTexture>;
  55825. private _isTintEnabled;
  55826. /**
  55827. * Defines if the clear coat tint is enabled in the material.
  55828. */
  55829. isTintEnabled: boolean;
  55830. /**
  55831. * Defines the clear coat tint of the material.
  55832. * This is only use if tint is enabled
  55833. */
  55834. tintColor: Color3;
  55835. /**
  55836. * Defines the distance at which the tint color should be found in the
  55837. * clear coat media.
  55838. * This is only use if tint is enabled
  55839. */
  55840. tintColorAtDistance: number;
  55841. /**
  55842. * Defines the clear coat layer thickness.
  55843. * This is only use if tint is enabled
  55844. */
  55845. tintThickness: number;
  55846. private _tintTexture;
  55847. /**
  55848. * Stores the clear tint values in a texture.
  55849. * rgb is tint
  55850. * a is a thickness factor
  55851. */
  55852. tintTexture: Nullable<BaseTexture>;
  55853. /** @hidden */
  55854. private _internalMarkAllSubMeshesAsTexturesDirty;
  55855. /** @hidden */
  55856. _markAllSubMeshesAsTexturesDirty(): void;
  55857. /**
  55858. * Instantiate a new istance of clear coat configuration.
  55859. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55860. */
  55861. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55862. /**
  55863. * Gets wehter the submesh is ready to be used or not.
  55864. * @param defines the list of "defines" to update.
  55865. * @param scene defines the scene the material belongs to.
  55866. * @param engine defines the engine the material belongs to.
  55867. * @param disableBumpMap defines wether the material disables bump or not.
  55868. * @returns - boolean indicating that the submesh is ready or not.
  55869. */
  55870. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  55871. /**
  55872. * Checks to see if a texture is used in the material.
  55873. * @param defines the list of "defines" to update.
  55874. * @param scene defines the scene to the material belongs to.
  55875. */
  55876. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  55877. /**
  55878. * Binds the material data.
  55879. * @param uniformBuffer defines the Uniform buffer to fill in.
  55880. * @param scene defines the scene the material belongs to.
  55881. * @param engine defines the engine the material belongs to.
  55882. * @param disableBumpMap defines wether the material disables bump or not.
  55883. * @param isFrozen defines wether the material is frozen or not.
  55884. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55885. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55886. */
  55887. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  55888. /**
  55889. * Checks to see if a texture is used in the material.
  55890. * @param texture - Base texture to use.
  55891. * @returns - Boolean specifying if a texture is used in the material.
  55892. */
  55893. hasTexture(texture: BaseTexture): boolean;
  55894. /**
  55895. * Returns an array of the actively used textures.
  55896. * @param activeTextures Array of BaseTextures
  55897. */
  55898. getActiveTextures(activeTextures: BaseTexture[]): void;
  55899. /**
  55900. * Returns the animatable textures.
  55901. * @param animatables Array of animatable textures.
  55902. */
  55903. getAnimatables(animatables: IAnimatable[]): void;
  55904. /**
  55905. * Disposes the resources of the material.
  55906. * @param forceDisposeTextures - Forces the disposal of all textures.
  55907. */
  55908. dispose(forceDisposeTextures?: boolean): void;
  55909. /**
  55910. * Get the current class name of the texture useful for serialization or dynamic coding.
  55911. * @returns "PBRClearCoatConfiguration"
  55912. */
  55913. getClassName(): string;
  55914. /**
  55915. * Add fallbacks to the effect fallbacks list.
  55916. * @param defines defines the Base texture to use.
  55917. * @param fallbacks defines the current fallback list.
  55918. * @param currentRank defines the current fallback rank.
  55919. * @returns the new fallback rank.
  55920. */
  55921. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55922. /**
  55923. * Add the required uniforms to the current list.
  55924. * @param uniforms defines the current uniform list.
  55925. */
  55926. static AddUniforms(uniforms: string[]): void;
  55927. /**
  55928. * Add the required samplers to the current list.
  55929. * @param samplers defines the current sampler list.
  55930. */
  55931. static AddSamplers(samplers: string[]): void;
  55932. /**
  55933. * Add the required uniforms to the current buffer.
  55934. * @param uniformBuffer defines the current uniform buffer.
  55935. */
  55936. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55937. /**
  55938. * Makes a duplicate of the current configuration into another one.
  55939. * @param clearCoatConfiguration define the config where to copy the info
  55940. */
  55941. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  55942. /**
  55943. * Serializes this clear coat configuration.
  55944. * @returns - An object with the serialized config.
  55945. */
  55946. serialize(): any;
  55947. /**
  55948. * Parses a anisotropy Configuration from a serialized object.
  55949. * @param source - Serialized object.
  55950. * @param scene Defines the scene we are parsing for
  55951. * @param rootUrl Defines the rootUrl to load from
  55952. */
  55953. parse(source: any, scene: Scene, rootUrl: string): void;
  55954. }
  55955. }
  55956. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  55957. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  55958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55959. import { Vector2 } from "babylonjs/Maths/math.vector";
  55960. import { Scene } from "babylonjs/scene";
  55961. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55962. import { Nullable } from "babylonjs/types";
  55963. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  55964. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55965. /**
  55966. * @hidden
  55967. */
  55968. export interface IMaterialAnisotropicDefines {
  55969. ANISOTROPIC: boolean;
  55970. ANISOTROPIC_TEXTURE: boolean;
  55971. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55972. MAINUV1: boolean;
  55973. _areTexturesDirty: boolean;
  55974. _needUVs: boolean;
  55975. }
  55976. /**
  55977. * Define the code related to the anisotropic parameters of the pbr material.
  55978. */
  55979. export class PBRAnisotropicConfiguration {
  55980. private _isEnabled;
  55981. /**
  55982. * Defines if the anisotropy is enabled in the material.
  55983. */
  55984. isEnabled: boolean;
  55985. /**
  55986. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  55987. */
  55988. intensity: number;
  55989. /**
  55990. * Defines if the effect is along the tangents, bitangents or in between.
  55991. * By default, the effect is "strectching" the highlights along the tangents.
  55992. */
  55993. direction: Vector2;
  55994. private _texture;
  55995. /**
  55996. * Stores the anisotropy values in a texture.
  55997. * rg is direction (like normal from -1 to 1)
  55998. * b is a intensity
  55999. */
  56000. texture: Nullable<BaseTexture>;
  56001. /** @hidden */
  56002. private _internalMarkAllSubMeshesAsTexturesDirty;
  56003. /** @hidden */
  56004. _markAllSubMeshesAsTexturesDirty(): void;
  56005. /**
  56006. * Instantiate a new istance of anisotropy configuration.
  56007. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56008. */
  56009. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56010. /**
  56011. * Specifies that the submesh is ready to be used.
  56012. * @param defines the list of "defines" to update.
  56013. * @param scene defines the scene the material belongs to.
  56014. * @returns - boolean indicating that the submesh is ready or not.
  56015. */
  56016. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  56017. /**
  56018. * Checks to see if a texture is used in the material.
  56019. * @param defines the list of "defines" to update.
  56020. * @param mesh the mesh we are preparing the defines for.
  56021. * @param scene defines the scene the material belongs to.
  56022. */
  56023. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  56024. /**
  56025. * Binds the material data.
  56026. * @param uniformBuffer defines the Uniform buffer to fill in.
  56027. * @param scene defines the scene the material belongs to.
  56028. * @param isFrozen defines wether the material is frozen or not.
  56029. */
  56030. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56031. /**
  56032. * Checks to see if a texture is used in the material.
  56033. * @param texture - Base texture to use.
  56034. * @returns - Boolean specifying if a texture is used in the material.
  56035. */
  56036. hasTexture(texture: BaseTexture): boolean;
  56037. /**
  56038. * Returns an array of the actively used textures.
  56039. * @param activeTextures Array of BaseTextures
  56040. */
  56041. getActiveTextures(activeTextures: BaseTexture[]): void;
  56042. /**
  56043. * Returns the animatable textures.
  56044. * @param animatables Array of animatable textures.
  56045. */
  56046. getAnimatables(animatables: IAnimatable[]): void;
  56047. /**
  56048. * Disposes the resources of the material.
  56049. * @param forceDisposeTextures - Forces the disposal of all textures.
  56050. */
  56051. dispose(forceDisposeTextures?: boolean): void;
  56052. /**
  56053. * Get the current class name of the texture useful for serialization or dynamic coding.
  56054. * @returns "PBRAnisotropicConfiguration"
  56055. */
  56056. getClassName(): string;
  56057. /**
  56058. * Add fallbacks to the effect fallbacks list.
  56059. * @param defines defines the Base texture to use.
  56060. * @param fallbacks defines the current fallback list.
  56061. * @param currentRank defines the current fallback rank.
  56062. * @returns the new fallback rank.
  56063. */
  56064. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56065. /**
  56066. * Add the required uniforms to the current list.
  56067. * @param uniforms defines the current uniform list.
  56068. */
  56069. static AddUniforms(uniforms: string[]): void;
  56070. /**
  56071. * Add the required uniforms to the current buffer.
  56072. * @param uniformBuffer defines the current uniform buffer.
  56073. */
  56074. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56075. /**
  56076. * Add the required samplers to the current list.
  56077. * @param samplers defines the current sampler list.
  56078. */
  56079. static AddSamplers(samplers: string[]): void;
  56080. /**
  56081. * Makes a duplicate of the current configuration into another one.
  56082. * @param anisotropicConfiguration define the config where to copy the info
  56083. */
  56084. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  56085. /**
  56086. * Serializes this anisotropy configuration.
  56087. * @returns - An object with the serialized config.
  56088. */
  56089. serialize(): any;
  56090. /**
  56091. * Parses a anisotropy Configuration from a serialized object.
  56092. * @param source - Serialized object.
  56093. * @param scene Defines the scene we are parsing for
  56094. * @param rootUrl Defines the rootUrl to load from
  56095. */
  56096. parse(source: any, scene: Scene, rootUrl: string): void;
  56097. }
  56098. }
  56099. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  56100. import { Scene } from "babylonjs/scene";
  56101. /**
  56102. * @hidden
  56103. */
  56104. export interface IMaterialBRDFDefines {
  56105. BRDF_V_HEIGHT_CORRELATED: boolean;
  56106. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56107. SPHERICAL_HARMONICS: boolean;
  56108. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56109. /** @hidden */
  56110. _areMiscDirty: boolean;
  56111. }
  56112. /**
  56113. * Define the code related to the BRDF parameters of the pbr material.
  56114. */
  56115. export class PBRBRDFConfiguration {
  56116. /**
  56117. * Default value used for the energy conservation.
  56118. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56119. */
  56120. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  56121. /**
  56122. * Default value used for the Smith Visibility Height Correlated mode.
  56123. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56124. */
  56125. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  56126. /**
  56127. * Default value used for the IBL diffuse part.
  56128. * This can help switching back to the polynomials mode globally which is a tiny bit
  56129. * less GPU intensive at the drawback of a lower quality.
  56130. */
  56131. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  56132. /**
  56133. * Default value used for activating energy conservation for the specular workflow.
  56134. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56135. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56136. */
  56137. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  56138. private _useEnergyConservation;
  56139. /**
  56140. * Defines if the material uses energy conservation.
  56141. */
  56142. useEnergyConservation: boolean;
  56143. private _useSmithVisibilityHeightCorrelated;
  56144. /**
  56145. * LEGACY Mode set to false
  56146. * Defines if the material uses height smith correlated visibility term.
  56147. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  56148. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  56149. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  56150. * Not relying on height correlated will also disable energy conservation.
  56151. */
  56152. useSmithVisibilityHeightCorrelated: boolean;
  56153. private _useSphericalHarmonics;
  56154. /**
  56155. * LEGACY Mode set to false
  56156. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  56157. * diffuse part of the IBL.
  56158. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  56159. * to the ground truth.
  56160. */
  56161. useSphericalHarmonics: boolean;
  56162. private _useSpecularGlossinessInputEnergyConservation;
  56163. /**
  56164. * Defines if the material uses energy conservation, when the specular workflow is active.
  56165. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56166. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56167. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  56168. */
  56169. useSpecularGlossinessInputEnergyConservation: boolean;
  56170. /** @hidden */
  56171. private _internalMarkAllSubMeshesAsMiscDirty;
  56172. /** @hidden */
  56173. _markAllSubMeshesAsMiscDirty(): void;
  56174. /**
  56175. * Instantiate a new istance of clear coat configuration.
  56176. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  56177. */
  56178. constructor(markAllSubMeshesAsMiscDirty: () => void);
  56179. /**
  56180. * Checks to see if a texture is used in the material.
  56181. * @param defines the list of "defines" to update.
  56182. */
  56183. prepareDefines(defines: IMaterialBRDFDefines): void;
  56184. /**
  56185. * Get the current class name of the texture useful for serialization or dynamic coding.
  56186. * @returns "PBRClearCoatConfiguration"
  56187. */
  56188. getClassName(): string;
  56189. /**
  56190. * Makes a duplicate of the current configuration into another one.
  56191. * @param brdfConfiguration define the config where to copy the info
  56192. */
  56193. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  56194. /**
  56195. * Serializes this BRDF configuration.
  56196. * @returns - An object with the serialized config.
  56197. */
  56198. serialize(): any;
  56199. /**
  56200. * Parses a anisotropy Configuration from a serialized object.
  56201. * @param source - Serialized object.
  56202. * @param scene Defines the scene we are parsing for
  56203. * @param rootUrl Defines the rootUrl to load from
  56204. */
  56205. parse(source: any, scene: Scene, rootUrl: string): void;
  56206. }
  56207. }
  56208. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  56209. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56210. import { Color3 } from "babylonjs/Maths/math.color";
  56211. import { Scene } from "babylonjs/scene";
  56212. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56213. import { Nullable } from "babylonjs/types";
  56214. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56215. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56216. /**
  56217. * @hidden
  56218. */
  56219. export interface IMaterialSheenDefines {
  56220. SHEEN: boolean;
  56221. SHEEN_TEXTURE: boolean;
  56222. SHEEN_TEXTUREDIRECTUV: number;
  56223. SHEEN_LINKWITHALBEDO: boolean;
  56224. SHEEN_ROUGHNESS: boolean;
  56225. SHEEN_ALBEDOSCALING: boolean;
  56226. /** @hidden */
  56227. _areTexturesDirty: boolean;
  56228. }
  56229. /**
  56230. * Define the code related to the Sheen parameters of the pbr material.
  56231. */
  56232. export class PBRSheenConfiguration {
  56233. private _isEnabled;
  56234. /**
  56235. * Defines if the material uses sheen.
  56236. */
  56237. isEnabled: boolean;
  56238. private _linkSheenWithAlbedo;
  56239. /**
  56240. * Defines if the sheen is linked to the sheen color.
  56241. */
  56242. linkSheenWithAlbedo: boolean;
  56243. /**
  56244. * Defines the sheen intensity.
  56245. */
  56246. intensity: number;
  56247. /**
  56248. * Defines the sheen color.
  56249. */
  56250. color: Color3;
  56251. private _texture;
  56252. /**
  56253. * Stores the sheen tint values in a texture.
  56254. * rgb is tint
  56255. * a is a intensity
  56256. */
  56257. texture: Nullable<BaseTexture>;
  56258. private _roughness;
  56259. /**
  56260. * Defines the sheen roughness.
  56261. * It is not taken into account if linkSheenWithAlbedo is true.
  56262. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  56263. */
  56264. roughness: Nullable<number>;
  56265. private _albedoScaling;
  56266. /**
  56267. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  56268. * It allows the strength of the sheen effect to not depend on the base color of the material,
  56269. * making it easier to setup and tweak the effect
  56270. */
  56271. albedoScaling: boolean;
  56272. /** @hidden */
  56273. private _internalMarkAllSubMeshesAsTexturesDirty;
  56274. /** @hidden */
  56275. _markAllSubMeshesAsTexturesDirty(): void;
  56276. /**
  56277. * Instantiate a new istance of clear coat configuration.
  56278. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56279. */
  56280. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56281. /**
  56282. * Specifies that the submesh is ready to be used.
  56283. * @param defines the list of "defines" to update.
  56284. * @param scene defines the scene the material belongs to.
  56285. * @returns - boolean indicating that the submesh is ready or not.
  56286. */
  56287. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  56288. /**
  56289. * Checks to see if a texture is used in the material.
  56290. * @param defines the list of "defines" to update.
  56291. * @param scene defines the scene the material belongs to.
  56292. */
  56293. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  56294. /**
  56295. * Binds the material data.
  56296. * @param uniformBuffer defines the Uniform buffer to fill in.
  56297. * @param scene defines the scene the material belongs to.
  56298. * @param isFrozen defines wether the material is frozen or not.
  56299. */
  56300. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56301. /**
  56302. * Checks to see if a texture is used in the material.
  56303. * @param texture - Base texture to use.
  56304. * @returns - Boolean specifying if a texture is used in the material.
  56305. */
  56306. hasTexture(texture: BaseTexture): boolean;
  56307. /**
  56308. * Returns an array of the actively used textures.
  56309. * @param activeTextures Array of BaseTextures
  56310. */
  56311. getActiveTextures(activeTextures: BaseTexture[]): void;
  56312. /**
  56313. * Returns the animatable textures.
  56314. * @param animatables Array of animatable textures.
  56315. */
  56316. getAnimatables(animatables: IAnimatable[]): void;
  56317. /**
  56318. * Disposes the resources of the material.
  56319. * @param forceDisposeTextures - Forces the disposal of all textures.
  56320. */
  56321. dispose(forceDisposeTextures?: boolean): void;
  56322. /**
  56323. * Get the current class name of the texture useful for serialization or dynamic coding.
  56324. * @returns "PBRSheenConfiguration"
  56325. */
  56326. getClassName(): string;
  56327. /**
  56328. * Add fallbacks to the effect fallbacks list.
  56329. * @param defines defines the Base texture to use.
  56330. * @param fallbacks defines the current fallback list.
  56331. * @param currentRank defines the current fallback rank.
  56332. * @returns the new fallback rank.
  56333. */
  56334. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56335. /**
  56336. * Add the required uniforms to the current list.
  56337. * @param uniforms defines the current uniform list.
  56338. */
  56339. static AddUniforms(uniforms: string[]): void;
  56340. /**
  56341. * Add the required uniforms to the current buffer.
  56342. * @param uniformBuffer defines the current uniform buffer.
  56343. */
  56344. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56345. /**
  56346. * Add the required samplers to the current list.
  56347. * @param samplers defines the current sampler list.
  56348. */
  56349. static AddSamplers(samplers: string[]): void;
  56350. /**
  56351. * Makes a duplicate of the current configuration into another one.
  56352. * @param sheenConfiguration define the config where to copy the info
  56353. */
  56354. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  56355. /**
  56356. * Serializes this BRDF configuration.
  56357. * @returns - An object with the serialized config.
  56358. */
  56359. serialize(): any;
  56360. /**
  56361. * Parses a anisotropy Configuration from a serialized object.
  56362. * @param source - Serialized object.
  56363. * @param scene Defines the scene we are parsing for
  56364. * @param rootUrl Defines the rootUrl to load from
  56365. */
  56366. parse(source: any, scene: Scene, rootUrl: string): void;
  56367. }
  56368. }
  56369. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  56370. import { Nullable } from "babylonjs/types";
  56371. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56372. import { Color3 } from "babylonjs/Maths/math.color";
  56373. import { SmartArray } from "babylonjs/Misc/smartArray";
  56374. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56375. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56376. import { Effect } from "babylonjs/Materials/effect";
  56377. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56378. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56379. import { Engine } from "babylonjs/Engines/engine";
  56380. import { Scene } from "babylonjs/scene";
  56381. /**
  56382. * @hidden
  56383. */
  56384. export interface IMaterialSubSurfaceDefines {
  56385. SUBSURFACE: boolean;
  56386. SS_REFRACTION: boolean;
  56387. SS_TRANSLUCENCY: boolean;
  56388. SS_SCATERRING: boolean;
  56389. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56390. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56391. SS_REFRACTIONMAP_3D: boolean;
  56392. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56393. SS_LODINREFRACTIONALPHA: boolean;
  56394. SS_GAMMAREFRACTION: boolean;
  56395. SS_RGBDREFRACTION: boolean;
  56396. SS_LINEARSPECULARREFRACTION: boolean;
  56397. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56398. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56399. /** @hidden */
  56400. _areTexturesDirty: boolean;
  56401. }
  56402. /**
  56403. * Define the code related to the sub surface parameters of the pbr material.
  56404. */
  56405. export class PBRSubSurfaceConfiguration {
  56406. private _isRefractionEnabled;
  56407. /**
  56408. * Defines if the refraction is enabled in the material.
  56409. */
  56410. isRefractionEnabled: boolean;
  56411. private _isTranslucencyEnabled;
  56412. /**
  56413. * Defines if the translucency is enabled in the material.
  56414. */
  56415. isTranslucencyEnabled: boolean;
  56416. private _isScatteringEnabled;
  56417. /**
  56418. * Defines the refraction intensity of the material.
  56419. * The refraction when enabled replaces the Diffuse part of the material.
  56420. * The intensity helps transitionning between diffuse and refraction.
  56421. */
  56422. refractionIntensity: number;
  56423. /**
  56424. * Defines the translucency intensity of the material.
  56425. * When translucency has been enabled, this defines how much of the "translucency"
  56426. * is addded to the diffuse part of the material.
  56427. */
  56428. translucencyIntensity: number;
  56429. /**
  56430. * Defines the scattering intensity of the material.
  56431. * When scattering has been enabled, this defines how much of the "scattered light"
  56432. * is addded to the diffuse part of the material.
  56433. */
  56434. scatteringIntensity: number;
  56435. private _thicknessTexture;
  56436. /**
  56437. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  56438. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  56439. * 0 would mean minimumThickness
  56440. * 1 would mean maximumThickness
  56441. * The other channels might be use as a mask to vary the different effects intensity.
  56442. */
  56443. thicknessTexture: Nullable<BaseTexture>;
  56444. private _refractionTexture;
  56445. /**
  56446. * Defines the texture to use for refraction.
  56447. */
  56448. refractionTexture: Nullable<BaseTexture>;
  56449. private _indexOfRefraction;
  56450. /**
  56451. * Index of refraction of the material base layer.
  56452. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56453. *
  56454. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56455. *
  56456. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56457. */
  56458. indexOfRefraction: number;
  56459. private _invertRefractionY;
  56460. /**
  56461. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56462. */
  56463. invertRefractionY: boolean;
  56464. private _linkRefractionWithTransparency;
  56465. /**
  56466. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56467. * Materials half opaque for instance using refraction could benefit from this control.
  56468. */
  56469. linkRefractionWithTransparency: boolean;
  56470. /**
  56471. * Defines the minimum thickness stored in the thickness map.
  56472. * If no thickness map is defined, this value will be used to simulate thickness.
  56473. */
  56474. minimumThickness: number;
  56475. /**
  56476. * Defines the maximum thickness stored in the thickness map.
  56477. */
  56478. maximumThickness: number;
  56479. /**
  56480. * Defines the volume tint of the material.
  56481. * This is used for both translucency and scattering.
  56482. */
  56483. tintColor: Color3;
  56484. /**
  56485. * Defines the distance at which the tint color should be found in the media.
  56486. * This is used for refraction only.
  56487. */
  56488. tintColorAtDistance: number;
  56489. /**
  56490. * Defines how far each channel transmit through the media.
  56491. * It is defined as a color to simplify it selection.
  56492. */
  56493. diffusionDistance: Color3;
  56494. private _useMaskFromThicknessTexture;
  56495. /**
  56496. * Stores the intensity of the different subsurface effects in the thickness texture.
  56497. * * the green channel is the translucency intensity.
  56498. * * the blue channel is the scattering intensity.
  56499. * * the alpha channel is the refraction intensity.
  56500. */
  56501. useMaskFromThicknessTexture: boolean;
  56502. /** @hidden */
  56503. private _internalMarkAllSubMeshesAsTexturesDirty;
  56504. /** @hidden */
  56505. _markAllSubMeshesAsTexturesDirty(): void;
  56506. /**
  56507. * Instantiate a new istance of sub surface configuration.
  56508. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56509. */
  56510. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56511. /**
  56512. * Gets wehter the submesh is ready to be used or not.
  56513. * @param defines the list of "defines" to update.
  56514. * @param scene defines the scene the material belongs to.
  56515. * @returns - boolean indicating that the submesh is ready or not.
  56516. */
  56517. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  56518. /**
  56519. * Checks to see if a texture is used in the material.
  56520. * @param defines the list of "defines" to update.
  56521. * @param scene defines the scene to the material belongs to.
  56522. */
  56523. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  56524. /**
  56525. * Binds the material data.
  56526. * @param uniformBuffer defines the Uniform buffer to fill in.
  56527. * @param scene defines the scene the material belongs to.
  56528. * @param engine defines the engine the material belongs to.
  56529. * @param isFrozen defines whether the material is frozen or not.
  56530. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  56531. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  56532. */
  56533. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  56534. /**
  56535. * Unbinds the material from the mesh.
  56536. * @param activeEffect defines the effect that should be unbound from.
  56537. * @returns true if unbound, otherwise false
  56538. */
  56539. unbind(activeEffect: Effect): boolean;
  56540. /**
  56541. * Returns the texture used for refraction or null if none is used.
  56542. * @param scene defines the scene the material belongs to.
  56543. * @returns - Refraction texture if present. If no refraction texture and refraction
  56544. * is linked with transparency, returns environment texture. Otherwise, returns null.
  56545. */
  56546. private _getRefractionTexture;
  56547. /**
  56548. * Returns true if alpha blending should be disabled.
  56549. */
  56550. get disableAlphaBlending(): boolean;
  56551. /**
  56552. * Fills the list of render target textures.
  56553. * @param renderTargets the list of render targets to update
  56554. */
  56555. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  56556. /**
  56557. * Checks to see if a texture is used in the material.
  56558. * @param texture - Base texture to use.
  56559. * @returns - Boolean specifying if a texture is used in the material.
  56560. */
  56561. hasTexture(texture: BaseTexture): boolean;
  56562. /**
  56563. * Gets a boolean indicating that current material needs to register RTT
  56564. * @returns true if this uses a render target otherwise false.
  56565. */
  56566. hasRenderTargetTextures(): boolean;
  56567. /**
  56568. * Returns an array of the actively used textures.
  56569. * @param activeTextures Array of BaseTextures
  56570. */
  56571. getActiveTextures(activeTextures: BaseTexture[]): void;
  56572. /**
  56573. * Returns the animatable textures.
  56574. * @param animatables Array of animatable textures.
  56575. */
  56576. getAnimatables(animatables: IAnimatable[]): void;
  56577. /**
  56578. * Disposes the resources of the material.
  56579. * @param forceDisposeTextures - Forces the disposal of all textures.
  56580. */
  56581. dispose(forceDisposeTextures?: boolean): void;
  56582. /**
  56583. * Get the current class name of the texture useful for serialization or dynamic coding.
  56584. * @returns "PBRSubSurfaceConfiguration"
  56585. */
  56586. getClassName(): string;
  56587. /**
  56588. * Add fallbacks to the effect fallbacks list.
  56589. * @param defines defines the Base texture to use.
  56590. * @param fallbacks defines the current fallback list.
  56591. * @param currentRank defines the current fallback rank.
  56592. * @returns the new fallback rank.
  56593. */
  56594. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56595. /**
  56596. * Add the required uniforms to the current list.
  56597. * @param uniforms defines the current uniform list.
  56598. */
  56599. static AddUniforms(uniforms: string[]): void;
  56600. /**
  56601. * Add the required samplers to the current list.
  56602. * @param samplers defines the current sampler list.
  56603. */
  56604. static AddSamplers(samplers: string[]): void;
  56605. /**
  56606. * Add the required uniforms to the current buffer.
  56607. * @param uniformBuffer defines the current uniform buffer.
  56608. */
  56609. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56610. /**
  56611. * Makes a duplicate of the current configuration into another one.
  56612. * @param configuration define the config where to copy the info
  56613. */
  56614. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  56615. /**
  56616. * Serializes this Sub Surface configuration.
  56617. * @returns - An object with the serialized config.
  56618. */
  56619. serialize(): any;
  56620. /**
  56621. * Parses a anisotropy Configuration from a serialized object.
  56622. * @param source - Serialized object.
  56623. * @param scene Defines the scene we are parsing for
  56624. * @param rootUrl Defines the rootUrl to load from
  56625. */
  56626. parse(source: any, scene: Scene, rootUrl: string): void;
  56627. }
  56628. }
  56629. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  56630. /** @hidden */
  56631. export var pbrFragmentDeclaration: {
  56632. name: string;
  56633. shader: string;
  56634. };
  56635. }
  56636. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  56637. /** @hidden */
  56638. export var pbrUboDeclaration: {
  56639. name: string;
  56640. shader: string;
  56641. };
  56642. }
  56643. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  56644. /** @hidden */
  56645. export var pbrFragmentExtraDeclaration: {
  56646. name: string;
  56647. shader: string;
  56648. };
  56649. }
  56650. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  56651. /** @hidden */
  56652. export var pbrFragmentSamplersDeclaration: {
  56653. name: string;
  56654. shader: string;
  56655. };
  56656. }
  56657. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  56658. /** @hidden */
  56659. export var importanceSampling: {
  56660. name: string;
  56661. shader: string;
  56662. };
  56663. }
  56664. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  56665. /** @hidden */
  56666. export var pbrHelperFunctions: {
  56667. name: string;
  56668. shader: string;
  56669. };
  56670. }
  56671. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  56672. /** @hidden */
  56673. export var harmonicsFunctions: {
  56674. name: string;
  56675. shader: string;
  56676. };
  56677. }
  56678. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  56679. /** @hidden */
  56680. export var pbrDirectLightingSetupFunctions: {
  56681. name: string;
  56682. shader: string;
  56683. };
  56684. }
  56685. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  56686. /** @hidden */
  56687. export var pbrDirectLightingFalloffFunctions: {
  56688. name: string;
  56689. shader: string;
  56690. };
  56691. }
  56692. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  56693. /** @hidden */
  56694. export var pbrBRDFFunctions: {
  56695. name: string;
  56696. shader: string;
  56697. };
  56698. }
  56699. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  56700. /** @hidden */
  56701. export var hdrFilteringFunctions: {
  56702. name: string;
  56703. shader: string;
  56704. };
  56705. }
  56706. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  56707. /** @hidden */
  56708. export var pbrDirectLightingFunctions: {
  56709. name: string;
  56710. shader: string;
  56711. };
  56712. }
  56713. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  56714. /** @hidden */
  56715. export var pbrIBLFunctions: {
  56716. name: string;
  56717. shader: string;
  56718. };
  56719. }
  56720. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  56721. /** @hidden */
  56722. export var pbrBlockAlbedoOpacity: {
  56723. name: string;
  56724. shader: string;
  56725. };
  56726. }
  56727. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  56728. /** @hidden */
  56729. export var pbrBlockReflectivity: {
  56730. name: string;
  56731. shader: string;
  56732. };
  56733. }
  56734. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  56735. /** @hidden */
  56736. export var pbrBlockAmbientOcclusion: {
  56737. name: string;
  56738. shader: string;
  56739. };
  56740. }
  56741. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  56742. /** @hidden */
  56743. export var pbrBlockAlphaFresnel: {
  56744. name: string;
  56745. shader: string;
  56746. };
  56747. }
  56748. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  56749. /** @hidden */
  56750. export var pbrBlockAnisotropic: {
  56751. name: string;
  56752. shader: string;
  56753. };
  56754. }
  56755. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  56756. /** @hidden */
  56757. export var pbrBlockReflection: {
  56758. name: string;
  56759. shader: string;
  56760. };
  56761. }
  56762. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  56763. /** @hidden */
  56764. export var pbrBlockSheen: {
  56765. name: string;
  56766. shader: string;
  56767. };
  56768. }
  56769. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  56770. /** @hidden */
  56771. export var pbrBlockClearcoat: {
  56772. name: string;
  56773. shader: string;
  56774. };
  56775. }
  56776. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  56777. /** @hidden */
  56778. export var pbrBlockSubSurface: {
  56779. name: string;
  56780. shader: string;
  56781. };
  56782. }
  56783. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  56784. /** @hidden */
  56785. export var pbrBlockNormalGeometric: {
  56786. name: string;
  56787. shader: string;
  56788. };
  56789. }
  56790. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  56791. /** @hidden */
  56792. export var pbrBlockNormalFinal: {
  56793. name: string;
  56794. shader: string;
  56795. };
  56796. }
  56797. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  56798. /** @hidden */
  56799. export var pbrBlockGeometryInfo: {
  56800. name: string;
  56801. shader: string;
  56802. };
  56803. }
  56804. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  56805. /** @hidden */
  56806. export var pbrBlockReflectance0: {
  56807. name: string;
  56808. shader: string;
  56809. };
  56810. }
  56811. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  56812. /** @hidden */
  56813. export var pbrBlockReflectance: {
  56814. name: string;
  56815. shader: string;
  56816. };
  56817. }
  56818. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  56819. /** @hidden */
  56820. export var pbrBlockDirectLighting: {
  56821. name: string;
  56822. shader: string;
  56823. };
  56824. }
  56825. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  56826. /** @hidden */
  56827. export var pbrBlockFinalLitComponents: {
  56828. name: string;
  56829. shader: string;
  56830. };
  56831. }
  56832. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  56833. /** @hidden */
  56834. export var pbrBlockFinalUnlitComponents: {
  56835. name: string;
  56836. shader: string;
  56837. };
  56838. }
  56839. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  56840. /** @hidden */
  56841. export var pbrBlockFinalColorComposition: {
  56842. name: string;
  56843. shader: string;
  56844. };
  56845. }
  56846. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  56847. /** @hidden */
  56848. export var pbrBlockImageProcessing: {
  56849. name: string;
  56850. shader: string;
  56851. };
  56852. }
  56853. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  56854. /** @hidden */
  56855. export var pbrDebug: {
  56856. name: string;
  56857. shader: string;
  56858. };
  56859. }
  56860. declare module "babylonjs/Shaders/pbr.fragment" {
  56861. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  56862. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  56863. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  56864. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56865. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56866. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  56867. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56868. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56869. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56870. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56871. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56872. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  56873. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  56874. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56875. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56876. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  56877. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  56878. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  56879. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  56880. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  56881. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  56882. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  56883. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  56884. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56885. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56886. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  56887. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  56888. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  56889. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  56890. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  56891. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  56892. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  56893. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  56894. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  56895. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56896. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  56897. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56898. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  56899. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  56900. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  56901. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  56902. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  56903. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  56904. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56905. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  56906. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  56907. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  56908. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  56909. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56910. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  56911. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  56912. /** @hidden */
  56913. export var pbrPixelShader: {
  56914. name: string;
  56915. shader: string;
  56916. };
  56917. }
  56918. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  56919. /** @hidden */
  56920. export var pbrVertexDeclaration: {
  56921. name: string;
  56922. shader: string;
  56923. };
  56924. }
  56925. declare module "babylonjs/Shaders/pbr.vertex" {
  56926. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  56927. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  56928. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56929. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56930. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56931. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  56932. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  56933. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56934. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56935. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56936. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56937. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56938. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56939. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56940. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56941. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56942. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56943. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  56944. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56945. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56946. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56947. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  56948. /** @hidden */
  56949. export var pbrVertexShader: {
  56950. name: string;
  56951. shader: string;
  56952. };
  56953. }
  56954. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  56955. import { Nullable } from "babylonjs/types";
  56956. import { Scene } from "babylonjs/scene";
  56957. import { Matrix } from "babylonjs/Maths/math.vector";
  56958. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56960. import { Mesh } from "babylonjs/Meshes/mesh";
  56961. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  56962. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  56963. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  56964. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  56965. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  56966. import { Color3 } from "babylonjs/Maths/math.color";
  56967. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  56968. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  56969. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  56970. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56971. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56972. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56973. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  56974. import "babylonjs/Shaders/pbr.fragment";
  56975. import "babylonjs/Shaders/pbr.vertex";
  56976. /**
  56977. * Manages the defines for the PBR Material.
  56978. * @hidden
  56979. */
  56980. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  56981. PBR: boolean;
  56982. NUM_SAMPLES: string;
  56983. REALTIME_FILTERING: boolean;
  56984. MAINUV1: boolean;
  56985. MAINUV2: boolean;
  56986. UV1: boolean;
  56987. UV2: boolean;
  56988. ALBEDO: boolean;
  56989. GAMMAALBEDO: boolean;
  56990. ALBEDODIRECTUV: number;
  56991. VERTEXCOLOR: boolean;
  56992. AMBIENT: boolean;
  56993. AMBIENTDIRECTUV: number;
  56994. AMBIENTINGRAYSCALE: boolean;
  56995. OPACITY: boolean;
  56996. VERTEXALPHA: boolean;
  56997. OPACITYDIRECTUV: number;
  56998. OPACITYRGB: boolean;
  56999. ALPHATEST: boolean;
  57000. DEPTHPREPASS: boolean;
  57001. ALPHABLEND: boolean;
  57002. ALPHAFROMALBEDO: boolean;
  57003. ALPHATESTVALUE: string;
  57004. SPECULAROVERALPHA: boolean;
  57005. RADIANCEOVERALPHA: boolean;
  57006. ALPHAFRESNEL: boolean;
  57007. LINEARALPHAFRESNEL: boolean;
  57008. PREMULTIPLYALPHA: boolean;
  57009. EMISSIVE: boolean;
  57010. EMISSIVEDIRECTUV: number;
  57011. REFLECTIVITY: boolean;
  57012. REFLECTIVITYDIRECTUV: number;
  57013. SPECULARTERM: boolean;
  57014. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  57015. MICROSURFACEAUTOMATIC: boolean;
  57016. LODBASEDMICROSFURACE: boolean;
  57017. MICROSURFACEMAP: boolean;
  57018. MICROSURFACEMAPDIRECTUV: number;
  57019. METALLICWORKFLOW: boolean;
  57020. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  57021. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  57022. METALLNESSSTOREINMETALMAPBLUE: boolean;
  57023. AOSTOREINMETALMAPRED: boolean;
  57024. METALLIC_REFLECTANCE: boolean;
  57025. METALLIC_REFLECTANCEDIRECTUV: number;
  57026. ENVIRONMENTBRDF: boolean;
  57027. ENVIRONMENTBRDF_RGBD: boolean;
  57028. NORMAL: boolean;
  57029. TANGENT: boolean;
  57030. BUMP: boolean;
  57031. BUMPDIRECTUV: number;
  57032. OBJECTSPACE_NORMALMAP: boolean;
  57033. PARALLAX: boolean;
  57034. PARALLAXOCCLUSION: boolean;
  57035. NORMALXYSCALE: boolean;
  57036. LIGHTMAP: boolean;
  57037. LIGHTMAPDIRECTUV: number;
  57038. USELIGHTMAPASSHADOWMAP: boolean;
  57039. GAMMALIGHTMAP: boolean;
  57040. RGBDLIGHTMAP: boolean;
  57041. REFLECTION: boolean;
  57042. REFLECTIONMAP_3D: boolean;
  57043. REFLECTIONMAP_SPHERICAL: boolean;
  57044. REFLECTIONMAP_PLANAR: boolean;
  57045. REFLECTIONMAP_CUBIC: boolean;
  57046. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  57047. REFLECTIONMAP_PROJECTION: boolean;
  57048. REFLECTIONMAP_SKYBOX: boolean;
  57049. REFLECTIONMAP_EXPLICIT: boolean;
  57050. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  57051. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  57052. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  57053. INVERTCUBICMAP: boolean;
  57054. USESPHERICALFROMREFLECTIONMAP: boolean;
  57055. USEIRRADIANCEMAP: boolean;
  57056. SPHERICAL_HARMONICS: boolean;
  57057. USESPHERICALINVERTEX: boolean;
  57058. REFLECTIONMAP_OPPOSITEZ: boolean;
  57059. LODINREFLECTIONALPHA: boolean;
  57060. GAMMAREFLECTION: boolean;
  57061. RGBDREFLECTION: boolean;
  57062. LINEARSPECULARREFLECTION: boolean;
  57063. RADIANCEOCCLUSION: boolean;
  57064. HORIZONOCCLUSION: boolean;
  57065. INSTANCES: boolean;
  57066. THIN_INSTANCES: boolean;
  57067. NUM_BONE_INFLUENCERS: number;
  57068. BonesPerMesh: number;
  57069. BONETEXTURE: boolean;
  57070. NONUNIFORMSCALING: boolean;
  57071. MORPHTARGETS: boolean;
  57072. MORPHTARGETS_NORMAL: boolean;
  57073. MORPHTARGETS_TANGENT: boolean;
  57074. MORPHTARGETS_UV: boolean;
  57075. NUM_MORPH_INFLUENCERS: number;
  57076. IMAGEPROCESSING: boolean;
  57077. VIGNETTE: boolean;
  57078. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57079. VIGNETTEBLENDMODEOPAQUE: boolean;
  57080. TONEMAPPING: boolean;
  57081. TONEMAPPING_ACES: boolean;
  57082. CONTRAST: boolean;
  57083. COLORCURVES: boolean;
  57084. COLORGRADING: boolean;
  57085. COLORGRADING3D: boolean;
  57086. SAMPLER3DGREENDEPTH: boolean;
  57087. SAMPLER3DBGRMAP: boolean;
  57088. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57089. EXPOSURE: boolean;
  57090. MULTIVIEW: boolean;
  57091. USEPHYSICALLIGHTFALLOFF: boolean;
  57092. USEGLTFLIGHTFALLOFF: boolean;
  57093. TWOSIDEDLIGHTING: boolean;
  57094. SHADOWFLOAT: boolean;
  57095. CLIPPLANE: boolean;
  57096. CLIPPLANE2: boolean;
  57097. CLIPPLANE3: boolean;
  57098. CLIPPLANE4: boolean;
  57099. CLIPPLANE5: boolean;
  57100. CLIPPLANE6: boolean;
  57101. POINTSIZE: boolean;
  57102. FOG: boolean;
  57103. LOGARITHMICDEPTH: boolean;
  57104. FORCENORMALFORWARD: boolean;
  57105. SPECULARAA: boolean;
  57106. CLEARCOAT: boolean;
  57107. CLEARCOAT_DEFAULTIOR: boolean;
  57108. CLEARCOAT_TEXTURE: boolean;
  57109. CLEARCOAT_TEXTUREDIRECTUV: number;
  57110. CLEARCOAT_BUMP: boolean;
  57111. CLEARCOAT_BUMPDIRECTUV: number;
  57112. CLEARCOAT_TINT: boolean;
  57113. CLEARCOAT_TINT_TEXTURE: boolean;
  57114. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57115. ANISOTROPIC: boolean;
  57116. ANISOTROPIC_TEXTURE: boolean;
  57117. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57118. BRDF_V_HEIGHT_CORRELATED: boolean;
  57119. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57120. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57121. SHEEN: boolean;
  57122. SHEEN_TEXTURE: boolean;
  57123. SHEEN_TEXTUREDIRECTUV: number;
  57124. SHEEN_LINKWITHALBEDO: boolean;
  57125. SHEEN_ROUGHNESS: boolean;
  57126. SHEEN_ALBEDOSCALING: boolean;
  57127. SUBSURFACE: boolean;
  57128. SS_REFRACTION: boolean;
  57129. SS_TRANSLUCENCY: boolean;
  57130. SS_SCATERRING: boolean;
  57131. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57132. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57133. SS_REFRACTIONMAP_3D: boolean;
  57134. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57135. SS_LODINREFRACTIONALPHA: boolean;
  57136. SS_GAMMAREFRACTION: boolean;
  57137. SS_RGBDREFRACTION: boolean;
  57138. SS_LINEARSPECULARREFRACTION: boolean;
  57139. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57140. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57141. UNLIT: boolean;
  57142. DEBUGMODE: number;
  57143. /**
  57144. * Initializes the PBR Material defines.
  57145. */
  57146. constructor();
  57147. /**
  57148. * Resets the PBR Material defines.
  57149. */
  57150. reset(): void;
  57151. }
  57152. /**
  57153. * The Physically based material base class of BJS.
  57154. *
  57155. * This offers the main features of a standard PBR material.
  57156. * For more information, please refer to the documentation :
  57157. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57158. */
  57159. export abstract class PBRBaseMaterial extends PushMaterial {
  57160. /**
  57161. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57162. */
  57163. static readonly PBRMATERIAL_OPAQUE: number;
  57164. /**
  57165. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57166. */
  57167. static readonly PBRMATERIAL_ALPHATEST: number;
  57168. /**
  57169. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57170. */
  57171. static readonly PBRMATERIAL_ALPHABLEND: number;
  57172. /**
  57173. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57174. * They are also discarded below the alpha cutoff threshold to improve performances.
  57175. */
  57176. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57177. /**
  57178. * Defines the default value of how much AO map is occluding the analytical lights
  57179. * (point spot...).
  57180. */
  57181. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57182. /**
  57183. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  57184. */
  57185. static readonly LIGHTFALLOFF_PHYSICAL: number;
  57186. /**
  57187. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  57188. * to enhance interoperability with other engines.
  57189. */
  57190. static readonly LIGHTFALLOFF_GLTF: number;
  57191. /**
  57192. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  57193. * to enhance interoperability with other materials.
  57194. */
  57195. static readonly LIGHTFALLOFF_STANDARD: number;
  57196. /**
  57197. * Intensity of the direct lights e.g. the four lights available in your scene.
  57198. * This impacts both the direct diffuse and specular highlights.
  57199. */
  57200. protected _directIntensity: number;
  57201. /**
  57202. * Intensity of the emissive part of the material.
  57203. * This helps controlling the emissive effect without modifying the emissive color.
  57204. */
  57205. protected _emissiveIntensity: number;
  57206. /**
  57207. * Intensity of the environment e.g. how much the environment will light the object
  57208. * either through harmonics for rough material or through the refelction for shiny ones.
  57209. */
  57210. protected _environmentIntensity: number;
  57211. /**
  57212. * This is a special control allowing the reduction of the specular highlights coming from the
  57213. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57214. */
  57215. protected _specularIntensity: number;
  57216. /**
  57217. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  57218. */
  57219. private _lightingInfos;
  57220. /**
  57221. * Debug Control allowing disabling the bump map on this material.
  57222. */
  57223. protected _disableBumpMap: boolean;
  57224. /**
  57225. * AKA Diffuse Texture in standard nomenclature.
  57226. */
  57227. protected _albedoTexture: Nullable<BaseTexture>;
  57228. /**
  57229. * AKA Occlusion Texture in other nomenclature.
  57230. */
  57231. protected _ambientTexture: Nullable<BaseTexture>;
  57232. /**
  57233. * AKA Occlusion Texture Intensity in other nomenclature.
  57234. */
  57235. protected _ambientTextureStrength: number;
  57236. /**
  57237. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57238. * 1 means it completely occludes it
  57239. * 0 mean it has no impact
  57240. */
  57241. protected _ambientTextureImpactOnAnalyticalLights: number;
  57242. /**
  57243. * Stores the alpha values in a texture.
  57244. */
  57245. protected _opacityTexture: Nullable<BaseTexture>;
  57246. /**
  57247. * Stores the reflection values in a texture.
  57248. */
  57249. protected _reflectionTexture: Nullable<BaseTexture>;
  57250. /**
  57251. * Stores the emissive values in a texture.
  57252. */
  57253. protected _emissiveTexture: Nullable<BaseTexture>;
  57254. /**
  57255. * AKA Specular texture in other nomenclature.
  57256. */
  57257. protected _reflectivityTexture: Nullable<BaseTexture>;
  57258. /**
  57259. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57260. */
  57261. protected _metallicTexture: Nullable<BaseTexture>;
  57262. /**
  57263. * Specifies the metallic scalar of the metallic/roughness workflow.
  57264. * Can also be used to scale the metalness values of the metallic texture.
  57265. */
  57266. protected _metallic: Nullable<number>;
  57267. /**
  57268. * Specifies the roughness scalar of the metallic/roughness workflow.
  57269. * Can also be used to scale the roughness values of the metallic texture.
  57270. */
  57271. protected _roughness: Nullable<number>;
  57272. /**
  57273. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57274. * By default the indexOfrefraction is used to compute F0;
  57275. *
  57276. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57277. *
  57278. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57279. * F90 = metallicReflectanceColor;
  57280. */
  57281. protected _metallicF0Factor: number;
  57282. /**
  57283. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57284. * By default the F90 is always 1;
  57285. *
  57286. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57287. *
  57288. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57289. * F90 = metallicReflectanceColor;
  57290. */
  57291. protected _metallicReflectanceColor: Color3;
  57292. /**
  57293. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57294. * This is multiply against the scalar values defined in the material.
  57295. */
  57296. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  57297. /**
  57298. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57299. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57300. */
  57301. protected _microSurfaceTexture: Nullable<BaseTexture>;
  57302. /**
  57303. * Stores surface normal data used to displace a mesh in a texture.
  57304. */
  57305. protected _bumpTexture: Nullable<BaseTexture>;
  57306. /**
  57307. * Stores the pre-calculated light information of a mesh in a texture.
  57308. */
  57309. protected _lightmapTexture: Nullable<BaseTexture>;
  57310. /**
  57311. * The color of a material in ambient lighting.
  57312. */
  57313. protected _ambientColor: Color3;
  57314. /**
  57315. * AKA Diffuse Color in other nomenclature.
  57316. */
  57317. protected _albedoColor: Color3;
  57318. /**
  57319. * AKA Specular Color in other nomenclature.
  57320. */
  57321. protected _reflectivityColor: Color3;
  57322. /**
  57323. * The color applied when light is reflected from a material.
  57324. */
  57325. protected _reflectionColor: Color3;
  57326. /**
  57327. * The color applied when light is emitted from a material.
  57328. */
  57329. protected _emissiveColor: Color3;
  57330. /**
  57331. * AKA Glossiness in other nomenclature.
  57332. */
  57333. protected _microSurface: number;
  57334. /**
  57335. * Specifies that the material will use the light map as a show map.
  57336. */
  57337. protected _useLightmapAsShadowmap: boolean;
  57338. /**
  57339. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57340. * makes the reflect vector face the model (under horizon).
  57341. */
  57342. protected _useHorizonOcclusion: boolean;
  57343. /**
  57344. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57345. * too much the area relying on ambient texture to define their ambient occlusion.
  57346. */
  57347. protected _useRadianceOcclusion: boolean;
  57348. /**
  57349. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57350. */
  57351. protected _useAlphaFromAlbedoTexture: boolean;
  57352. /**
  57353. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  57354. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57355. */
  57356. protected _useSpecularOverAlpha: boolean;
  57357. /**
  57358. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57359. */
  57360. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57361. /**
  57362. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57363. */
  57364. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  57365. /**
  57366. * Specifies if the metallic texture contains the roughness information in its green channel.
  57367. */
  57368. protected _useRoughnessFromMetallicTextureGreen: boolean;
  57369. /**
  57370. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57371. */
  57372. protected _useMetallnessFromMetallicTextureBlue: boolean;
  57373. /**
  57374. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57375. */
  57376. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  57377. /**
  57378. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57379. */
  57380. protected _useAmbientInGrayScale: boolean;
  57381. /**
  57382. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57383. * The material will try to infer what glossiness each pixel should be.
  57384. */
  57385. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  57386. /**
  57387. * Defines the falloff type used in this material.
  57388. * It by default is Physical.
  57389. */
  57390. protected _lightFalloff: number;
  57391. /**
  57392. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57393. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57394. */
  57395. protected _useRadianceOverAlpha: boolean;
  57396. /**
  57397. * Allows using an object space normal map (instead of tangent space).
  57398. */
  57399. protected _useObjectSpaceNormalMap: boolean;
  57400. /**
  57401. * Allows using the bump map in parallax mode.
  57402. */
  57403. protected _useParallax: boolean;
  57404. /**
  57405. * Allows using the bump map in parallax occlusion mode.
  57406. */
  57407. protected _useParallaxOcclusion: boolean;
  57408. /**
  57409. * Controls the scale bias of the parallax mode.
  57410. */
  57411. protected _parallaxScaleBias: number;
  57412. /**
  57413. * If sets to true, disables all the lights affecting the material.
  57414. */
  57415. protected _disableLighting: boolean;
  57416. /**
  57417. * Number of Simultaneous lights allowed on the material.
  57418. */
  57419. protected _maxSimultaneousLights: number;
  57420. /**
  57421. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57422. */
  57423. protected _invertNormalMapX: boolean;
  57424. /**
  57425. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57426. */
  57427. protected _invertNormalMapY: boolean;
  57428. /**
  57429. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57430. */
  57431. protected _twoSidedLighting: boolean;
  57432. /**
  57433. * Defines the alpha limits in alpha test mode.
  57434. */
  57435. protected _alphaCutOff: number;
  57436. /**
  57437. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57438. */
  57439. protected _forceAlphaTest: boolean;
  57440. /**
  57441. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57442. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57443. */
  57444. protected _useAlphaFresnel: boolean;
  57445. /**
  57446. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57447. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57448. */
  57449. protected _useLinearAlphaFresnel: boolean;
  57450. /**
  57451. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  57452. * from cos thetav and roughness:
  57453. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  57454. */
  57455. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  57456. /**
  57457. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57458. */
  57459. protected _forceIrradianceInFragment: boolean;
  57460. private _realTimeFiltering;
  57461. /**
  57462. * Enables realtime filtering on the texture.
  57463. */
  57464. get realTimeFiltering(): boolean;
  57465. set realTimeFiltering(b: boolean);
  57466. private _realTimeFilteringQuality;
  57467. /**
  57468. * Quality switch for realtime filtering
  57469. */
  57470. get realTimeFilteringQuality(): number;
  57471. set realTimeFilteringQuality(n: number);
  57472. /**
  57473. * Force normal to face away from face.
  57474. */
  57475. protected _forceNormalForward: boolean;
  57476. /**
  57477. * Enables specular anti aliasing in the PBR shader.
  57478. * It will both interacts on the Geometry for analytical and IBL lighting.
  57479. * It also prefilter the roughness map based on the bump values.
  57480. */
  57481. protected _enableSpecularAntiAliasing: boolean;
  57482. /**
  57483. * Default configuration related to image processing available in the PBR Material.
  57484. */
  57485. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57486. /**
  57487. * Keep track of the image processing observer to allow dispose and replace.
  57488. */
  57489. private _imageProcessingObserver;
  57490. /**
  57491. * Attaches a new image processing configuration to the PBR Material.
  57492. * @param configuration
  57493. */
  57494. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57495. /**
  57496. * Stores the available render targets.
  57497. */
  57498. private _renderTargets;
  57499. /**
  57500. * Sets the global ambient color for the material used in lighting calculations.
  57501. */
  57502. private _globalAmbientColor;
  57503. /**
  57504. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  57505. */
  57506. private _useLogarithmicDepth;
  57507. /**
  57508. * If set to true, no lighting calculations will be applied.
  57509. */
  57510. private _unlit;
  57511. private _debugMode;
  57512. /**
  57513. * @hidden
  57514. * This is reserved for the inspector.
  57515. * Defines the material debug mode.
  57516. * It helps seeing only some components of the material while troubleshooting.
  57517. */
  57518. debugMode: number;
  57519. /**
  57520. * @hidden
  57521. * This is reserved for the inspector.
  57522. * Specify from where on screen the debug mode should start.
  57523. * The value goes from -1 (full screen) to 1 (not visible)
  57524. * It helps with side by side comparison against the final render
  57525. * This defaults to -1
  57526. */
  57527. private debugLimit;
  57528. /**
  57529. * @hidden
  57530. * This is reserved for the inspector.
  57531. * As the default viewing range might not be enough (if the ambient is really small for instance)
  57532. * You can use the factor to better multiply the final value.
  57533. */
  57534. private debugFactor;
  57535. /**
  57536. * Defines the clear coat layer parameters for the material.
  57537. */
  57538. readonly clearCoat: PBRClearCoatConfiguration;
  57539. /**
  57540. * Defines the anisotropic parameters for the material.
  57541. */
  57542. readonly anisotropy: PBRAnisotropicConfiguration;
  57543. /**
  57544. * Defines the BRDF parameters for the material.
  57545. */
  57546. readonly brdf: PBRBRDFConfiguration;
  57547. /**
  57548. * Defines the Sheen parameters for the material.
  57549. */
  57550. readonly sheen: PBRSheenConfiguration;
  57551. /**
  57552. * Defines the SubSurface parameters for the material.
  57553. */
  57554. readonly subSurface: PBRSubSurfaceConfiguration;
  57555. protected _rebuildInParallel: boolean;
  57556. /**
  57557. * Instantiates a new PBRMaterial instance.
  57558. *
  57559. * @param name The material name
  57560. * @param scene The scene the material will be use in.
  57561. */
  57562. constructor(name: string, scene: Scene);
  57563. /**
  57564. * Gets a boolean indicating that current material needs to register RTT
  57565. */
  57566. get hasRenderTargetTextures(): boolean;
  57567. /**
  57568. * Gets the name of the material class.
  57569. */
  57570. getClassName(): string;
  57571. /**
  57572. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57573. */
  57574. get useLogarithmicDepth(): boolean;
  57575. /**
  57576. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57577. */
  57578. set useLogarithmicDepth(value: boolean);
  57579. /**
  57580. * Returns true if alpha blending should be disabled.
  57581. */
  57582. protected get _disableAlphaBlending(): boolean;
  57583. /**
  57584. * Specifies whether or not this material should be rendered in alpha blend mode.
  57585. */
  57586. needAlphaBlending(): boolean;
  57587. /**
  57588. * Specifies whether or not this material should be rendered in alpha test mode.
  57589. */
  57590. needAlphaTesting(): boolean;
  57591. /**
  57592. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  57593. */
  57594. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  57595. /**
  57596. * Gets the texture used for the alpha test.
  57597. */
  57598. getAlphaTestTexture(): Nullable<BaseTexture>;
  57599. /**
  57600. * Specifies that the submesh is ready to be used.
  57601. * @param mesh - BJS mesh.
  57602. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  57603. * @param useInstances - Specifies that instances should be used.
  57604. * @returns - boolean indicating that the submesh is ready or not.
  57605. */
  57606. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57607. /**
  57608. * Specifies if the material uses metallic roughness workflow.
  57609. * @returns boolean specifiying if the material uses metallic roughness workflow.
  57610. */
  57611. isMetallicWorkflow(): boolean;
  57612. private _prepareEffect;
  57613. private _prepareDefines;
  57614. /**
  57615. * Force shader compilation
  57616. */
  57617. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  57618. /**
  57619. * Initializes the uniform buffer layout for the shader.
  57620. */
  57621. buildUniformLayout(): void;
  57622. /**
  57623. * Unbinds the material from the mesh
  57624. */
  57625. unbind(): void;
  57626. /**
  57627. * Binds the submesh data.
  57628. * @param world - The world matrix.
  57629. * @param mesh - The BJS mesh.
  57630. * @param subMesh - A submesh of the BJS mesh.
  57631. */
  57632. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57633. /**
  57634. * Returns the animatable textures.
  57635. * @returns - Array of animatable textures.
  57636. */
  57637. getAnimatables(): IAnimatable[];
  57638. /**
  57639. * Returns the texture used for reflections.
  57640. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  57641. */
  57642. private _getReflectionTexture;
  57643. /**
  57644. * Returns an array of the actively used textures.
  57645. * @returns - Array of BaseTextures
  57646. */
  57647. getActiveTextures(): BaseTexture[];
  57648. /**
  57649. * Checks to see if a texture is used in the material.
  57650. * @param texture - Base texture to use.
  57651. * @returns - Boolean specifying if a texture is used in the material.
  57652. */
  57653. hasTexture(texture: BaseTexture): boolean;
  57654. /**
  57655. * Disposes the resources of the material.
  57656. * @param forceDisposeEffect - Forces the disposal of effects.
  57657. * @param forceDisposeTextures - Forces the disposal of all textures.
  57658. */
  57659. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57660. }
  57661. }
  57662. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  57663. import { Nullable } from "babylonjs/types";
  57664. import { Scene } from "babylonjs/scene";
  57665. import { Color3 } from "babylonjs/Maths/math.color";
  57666. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  57667. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  57668. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57669. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  57670. /**
  57671. * The Physically based material of BJS.
  57672. *
  57673. * This offers the main features of a standard PBR material.
  57674. * For more information, please refer to the documentation :
  57675. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57676. */
  57677. export class PBRMaterial extends PBRBaseMaterial {
  57678. /**
  57679. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57680. */
  57681. static readonly PBRMATERIAL_OPAQUE: number;
  57682. /**
  57683. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57684. */
  57685. static readonly PBRMATERIAL_ALPHATEST: number;
  57686. /**
  57687. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57688. */
  57689. static readonly PBRMATERIAL_ALPHABLEND: number;
  57690. /**
  57691. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57692. * They are also discarded below the alpha cutoff threshold to improve performances.
  57693. */
  57694. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57695. /**
  57696. * Defines the default value of how much AO map is occluding the analytical lights
  57697. * (point spot...).
  57698. */
  57699. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57700. /**
  57701. * Intensity of the direct lights e.g. the four lights available in your scene.
  57702. * This impacts both the direct diffuse and specular highlights.
  57703. */
  57704. directIntensity: number;
  57705. /**
  57706. * Intensity of the emissive part of the material.
  57707. * This helps controlling the emissive effect without modifying the emissive color.
  57708. */
  57709. emissiveIntensity: number;
  57710. /**
  57711. * Intensity of the environment e.g. how much the environment will light the object
  57712. * either through harmonics for rough material or through the refelction for shiny ones.
  57713. */
  57714. environmentIntensity: number;
  57715. /**
  57716. * This is a special control allowing the reduction of the specular highlights coming from the
  57717. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57718. */
  57719. specularIntensity: number;
  57720. /**
  57721. * Debug Control allowing disabling the bump map on this material.
  57722. */
  57723. disableBumpMap: boolean;
  57724. /**
  57725. * AKA Diffuse Texture in standard nomenclature.
  57726. */
  57727. albedoTexture: BaseTexture;
  57728. /**
  57729. * AKA Occlusion Texture in other nomenclature.
  57730. */
  57731. ambientTexture: BaseTexture;
  57732. /**
  57733. * AKA Occlusion Texture Intensity in other nomenclature.
  57734. */
  57735. ambientTextureStrength: number;
  57736. /**
  57737. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57738. * 1 means it completely occludes it
  57739. * 0 mean it has no impact
  57740. */
  57741. ambientTextureImpactOnAnalyticalLights: number;
  57742. /**
  57743. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  57744. */
  57745. opacityTexture: BaseTexture;
  57746. /**
  57747. * Stores the reflection values in a texture.
  57748. */
  57749. reflectionTexture: Nullable<BaseTexture>;
  57750. /**
  57751. * Stores the emissive values in a texture.
  57752. */
  57753. emissiveTexture: BaseTexture;
  57754. /**
  57755. * AKA Specular texture in other nomenclature.
  57756. */
  57757. reflectivityTexture: BaseTexture;
  57758. /**
  57759. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57760. */
  57761. metallicTexture: BaseTexture;
  57762. /**
  57763. * Specifies the metallic scalar of the metallic/roughness workflow.
  57764. * Can also be used to scale the metalness values of the metallic texture.
  57765. */
  57766. metallic: Nullable<number>;
  57767. /**
  57768. * Specifies the roughness scalar of the metallic/roughness workflow.
  57769. * Can also be used to scale the roughness values of the metallic texture.
  57770. */
  57771. roughness: Nullable<number>;
  57772. /**
  57773. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57774. * By default the indexOfrefraction is used to compute F0;
  57775. *
  57776. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57777. *
  57778. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57779. * F90 = metallicReflectanceColor;
  57780. */
  57781. metallicF0Factor: number;
  57782. /**
  57783. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57784. * By default the F90 is always 1;
  57785. *
  57786. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57787. *
  57788. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57789. * F90 = metallicReflectanceColor;
  57790. */
  57791. metallicReflectanceColor: Color3;
  57792. /**
  57793. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57794. * This is multiply against the scalar values defined in the material.
  57795. */
  57796. metallicReflectanceTexture: Nullable<BaseTexture>;
  57797. /**
  57798. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57799. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57800. */
  57801. microSurfaceTexture: BaseTexture;
  57802. /**
  57803. * Stores surface normal data used to displace a mesh in a texture.
  57804. */
  57805. bumpTexture: BaseTexture;
  57806. /**
  57807. * Stores the pre-calculated light information of a mesh in a texture.
  57808. */
  57809. lightmapTexture: BaseTexture;
  57810. /**
  57811. * Stores the refracted light information in a texture.
  57812. */
  57813. get refractionTexture(): Nullable<BaseTexture>;
  57814. set refractionTexture(value: Nullable<BaseTexture>);
  57815. /**
  57816. * The color of a material in ambient lighting.
  57817. */
  57818. ambientColor: Color3;
  57819. /**
  57820. * AKA Diffuse Color in other nomenclature.
  57821. */
  57822. albedoColor: Color3;
  57823. /**
  57824. * AKA Specular Color in other nomenclature.
  57825. */
  57826. reflectivityColor: Color3;
  57827. /**
  57828. * The color reflected from the material.
  57829. */
  57830. reflectionColor: Color3;
  57831. /**
  57832. * The color emitted from the material.
  57833. */
  57834. emissiveColor: Color3;
  57835. /**
  57836. * AKA Glossiness in other nomenclature.
  57837. */
  57838. microSurface: number;
  57839. /**
  57840. * Index of refraction of the material base layer.
  57841. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57842. *
  57843. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57844. *
  57845. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57846. */
  57847. get indexOfRefraction(): number;
  57848. set indexOfRefraction(value: number);
  57849. /**
  57850. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57851. */
  57852. get invertRefractionY(): boolean;
  57853. set invertRefractionY(value: boolean);
  57854. /**
  57855. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57856. * Materials half opaque for instance using refraction could benefit from this control.
  57857. */
  57858. get linkRefractionWithTransparency(): boolean;
  57859. set linkRefractionWithTransparency(value: boolean);
  57860. /**
  57861. * If true, the light map contains occlusion information instead of lighting info.
  57862. */
  57863. useLightmapAsShadowmap: boolean;
  57864. /**
  57865. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57866. */
  57867. useAlphaFromAlbedoTexture: boolean;
  57868. /**
  57869. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57870. */
  57871. forceAlphaTest: boolean;
  57872. /**
  57873. * Defines the alpha limits in alpha test mode.
  57874. */
  57875. alphaCutOff: number;
  57876. /**
  57877. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  57878. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57879. */
  57880. useSpecularOverAlpha: boolean;
  57881. /**
  57882. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57883. */
  57884. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57885. /**
  57886. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57887. */
  57888. useRoughnessFromMetallicTextureAlpha: boolean;
  57889. /**
  57890. * Specifies if the metallic texture contains the roughness information in its green channel.
  57891. */
  57892. useRoughnessFromMetallicTextureGreen: boolean;
  57893. /**
  57894. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57895. */
  57896. useMetallnessFromMetallicTextureBlue: boolean;
  57897. /**
  57898. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57899. */
  57900. useAmbientOcclusionFromMetallicTextureRed: boolean;
  57901. /**
  57902. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57903. */
  57904. useAmbientInGrayScale: boolean;
  57905. /**
  57906. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57907. * The material will try to infer what glossiness each pixel should be.
  57908. */
  57909. useAutoMicroSurfaceFromReflectivityMap: boolean;
  57910. /**
  57911. * BJS is using an harcoded light falloff based on a manually sets up range.
  57912. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57913. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57914. */
  57915. get usePhysicalLightFalloff(): boolean;
  57916. /**
  57917. * BJS is using an harcoded light falloff based on a manually sets up range.
  57918. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57919. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57920. */
  57921. set usePhysicalLightFalloff(value: boolean);
  57922. /**
  57923. * In order to support the falloff compatibility with gltf, a special mode has been added
  57924. * to reproduce the gltf light falloff.
  57925. */
  57926. get useGLTFLightFalloff(): boolean;
  57927. /**
  57928. * In order to support the falloff compatibility with gltf, a special mode has been added
  57929. * to reproduce the gltf light falloff.
  57930. */
  57931. set useGLTFLightFalloff(value: boolean);
  57932. /**
  57933. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57934. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57935. */
  57936. useRadianceOverAlpha: boolean;
  57937. /**
  57938. * Allows using an object space normal map (instead of tangent space).
  57939. */
  57940. useObjectSpaceNormalMap: boolean;
  57941. /**
  57942. * Allows using the bump map in parallax mode.
  57943. */
  57944. useParallax: boolean;
  57945. /**
  57946. * Allows using the bump map in parallax occlusion mode.
  57947. */
  57948. useParallaxOcclusion: boolean;
  57949. /**
  57950. * Controls the scale bias of the parallax mode.
  57951. */
  57952. parallaxScaleBias: number;
  57953. /**
  57954. * If sets to true, disables all the lights affecting the material.
  57955. */
  57956. disableLighting: boolean;
  57957. /**
  57958. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57959. */
  57960. forceIrradianceInFragment: boolean;
  57961. /**
  57962. * Number of Simultaneous lights allowed on the material.
  57963. */
  57964. maxSimultaneousLights: number;
  57965. /**
  57966. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57967. */
  57968. invertNormalMapX: boolean;
  57969. /**
  57970. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57971. */
  57972. invertNormalMapY: boolean;
  57973. /**
  57974. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57975. */
  57976. twoSidedLighting: boolean;
  57977. /**
  57978. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57979. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57980. */
  57981. useAlphaFresnel: boolean;
  57982. /**
  57983. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57984. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57985. */
  57986. useLinearAlphaFresnel: boolean;
  57987. /**
  57988. * Let user defines the brdf lookup texture used for IBL.
  57989. * A default 8bit version is embedded but you could point at :
  57990. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  57991. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  57992. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  57993. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  57994. */
  57995. environmentBRDFTexture: Nullable<BaseTexture>;
  57996. /**
  57997. * Force normal to face away from face.
  57998. */
  57999. forceNormalForward: boolean;
  58000. /**
  58001. * Enables specular anti aliasing in the PBR shader.
  58002. * It will both interacts on the Geometry for analytical and IBL lighting.
  58003. * It also prefilter the roughness map based on the bump values.
  58004. */
  58005. enableSpecularAntiAliasing: boolean;
  58006. /**
  58007. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58008. * makes the reflect vector face the model (under horizon).
  58009. */
  58010. useHorizonOcclusion: boolean;
  58011. /**
  58012. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58013. * too much the area relying on ambient texture to define their ambient occlusion.
  58014. */
  58015. useRadianceOcclusion: boolean;
  58016. /**
  58017. * If set to true, no lighting calculations will be applied.
  58018. */
  58019. unlit: boolean;
  58020. /**
  58021. * Gets the image processing configuration used either in this material.
  58022. */
  58023. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58024. /**
  58025. * Sets the Default image processing configuration used either in the this material.
  58026. *
  58027. * If sets to null, the scene one is in use.
  58028. */
  58029. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58030. /**
  58031. * Gets wether the color curves effect is enabled.
  58032. */
  58033. get cameraColorCurvesEnabled(): boolean;
  58034. /**
  58035. * Sets wether the color curves effect is enabled.
  58036. */
  58037. set cameraColorCurvesEnabled(value: boolean);
  58038. /**
  58039. * Gets wether the color grading effect is enabled.
  58040. */
  58041. get cameraColorGradingEnabled(): boolean;
  58042. /**
  58043. * Gets wether the color grading effect is enabled.
  58044. */
  58045. set cameraColorGradingEnabled(value: boolean);
  58046. /**
  58047. * Gets wether tonemapping is enabled or not.
  58048. */
  58049. get cameraToneMappingEnabled(): boolean;
  58050. /**
  58051. * Sets wether tonemapping is enabled or not
  58052. */
  58053. set cameraToneMappingEnabled(value: boolean);
  58054. /**
  58055. * The camera exposure used on this material.
  58056. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58057. * This corresponds to a photographic exposure.
  58058. */
  58059. get cameraExposure(): number;
  58060. /**
  58061. * The camera exposure used on this material.
  58062. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58063. * This corresponds to a photographic exposure.
  58064. */
  58065. set cameraExposure(value: number);
  58066. /**
  58067. * Gets The camera contrast used on this material.
  58068. */
  58069. get cameraContrast(): number;
  58070. /**
  58071. * Sets The camera contrast used on this material.
  58072. */
  58073. set cameraContrast(value: number);
  58074. /**
  58075. * Gets the Color Grading 2D Lookup Texture.
  58076. */
  58077. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58078. /**
  58079. * Sets the Color Grading 2D Lookup Texture.
  58080. */
  58081. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58082. /**
  58083. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58084. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58085. * 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;
  58086. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58087. */
  58088. get cameraColorCurves(): Nullable<ColorCurves>;
  58089. /**
  58090. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58091. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58092. * 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;
  58093. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58094. */
  58095. set cameraColorCurves(value: Nullable<ColorCurves>);
  58096. /**
  58097. * Instantiates a new PBRMaterial instance.
  58098. *
  58099. * @param name The material name
  58100. * @param scene The scene the material will be use in.
  58101. */
  58102. constructor(name: string, scene: Scene);
  58103. /**
  58104. * Returns the name of this material class.
  58105. */
  58106. getClassName(): string;
  58107. /**
  58108. * Makes a duplicate of the current material.
  58109. * @param name - name to use for the new material.
  58110. */
  58111. clone(name: string): PBRMaterial;
  58112. /**
  58113. * Serializes this PBR Material.
  58114. * @returns - An object with the serialized material.
  58115. */
  58116. serialize(): any;
  58117. /**
  58118. * Parses a PBR Material from a serialized object.
  58119. * @param source - Serialized object.
  58120. * @param scene - BJS scene instance.
  58121. * @param rootUrl - url for the scene object
  58122. * @returns - PBRMaterial
  58123. */
  58124. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  58125. }
  58126. }
  58127. declare module "babylonjs/Misc/dds" {
  58128. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58129. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58130. import { Nullable } from "babylonjs/types";
  58131. import { Scene } from "babylonjs/scene";
  58132. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  58133. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58134. /**
  58135. * Direct draw surface info
  58136. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58137. */
  58138. export interface DDSInfo {
  58139. /**
  58140. * Width of the texture
  58141. */
  58142. width: number;
  58143. /**
  58144. * Width of the texture
  58145. */
  58146. height: number;
  58147. /**
  58148. * Number of Mipmaps for the texture
  58149. * @see https://en.wikipedia.org/wiki/Mipmap
  58150. */
  58151. mipmapCount: number;
  58152. /**
  58153. * If the textures format is a known fourCC format
  58154. * @see https://www.fourcc.org/
  58155. */
  58156. isFourCC: boolean;
  58157. /**
  58158. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58159. */
  58160. isRGB: boolean;
  58161. /**
  58162. * If the texture is a lumincance format
  58163. */
  58164. isLuminance: boolean;
  58165. /**
  58166. * If this is a cube texture
  58167. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58168. */
  58169. isCube: boolean;
  58170. /**
  58171. * If the texture is a compressed format eg. FOURCC_DXT1
  58172. */
  58173. isCompressed: boolean;
  58174. /**
  58175. * The dxgiFormat of the texture
  58176. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58177. */
  58178. dxgiFormat: number;
  58179. /**
  58180. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58181. */
  58182. textureType: number;
  58183. /**
  58184. * Sphericle polynomial created for the dds texture
  58185. */
  58186. sphericalPolynomial?: SphericalPolynomial;
  58187. }
  58188. /**
  58189. * Class used to provide DDS decompression tools
  58190. */
  58191. export class DDSTools {
  58192. /**
  58193. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58194. */
  58195. static StoreLODInAlphaChannel: boolean;
  58196. /**
  58197. * Gets DDS information from an array buffer
  58198. * @param data defines the array buffer view to read data from
  58199. * @returns the DDS information
  58200. */
  58201. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58202. private static _FloatView;
  58203. private static _Int32View;
  58204. private static _ToHalfFloat;
  58205. private static _FromHalfFloat;
  58206. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58207. private static _GetHalfFloatRGBAArrayBuffer;
  58208. private static _GetFloatRGBAArrayBuffer;
  58209. private static _GetFloatAsUIntRGBAArrayBuffer;
  58210. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58211. private static _GetRGBAArrayBuffer;
  58212. private static _ExtractLongWordOrder;
  58213. private static _GetRGBArrayBuffer;
  58214. private static _GetLuminanceArrayBuffer;
  58215. /**
  58216. * Uploads DDS Levels to a Babylon Texture
  58217. * @hidden
  58218. */
  58219. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58220. }
  58221. module "babylonjs/Engines/thinEngine" {
  58222. interface ThinEngine {
  58223. /**
  58224. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58225. * @param rootUrl defines the url where the file to load is located
  58226. * @param scene defines the current scene
  58227. * @param lodScale defines scale to apply to the mip map selection
  58228. * @param lodOffset defines offset to apply to the mip map selection
  58229. * @param onLoad defines an optional callback raised when the texture is loaded
  58230. * @param onError defines an optional callback raised if there is an issue to load the texture
  58231. * @param format defines the format of the data
  58232. * @param forcedExtension defines the extension to use to pick the right loader
  58233. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58234. * @returns the cube texture as an InternalTexture
  58235. */
  58236. 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;
  58237. }
  58238. }
  58239. }
  58240. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  58241. import { Nullable } from "babylonjs/types";
  58242. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58243. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58244. /**
  58245. * Implementation of the DDS Texture Loader.
  58246. * @hidden
  58247. */
  58248. export class _DDSTextureLoader implements IInternalTextureLoader {
  58249. /**
  58250. * Defines wether the loader supports cascade loading the different faces.
  58251. */
  58252. readonly supportCascades: boolean;
  58253. /**
  58254. * This returns if the loader support the current file information.
  58255. * @param extension defines the file extension of the file being loaded
  58256. * @returns true if the loader can load the specified file
  58257. */
  58258. canLoad(extension: string): boolean;
  58259. /**
  58260. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58261. * @param data contains the texture data
  58262. * @param texture defines the BabylonJS internal texture
  58263. * @param createPolynomials will be true if polynomials have been requested
  58264. * @param onLoad defines the callback to trigger once the texture is ready
  58265. * @param onError defines the callback to trigger in case of error
  58266. */
  58267. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58268. /**
  58269. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58270. * @param data contains the texture data
  58271. * @param texture defines the BabylonJS internal texture
  58272. * @param callback defines the method to call once ready to upload
  58273. */
  58274. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58275. }
  58276. }
  58277. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  58278. import { Nullable } from "babylonjs/types";
  58279. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58280. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58281. /**
  58282. * Implementation of the ENV Texture Loader.
  58283. * @hidden
  58284. */
  58285. export class _ENVTextureLoader implements IInternalTextureLoader {
  58286. /**
  58287. * Defines wether the loader supports cascade loading the different faces.
  58288. */
  58289. readonly supportCascades: boolean;
  58290. /**
  58291. * This returns if the loader support the current file information.
  58292. * @param extension defines the file extension of the file being loaded
  58293. * @returns true if the loader can load the specified file
  58294. */
  58295. canLoad(extension: string): boolean;
  58296. /**
  58297. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58298. * @param data contains the texture data
  58299. * @param texture defines the BabylonJS internal texture
  58300. * @param createPolynomials will be true if polynomials have been requested
  58301. * @param onLoad defines the callback to trigger once the texture is ready
  58302. * @param onError defines the callback to trigger in case of error
  58303. */
  58304. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58305. /**
  58306. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58307. * @param data contains the texture data
  58308. * @param texture defines the BabylonJS internal texture
  58309. * @param callback defines the method to call once ready to upload
  58310. */
  58311. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58312. }
  58313. }
  58314. declare module "babylonjs/Misc/khronosTextureContainer" {
  58315. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58316. /**
  58317. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58318. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58319. */
  58320. export class KhronosTextureContainer {
  58321. /** contents of the KTX container file */
  58322. data: ArrayBufferView;
  58323. private static HEADER_LEN;
  58324. private static COMPRESSED_2D;
  58325. private static COMPRESSED_3D;
  58326. private static TEX_2D;
  58327. private static TEX_3D;
  58328. /**
  58329. * Gets the openGL type
  58330. */
  58331. glType: number;
  58332. /**
  58333. * Gets the openGL type size
  58334. */
  58335. glTypeSize: number;
  58336. /**
  58337. * Gets the openGL format
  58338. */
  58339. glFormat: number;
  58340. /**
  58341. * Gets the openGL internal format
  58342. */
  58343. glInternalFormat: number;
  58344. /**
  58345. * Gets the base internal format
  58346. */
  58347. glBaseInternalFormat: number;
  58348. /**
  58349. * Gets image width in pixel
  58350. */
  58351. pixelWidth: number;
  58352. /**
  58353. * Gets image height in pixel
  58354. */
  58355. pixelHeight: number;
  58356. /**
  58357. * Gets image depth in pixels
  58358. */
  58359. pixelDepth: number;
  58360. /**
  58361. * Gets the number of array elements
  58362. */
  58363. numberOfArrayElements: number;
  58364. /**
  58365. * Gets the number of faces
  58366. */
  58367. numberOfFaces: number;
  58368. /**
  58369. * Gets the number of mipmap levels
  58370. */
  58371. numberOfMipmapLevels: number;
  58372. /**
  58373. * Gets the bytes of key value data
  58374. */
  58375. bytesOfKeyValueData: number;
  58376. /**
  58377. * Gets the load type
  58378. */
  58379. loadType: number;
  58380. /**
  58381. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58382. */
  58383. isInvalid: boolean;
  58384. /**
  58385. * Creates a new KhronosTextureContainer
  58386. * @param data contents of the KTX container file
  58387. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58388. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58389. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58390. */
  58391. constructor(
  58392. /** contents of the KTX container file */
  58393. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58394. /**
  58395. * Uploads KTX content to a Babylon Texture.
  58396. * It is assumed that the texture has already been created & is currently bound
  58397. * @hidden
  58398. */
  58399. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58400. private _upload2DCompressedLevels;
  58401. /**
  58402. * Checks if the given data starts with a KTX file identifier.
  58403. * @param data the data to check
  58404. * @returns true if the data is a KTX file or false otherwise
  58405. */
  58406. static IsValid(data: ArrayBufferView): boolean;
  58407. }
  58408. }
  58409. declare module "babylonjs/Misc/khronosTextureContainer2" {
  58410. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58411. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58412. /**
  58413. * Class for loading KTX2 files
  58414. * !!! Experimental Extension Subject to Changes !!!
  58415. * @hidden
  58416. */
  58417. export class KhronosTextureContainer2 {
  58418. private static _ModulePromise;
  58419. private static _TranscodeFormat;
  58420. constructor(engine: ThinEngine);
  58421. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  58422. private _determineTranscodeFormat;
  58423. /**
  58424. * Checks if the given data starts with a KTX2 file identifier.
  58425. * @param data the data to check
  58426. * @returns true if the data is a KTX2 file or false otherwise
  58427. */
  58428. static IsValid(data: ArrayBufferView): boolean;
  58429. }
  58430. }
  58431. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  58432. import { Nullable } from "babylonjs/types";
  58433. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58434. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58435. /**
  58436. * Implementation of the KTX Texture Loader.
  58437. * @hidden
  58438. */
  58439. export class _KTXTextureLoader implements IInternalTextureLoader {
  58440. /**
  58441. * Defines wether the loader supports cascade loading the different faces.
  58442. */
  58443. readonly supportCascades: boolean;
  58444. /**
  58445. * This returns if the loader support the current file information.
  58446. * @param extension defines the file extension of the file being loaded
  58447. * @returns true if the loader can load the specified file
  58448. */
  58449. canLoad(extension: string): boolean;
  58450. /**
  58451. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58452. * @param data contains the texture data
  58453. * @param texture defines the BabylonJS internal texture
  58454. * @param createPolynomials will be true if polynomials have been requested
  58455. * @param onLoad defines the callback to trigger once the texture is ready
  58456. * @param onError defines the callback to trigger in case of error
  58457. */
  58458. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58459. /**
  58460. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58461. * @param data contains the texture data
  58462. * @param texture defines the BabylonJS internal texture
  58463. * @param callback defines the method to call once ready to upload
  58464. */
  58465. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  58466. }
  58467. }
  58468. declare module "babylonjs/Helpers/sceneHelpers" {
  58469. import { Nullable } from "babylonjs/types";
  58470. import { Mesh } from "babylonjs/Meshes/mesh";
  58471. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58472. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  58473. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  58474. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58475. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58476. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58477. import "babylonjs/Meshes/Builders/boxBuilder";
  58478. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  58479. /** @hidden */
  58480. export var _forceSceneHelpersToBundle: boolean;
  58481. module "babylonjs/scene" {
  58482. interface Scene {
  58483. /**
  58484. * Creates a default light for the scene.
  58485. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58486. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58487. */
  58488. createDefaultLight(replace?: boolean): void;
  58489. /**
  58490. * Creates a default camera for the scene.
  58491. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58492. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58493. * @param replace has default false, when true replaces the active camera in the scene
  58494. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58495. */
  58496. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58497. /**
  58498. * Creates a default camera and a default light.
  58499. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58500. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58501. * @param replace has the default false, when true replaces the active camera/light in the scene
  58502. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58503. */
  58504. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58505. /**
  58506. * Creates a new sky box
  58507. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58508. * @param environmentTexture defines the texture to use as environment texture
  58509. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58510. * @param scale defines the overall scale of the skybox
  58511. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58512. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58513. * @returns a new mesh holding the sky box
  58514. */
  58515. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58516. /**
  58517. * Creates a new environment
  58518. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58519. * @param options defines the options you can use to configure the environment
  58520. * @returns the new EnvironmentHelper
  58521. */
  58522. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58523. /**
  58524. * Creates a new VREXperienceHelper
  58525. * @see http://doc.babylonjs.com/how_to/webvr_helper
  58526. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58527. * @returns a new VREXperienceHelper
  58528. */
  58529. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58530. /**
  58531. * Creates a new WebXRDefaultExperience
  58532. * @see http://doc.babylonjs.com/how_to/webxr
  58533. * @param options experience options
  58534. * @returns a promise for a new WebXRDefaultExperience
  58535. */
  58536. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58537. }
  58538. }
  58539. }
  58540. declare module "babylonjs/Helpers/videoDome" {
  58541. import { Scene } from "babylonjs/scene";
  58542. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58543. import { Mesh } from "babylonjs/Meshes/mesh";
  58544. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  58545. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  58546. import "babylonjs/Meshes/Builders/sphereBuilder";
  58547. /**
  58548. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58549. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58550. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58551. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58552. */
  58553. export class VideoDome extends TransformNode {
  58554. /**
  58555. * Define the video source as a Monoscopic panoramic 360 video.
  58556. */
  58557. static readonly MODE_MONOSCOPIC: number;
  58558. /**
  58559. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58560. */
  58561. static readonly MODE_TOPBOTTOM: number;
  58562. /**
  58563. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58564. */
  58565. static readonly MODE_SIDEBYSIDE: number;
  58566. private _halfDome;
  58567. private _useDirectMapping;
  58568. /**
  58569. * The video texture being displayed on the sphere
  58570. */
  58571. protected _videoTexture: VideoTexture;
  58572. /**
  58573. * Gets the video texture being displayed on the sphere
  58574. */
  58575. get videoTexture(): VideoTexture;
  58576. /**
  58577. * The skybox material
  58578. */
  58579. protected _material: BackgroundMaterial;
  58580. /**
  58581. * The surface used for the skybox
  58582. */
  58583. protected _mesh: Mesh;
  58584. /**
  58585. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  58586. */
  58587. private _halfDomeMask;
  58588. /**
  58589. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58590. * Also see the options.resolution property.
  58591. */
  58592. get fovMultiplier(): number;
  58593. set fovMultiplier(value: number);
  58594. private _videoMode;
  58595. /**
  58596. * Gets or set the current video mode for the video. It can be:
  58597. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  58598. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58599. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58600. */
  58601. get videoMode(): number;
  58602. set videoMode(value: number);
  58603. /**
  58604. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  58605. *
  58606. */
  58607. get halfDome(): boolean;
  58608. /**
  58609. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58610. */
  58611. set halfDome(enabled: boolean);
  58612. /**
  58613. * Oberserver used in Stereoscopic VR Mode.
  58614. */
  58615. private _onBeforeCameraRenderObserver;
  58616. /**
  58617. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  58618. * @param name Element's name, child elements will append suffixes for their own names.
  58619. * @param urlsOrVideo defines the url(s) or the video element to use
  58620. * @param options An object containing optional or exposed sub element properties
  58621. */
  58622. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  58623. resolution?: number;
  58624. clickToPlay?: boolean;
  58625. autoPlay?: boolean;
  58626. loop?: boolean;
  58627. size?: number;
  58628. poster?: string;
  58629. faceForward?: boolean;
  58630. useDirectMapping?: boolean;
  58631. halfDomeMode?: boolean;
  58632. }, scene: Scene);
  58633. private _changeVideoMode;
  58634. /**
  58635. * Releases resources associated with this node.
  58636. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58637. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58638. */
  58639. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58640. }
  58641. }
  58642. declare module "babylonjs/Helpers/index" {
  58643. export * from "babylonjs/Helpers/environmentHelper";
  58644. export * from "babylonjs/Helpers/photoDome";
  58645. export * from "babylonjs/Helpers/sceneHelpers";
  58646. export * from "babylonjs/Helpers/videoDome";
  58647. }
  58648. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  58649. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  58650. import { IDisposable } from "babylonjs/scene";
  58651. import { Engine } from "babylonjs/Engines/engine";
  58652. /**
  58653. * This class can be used to get instrumentation data from a Babylon engine
  58654. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58655. */
  58656. export class EngineInstrumentation implements IDisposable {
  58657. /**
  58658. * Define the instrumented engine.
  58659. */
  58660. engine: Engine;
  58661. private _captureGPUFrameTime;
  58662. private _gpuFrameTimeToken;
  58663. private _gpuFrameTime;
  58664. private _captureShaderCompilationTime;
  58665. private _shaderCompilationTime;
  58666. private _onBeginFrameObserver;
  58667. private _onEndFrameObserver;
  58668. private _onBeforeShaderCompilationObserver;
  58669. private _onAfterShaderCompilationObserver;
  58670. /**
  58671. * Gets the perf counter used for GPU frame time
  58672. */
  58673. get gpuFrameTimeCounter(): PerfCounter;
  58674. /**
  58675. * Gets the GPU frame time capture status
  58676. */
  58677. get captureGPUFrameTime(): boolean;
  58678. /**
  58679. * Enable or disable the GPU frame time capture
  58680. */
  58681. set captureGPUFrameTime(value: boolean);
  58682. /**
  58683. * Gets the perf counter used for shader compilation time
  58684. */
  58685. get shaderCompilationTimeCounter(): PerfCounter;
  58686. /**
  58687. * Gets the shader compilation time capture status
  58688. */
  58689. get captureShaderCompilationTime(): boolean;
  58690. /**
  58691. * Enable or disable the shader compilation time capture
  58692. */
  58693. set captureShaderCompilationTime(value: boolean);
  58694. /**
  58695. * Instantiates a new engine instrumentation.
  58696. * This class can be used to get instrumentation data from a Babylon engine
  58697. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58698. * @param engine Defines the engine to instrument
  58699. */
  58700. constructor(
  58701. /**
  58702. * Define the instrumented engine.
  58703. */
  58704. engine: Engine);
  58705. /**
  58706. * Dispose and release associated resources.
  58707. */
  58708. dispose(): void;
  58709. }
  58710. }
  58711. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  58712. import { Scene, IDisposable } from "babylonjs/scene";
  58713. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  58714. /**
  58715. * This class can be used to get instrumentation data from a Babylon engine
  58716. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58717. */
  58718. export class SceneInstrumentation implements IDisposable {
  58719. /**
  58720. * Defines the scene to instrument
  58721. */
  58722. scene: Scene;
  58723. private _captureActiveMeshesEvaluationTime;
  58724. private _activeMeshesEvaluationTime;
  58725. private _captureRenderTargetsRenderTime;
  58726. private _renderTargetsRenderTime;
  58727. private _captureFrameTime;
  58728. private _frameTime;
  58729. private _captureRenderTime;
  58730. private _renderTime;
  58731. private _captureInterFrameTime;
  58732. private _interFrameTime;
  58733. private _captureParticlesRenderTime;
  58734. private _particlesRenderTime;
  58735. private _captureSpritesRenderTime;
  58736. private _spritesRenderTime;
  58737. private _capturePhysicsTime;
  58738. private _physicsTime;
  58739. private _captureAnimationsTime;
  58740. private _animationsTime;
  58741. private _captureCameraRenderTime;
  58742. private _cameraRenderTime;
  58743. private _onBeforeActiveMeshesEvaluationObserver;
  58744. private _onAfterActiveMeshesEvaluationObserver;
  58745. private _onBeforeRenderTargetsRenderObserver;
  58746. private _onAfterRenderTargetsRenderObserver;
  58747. private _onAfterRenderObserver;
  58748. private _onBeforeDrawPhaseObserver;
  58749. private _onAfterDrawPhaseObserver;
  58750. private _onBeforeAnimationsObserver;
  58751. private _onBeforeParticlesRenderingObserver;
  58752. private _onAfterParticlesRenderingObserver;
  58753. private _onBeforeSpritesRenderingObserver;
  58754. private _onAfterSpritesRenderingObserver;
  58755. private _onBeforePhysicsObserver;
  58756. private _onAfterPhysicsObserver;
  58757. private _onAfterAnimationsObserver;
  58758. private _onBeforeCameraRenderObserver;
  58759. private _onAfterCameraRenderObserver;
  58760. /**
  58761. * Gets the perf counter used for active meshes evaluation time
  58762. */
  58763. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  58764. /**
  58765. * Gets the active meshes evaluation time capture status
  58766. */
  58767. get captureActiveMeshesEvaluationTime(): boolean;
  58768. /**
  58769. * Enable or disable the active meshes evaluation time capture
  58770. */
  58771. set captureActiveMeshesEvaluationTime(value: boolean);
  58772. /**
  58773. * Gets the perf counter used for render targets render time
  58774. */
  58775. get renderTargetsRenderTimeCounter(): PerfCounter;
  58776. /**
  58777. * Gets the render targets render time capture status
  58778. */
  58779. get captureRenderTargetsRenderTime(): boolean;
  58780. /**
  58781. * Enable or disable the render targets render time capture
  58782. */
  58783. set captureRenderTargetsRenderTime(value: boolean);
  58784. /**
  58785. * Gets the perf counter used for particles render time
  58786. */
  58787. get particlesRenderTimeCounter(): PerfCounter;
  58788. /**
  58789. * Gets the particles render time capture status
  58790. */
  58791. get captureParticlesRenderTime(): boolean;
  58792. /**
  58793. * Enable or disable the particles render time capture
  58794. */
  58795. set captureParticlesRenderTime(value: boolean);
  58796. /**
  58797. * Gets the perf counter used for sprites render time
  58798. */
  58799. get spritesRenderTimeCounter(): PerfCounter;
  58800. /**
  58801. * Gets the sprites render time capture status
  58802. */
  58803. get captureSpritesRenderTime(): boolean;
  58804. /**
  58805. * Enable or disable the sprites render time capture
  58806. */
  58807. set captureSpritesRenderTime(value: boolean);
  58808. /**
  58809. * Gets the perf counter used for physics time
  58810. */
  58811. get physicsTimeCounter(): PerfCounter;
  58812. /**
  58813. * Gets the physics time capture status
  58814. */
  58815. get capturePhysicsTime(): boolean;
  58816. /**
  58817. * Enable or disable the physics time capture
  58818. */
  58819. set capturePhysicsTime(value: boolean);
  58820. /**
  58821. * Gets the perf counter used for animations time
  58822. */
  58823. get animationsTimeCounter(): PerfCounter;
  58824. /**
  58825. * Gets the animations time capture status
  58826. */
  58827. get captureAnimationsTime(): boolean;
  58828. /**
  58829. * Enable or disable the animations time capture
  58830. */
  58831. set captureAnimationsTime(value: boolean);
  58832. /**
  58833. * Gets the perf counter used for frame time capture
  58834. */
  58835. get frameTimeCounter(): PerfCounter;
  58836. /**
  58837. * Gets the frame time capture status
  58838. */
  58839. get captureFrameTime(): boolean;
  58840. /**
  58841. * Enable or disable the frame time capture
  58842. */
  58843. set captureFrameTime(value: boolean);
  58844. /**
  58845. * Gets the perf counter used for inter-frames time capture
  58846. */
  58847. get interFrameTimeCounter(): PerfCounter;
  58848. /**
  58849. * Gets the inter-frames time capture status
  58850. */
  58851. get captureInterFrameTime(): boolean;
  58852. /**
  58853. * Enable or disable the inter-frames time capture
  58854. */
  58855. set captureInterFrameTime(value: boolean);
  58856. /**
  58857. * Gets the perf counter used for render time capture
  58858. */
  58859. get renderTimeCounter(): PerfCounter;
  58860. /**
  58861. * Gets the render time capture status
  58862. */
  58863. get captureRenderTime(): boolean;
  58864. /**
  58865. * Enable or disable the render time capture
  58866. */
  58867. set captureRenderTime(value: boolean);
  58868. /**
  58869. * Gets the perf counter used for camera render time capture
  58870. */
  58871. get cameraRenderTimeCounter(): PerfCounter;
  58872. /**
  58873. * Gets the camera render time capture status
  58874. */
  58875. get captureCameraRenderTime(): boolean;
  58876. /**
  58877. * Enable or disable the camera render time capture
  58878. */
  58879. set captureCameraRenderTime(value: boolean);
  58880. /**
  58881. * Gets the perf counter used for draw calls
  58882. */
  58883. get drawCallsCounter(): PerfCounter;
  58884. /**
  58885. * Instantiates a new scene instrumentation.
  58886. * This class can be used to get instrumentation data from a Babylon engine
  58887. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58888. * @param scene Defines the scene to instrument
  58889. */
  58890. constructor(
  58891. /**
  58892. * Defines the scene to instrument
  58893. */
  58894. scene: Scene);
  58895. /**
  58896. * Dispose and release associated resources.
  58897. */
  58898. dispose(): void;
  58899. }
  58900. }
  58901. declare module "babylonjs/Instrumentation/index" {
  58902. export * from "babylonjs/Instrumentation/engineInstrumentation";
  58903. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  58904. export * from "babylonjs/Instrumentation/timeToken";
  58905. }
  58906. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  58907. /** @hidden */
  58908. export var glowMapGenerationPixelShader: {
  58909. name: string;
  58910. shader: string;
  58911. };
  58912. }
  58913. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  58914. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58915. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58916. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58917. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58918. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58919. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58920. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58921. /** @hidden */
  58922. export var glowMapGenerationVertexShader: {
  58923. name: string;
  58924. shader: string;
  58925. };
  58926. }
  58927. declare module "babylonjs/Layers/effectLayer" {
  58928. import { Observable } from "babylonjs/Misc/observable";
  58929. import { Nullable } from "babylonjs/types";
  58930. import { Camera } from "babylonjs/Cameras/camera";
  58931. import { Scene } from "babylonjs/scene";
  58932. import { ISize } from "babylonjs/Maths/math.size";
  58933. import { Color4 } from "babylonjs/Maths/math.color";
  58934. import { Engine } from "babylonjs/Engines/engine";
  58935. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58937. import { Mesh } from "babylonjs/Meshes/mesh";
  58938. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58939. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58940. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58941. import { Effect } from "babylonjs/Materials/effect";
  58942. import { Material } from "babylonjs/Materials/material";
  58943. import "babylonjs/Shaders/glowMapGeneration.fragment";
  58944. import "babylonjs/Shaders/glowMapGeneration.vertex";
  58945. /**
  58946. * Effect layer options. This helps customizing the behaviour
  58947. * of the effect layer.
  58948. */
  58949. export interface IEffectLayerOptions {
  58950. /**
  58951. * Multiplication factor apply to the canvas size to compute the render target size
  58952. * used to generated the objects (the smaller the faster).
  58953. */
  58954. mainTextureRatio: number;
  58955. /**
  58956. * Enforces a fixed size texture to ensure effect stability across devices.
  58957. */
  58958. mainTextureFixedSize?: number;
  58959. /**
  58960. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58961. */
  58962. alphaBlendingMode: number;
  58963. /**
  58964. * The camera attached to the layer.
  58965. */
  58966. camera: Nullable<Camera>;
  58967. /**
  58968. * The rendering group to draw the layer in.
  58969. */
  58970. renderingGroupId: number;
  58971. }
  58972. /**
  58973. * The effect layer Helps adding post process effect blended with the main pass.
  58974. *
  58975. * This can be for instance use to generate glow or higlight effects on the scene.
  58976. *
  58977. * The effect layer class can not be used directly and is intented to inherited from to be
  58978. * customized per effects.
  58979. */
  58980. export abstract class EffectLayer {
  58981. private _vertexBuffers;
  58982. private _indexBuffer;
  58983. private _cachedDefines;
  58984. private _effectLayerMapGenerationEffect;
  58985. private _effectLayerOptions;
  58986. private _mergeEffect;
  58987. protected _scene: Scene;
  58988. protected _engine: Engine;
  58989. protected _maxSize: number;
  58990. protected _mainTextureDesiredSize: ISize;
  58991. protected _mainTexture: RenderTargetTexture;
  58992. protected _shouldRender: boolean;
  58993. protected _postProcesses: PostProcess[];
  58994. protected _textures: BaseTexture[];
  58995. protected _emissiveTextureAndColor: {
  58996. texture: Nullable<BaseTexture>;
  58997. color: Color4;
  58998. };
  58999. /**
  59000. * The name of the layer
  59001. */
  59002. name: string;
  59003. /**
  59004. * The clear color of the texture used to generate the glow map.
  59005. */
  59006. neutralColor: Color4;
  59007. /**
  59008. * Specifies whether the highlight layer is enabled or not.
  59009. */
  59010. isEnabled: boolean;
  59011. /**
  59012. * Gets the camera attached to the layer.
  59013. */
  59014. get camera(): Nullable<Camera>;
  59015. /**
  59016. * Gets the rendering group id the layer should render in.
  59017. */
  59018. get renderingGroupId(): number;
  59019. set renderingGroupId(renderingGroupId: number);
  59020. /**
  59021. * An event triggered when the effect layer has been disposed.
  59022. */
  59023. onDisposeObservable: Observable<EffectLayer>;
  59024. /**
  59025. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59026. */
  59027. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59028. /**
  59029. * An event triggered when the generated texture is being merged in the scene.
  59030. */
  59031. onBeforeComposeObservable: Observable<EffectLayer>;
  59032. /**
  59033. * An event triggered when the mesh is rendered into the effect render target.
  59034. */
  59035. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59036. /**
  59037. * An event triggered after the mesh has been rendered into the effect render target.
  59038. */
  59039. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59040. /**
  59041. * An event triggered when the generated texture has been merged in the scene.
  59042. */
  59043. onAfterComposeObservable: Observable<EffectLayer>;
  59044. /**
  59045. * An event triggered when the efffect layer changes its size.
  59046. */
  59047. onSizeChangedObservable: Observable<EffectLayer>;
  59048. /** @hidden */
  59049. static _SceneComponentInitialization: (scene: Scene) => void;
  59050. /**
  59051. * Instantiates a new effect Layer and references it in the scene.
  59052. * @param name The name of the layer
  59053. * @param scene The scene to use the layer in
  59054. */
  59055. constructor(
  59056. /** The Friendly of the effect in the scene */
  59057. name: string, scene: Scene);
  59058. /**
  59059. * Get the effect name of the layer.
  59060. * @return The effect name
  59061. */
  59062. abstract getEffectName(): string;
  59063. /**
  59064. * Checks for the readiness of the element composing the layer.
  59065. * @param subMesh the mesh to check for
  59066. * @param useInstances specify whether or not to use instances to render the mesh
  59067. * @return true if ready otherwise, false
  59068. */
  59069. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59070. /**
  59071. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59072. * @returns true if the effect requires stencil during the main canvas render pass.
  59073. */
  59074. abstract needStencil(): boolean;
  59075. /**
  59076. * Create the merge effect. This is the shader use to blit the information back
  59077. * to the main canvas at the end of the scene rendering.
  59078. * @returns The effect containing the shader used to merge the effect on the main canvas
  59079. */
  59080. protected abstract _createMergeEffect(): Effect;
  59081. /**
  59082. * Creates the render target textures and post processes used in the effect layer.
  59083. */
  59084. protected abstract _createTextureAndPostProcesses(): void;
  59085. /**
  59086. * Implementation specific of rendering the generating effect on the main canvas.
  59087. * @param effect The effect used to render through
  59088. */
  59089. protected abstract _internalRender(effect: Effect): void;
  59090. /**
  59091. * Sets the required values for both the emissive texture and and the main color.
  59092. */
  59093. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59094. /**
  59095. * Free any resources and references associated to a mesh.
  59096. * Internal use
  59097. * @param mesh The mesh to free.
  59098. */
  59099. abstract _disposeMesh(mesh: Mesh): void;
  59100. /**
  59101. * Serializes this layer (Glow or Highlight for example)
  59102. * @returns a serialized layer object
  59103. */
  59104. abstract serialize?(): any;
  59105. /**
  59106. * Initializes the effect layer with the required options.
  59107. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59108. */
  59109. protected _init(options: Partial<IEffectLayerOptions>): void;
  59110. /**
  59111. * Generates the index buffer of the full screen quad blending to the main canvas.
  59112. */
  59113. private _generateIndexBuffer;
  59114. /**
  59115. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59116. */
  59117. private _generateVertexBuffer;
  59118. /**
  59119. * Sets the main texture desired size which is the closest power of two
  59120. * of the engine canvas size.
  59121. */
  59122. private _setMainTextureSize;
  59123. /**
  59124. * Creates the main texture for the effect layer.
  59125. */
  59126. protected _createMainTexture(): void;
  59127. /**
  59128. * Adds specific effects defines.
  59129. * @param defines The defines to add specifics to.
  59130. */
  59131. protected _addCustomEffectDefines(defines: string[]): void;
  59132. /**
  59133. * Checks for the readiness of the element composing the layer.
  59134. * @param subMesh the mesh to check for
  59135. * @param useInstances specify whether or not to use instances to render the mesh
  59136. * @param emissiveTexture the associated emissive texture used to generate the glow
  59137. * @return true if ready otherwise, false
  59138. */
  59139. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59140. /**
  59141. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59142. */
  59143. render(): void;
  59144. /**
  59145. * Determine if a given mesh will be used in the current effect.
  59146. * @param mesh mesh to test
  59147. * @returns true if the mesh will be used
  59148. */
  59149. hasMesh(mesh: AbstractMesh): boolean;
  59150. /**
  59151. * Returns true if the layer contains information to display, otherwise false.
  59152. * @returns true if the glow layer should be rendered
  59153. */
  59154. shouldRender(): boolean;
  59155. /**
  59156. * Returns true if the mesh should render, otherwise false.
  59157. * @param mesh The mesh to render
  59158. * @returns true if it should render otherwise false
  59159. */
  59160. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59161. /**
  59162. * Returns true if the mesh can be rendered, otherwise false.
  59163. * @param mesh The mesh to render
  59164. * @param material The material used on the mesh
  59165. * @returns true if it can be rendered otherwise false
  59166. */
  59167. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59168. /**
  59169. * Returns true if the mesh should render, otherwise false.
  59170. * @param mesh The mesh to render
  59171. * @returns true if it should render otherwise false
  59172. */
  59173. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59174. /**
  59175. * Renders the submesh passed in parameter to the generation map.
  59176. */
  59177. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59178. /**
  59179. * Defines whether the current material of the mesh should be use to render the effect.
  59180. * @param mesh defines the current mesh to render
  59181. */
  59182. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59183. /**
  59184. * Rebuild the required buffers.
  59185. * @hidden Internal use only.
  59186. */
  59187. _rebuild(): void;
  59188. /**
  59189. * Dispose only the render target textures and post process.
  59190. */
  59191. private _disposeTextureAndPostProcesses;
  59192. /**
  59193. * Dispose the highlight layer and free resources.
  59194. */
  59195. dispose(): void;
  59196. /**
  59197. * Gets the class name of the effect layer
  59198. * @returns the string with the class name of the effect layer
  59199. */
  59200. getClassName(): string;
  59201. /**
  59202. * Creates an effect layer from parsed effect layer data
  59203. * @param parsedEffectLayer defines effect layer data
  59204. * @param scene defines the current scene
  59205. * @param rootUrl defines the root URL containing the effect layer information
  59206. * @returns a parsed effect Layer
  59207. */
  59208. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59209. }
  59210. }
  59211. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  59212. import { Scene } from "babylonjs/scene";
  59213. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  59214. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59215. import { AbstractScene } from "babylonjs/abstractScene";
  59216. module "babylonjs/abstractScene" {
  59217. interface AbstractScene {
  59218. /**
  59219. * The list of effect layers (highlights/glow) added to the scene
  59220. * @see http://doc.babylonjs.com/how_to/highlight_layer
  59221. * @see http://doc.babylonjs.com/how_to/glow_layer
  59222. */
  59223. effectLayers: Array<EffectLayer>;
  59224. /**
  59225. * Removes the given effect layer from this scene.
  59226. * @param toRemove defines the effect layer to remove
  59227. * @returns the index of the removed effect layer
  59228. */
  59229. removeEffectLayer(toRemove: EffectLayer): number;
  59230. /**
  59231. * Adds the given effect layer to this scene
  59232. * @param newEffectLayer defines the effect layer to add
  59233. */
  59234. addEffectLayer(newEffectLayer: EffectLayer): void;
  59235. }
  59236. }
  59237. /**
  59238. * Defines the layer scene component responsible to manage any effect layers
  59239. * in a given scene.
  59240. */
  59241. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59242. /**
  59243. * The component name helpfull to identify the component in the list of scene components.
  59244. */
  59245. readonly name: string;
  59246. /**
  59247. * The scene the component belongs to.
  59248. */
  59249. scene: Scene;
  59250. private _engine;
  59251. private _renderEffects;
  59252. private _needStencil;
  59253. private _previousStencilState;
  59254. /**
  59255. * Creates a new instance of the component for the given scene
  59256. * @param scene Defines the scene to register the component in
  59257. */
  59258. constructor(scene: Scene);
  59259. /**
  59260. * Registers the component in a given scene
  59261. */
  59262. register(): void;
  59263. /**
  59264. * Rebuilds the elements related to this component in case of
  59265. * context lost for instance.
  59266. */
  59267. rebuild(): void;
  59268. /**
  59269. * Serializes the component data to the specified json object
  59270. * @param serializationObject The object to serialize to
  59271. */
  59272. serialize(serializationObject: any): void;
  59273. /**
  59274. * Adds all the elements from the container to the scene
  59275. * @param container the container holding the elements
  59276. */
  59277. addFromContainer(container: AbstractScene): void;
  59278. /**
  59279. * Removes all the elements in the container from the scene
  59280. * @param container contains the elements to remove
  59281. * @param dispose if the removed element should be disposed (default: false)
  59282. */
  59283. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59284. /**
  59285. * Disposes the component and the associated ressources.
  59286. */
  59287. dispose(): void;
  59288. private _isReadyForMesh;
  59289. private _renderMainTexture;
  59290. private _setStencil;
  59291. private _setStencilBack;
  59292. private _draw;
  59293. private _drawCamera;
  59294. private _drawRenderingGroup;
  59295. }
  59296. }
  59297. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  59298. /** @hidden */
  59299. export var glowMapMergePixelShader: {
  59300. name: string;
  59301. shader: string;
  59302. };
  59303. }
  59304. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  59305. /** @hidden */
  59306. export var glowMapMergeVertexShader: {
  59307. name: string;
  59308. shader: string;
  59309. };
  59310. }
  59311. declare module "babylonjs/Layers/glowLayer" {
  59312. import { Nullable } from "babylonjs/types";
  59313. import { Camera } from "babylonjs/Cameras/camera";
  59314. import { Scene } from "babylonjs/scene";
  59315. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59317. import { Mesh } from "babylonjs/Meshes/mesh";
  59318. import { Texture } from "babylonjs/Materials/Textures/texture";
  59319. import { Effect } from "babylonjs/Materials/effect";
  59320. import { Material } from "babylonjs/Materials/material";
  59321. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59322. import { Color4 } from "babylonjs/Maths/math.color";
  59323. import "babylonjs/Shaders/glowMapMerge.fragment";
  59324. import "babylonjs/Shaders/glowMapMerge.vertex";
  59325. import "babylonjs/Layers/effectLayerSceneComponent";
  59326. module "babylonjs/abstractScene" {
  59327. interface AbstractScene {
  59328. /**
  59329. * Return a the first highlight layer of the scene with a given name.
  59330. * @param name The name of the highlight layer to look for.
  59331. * @return The highlight layer if found otherwise null.
  59332. */
  59333. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59334. }
  59335. }
  59336. /**
  59337. * Glow layer options. This helps customizing the behaviour
  59338. * of the glow layer.
  59339. */
  59340. export interface IGlowLayerOptions {
  59341. /**
  59342. * Multiplication factor apply to the canvas size to compute the render target size
  59343. * used to generated the glowing objects (the smaller the faster).
  59344. */
  59345. mainTextureRatio: number;
  59346. /**
  59347. * Enforces a fixed size texture to ensure resize independant blur.
  59348. */
  59349. mainTextureFixedSize?: number;
  59350. /**
  59351. * How big is the kernel of the blur texture.
  59352. */
  59353. blurKernelSize: number;
  59354. /**
  59355. * The camera attached to the layer.
  59356. */
  59357. camera: Nullable<Camera>;
  59358. /**
  59359. * Enable MSAA by chosing the number of samples.
  59360. */
  59361. mainTextureSamples?: number;
  59362. /**
  59363. * The rendering group to draw the layer in.
  59364. */
  59365. renderingGroupId: number;
  59366. }
  59367. /**
  59368. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59369. *
  59370. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59371. *
  59372. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59373. */
  59374. export class GlowLayer extends EffectLayer {
  59375. /**
  59376. * Effect Name of the layer.
  59377. */
  59378. static readonly EffectName: string;
  59379. /**
  59380. * The default blur kernel size used for the glow.
  59381. */
  59382. static DefaultBlurKernelSize: number;
  59383. /**
  59384. * The default texture size ratio used for the glow.
  59385. */
  59386. static DefaultTextureRatio: number;
  59387. /**
  59388. * Sets the kernel size of the blur.
  59389. */
  59390. set blurKernelSize(value: number);
  59391. /**
  59392. * Gets the kernel size of the blur.
  59393. */
  59394. get blurKernelSize(): number;
  59395. /**
  59396. * Sets the glow intensity.
  59397. */
  59398. set intensity(value: number);
  59399. /**
  59400. * Gets the glow intensity.
  59401. */
  59402. get intensity(): number;
  59403. private _options;
  59404. private _intensity;
  59405. private _horizontalBlurPostprocess1;
  59406. private _verticalBlurPostprocess1;
  59407. private _horizontalBlurPostprocess2;
  59408. private _verticalBlurPostprocess2;
  59409. private _blurTexture1;
  59410. private _blurTexture2;
  59411. private _postProcesses1;
  59412. private _postProcesses2;
  59413. private _includedOnlyMeshes;
  59414. private _excludedMeshes;
  59415. private _meshesUsingTheirOwnMaterials;
  59416. /**
  59417. * Callback used to let the user override the color selection on a per mesh basis
  59418. */
  59419. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59420. /**
  59421. * Callback used to let the user override the texture selection on a per mesh basis
  59422. */
  59423. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59424. /**
  59425. * Instantiates a new glow Layer and references it to the scene.
  59426. * @param name The name of the layer
  59427. * @param scene The scene to use the layer in
  59428. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59429. */
  59430. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59431. /**
  59432. * Get the effect name of the layer.
  59433. * @return The effect name
  59434. */
  59435. getEffectName(): string;
  59436. /**
  59437. * Create the merge effect. This is the shader use to blit the information back
  59438. * to the main canvas at the end of the scene rendering.
  59439. */
  59440. protected _createMergeEffect(): Effect;
  59441. /**
  59442. * Creates the render target textures and post processes used in the glow layer.
  59443. */
  59444. protected _createTextureAndPostProcesses(): void;
  59445. /**
  59446. * Checks for the readiness of the element composing the layer.
  59447. * @param subMesh the mesh to check for
  59448. * @param useInstances specify wether or not to use instances to render the mesh
  59449. * @param emissiveTexture the associated emissive texture used to generate the glow
  59450. * @return true if ready otherwise, false
  59451. */
  59452. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59453. /**
  59454. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59455. */
  59456. needStencil(): boolean;
  59457. /**
  59458. * Returns true if the mesh can be rendered, otherwise false.
  59459. * @param mesh The mesh to render
  59460. * @param material The material used on the mesh
  59461. * @returns true if it can be rendered otherwise false
  59462. */
  59463. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59464. /**
  59465. * Implementation specific of rendering the generating effect on the main canvas.
  59466. * @param effect The effect used to render through
  59467. */
  59468. protected _internalRender(effect: Effect): void;
  59469. /**
  59470. * Sets the required values for both the emissive texture and and the main color.
  59471. */
  59472. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59473. /**
  59474. * Returns true if the mesh should render, otherwise false.
  59475. * @param mesh The mesh to render
  59476. * @returns true if it should render otherwise false
  59477. */
  59478. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59479. /**
  59480. * Adds specific effects defines.
  59481. * @param defines The defines to add specifics to.
  59482. */
  59483. protected _addCustomEffectDefines(defines: string[]): void;
  59484. /**
  59485. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59486. * @param mesh The mesh to exclude from the glow layer
  59487. */
  59488. addExcludedMesh(mesh: Mesh): void;
  59489. /**
  59490. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59491. * @param mesh The mesh to remove
  59492. */
  59493. removeExcludedMesh(mesh: Mesh): void;
  59494. /**
  59495. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59496. * @param mesh The mesh to include in the glow layer
  59497. */
  59498. addIncludedOnlyMesh(mesh: Mesh): void;
  59499. /**
  59500. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59501. * @param mesh The mesh to remove
  59502. */
  59503. removeIncludedOnlyMesh(mesh: Mesh): void;
  59504. /**
  59505. * Determine if a given mesh will be used in the glow layer
  59506. * @param mesh The mesh to test
  59507. * @returns true if the mesh will be highlighted by the current glow layer
  59508. */
  59509. hasMesh(mesh: AbstractMesh): boolean;
  59510. /**
  59511. * Defines whether the current material of the mesh should be use to render the effect.
  59512. * @param mesh defines the current mesh to render
  59513. */
  59514. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59515. /**
  59516. * Add a mesh to be rendered through its own material and not with emissive only.
  59517. * @param mesh The mesh for which we need to use its material
  59518. */
  59519. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59520. /**
  59521. * Remove a mesh from being rendered through its own material and not with emissive only.
  59522. * @param mesh The mesh for which we need to not use its material
  59523. */
  59524. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59525. /**
  59526. * Free any resources and references associated to a mesh.
  59527. * Internal use
  59528. * @param mesh The mesh to free.
  59529. * @hidden
  59530. */
  59531. _disposeMesh(mesh: Mesh): void;
  59532. /**
  59533. * Gets the class name of the effect layer
  59534. * @returns the string with the class name of the effect layer
  59535. */
  59536. getClassName(): string;
  59537. /**
  59538. * Serializes this glow layer
  59539. * @returns a serialized glow layer object
  59540. */
  59541. serialize(): any;
  59542. /**
  59543. * Creates a Glow Layer from parsed glow layer data
  59544. * @param parsedGlowLayer defines glow layer data
  59545. * @param scene defines the current scene
  59546. * @param rootUrl defines the root URL containing the glow layer information
  59547. * @returns a parsed Glow Layer
  59548. */
  59549. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59550. }
  59551. }
  59552. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  59553. /** @hidden */
  59554. export var glowBlurPostProcessPixelShader: {
  59555. name: string;
  59556. shader: string;
  59557. };
  59558. }
  59559. declare module "babylonjs/Layers/highlightLayer" {
  59560. import { Observable } from "babylonjs/Misc/observable";
  59561. import { Nullable } from "babylonjs/types";
  59562. import { Camera } from "babylonjs/Cameras/camera";
  59563. import { Scene } from "babylonjs/scene";
  59564. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59566. import { Mesh } from "babylonjs/Meshes/mesh";
  59567. import { Effect } from "babylonjs/Materials/effect";
  59568. import { Material } from "babylonjs/Materials/material";
  59569. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59570. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59571. import "babylonjs/Shaders/glowMapMerge.fragment";
  59572. import "babylonjs/Shaders/glowMapMerge.vertex";
  59573. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  59574. module "babylonjs/abstractScene" {
  59575. interface AbstractScene {
  59576. /**
  59577. * Return a the first highlight layer of the scene with a given name.
  59578. * @param name The name of the highlight layer to look for.
  59579. * @return The highlight layer if found otherwise null.
  59580. */
  59581. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59582. }
  59583. }
  59584. /**
  59585. * Highlight layer options. This helps customizing the behaviour
  59586. * of the highlight layer.
  59587. */
  59588. export interface IHighlightLayerOptions {
  59589. /**
  59590. * Multiplication factor apply to the canvas size to compute the render target size
  59591. * used to generated the glowing objects (the smaller the faster).
  59592. */
  59593. mainTextureRatio: number;
  59594. /**
  59595. * Enforces a fixed size texture to ensure resize independant blur.
  59596. */
  59597. mainTextureFixedSize?: number;
  59598. /**
  59599. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59600. * of the picture to blur (the smaller the faster).
  59601. */
  59602. blurTextureSizeRatio: number;
  59603. /**
  59604. * How big in texel of the blur texture is the vertical blur.
  59605. */
  59606. blurVerticalSize: number;
  59607. /**
  59608. * How big in texel of the blur texture is the horizontal blur.
  59609. */
  59610. blurHorizontalSize: number;
  59611. /**
  59612. * Alpha blending mode used to apply the blur. Default is combine.
  59613. */
  59614. alphaBlendingMode: number;
  59615. /**
  59616. * The camera attached to the layer.
  59617. */
  59618. camera: Nullable<Camera>;
  59619. /**
  59620. * Should we display highlight as a solid stroke?
  59621. */
  59622. isStroke?: boolean;
  59623. /**
  59624. * The rendering group to draw the layer in.
  59625. */
  59626. renderingGroupId: number;
  59627. }
  59628. /**
  59629. * The highlight layer Helps adding a glow effect around a mesh.
  59630. *
  59631. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59632. * glowy meshes to your scene.
  59633. *
  59634. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59635. */
  59636. export class HighlightLayer extends EffectLayer {
  59637. name: string;
  59638. /**
  59639. * Effect Name of the highlight layer.
  59640. */
  59641. static readonly EffectName: string;
  59642. /**
  59643. * The neutral color used during the preparation of the glow effect.
  59644. * This is black by default as the blend operation is a blend operation.
  59645. */
  59646. static NeutralColor: Color4;
  59647. /**
  59648. * Stencil value used for glowing meshes.
  59649. */
  59650. static GlowingMeshStencilReference: number;
  59651. /**
  59652. * Stencil value used for the other meshes in the scene.
  59653. */
  59654. static NormalMeshStencilReference: number;
  59655. /**
  59656. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59657. */
  59658. innerGlow: boolean;
  59659. /**
  59660. * Specifies whether or not the outer glow is ACTIVE in the layer.
  59661. */
  59662. outerGlow: boolean;
  59663. /**
  59664. * Specifies the horizontal size of the blur.
  59665. */
  59666. set blurHorizontalSize(value: number);
  59667. /**
  59668. * Specifies the vertical size of the blur.
  59669. */
  59670. set blurVerticalSize(value: number);
  59671. /**
  59672. * Gets the horizontal size of the blur.
  59673. */
  59674. get blurHorizontalSize(): number;
  59675. /**
  59676. * Gets the vertical size of the blur.
  59677. */
  59678. get blurVerticalSize(): number;
  59679. /**
  59680. * An event triggered when the highlight layer is being blurred.
  59681. */
  59682. onBeforeBlurObservable: Observable<HighlightLayer>;
  59683. /**
  59684. * An event triggered when the highlight layer has been blurred.
  59685. */
  59686. onAfterBlurObservable: Observable<HighlightLayer>;
  59687. private _instanceGlowingMeshStencilReference;
  59688. private _options;
  59689. private _downSamplePostprocess;
  59690. private _horizontalBlurPostprocess;
  59691. private _verticalBlurPostprocess;
  59692. private _blurTexture;
  59693. private _meshes;
  59694. private _excludedMeshes;
  59695. /**
  59696. * Instantiates a new highlight Layer and references it to the scene..
  59697. * @param name The name of the layer
  59698. * @param scene The scene to use the layer in
  59699. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  59700. */
  59701. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  59702. /**
  59703. * Get the effect name of the layer.
  59704. * @return The effect name
  59705. */
  59706. getEffectName(): string;
  59707. /**
  59708. * Create the merge effect. This is the shader use to blit the information back
  59709. * to the main canvas at the end of the scene rendering.
  59710. */
  59711. protected _createMergeEffect(): Effect;
  59712. /**
  59713. * Creates the render target textures and post processes used in the highlight layer.
  59714. */
  59715. protected _createTextureAndPostProcesses(): void;
  59716. /**
  59717. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  59718. */
  59719. needStencil(): boolean;
  59720. /**
  59721. * Checks for the readiness of the element composing the layer.
  59722. * @param subMesh the mesh to check for
  59723. * @param useInstances specify wether or not to use instances to render the mesh
  59724. * @param emissiveTexture the associated emissive texture used to generate the glow
  59725. * @return true if ready otherwise, false
  59726. */
  59727. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59728. /**
  59729. * Implementation specific of rendering the generating effect on the main canvas.
  59730. * @param effect The effect used to render through
  59731. */
  59732. protected _internalRender(effect: Effect): void;
  59733. /**
  59734. * Returns true if the layer contains information to display, otherwise false.
  59735. */
  59736. shouldRender(): boolean;
  59737. /**
  59738. * Returns true if the mesh should render, otherwise false.
  59739. * @param mesh The mesh to render
  59740. * @returns true if it should render otherwise false
  59741. */
  59742. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59743. /**
  59744. * Adds specific effects defines.
  59745. * @param defines The defines to add specifics to.
  59746. */
  59747. protected _addCustomEffectDefines(defines: string[]): void;
  59748. /**
  59749. * Sets the required values for both the emissive texture and and the main color.
  59750. */
  59751. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59752. /**
  59753. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  59754. * @param mesh The mesh to exclude from the highlight layer
  59755. */
  59756. addExcludedMesh(mesh: Mesh): void;
  59757. /**
  59758. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  59759. * @param mesh The mesh to highlight
  59760. */
  59761. removeExcludedMesh(mesh: Mesh): void;
  59762. /**
  59763. * Determine if a given mesh will be highlighted by the current HighlightLayer
  59764. * @param mesh mesh to test
  59765. * @returns true if the mesh will be highlighted by the current HighlightLayer
  59766. */
  59767. hasMesh(mesh: AbstractMesh): boolean;
  59768. /**
  59769. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  59770. * @param mesh The mesh to highlight
  59771. * @param color The color of the highlight
  59772. * @param glowEmissiveOnly Extract the glow from the emissive texture
  59773. */
  59774. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  59775. /**
  59776. * Remove a mesh from the highlight layer in order to make it stop glowing.
  59777. * @param mesh The mesh to highlight
  59778. */
  59779. removeMesh(mesh: Mesh): void;
  59780. /**
  59781. * Remove all the meshes currently referenced in the highlight layer
  59782. */
  59783. removeAllMeshes(): void;
  59784. /**
  59785. * Force the stencil to the normal expected value for none glowing parts
  59786. */
  59787. private _defaultStencilReference;
  59788. /**
  59789. * Free any resources and references associated to a mesh.
  59790. * Internal use
  59791. * @param mesh The mesh to free.
  59792. * @hidden
  59793. */
  59794. _disposeMesh(mesh: Mesh): void;
  59795. /**
  59796. * Dispose the highlight layer and free resources.
  59797. */
  59798. dispose(): void;
  59799. /**
  59800. * Gets the class name of the effect layer
  59801. * @returns the string with the class name of the effect layer
  59802. */
  59803. getClassName(): string;
  59804. /**
  59805. * Serializes this Highlight layer
  59806. * @returns a serialized Highlight layer object
  59807. */
  59808. serialize(): any;
  59809. /**
  59810. * Creates a Highlight layer from parsed Highlight layer data
  59811. * @param parsedHightlightLayer defines the Highlight layer data
  59812. * @param scene defines the current scene
  59813. * @param rootUrl defines the root URL containing the Highlight layer information
  59814. * @returns a parsed Highlight layer
  59815. */
  59816. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  59817. }
  59818. }
  59819. declare module "babylonjs/Layers/layerSceneComponent" {
  59820. import { Scene } from "babylonjs/scene";
  59821. import { ISceneComponent } from "babylonjs/sceneComponent";
  59822. import { Layer } from "babylonjs/Layers/layer";
  59823. import { AbstractScene } from "babylonjs/abstractScene";
  59824. module "babylonjs/abstractScene" {
  59825. interface AbstractScene {
  59826. /**
  59827. * The list of layers (background and foreground) of the scene
  59828. */
  59829. layers: Array<Layer>;
  59830. }
  59831. }
  59832. /**
  59833. * Defines the layer scene component responsible to manage any layers
  59834. * in a given scene.
  59835. */
  59836. export class LayerSceneComponent implements ISceneComponent {
  59837. /**
  59838. * The component name helpfull to identify the component in the list of scene components.
  59839. */
  59840. readonly name: string;
  59841. /**
  59842. * The scene the component belongs to.
  59843. */
  59844. scene: Scene;
  59845. private _engine;
  59846. /**
  59847. * Creates a new instance of the component for the given scene
  59848. * @param scene Defines the scene to register the component in
  59849. */
  59850. constructor(scene: Scene);
  59851. /**
  59852. * Registers the component in a given scene
  59853. */
  59854. register(): void;
  59855. /**
  59856. * Rebuilds the elements related to this component in case of
  59857. * context lost for instance.
  59858. */
  59859. rebuild(): void;
  59860. /**
  59861. * Disposes the component and the associated ressources.
  59862. */
  59863. dispose(): void;
  59864. private _draw;
  59865. private _drawCameraPredicate;
  59866. private _drawCameraBackground;
  59867. private _drawCameraForeground;
  59868. private _drawRenderTargetPredicate;
  59869. private _drawRenderTargetBackground;
  59870. private _drawRenderTargetForeground;
  59871. /**
  59872. * Adds all the elements from the container to the scene
  59873. * @param container the container holding the elements
  59874. */
  59875. addFromContainer(container: AbstractScene): void;
  59876. /**
  59877. * Removes all the elements in the container from the scene
  59878. * @param container contains the elements to remove
  59879. * @param dispose if the removed element should be disposed (default: false)
  59880. */
  59881. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59882. }
  59883. }
  59884. declare module "babylonjs/Shaders/layer.fragment" {
  59885. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59886. /** @hidden */
  59887. export var layerPixelShader: {
  59888. name: string;
  59889. shader: string;
  59890. };
  59891. }
  59892. declare module "babylonjs/Shaders/layer.vertex" {
  59893. /** @hidden */
  59894. export var layerVertexShader: {
  59895. name: string;
  59896. shader: string;
  59897. };
  59898. }
  59899. declare module "babylonjs/Layers/layer" {
  59900. import { Observable } from "babylonjs/Misc/observable";
  59901. import { Nullable } from "babylonjs/types";
  59902. import { Scene } from "babylonjs/scene";
  59903. import { Vector2 } from "babylonjs/Maths/math.vector";
  59904. import { Color4 } from "babylonjs/Maths/math.color";
  59905. import { Texture } from "babylonjs/Materials/Textures/texture";
  59906. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59907. import "babylonjs/Shaders/layer.fragment";
  59908. import "babylonjs/Shaders/layer.vertex";
  59909. /**
  59910. * This represents a full screen 2d layer.
  59911. * This can be useful to display a picture in the background of your scene for instance.
  59912. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59913. */
  59914. export class Layer {
  59915. /**
  59916. * Define the name of the layer.
  59917. */
  59918. name: string;
  59919. /**
  59920. * Define the texture the layer should display.
  59921. */
  59922. texture: Nullable<Texture>;
  59923. /**
  59924. * Is the layer in background or foreground.
  59925. */
  59926. isBackground: boolean;
  59927. /**
  59928. * Define the color of the layer (instead of texture).
  59929. */
  59930. color: Color4;
  59931. /**
  59932. * Define the scale of the layer in order to zoom in out of the texture.
  59933. */
  59934. scale: Vector2;
  59935. /**
  59936. * Define an offset for the layer in order to shift the texture.
  59937. */
  59938. offset: Vector2;
  59939. /**
  59940. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59941. */
  59942. alphaBlendingMode: number;
  59943. /**
  59944. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59945. * Alpha test will not mix with the background color in case of transparency.
  59946. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59947. */
  59948. alphaTest: boolean;
  59949. /**
  59950. * Define a mask to restrict the layer to only some of the scene cameras.
  59951. */
  59952. layerMask: number;
  59953. /**
  59954. * Define the list of render target the layer is visible into.
  59955. */
  59956. renderTargetTextures: RenderTargetTexture[];
  59957. /**
  59958. * Define if the layer is only used in renderTarget or if it also
  59959. * renders in the main frame buffer of the canvas.
  59960. */
  59961. renderOnlyInRenderTargetTextures: boolean;
  59962. private _scene;
  59963. private _vertexBuffers;
  59964. private _indexBuffer;
  59965. private _effect;
  59966. private _previousDefines;
  59967. /**
  59968. * An event triggered when the layer is disposed.
  59969. */
  59970. onDisposeObservable: Observable<Layer>;
  59971. private _onDisposeObserver;
  59972. /**
  59973. * Back compatibility with callback before the onDisposeObservable existed.
  59974. * The set callback will be triggered when the layer has been disposed.
  59975. */
  59976. set onDispose(callback: () => void);
  59977. /**
  59978. * An event triggered before rendering the scene
  59979. */
  59980. onBeforeRenderObservable: Observable<Layer>;
  59981. private _onBeforeRenderObserver;
  59982. /**
  59983. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59984. * The set callback will be triggered just before rendering the layer.
  59985. */
  59986. set onBeforeRender(callback: () => void);
  59987. /**
  59988. * An event triggered after rendering the scene
  59989. */
  59990. onAfterRenderObservable: Observable<Layer>;
  59991. private _onAfterRenderObserver;
  59992. /**
  59993. * Back compatibility with callback before the onAfterRenderObservable existed.
  59994. * The set callback will be triggered just after rendering the layer.
  59995. */
  59996. set onAfterRender(callback: () => void);
  59997. /**
  59998. * Instantiates a new layer.
  59999. * This represents a full screen 2d layer.
  60000. * This can be useful to display a picture in the background of your scene for instance.
  60001. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60002. * @param name Define the name of the layer in the scene
  60003. * @param imgUrl Define the url of the texture to display in the layer
  60004. * @param scene Define the scene the layer belongs to
  60005. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60006. * @param color Defines a color for the layer
  60007. */
  60008. constructor(
  60009. /**
  60010. * Define the name of the layer.
  60011. */
  60012. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60013. private _createIndexBuffer;
  60014. /** @hidden */
  60015. _rebuild(): void;
  60016. /**
  60017. * Renders the layer in the scene.
  60018. */
  60019. render(): void;
  60020. /**
  60021. * Disposes and releases the associated ressources.
  60022. */
  60023. dispose(): void;
  60024. }
  60025. }
  60026. declare module "babylonjs/Layers/index" {
  60027. export * from "babylonjs/Layers/effectLayer";
  60028. export * from "babylonjs/Layers/effectLayerSceneComponent";
  60029. export * from "babylonjs/Layers/glowLayer";
  60030. export * from "babylonjs/Layers/highlightLayer";
  60031. export * from "babylonjs/Layers/layer";
  60032. export * from "babylonjs/Layers/layerSceneComponent";
  60033. }
  60034. declare module "babylonjs/Shaders/lensFlare.fragment" {
  60035. /** @hidden */
  60036. export var lensFlarePixelShader: {
  60037. name: string;
  60038. shader: string;
  60039. };
  60040. }
  60041. declare module "babylonjs/Shaders/lensFlare.vertex" {
  60042. /** @hidden */
  60043. export var lensFlareVertexShader: {
  60044. name: string;
  60045. shader: string;
  60046. };
  60047. }
  60048. declare module "babylonjs/LensFlares/lensFlareSystem" {
  60049. import { Scene } from "babylonjs/scene";
  60050. import { Vector3 } from "babylonjs/Maths/math.vector";
  60051. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60052. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  60053. import "babylonjs/Shaders/lensFlare.fragment";
  60054. import "babylonjs/Shaders/lensFlare.vertex";
  60055. import { Viewport } from "babylonjs/Maths/math.viewport";
  60056. /**
  60057. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60058. * It is usually composed of several `lensFlare`.
  60059. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60060. */
  60061. export class LensFlareSystem {
  60062. /**
  60063. * Define the name of the lens flare system
  60064. */
  60065. name: string;
  60066. /**
  60067. * List of lens flares used in this system.
  60068. */
  60069. lensFlares: LensFlare[];
  60070. /**
  60071. * Define a limit from the border the lens flare can be visible.
  60072. */
  60073. borderLimit: number;
  60074. /**
  60075. * Define a viewport border we do not want to see the lens flare in.
  60076. */
  60077. viewportBorder: number;
  60078. /**
  60079. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60080. */
  60081. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60082. /**
  60083. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60084. */
  60085. layerMask: number;
  60086. /**
  60087. * Define the id of the lens flare system in the scene.
  60088. * (equal to name by default)
  60089. */
  60090. id: string;
  60091. private _scene;
  60092. private _emitter;
  60093. private _vertexBuffers;
  60094. private _indexBuffer;
  60095. private _effect;
  60096. private _positionX;
  60097. private _positionY;
  60098. private _isEnabled;
  60099. /** @hidden */
  60100. static _SceneComponentInitialization: (scene: Scene) => void;
  60101. /**
  60102. * Instantiates a lens flare system.
  60103. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60104. * It is usually composed of several `lensFlare`.
  60105. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60106. * @param name Define the name of the lens flare system in the scene
  60107. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60108. * @param scene Define the scene the lens flare system belongs to
  60109. */
  60110. constructor(
  60111. /**
  60112. * Define the name of the lens flare system
  60113. */
  60114. name: string, emitter: any, scene: Scene);
  60115. /**
  60116. * Define if the lens flare system is enabled.
  60117. */
  60118. get isEnabled(): boolean;
  60119. set isEnabled(value: boolean);
  60120. /**
  60121. * Get the scene the effects belongs to.
  60122. * @returns the scene holding the lens flare system
  60123. */
  60124. getScene(): Scene;
  60125. /**
  60126. * Get the emitter of the lens flare system.
  60127. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60128. * @returns the emitter of the lens flare system
  60129. */
  60130. getEmitter(): any;
  60131. /**
  60132. * Set the emitter of the lens flare system.
  60133. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60134. * @param newEmitter Define the new emitter of the system
  60135. */
  60136. setEmitter(newEmitter: any): void;
  60137. /**
  60138. * Get the lens flare system emitter position.
  60139. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60140. * @returns the position
  60141. */
  60142. getEmitterPosition(): Vector3;
  60143. /**
  60144. * @hidden
  60145. */
  60146. computeEffectivePosition(globalViewport: Viewport): boolean;
  60147. /** @hidden */
  60148. _isVisible(): boolean;
  60149. /**
  60150. * @hidden
  60151. */
  60152. render(): boolean;
  60153. /**
  60154. * Dispose and release the lens flare with its associated resources.
  60155. */
  60156. dispose(): void;
  60157. /**
  60158. * Parse a lens flare system from a JSON repressentation
  60159. * @param parsedLensFlareSystem Define the JSON to parse
  60160. * @param scene Define the scene the parsed system should be instantiated in
  60161. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60162. * @returns the parsed system
  60163. */
  60164. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60165. /**
  60166. * Serialize the current Lens Flare System into a JSON representation.
  60167. * @returns the serialized JSON
  60168. */
  60169. serialize(): any;
  60170. }
  60171. }
  60172. declare module "babylonjs/LensFlares/lensFlare" {
  60173. import { Nullable } from "babylonjs/types";
  60174. import { Color3 } from "babylonjs/Maths/math.color";
  60175. import { Texture } from "babylonjs/Materials/Textures/texture";
  60176. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60177. /**
  60178. * This represents one of the lens effect in a `lensFlareSystem`.
  60179. * It controls one of the indiviual texture used in the effect.
  60180. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60181. */
  60182. export class LensFlare {
  60183. /**
  60184. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60185. */
  60186. size: number;
  60187. /**
  60188. * 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.
  60189. */
  60190. position: number;
  60191. /**
  60192. * Define the lens color.
  60193. */
  60194. color: Color3;
  60195. /**
  60196. * Define the lens texture.
  60197. */
  60198. texture: Nullable<Texture>;
  60199. /**
  60200. * Define the alpha mode to render this particular lens.
  60201. */
  60202. alphaMode: number;
  60203. private _system;
  60204. /**
  60205. * Creates a new Lens Flare.
  60206. * This represents one of the lens effect in a `lensFlareSystem`.
  60207. * It controls one of the indiviual texture used in the effect.
  60208. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60209. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60210. * @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.
  60211. * @param color Define the lens color
  60212. * @param imgUrl Define the lens texture url
  60213. * @param system Define the `lensFlareSystem` this flare is part of
  60214. * @returns The newly created Lens Flare
  60215. */
  60216. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60217. /**
  60218. * Instantiates a new Lens Flare.
  60219. * This represents one of the lens effect in a `lensFlareSystem`.
  60220. * It controls one of the indiviual texture used in the effect.
  60221. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60222. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60223. * @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.
  60224. * @param color Define the lens color
  60225. * @param imgUrl Define the lens texture url
  60226. * @param system Define the `lensFlareSystem` this flare is part of
  60227. */
  60228. constructor(
  60229. /**
  60230. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60231. */
  60232. size: number,
  60233. /**
  60234. * 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.
  60235. */
  60236. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60237. /**
  60238. * Dispose and release the lens flare with its associated resources.
  60239. */
  60240. dispose(): void;
  60241. }
  60242. }
  60243. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  60244. import { Nullable } from "babylonjs/types";
  60245. import { Scene } from "babylonjs/scene";
  60246. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60247. import { AbstractScene } from "babylonjs/abstractScene";
  60248. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60249. module "babylonjs/abstractScene" {
  60250. interface AbstractScene {
  60251. /**
  60252. * The list of lens flare system added to the scene
  60253. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60254. */
  60255. lensFlareSystems: Array<LensFlareSystem>;
  60256. /**
  60257. * Removes the given lens flare system from this scene.
  60258. * @param toRemove The lens flare system to remove
  60259. * @returns The index of the removed lens flare system
  60260. */
  60261. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60262. /**
  60263. * Adds the given lens flare system to this scene
  60264. * @param newLensFlareSystem The lens flare system to add
  60265. */
  60266. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60267. /**
  60268. * Gets a lens flare system using its name
  60269. * @param name defines the name to look for
  60270. * @returns the lens flare system or null if not found
  60271. */
  60272. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60273. /**
  60274. * Gets a lens flare system using its id
  60275. * @param id defines the id to look for
  60276. * @returns the lens flare system or null if not found
  60277. */
  60278. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60279. }
  60280. }
  60281. /**
  60282. * Defines the lens flare scene component responsible to manage any lens flares
  60283. * in a given scene.
  60284. */
  60285. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60286. /**
  60287. * The component name helpfull to identify the component in the list of scene components.
  60288. */
  60289. readonly name: string;
  60290. /**
  60291. * The scene the component belongs to.
  60292. */
  60293. scene: Scene;
  60294. /**
  60295. * Creates a new instance of the component for the given scene
  60296. * @param scene Defines the scene to register the component in
  60297. */
  60298. constructor(scene: Scene);
  60299. /**
  60300. * Registers the component in a given scene
  60301. */
  60302. register(): void;
  60303. /**
  60304. * Rebuilds the elements related to this component in case of
  60305. * context lost for instance.
  60306. */
  60307. rebuild(): void;
  60308. /**
  60309. * Adds all the elements from the container to the scene
  60310. * @param container the container holding the elements
  60311. */
  60312. addFromContainer(container: AbstractScene): void;
  60313. /**
  60314. * Removes all the elements in the container from the scene
  60315. * @param container contains the elements to remove
  60316. * @param dispose if the removed element should be disposed (default: false)
  60317. */
  60318. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60319. /**
  60320. * Serializes the component data to the specified json object
  60321. * @param serializationObject The object to serialize to
  60322. */
  60323. serialize(serializationObject: any): void;
  60324. /**
  60325. * Disposes the component and the associated ressources.
  60326. */
  60327. dispose(): void;
  60328. private _draw;
  60329. }
  60330. }
  60331. declare module "babylonjs/LensFlares/index" {
  60332. export * from "babylonjs/LensFlares/lensFlare";
  60333. export * from "babylonjs/LensFlares/lensFlareSystem";
  60334. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  60335. }
  60336. declare module "babylonjs/Shaders/depth.fragment" {
  60337. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  60338. /** @hidden */
  60339. export var depthPixelShader: {
  60340. name: string;
  60341. shader: string;
  60342. };
  60343. }
  60344. declare module "babylonjs/Shaders/depth.vertex" {
  60345. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60346. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60347. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60348. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60349. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60350. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60351. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60352. /** @hidden */
  60353. export var depthVertexShader: {
  60354. name: string;
  60355. shader: string;
  60356. };
  60357. }
  60358. declare module "babylonjs/Rendering/depthRenderer" {
  60359. import { Nullable } from "babylonjs/types";
  60360. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60361. import { Scene } from "babylonjs/scene";
  60362. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60363. import { Camera } from "babylonjs/Cameras/camera";
  60364. import "babylonjs/Shaders/depth.fragment";
  60365. import "babylonjs/Shaders/depth.vertex";
  60366. /**
  60367. * This represents a depth renderer in Babylon.
  60368. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60369. */
  60370. export class DepthRenderer {
  60371. private _scene;
  60372. private _depthMap;
  60373. private _effect;
  60374. private readonly _storeNonLinearDepth;
  60375. private readonly _clearColor;
  60376. /** Get if the depth renderer is using packed depth or not */
  60377. readonly isPacked: boolean;
  60378. private _cachedDefines;
  60379. private _camera;
  60380. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60381. enabled: boolean;
  60382. /**
  60383. * Specifiess that the depth renderer will only be used within
  60384. * the camera it is created for.
  60385. * This can help forcing its rendering during the camera processing.
  60386. */
  60387. useOnlyInActiveCamera: boolean;
  60388. /** @hidden */
  60389. static _SceneComponentInitialization: (scene: Scene) => void;
  60390. /**
  60391. * Instantiates a depth renderer
  60392. * @param scene The scene the renderer belongs to
  60393. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60394. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60395. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60396. */
  60397. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60398. /**
  60399. * Creates the depth rendering effect and checks if the effect is ready.
  60400. * @param subMesh The submesh to be used to render the depth map of
  60401. * @param useInstances If multiple world instances should be used
  60402. * @returns if the depth renderer is ready to render the depth map
  60403. */
  60404. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60405. /**
  60406. * Gets the texture which the depth map will be written to.
  60407. * @returns The depth map texture
  60408. */
  60409. getDepthMap(): RenderTargetTexture;
  60410. /**
  60411. * Disposes of the depth renderer.
  60412. */
  60413. dispose(): void;
  60414. }
  60415. }
  60416. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  60417. /** @hidden */
  60418. export var minmaxReduxPixelShader: {
  60419. name: string;
  60420. shader: string;
  60421. };
  60422. }
  60423. declare module "babylonjs/Misc/minMaxReducer" {
  60424. import { Nullable } from "babylonjs/types";
  60425. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60426. import { Camera } from "babylonjs/Cameras/camera";
  60427. import { Observer } from "babylonjs/Misc/observable";
  60428. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60429. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  60430. import { Observable } from "babylonjs/Misc/observable";
  60431. import "babylonjs/Shaders/minmaxRedux.fragment";
  60432. /**
  60433. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60434. * and maximum values from all values of the texture.
  60435. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60436. * The source values are read from the red channel of the texture.
  60437. */
  60438. export class MinMaxReducer {
  60439. /**
  60440. * Observable triggered when the computation has been performed
  60441. */
  60442. onAfterReductionPerformed: Observable<{
  60443. min: number;
  60444. max: number;
  60445. }>;
  60446. protected _camera: Camera;
  60447. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60448. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60449. protected _postProcessManager: PostProcessManager;
  60450. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60451. protected _forceFullscreenViewport: boolean;
  60452. /**
  60453. * Creates a min/max reducer
  60454. * @param camera The camera to use for the post processes
  60455. */
  60456. constructor(camera: Camera);
  60457. /**
  60458. * Gets the texture used to read the values from.
  60459. */
  60460. get sourceTexture(): Nullable<RenderTargetTexture>;
  60461. /**
  60462. * Sets the source texture to read the values from.
  60463. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  60464. * because in such textures '1' value must not be taken into account to compute the maximum
  60465. * as this value is used to clear the texture.
  60466. * Note that the computation is not activated by calling this function, you must call activate() for that!
  60467. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  60468. * @param depthRedux Indicates if the texture is a depth texture or not
  60469. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  60470. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60471. */
  60472. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60473. /**
  60474. * Defines the refresh rate of the computation.
  60475. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60476. */
  60477. get refreshRate(): number;
  60478. set refreshRate(value: number);
  60479. protected _activated: boolean;
  60480. /**
  60481. * Gets the activation status of the reducer
  60482. */
  60483. get activated(): boolean;
  60484. /**
  60485. * Activates the reduction computation.
  60486. * When activated, the observers registered in onAfterReductionPerformed are
  60487. * called after the compuation is performed
  60488. */
  60489. activate(): void;
  60490. /**
  60491. * Deactivates the reduction computation.
  60492. */
  60493. deactivate(): void;
  60494. /**
  60495. * Disposes the min/max reducer
  60496. * @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.
  60497. */
  60498. dispose(disposeAll?: boolean): void;
  60499. }
  60500. }
  60501. declare module "babylonjs/Misc/depthReducer" {
  60502. import { Nullable } from "babylonjs/types";
  60503. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60504. import { Camera } from "babylonjs/Cameras/camera";
  60505. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60506. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  60507. /**
  60508. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60509. */
  60510. export class DepthReducer extends MinMaxReducer {
  60511. private _depthRenderer;
  60512. private _depthRendererId;
  60513. /**
  60514. * Gets the depth renderer used for the computation.
  60515. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60516. */
  60517. get depthRenderer(): Nullable<DepthRenderer>;
  60518. /**
  60519. * Creates a depth reducer
  60520. * @param camera The camera used to render the depth texture
  60521. */
  60522. constructor(camera: Camera);
  60523. /**
  60524. * Sets the depth renderer to use to generate the depth map
  60525. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60526. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60527. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60528. */
  60529. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60530. /** @hidden */
  60531. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60532. /**
  60533. * Activates the reduction computation.
  60534. * When activated, the observers registered in onAfterReductionPerformed are
  60535. * called after the compuation is performed
  60536. */
  60537. activate(): void;
  60538. /**
  60539. * Deactivates the reduction computation.
  60540. */
  60541. deactivate(): void;
  60542. /**
  60543. * Disposes the depth reducer
  60544. * @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.
  60545. */
  60546. dispose(disposeAll?: boolean): void;
  60547. }
  60548. }
  60549. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  60550. import { Nullable } from "babylonjs/types";
  60551. import { Scene } from "babylonjs/scene";
  60552. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60553. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60555. import { Effect } from "babylonjs/Materials/effect";
  60556. import "babylonjs/Shaders/shadowMap.fragment";
  60557. import "babylonjs/Shaders/shadowMap.vertex";
  60558. import "babylonjs/Shaders/depthBoxBlur.fragment";
  60559. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  60560. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  60561. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  60562. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60563. /**
  60564. * A CSM implementation allowing casting shadows on large scenes.
  60565. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60566. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60567. */
  60568. export class CascadedShadowGenerator extends ShadowGenerator {
  60569. private static readonly frustumCornersNDCSpace;
  60570. /**
  60571. * Name of the CSM class
  60572. */
  60573. static CLASSNAME: string;
  60574. /**
  60575. * Defines the default number of cascades used by the CSM.
  60576. */
  60577. static readonly DEFAULT_CASCADES_COUNT: number;
  60578. /**
  60579. * Defines the minimum number of cascades used by the CSM.
  60580. */
  60581. static readonly MIN_CASCADES_COUNT: number;
  60582. /**
  60583. * Defines the maximum number of cascades used by the CSM.
  60584. */
  60585. static readonly MAX_CASCADES_COUNT: number;
  60586. protected _validateFilter(filter: number): number;
  60587. /**
  60588. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  60589. */
  60590. penumbraDarkness: number;
  60591. private _numCascades;
  60592. /**
  60593. * Gets or set the number of cascades used by the CSM.
  60594. */
  60595. get numCascades(): number;
  60596. set numCascades(value: number);
  60597. /**
  60598. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  60599. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  60600. */
  60601. stabilizeCascades: boolean;
  60602. private _freezeShadowCastersBoundingInfo;
  60603. private _freezeShadowCastersBoundingInfoObservable;
  60604. /**
  60605. * Enables or disables the shadow casters bounding info computation.
  60606. * If your shadow casters don't move, you can disable this feature.
  60607. * If it is enabled, the bounding box computation is done every frame.
  60608. */
  60609. get freezeShadowCastersBoundingInfo(): boolean;
  60610. set freezeShadowCastersBoundingInfo(freeze: boolean);
  60611. private _scbiMin;
  60612. private _scbiMax;
  60613. protected _computeShadowCastersBoundingInfo(): void;
  60614. protected _shadowCastersBoundingInfo: BoundingInfo;
  60615. /**
  60616. * Gets or sets the shadow casters bounding info.
  60617. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  60618. * so that the system won't overwrite the bounds you provide
  60619. */
  60620. get shadowCastersBoundingInfo(): BoundingInfo;
  60621. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  60622. protected _breaksAreDirty: boolean;
  60623. protected _minDistance: number;
  60624. protected _maxDistance: number;
  60625. /**
  60626. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  60627. *
  60628. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  60629. * If you don't know these values, simply leave them to their defaults and don't call this function.
  60630. * @param min minimal distance for the breaks (default to 0.)
  60631. * @param max maximal distance for the breaks (default to 1.)
  60632. */
  60633. setMinMaxDistance(min: number, max: number): void;
  60634. /** Gets the minimal distance used in the cascade break computation */
  60635. get minDistance(): number;
  60636. /** Gets the maximal distance used in the cascade break computation */
  60637. get maxDistance(): number;
  60638. /**
  60639. * Gets the class name of that object
  60640. * @returns "CascadedShadowGenerator"
  60641. */
  60642. getClassName(): string;
  60643. private _cascadeMinExtents;
  60644. private _cascadeMaxExtents;
  60645. /**
  60646. * Gets a cascade minimum extents
  60647. * @param cascadeIndex index of the cascade
  60648. * @returns the minimum cascade extents
  60649. */
  60650. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  60651. /**
  60652. * Gets a cascade maximum extents
  60653. * @param cascadeIndex index of the cascade
  60654. * @returns the maximum cascade extents
  60655. */
  60656. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  60657. private _cascades;
  60658. private _currentLayer;
  60659. private _viewSpaceFrustumsZ;
  60660. private _viewMatrices;
  60661. private _projectionMatrices;
  60662. private _transformMatrices;
  60663. private _transformMatricesAsArray;
  60664. private _frustumLengths;
  60665. private _lightSizeUVCorrection;
  60666. private _depthCorrection;
  60667. private _frustumCornersWorldSpace;
  60668. private _frustumCenter;
  60669. private _shadowCameraPos;
  60670. private _shadowMaxZ;
  60671. /**
  60672. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60673. * It defaults to camera.maxZ
  60674. */
  60675. get shadowMaxZ(): number;
  60676. /**
  60677. * Sets the shadow max z distance.
  60678. */
  60679. set shadowMaxZ(value: number);
  60680. protected _debug: boolean;
  60681. /**
  60682. * Gets or sets the debug flag.
  60683. * When enabled, the cascades are materialized by different colors on the screen.
  60684. */
  60685. get debug(): boolean;
  60686. set debug(dbg: boolean);
  60687. private _depthClamp;
  60688. /**
  60689. * Gets or sets the depth clamping value.
  60690. *
  60691. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60692. * to account for the shadow casters far away.
  60693. *
  60694. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60695. */
  60696. get depthClamp(): boolean;
  60697. set depthClamp(value: boolean);
  60698. private _cascadeBlendPercentage;
  60699. /**
  60700. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60701. * It defaults to 0.1 (10% blending).
  60702. */
  60703. get cascadeBlendPercentage(): number;
  60704. set cascadeBlendPercentage(value: number);
  60705. private _lambda;
  60706. /**
  60707. * Gets or set the lambda parameter.
  60708. * This parameter is used to split the camera frustum and create the cascades.
  60709. * 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.
  60710. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60711. */
  60712. get lambda(): number;
  60713. set lambda(value: number);
  60714. /**
  60715. * Gets the view matrix corresponding to a given cascade
  60716. * @param cascadeNum cascade to retrieve the view matrix from
  60717. * @returns the cascade view matrix
  60718. */
  60719. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60720. /**
  60721. * Gets the projection matrix corresponding to a given cascade
  60722. * @param cascadeNum cascade to retrieve the projection matrix from
  60723. * @returns the cascade projection matrix
  60724. */
  60725. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60726. /**
  60727. * Gets the transformation matrix corresponding to a given cascade
  60728. * @param cascadeNum cascade to retrieve the transformation matrix from
  60729. * @returns the cascade transformation matrix
  60730. */
  60731. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60732. private _depthRenderer;
  60733. /**
  60734. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60735. *
  60736. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60737. *
  60738. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60739. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60740. * @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
  60741. */
  60742. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  60743. private _depthReducer;
  60744. private _autoCalcDepthBounds;
  60745. /**
  60746. * Gets or sets the autoCalcDepthBounds property.
  60747. *
  60748. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  60749. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  60750. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  60751. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  60752. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  60753. */
  60754. get autoCalcDepthBounds(): boolean;
  60755. set autoCalcDepthBounds(value: boolean);
  60756. /**
  60757. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  60758. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60759. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  60760. * for setting the refresh rate on the renderer yourself!
  60761. */
  60762. get autoCalcDepthBoundsRefreshRate(): number;
  60763. set autoCalcDepthBoundsRefreshRate(value: number);
  60764. /**
  60765. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  60766. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  60767. * you change the camera near/far planes!
  60768. */
  60769. splitFrustum(): void;
  60770. private _splitFrustum;
  60771. private _computeMatrices;
  60772. private _computeFrustumInWorldSpace;
  60773. private _computeCascadeFrustum;
  60774. /**
  60775. * Support test.
  60776. */
  60777. static get IsSupported(): boolean;
  60778. /** @hidden */
  60779. static _SceneComponentInitialization: (scene: Scene) => void;
  60780. /**
  60781. * Creates a Cascaded Shadow Generator object.
  60782. * A ShadowGenerator is the required tool to use the shadows.
  60783. * Each directional light casting shadows needs to use its own ShadowGenerator.
  60784. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60785. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  60786. * @param light The directional light object generating the shadows.
  60787. * @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.
  60788. */
  60789. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  60790. protected _initializeGenerator(): void;
  60791. protected _createTargetRenderTexture(): void;
  60792. protected _initializeShadowMap(): void;
  60793. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  60794. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  60795. /**
  60796. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  60797. * @param defines Defines of the material we want to update
  60798. * @param lightIndex Index of the light in the enabled light list of the material
  60799. */
  60800. prepareDefines(defines: any, lightIndex: number): void;
  60801. /**
  60802. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  60803. * defined in the generator but impacting the effect).
  60804. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  60805. * @param effect The effect we are binfing the information for
  60806. */
  60807. bindShadowLight(lightIndex: string, effect: Effect): void;
  60808. /**
  60809. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  60810. * (eq to view projection * shadow projection matrices)
  60811. * @returns The transform matrix used to create the shadow map
  60812. */
  60813. getTransformMatrix(): Matrix;
  60814. /**
  60815. * Disposes the ShadowGenerator.
  60816. * Returns nothing.
  60817. */
  60818. dispose(): void;
  60819. /**
  60820. * Serializes the shadow generator setup to a json object.
  60821. * @returns The serialized JSON object
  60822. */
  60823. serialize(): any;
  60824. /**
  60825. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  60826. * @param parsedShadowGenerator The JSON object to parse
  60827. * @param scene The scene to create the shadow map for
  60828. * @returns The parsed shadow generator
  60829. */
  60830. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  60831. }
  60832. }
  60833. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  60834. import { Scene } from "babylonjs/scene";
  60835. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60836. import { AbstractScene } from "babylonjs/abstractScene";
  60837. /**
  60838. * Defines the shadow generator component responsible to manage any shadow generators
  60839. * in a given scene.
  60840. */
  60841. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  60842. /**
  60843. * The component name helpfull to identify the component in the list of scene components.
  60844. */
  60845. readonly name: string;
  60846. /**
  60847. * The scene the component belongs to.
  60848. */
  60849. scene: Scene;
  60850. /**
  60851. * Creates a new instance of the component for the given scene
  60852. * @param scene Defines the scene to register the component in
  60853. */
  60854. constructor(scene: Scene);
  60855. /**
  60856. * Registers the component in a given scene
  60857. */
  60858. register(): void;
  60859. /**
  60860. * Rebuilds the elements related to this component in case of
  60861. * context lost for instance.
  60862. */
  60863. rebuild(): void;
  60864. /**
  60865. * Serializes the component data to the specified json object
  60866. * @param serializationObject The object to serialize to
  60867. */
  60868. serialize(serializationObject: any): void;
  60869. /**
  60870. * Adds all the elements from the container to the scene
  60871. * @param container the container holding the elements
  60872. */
  60873. addFromContainer(container: AbstractScene): void;
  60874. /**
  60875. * Removes all the elements in the container from the scene
  60876. * @param container contains the elements to remove
  60877. * @param dispose if the removed element should be disposed (default: false)
  60878. */
  60879. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60880. /**
  60881. * Rebuilds the elements related to this component in case of
  60882. * context lost for instance.
  60883. */
  60884. dispose(): void;
  60885. private _gatherRenderTargets;
  60886. }
  60887. }
  60888. declare module "babylonjs/Lights/Shadows/index" {
  60889. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  60890. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  60891. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  60892. }
  60893. declare module "babylonjs/Lights/pointLight" {
  60894. import { Scene } from "babylonjs/scene";
  60895. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60897. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  60898. import { Effect } from "babylonjs/Materials/effect";
  60899. /**
  60900. * A point light is a light defined by an unique point in world space.
  60901. * The light is emitted in every direction from this point.
  60902. * A good example of a point light is a standard light bulb.
  60903. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60904. */
  60905. export class PointLight extends ShadowLight {
  60906. private _shadowAngle;
  60907. /**
  60908. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60909. * This specifies what angle the shadow will use to be created.
  60910. *
  60911. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60912. */
  60913. get shadowAngle(): number;
  60914. /**
  60915. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60916. * This specifies what angle the shadow will use to be created.
  60917. *
  60918. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60919. */
  60920. set shadowAngle(value: number);
  60921. /**
  60922. * Gets the direction if it has been set.
  60923. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60924. */
  60925. get direction(): Vector3;
  60926. /**
  60927. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60928. */
  60929. set direction(value: Vector3);
  60930. /**
  60931. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  60932. * A PointLight emits the light in every direction.
  60933. * It can cast shadows.
  60934. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  60935. * ```javascript
  60936. * var pointLight = new PointLight("pl", camera.position, scene);
  60937. * ```
  60938. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60939. * @param name The light friendly name
  60940. * @param position The position of the point light in the scene
  60941. * @param scene The scene the lights belongs to
  60942. */
  60943. constructor(name: string, position: Vector3, scene: Scene);
  60944. /**
  60945. * Returns the string "PointLight"
  60946. * @returns the class name
  60947. */
  60948. getClassName(): string;
  60949. /**
  60950. * Returns the integer 0.
  60951. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60952. */
  60953. getTypeID(): number;
  60954. /**
  60955. * Specifies wether or not the shadowmap should be a cube texture.
  60956. * @returns true if the shadowmap needs to be a cube texture.
  60957. */
  60958. needCube(): boolean;
  60959. /**
  60960. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  60961. * @param faceIndex The index of the face we are computed the direction to generate shadow
  60962. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  60963. */
  60964. getShadowDirection(faceIndex?: number): Vector3;
  60965. /**
  60966. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  60967. * - fov = PI / 2
  60968. * - aspect ratio : 1.0
  60969. * - z-near and far equal to the active camera minZ and maxZ.
  60970. * Returns the PointLight.
  60971. */
  60972. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60973. protected _buildUniformLayout(): void;
  60974. /**
  60975. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  60976. * @param effect The effect to update
  60977. * @param lightIndex The index of the light in the effect to update
  60978. * @returns The point light
  60979. */
  60980. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  60981. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60982. /**
  60983. * Prepares the list of defines specific to the light type.
  60984. * @param defines the list of defines
  60985. * @param lightIndex defines the index of the light for the effect
  60986. */
  60987. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60988. }
  60989. }
  60990. declare module "babylonjs/Lights/index" {
  60991. export * from "babylonjs/Lights/light";
  60992. export * from "babylonjs/Lights/shadowLight";
  60993. export * from "babylonjs/Lights/Shadows/index";
  60994. export * from "babylonjs/Lights/directionalLight";
  60995. export * from "babylonjs/Lights/hemisphericLight";
  60996. export * from "babylonjs/Lights/pointLight";
  60997. export * from "babylonjs/Lights/spotLight";
  60998. }
  60999. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  61000. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61001. /**
  61002. * Header information of HDR texture files.
  61003. */
  61004. export interface HDRInfo {
  61005. /**
  61006. * The height of the texture in pixels.
  61007. */
  61008. height: number;
  61009. /**
  61010. * The width of the texture in pixels.
  61011. */
  61012. width: number;
  61013. /**
  61014. * The index of the beginning of the data in the binary file.
  61015. */
  61016. dataPosition: number;
  61017. }
  61018. /**
  61019. * This groups tools to convert HDR texture to native colors array.
  61020. */
  61021. export class HDRTools {
  61022. private static Ldexp;
  61023. private static Rgbe2float;
  61024. private static readStringLine;
  61025. /**
  61026. * Reads header information from an RGBE texture stored in a native array.
  61027. * More information on this format are available here:
  61028. * https://en.wikipedia.org/wiki/RGBE_image_format
  61029. *
  61030. * @param uint8array The binary file stored in native array.
  61031. * @return The header information.
  61032. */
  61033. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61034. /**
  61035. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61036. * This RGBE texture needs to store the information as a panorama.
  61037. *
  61038. * More information on this format are available here:
  61039. * https://en.wikipedia.org/wiki/RGBE_image_format
  61040. *
  61041. * @param buffer The binary file stored in an array buffer.
  61042. * @param size The expected size of the extracted cubemap.
  61043. * @return The Cube Map information.
  61044. */
  61045. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61046. /**
  61047. * Returns the pixels data extracted from an RGBE texture.
  61048. * This pixels will be stored left to right up to down in the R G B order in one array.
  61049. *
  61050. * More information on this format are available here:
  61051. * https://en.wikipedia.org/wiki/RGBE_image_format
  61052. *
  61053. * @param uint8array The binary file stored in an array buffer.
  61054. * @param hdrInfo The header information of the file.
  61055. * @return The pixels data in RGB right to left up to down order.
  61056. */
  61057. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61058. private static RGBE_ReadPixels_RLE;
  61059. }
  61060. }
  61061. declare module "babylonjs/Materials/effectRenderer" {
  61062. import { Nullable } from "babylonjs/types";
  61063. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61064. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61065. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61066. import { Viewport } from "babylonjs/Maths/math.viewport";
  61067. import { Observable } from "babylonjs/Misc/observable";
  61068. import { Effect } from "babylonjs/Materials/effect";
  61069. import "babylonjs/Shaders/postprocess.vertex";
  61070. /**
  61071. * Effect Render Options
  61072. */
  61073. export interface IEffectRendererOptions {
  61074. /**
  61075. * Defines the vertices positions.
  61076. */
  61077. positions?: number[];
  61078. /**
  61079. * Defines the indices.
  61080. */
  61081. indices?: number[];
  61082. }
  61083. /**
  61084. * Helper class to render one or more effects.
  61085. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61086. */
  61087. export class EffectRenderer {
  61088. private engine;
  61089. private static _DefaultOptions;
  61090. private _vertexBuffers;
  61091. private _indexBuffer;
  61092. private _fullscreenViewport;
  61093. /**
  61094. * Creates an effect renderer
  61095. * @param engine the engine to use for rendering
  61096. * @param options defines the options of the effect renderer
  61097. */
  61098. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61099. /**
  61100. * Sets the current viewport in normalized coordinates 0-1
  61101. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61102. */
  61103. setViewport(viewport?: Viewport): void;
  61104. /**
  61105. * Binds the embedded attributes buffer to the effect.
  61106. * @param effect Defines the effect to bind the attributes for
  61107. */
  61108. bindBuffers(effect: Effect): void;
  61109. /**
  61110. * Sets the current effect wrapper to use during draw.
  61111. * The effect needs to be ready before calling this api.
  61112. * This also sets the default full screen position attribute.
  61113. * @param effectWrapper Defines the effect to draw with
  61114. */
  61115. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61116. /**
  61117. * Restores engine states
  61118. */
  61119. restoreStates(): void;
  61120. /**
  61121. * Draws a full screen quad.
  61122. */
  61123. draw(): void;
  61124. private isRenderTargetTexture;
  61125. /**
  61126. * renders one or more effects to a specified texture
  61127. * @param effectWrapper the effect to renderer
  61128. * @param outputTexture texture to draw to, if null it will render to the screen.
  61129. */
  61130. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61131. /**
  61132. * Disposes of the effect renderer
  61133. */
  61134. dispose(): void;
  61135. }
  61136. /**
  61137. * Options to create an EffectWrapper
  61138. */
  61139. interface EffectWrapperCreationOptions {
  61140. /**
  61141. * Engine to use to create the effect
  61142. */
  61143. engine: ThinEngine;
  61144. /**
  61145. * Fragment shader for the effect
  61146. */
  61147. fragmentShader: string;
  61148. /**
  61149. * Use the shader store instead of direct source code
  61150. */
  61151. useShaderStore?: boolean;
  61152. /**
  61153. * Vertex shader for the effect
  61154. */
  61155. vertexShader?: string;
  61156. /**
  61157. * Attributes to use in the shader
  61158. */
  61159. attributeNames?: Array<string>;
  61160. /**
  61161. * Uniforms to use in the shader
  61162. */
  61163. uniformNames?: Array<string>;
  61164. /**
  61165. * Texture sampler names to use in the shader
  61166. */
  61167. samplerNames?: Array<string>;
  61168. /**
  61169. * Defines to use in the shader
  61170. */
  61171. defines?: Array<string>;
  61172. /**
  61173. * Callback when effect is compiled
  61174. */
  61175. onCompiled?: Nullable<(effect: Effect) => void>;
  61176. /**
  61177. * The friendly name of the effect displayed in Spector.
  61178. */
  61179. name?: string;
  61180. }
  61181. /**
  61182. * Wraps an effect to be used for rendering
  61183. */
  61184. export class EffectWrapper {
  61185. /**
  61186. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61187. */
  61188. onApplyObservable: Observable<{}>;
  61189. /**
  61190. * The underlying effect
  61191. */
  61192. effect: Effect;
  61193. /**
  61194. * Creates an effect to be renderer
  61195. * @param creationOptions options to create the effect
  61196. */
  61197. constructor(creationOptions: EffectWrapperCreationOptions);
  61198. /**
  61199. * Disposes of the effect wrapper
  61200. */
  61201. dispose(): void;
  61202. }
  61203. }
  61204. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  61205. /** @hidden */
  61206. export var hdrFilteringVertexShader: {
  61207. name: string;
  61208. shader: string;
  61209. };
  61210. }
  61211. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  61212. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61213. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  61214. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  61215. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  61216. /** @hidden */
  61217. export var hdrFilteringPixelShader: {
  61218. name: string;
  61219. shader: string;
  61220. };
  61221. }
  61222. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  61223. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61224. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61225. import { Nullable } from "babylonjs/types";
  61226. import "babylonjs/Shaders/hdrFiltering.vertex";
  61227. import "babylonjs/Shaders/hdrFiltering.fragment";
  61228. /**
  61229. * Options for texture filtering
  61230. */
  61231. interface IHDRFilteringOptions {
  61232. /**
  61233. * Scales pixel intensity for the input HDR map.
  61234. */
  61235. hdrScale?: number;
  61236. /**
  61237. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61238. */
  61239. quality?: number;
  61240. }
  61241. /**
  61242. * Filters HDR maps to get correct renderings of PBR reflections
  61243. */
  61244. export class HDRFiltering {
  61245. private _engine;
  61246. private _effectRenderer;
  61247. private _effectWrapper;
  61248. private _lodGenerationOffset;
  61249. private _lodGenerationScale;
  61250. /**
  61251. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61252. * you care about baking speed.
  61253. */
  61254. quality: number;
  61255. /**
  61256. * Scales pixel intensity for the input HDR map.
  61257. */
  61258. hdrScale: number;
  61259. /**
  61260. * Instantiates HDR filter for reflection maps
  61261. *
  61262. * @param engine Thin engine
  61263. * @param options Options
  61264. */
  61265. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61266. private _createRenderTarget;
  61267. private _prefilterInternal;
  61268. private _createEffect;
  61269. /**
  61270. * Get a value indicating if the filter is ready to be used
  61271. * @param texture Texture to filter
  61272. * @returns true if the filter is ready
  61273. */
  61274. isReady(texture: BaseTexture): boolean;
  61275. /**
  61276. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61277. * Prefiltering will be invoked at the end of next rendering pass.
  61278. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61279. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61280. * @param texture Texture to filter
  61281. * @param onFinished Callback when filtering is done
  61282. * @return Promise called when prefiltering is done
  61283. */
  61284. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61285. }
  61286. }
  61287. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  61288. import { Nullable } from "babylonjs/types";
  61289. import { Scene } from "babylonjs/scene";
  61290. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61291. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61292. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61293. import "babylonjs/Engines/Extensions/engine.rawTexture";
  61294. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  61295. /**
  61296. * This represents a texture coming from an HDR input.
  61297. *
  61298. * The only supported format is currently panorama picture stored in RGBE format.
  61299. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61300. */
  61301. export class HDRCubeTexture extends BaseTexture {
  61302. private static _facesMapping;
  61303. private _generateHarmonics;
  61304. private _noMipmap;
  61305. private _prefilterOnLoad;
  61306. private _textureMatrix;
  61307. private _size;
  61308. private _onLoad;
  61309. private _onError;
  61310. /**
  61311. * The texture URL.
  61312. */
  61313. url: string;
  61314. /**
  61315. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  61316. */
  61317. coordinatesMode: number;
  61318. protected _isBlocking: boolean;
  61319. /**
  61320. * Sets wether or not the texture is blocking during loading.
  61321. */
  61322. set isBlocking(value: boolean);
  61323. /**
  61324. * Gets wether or not the texture is blocking during loading.
  61325. */
  61326. get isBlocking(): boolean;
  61327. protected _rotationY: number;
  61328. /**
  61329. * Sets texture matrix rotation angle around Y axis in radians.
  61330. */
  61331. set rotationY(value: number);
  61332. /**
  61333. * Gets texture matrix rotation angle around Y axis radians.
  61334. */
  61335. get rotationY(): number;
  61336. /**
  61337. * Gets or sets the center of the bounding box associated with the cube texture
  61338. * It must define where the camera used to render the texture was set
  61339. */
  61340. boundingBoxPosition: Vector3;
  61341. private _boundingBoxSize;
  61342. /**
  61343. * Gets or sets the size of the bounding box associated with the cube texture
  61344. * When defined, the cubemap will switch to local mode
  61345. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61346. * @example https://www.babylonjs-playground.com/#RNASML
  61347. */
  61348. set boundingBoxSize(value: Vector3);
  61349. get boundingBoxSize(): Vector3;
  61350. /**
  61351. * Instantiates an HDRTexture from the following parameters.
  61352. *
  61353. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61354. * @param sceneOrEngine The scene or engine the texture will be used in
  61355. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61356. * @param noMipmap Forces to not generate the mipmap if true
  61357. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61358. * @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)
  61359. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61360. */
  61361. 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>);
  61362. /**
  61363. * Get the current class name of the texture useful for serialization or dynamic coding.
  61364. * @returns "HDRCubeTexture"
  61365. */
  61366. getClassName(): string;
  61367. /**
  61368. * Occurs when the file is raw .hdr file.
  61369. */
  61370. private loadTexture;
  61371. clone(): HDRCubeTexture;
  61372. delayLoad(): void;
  61373. /**
  61374. * Get the texture reflection matrix used to rotate/transform the reflection.
  61375. * @returns the reflection matrix
  61376. */
  61377. getReflectionTextureMatrix(): Matrix;
  61378. /**
  61379. * Set the texture reflection matrix used to rotate/transform the reflection.
  61380. * @param value Define the reflection matrix to set
  61381. */
  61382. setReflectionTextureMatrix(value: Matrix): void;
  61383. /**
  61384. * Parses a JSON representation of an HDR Texture in order to create the texture
  61385. * @param parsedTexture Define the JSON representation
  61386. * @param scene Define the scene the texture should be created in
  61387. * @param rootUrl Define the root url in case we need to load relative dependencies
  61388. * @returns the newly created texture after parsing
  61389. */
  61390. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61391. serialize(): any;
  61392. }
  61393. }
  61394. declare module "babylonjs/Physics/physicsEngine" {
  61395. import { Nullable } from "babylonjs/types";
  61396. import { Vector3 } from "babylonjs/Maths/math.vector";
  61397. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61398. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  61399. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  61400. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61401. /**
  61402. * Class used to control physics engine
  61403. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61404. */
  61405. export class PhysicsEngine implements IPhysicsEngine {
  61406. private _physicsPlugin;
  61407. /**
  61408. * Global value used to control the smallest number supported by the simulation
  61409. */
  61410. static Epsilon: number;
  61411. private _impostors;
  61412. private _joints;
  61413. private _subTimeStep;
  61414. /**
  61415. * Gets the gravity vector used by the simulation
  61416. */
  61417. gravity: Vector3;
  61418. /**
  61419. * Factory used to create the default physics plugin.
  61420. * @returns The default physics plugin
  61421. */
  61422. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61423. /**
  61424. * Creates a new Physics Engine
  61425. * @param gravity defines the gravity vector used by the simulation
  61426. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61427. */
  61428. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61429. /**
  61430. * Sets the gravity vector used by the simulation
  61431. * @param gravity defines the gravity vector to use
  61432. */
  61433. setGravity(gravity: Vector3): void;
  61434. /**
  61435. * Set the time step of the physics engine.
  61436. * Default is 1/60.
  61437. * To slow it down, enter 1/600 for example.
  61438. * To speed it up, 1/30
  61439. * @param newTimeStep defines the new timestep to apply to this world.
  61440. */
  61441. setTimeStep(newTimeStep?: number): void;
  61442. /**
  61443. * Get the time step of the physics engine.
  61444. * @returns the current time step
  61445. */
  61446. getTimeStep(): number;
  61447. /**
  61448. * Set the sub time step of the physics engine.
  61449. * Default is 0 meaning there is no sub steps
  61450. * To increase physics resolution precision, set a small value (like 1 ms)
  61451. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61452. */
  61453. setSubTimeStep(subTimeStep?: number): void;
  61454. /**
  61455. * Get the sub time step of the physics engine.
  61456. * @returns the current sub time step
  61457. */
  61458. getSubTimeStep(): number;
  61459. /**
  61460. * Release all resources
  61461. */
  61462. dispose(): void;
  61463. /**
  61464. * Gets the name of the current physics plugin
  61465. * @returns the name of the plugin
  61466. */
  61467. getPhysicsPluginName(): string;
  61468. /**
  61469. * Adding a new impostor for the impostor tracking.
  61470. * This will be done by the impostor itself.
  61471. * @param impostor the impostor to add
  61472. */
  61473. addImpostor(impostor: PhysicsImpostor): void;
  61474. /**
  61475. * Remove an impostor from the engine.
  61476. * This impostor and its mesh will not longer be updated by the physics engine.
  61477. * @param impostor the impostor to remove
  61478. */
  61479. removeImpostor(impostor: PhysicsImpostor): void;
  61480. /**
  61481. * Add a joint to the physics engine
  61482. * @param mainImpostor defines the main impostor to which the joint is added.
  61483. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61484. * @param joint defines the joint that will connect both impostors.
  61485. */
  61486. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61487. /**
  61488. * Removes a joint from the simulation
  61489. * @param mainImpostor defines the impostor used with the joint
  61490. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61491. * @param joint defines the joint to remove
  61492. */
  61493. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61494. /**
  61495. * Called by the scene. No need to call it.
  61496. * @param delta defines the timespam between frames
  61497. */
  61498. _step(delta: number): void;
  61499. /**
  61500. * Gets the current plugin used to run the simulation
  61501. * @returns current plugin
  61502. */
  61503. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61504. /**
  61505. * Gets the list of physic impostors
  61506. * @returns an array of PhysicsImpostor
  61507. */
  61508. getImpostors(): Array<PhysicsImpostor>;
  61509. /**
  61510. * Gets the impostor for a physics enabled object
  61511. * @param object defines the object impersonated by the impostor
  61512. * @returns the PhysicsImpostor or null if not found
  61513. */
  61514. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61515. /**
  61516. * Gets the impostor for a physics body object
  61517. * @param body defines physics body used by the impostor
  61518. * @returns the PhysicsImpostor or null if not found
  61519. */
  61520. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61521. /**
  61522. * Does a raycast in the physics world
  61523. * @param from when should the ray start?
  61524. * @param to when should the ray end?
  61525. * @returns PhysicsRaycastResult
  61526. */
  61527. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61528. }
  61529. }
  61530. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  61531. import { Nullable } from "babylonjs/types";
  61532. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  61533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61534. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  61535. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61536. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  61537. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61538. /** @hidden */
  61539. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  61540. private _useDeltaForWorldStep;
  61541. world: any;
  61542. name: string;
  61543. private _physicsMaterials;
  61544. private _fixedTimeStep;
  61545. private _cannonRaycastResult;
  61546. private _raycastResult;
  61547. private _physicsBodysToRemoveAfterStep;
  61548. private _firstFrame;
  61549. BJSCANNON: any;
  61550. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  61551. setGravity(gravity: Vector3): void;
  61552. setTimeStep(timeStep: number): void;
  61553. getTimeStep(): number;
  61554. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61555. private _removeMarkedPhysicsBodiesFromWorld;
  61556. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61557. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61558. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61559. private _processChildMeshes;
  61560. removePhysicsBody(impostor: PhysicsImpostor): void;
  61561. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61562. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61563. private _addMaterial;
  61564. private _checkWithEpsilon;
  61565. private _createShape;
  61566. private _createHeightmap;
  61567. private _minus90X;
  61568. private _plus90X;
  61569. private _tmpPosition;
  61570. private _tmpDeltaPosition;
  61571. private _tmpUnityRotation;
  61572. private _updatePhysicsBodyTransformation;
  61573. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61574. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61575. isSupported(): boolean;
  61576. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61577. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61578. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61579. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61580. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61581. getBodyMass(impostor: PhysicsImpostor): number;
  61582. getBodyFriction(impostor: PhysicsImpostor): number;
  61583. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61584. getBodyRestitution(impostor: PhysicsImpostor): number;
  61585. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61586. sleepBody(impostor: PhysicsImpostor): void;
  61587. wakeUpBody(impostor: PhysicsImpostor): void;
  61588. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  61589. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61590. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61591. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61592. getRadius(impostor: PhysicsImpostor): number;
  61593. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61594. dispose(): void;
  61595. private _extendNamespace;
  61596. /**
  61597. * Does a raycast in the physics world
  61598. * @param from when should the ray start?
  61599. * @param to when should the ray end?
  61600. * @returns PhysicsRaycastResult
  61601. */
  61602. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61603. }
  61604. }
  61605. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  61606. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  61607. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61608. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  61609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61610. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  61611. import { Nullable } from "babylonjs/types";
  61612. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61613. /** @hidden */
  61614. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  61615. private _useDeltaForWorldStep;
  61616. world: any;
  61617. name: string;
  61618. BJSOIMO: any;
  61619. private _raycastResult;
  61620. private _fixedTimeStep;
  61621. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  61622. setGravity(gravity: Vector3): void;
  61623. setTimeStep(timeStep: number): void;
  61624. getTimeStep(): number;
  61625. private _tmpImpostorsArray;
  61626. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61627. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61628. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61629. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61630. private _tmpPositionVector;
  61631. removePhysicsBody(impostor: PhysicsImpostor): void;
  61632. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61633. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61634. isSupported(): boolean;
  61635. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61636. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61637. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61638. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61639. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61640. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61641. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61642. getBodyMass(impostor: PhysicsImpostor): number;
  61643. getBodyFriction(impostor: PhysicsImpostor): number;
  61644. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61645. getBodyRestitution(impostor: PhysicsImpostor): number;
  61646. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61647. sleepBody(impostor: PhysicsImpostor): void;
  61648. wakeUpBody(impostor: PhysicsImpostor): void;
  61649. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61650. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  61651. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  61652. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61653. getRadius(impostor: PhysicsImpostor): number;
  61654. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61655. dispose(): void;
  61656. /**
  61657. * Does a raycast in the physics world
  61658. * @param from when should the ray start?
  61659. * @param to when should the ray end?
  61660. * @returns PhysicsRaycastResult
  61661. */
  61662. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61663. }
  61664. }
  61665. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  61666. import { Nullable } from "babylonjs/types";
  61667. import { Scene } from "babylonjs/scene";
  61668. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  61669. import { Color4 } from "babylonjs/Maths/math.color";
  61670. import { Mesh } from "babylonjs/Meshes/mesh";
  61671. /**
  61672. * Class containing static functions to help procedurally build meshes
  61673. */
  61674. export class RibbonBuilder {
  61675. /**
  61676. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61677. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61678. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61679. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61680. * * 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
  61681. * * 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
  61682. * * 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
  61683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61685. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61686. * * 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
  61687. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61688. * * 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
  61689. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61691. * @param name defines the name of the mesh
  61692. * @param options defines the options used to create the mesh
  61693. * @param scene defines the hosting scene
  61694. * @returns the ribbon mesh
  61695. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61696. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61697. */
  61698. static CreateRibbon(name: string, options: {
  61699. pathArray: Vector3[][];
  61700. closeArray?: boolean;
  61701. closePath?: boolean;
  61702. offset?: number;
  61703. updatable?: boolean;
  61704. sideOrientation?: number;
  61705. frontUVs?: Vector4;
  61706. backUVs?: Vector4;
  61707. instance?: Mesh;
  61708. invertUV?: boolean;
  61709. uvs?: Vector2[];
  61710. colors?: Color4[];
  61711. }, scene?: Nullable<Scene>): Mesh;
  61712. }
  61713. }
  61714. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  61715. import { Nullable } from "babylonjs/types";
  61716. import { Scene } from "babylonjs/scene";
  61717. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  61718. import { Mesh } from "babylonjs/Meshes/mesh";
  61719. /**
  61720. * Class containing static functions to help procedurally build meshes
  61721. */
  61722. export class ShapeBuilder {
  61723. /**
  61724. * 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.
  61725. * * 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.
  61726. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61727. * * 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.
  61728. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61729. * * 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
  61730. * * 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
  61731. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61734. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61736. * @param name defines the name of the mesh
  61737. * @param options defines the options used to create the mesh
  61738. * @param scene defines the hosting scene
  61739. * @returns the extruded shape mesh
  61740. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61741. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61742. */
  61743. static ExtrudeShape(name: string, options: {
  61744. shape: Vector3[];
  61745. path: Vector3[];
  61746. scale?: number;
  61747. rotation?: number;
  61748. cap?: number;
  61749. updatable?: boolean;
  61750. sideOrientation?: number;
  61751. frontUVs?: Vector4;
  61752. backUVs?: Vector4;
  61753. instance?: Mesh;
  61754. invertUV?: boolean;
  61755. }, scene?: Nullable<Scene>): Mesh;
  61756. /**
  61757. * Creates an custom extruded shape mesh.
  61758. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61759. * * 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.
  61760. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61761. * * 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
  61762. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61763. * * 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
  61764. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61765. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61766. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61767. * * 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
  61768. * * 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
  61769. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61771. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61772. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61774. * @param name defines the name of the mesh
  61775. * @param options defines the options used to create the mesh
  61776. * @param scene defines the hosting scene
  61777. * @returns the custom extruded shape mesh
  61778. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61779. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61780. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61781. */
  61782. static ExtrudeShapeCustom(name: string, options: {
  61783. shape: Vector3[];
  61784. path: Vector3[];
  61785. scaleFunction?: any;
  61786. rotationFunction?: any;
  61787. ribbonCloseArray?: boolean;
  61788. ribbonClosePath?: boolean;
  61789. cap?: number;
  61790. updatable?: boolean;
  61791. sideOrientation?: number;
  61792. frontUVs?: Vector4;
  61793. backUVs?: Vector4;
  61794. instance?: Mesh;
  61795. invertUV?: boolean;
  61796. }, scene?: Nullable<Scene>): Mesh;
  61797. private static _ExtrudeShapeGeneric;
  61798. }
  61799. }
  61800. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  61801. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  61802. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  61803. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61804. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  61805. import { Nullable } from "babylonjs/types";
  61806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61807. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61808. /**
  61809. * AmmoJS Physics plugin
  61810. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61811. * @see https://github.com/kripken/ammo.js/
  61812. */
  61813. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  61814. private _useDeltaForWorldStep;
  61815. /**
  61816. * Reference to the Ammo library
  61817. */
  61818. bjsAMMO: any;
  61819. /**
  61820. * Created ammoJS world which physics bodies are added to
  61821. */
  61822. world: any;
  61823. /**
  61824. * Name of the plugin
  61825. */
  61826. name: string;
  61827. private _timeStep;
  61828. private _fixedTimeStep;
  61829. private _maxSteps;
  61830. private _tmpQuaternion;
  61831. private _tmpAmmoTransform;
  61832. private _tmpAmmoQuaternion;
  61833. private _tmpAmmoConcreteContactResultCallback;
  61834. private _collisionConfiguration;
  61835. private _dispatcher;
  61836. private _overlappingPairCache;
  61837. private _solver;
  61838. private _softBodySolver;
  61839. private _tmpAmmoVectorA;
  61840. private _tmpAmmoVectorB;
  61841. private _tmpAmmoVectorC;
  61842. private _tmpAmmoVectorD;
  61843. private _tmpContactCallbackResult;
  61844. private _tmpAmmoVectorRCA;
  61845. private _tmpAmmoVectorRCB;
  61846. private _raycastResult;
  61847. private static readonly DISABLE_COLLISION_FLAG;
  61848. private static readonly KINEMATIC_FLAG;
  61849. private static readonly DISABLE_DEACTIVATION_FLAG;
  61850. /**
  61851. * Initializes the ammoJS plugin
  61852. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  61853. * @param ammoInjection can be used to inject your own ammo reference
  61854. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  61855. */
  61856. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  61857. /**
  61858. * Sets the gravity of the physics world (m/(s^2))
  61859. * @param gravity Gravity to set
  61860. */
  61861. setGravity(gravity: Vector3): void;
  61862. /**
  61863. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  61864. * @param timeStep timestep to use in seconds
  61865. */
  61866. setTimeStep(timeStep: number): void;
  61867. /**
  61868. * 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)
  61869. * @param fixedTimeStep fixedTimeStep to use in seconds
  61870. */
  61871. setFixedTimeStep(fixedTimeStep: number): void;
  61872. /**
  61873. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  61874. * @param maxSteps the maximum number of steps by the physics engine per frame
  61875. */
  61876. setMaxSteps(maxSteps: number): void;
  61877. /**
  61878. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  61879. * @returns the current timestep in seconds
  61880. */
  61881. getTimeStep(): number;
  61882. /**
  61883. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61884. */
  61885. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61886. private _isImpostorInContact;
  61887. private _isImpostorPairInContact;
  61888. private _stepSimulation;
  61889. /**
  61890. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61891. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61892. * After the step the babylon meshes are set to the position of the physics imposters
  61893. * @param delta amount of time to step forward
  61894. * @param impostors array of imposters to update before/after the step
  61895. */
  61896. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61897. /**
  61898. * Update babylon mesh to match physics world object
  61899. * @param impostor imposter to match
  61900. */
  61901. private _afterSoftStep;
  61902. /**
  61903. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61904. * @param impostor imposter to match
  61905. */
  61906. private _ropeStep;
  61907. /**
  61908. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61909. * @param impostor imposter to match
  61910. */
  61911. private _softbodyOrClothStep;
  61912. private _tmpMatrix;
  61913. /**
  61914. * Applies an impulse on the imposter
  61915. * @param impostor imposter to apply impulse to
  61916. * @param force amount of force to be applied to the imposter
  61917. * @param contactPoint the location to apply the impulse on the imposter
  61918. */
  61919. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61920. /**
  61921. * Applies a force on the imposter
  61922. * @param impostor imposter to apply force
  61923. * @param force amount of force to be applied to the imposter
  61924. * @param contactPoint the location to apply the force on the imposter
  61925. */
  61926. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61927. /**
  61928. * Creates a physics body using the plugin
  61929. * @param impostor the imposter to create the physics body on
  61930. */
  61931. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61932. /**
  61933. * Removes the physics body from the imposter and disposes of the body's memory
  61934. * @param impostor imposter to remove the physics body from
  61935. */
  61936. removePhysicsBody(impostor: PhysicsImpostor): void;
  61937. /**
  61938. * Generates a joint
  61939. * @param impostorJoint the imposter joint to create the joint with
  61940. */
  61941. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61942. /**
  61943. * Removes a joint
  61944. * @param impostorJoint the imposter joint to remove the joint from
  61945. */
  61946. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61947. private _addMeshVerts;
  61948. /**
  61949. * Initialise the soft body vertices to match its object's (mesh) vertices
  61950. * Softbody vertices (nodes) are in world space and to match this
  61951. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  61952. * @param impostor to create the softbody for
  61953. */
  61954. private _softVertexData;
  61955. /**
  61956. * Create an impostor's soft body
  61957. * @param impostor to create the softbody for
  61958. */
  61959. private _createSoftbody;
  61960. /**
  61961. * Create cloth for an impostor
  61962. * @param impostor to create the softbody for
  61963. */
  61964. private _createCloth;
  61965. /**
  61966. * Create rope for an impostor
  61967. * @param impostor to create the softbody for
  61968. */
  61969. private _createRope;
  61970. /**
  61971. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  61972. * @param impostor to create the custom physics shape for
  61973. */
  61974. private _createCustom;
  61975. private _addHullVerts;
  61976. private _createShape;
  61977. /**
  61978. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  61979. * @param impostor imposter containing the physics body and babylon object
  61980. */
  61981. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61982. /**
  61983. * Sets the babylon object's position/rotation from the physics body's position/rotation
  61984. * @param impostor imposter containing the physics body and babylon object
  61985. * @param newPosition new position
  61986. * @param newRotation new rotation
  61987. */
  61988. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61989. /**
  61990. * If this plugin is supported
  61991. * @returns true if its supported
  61992. */
  61993. isSupported(): boolean;
  61994. /**
  61995. * Sets the linear velocity of the physics body
  61996. * @param impostor imposter to set the velocity on
  61997. * @param velocity velocity to set
  61998. */
  61999. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62000. /**
  62001. * Sets the angular velocity of the physics body
  62002. * @param impostor imposter to set the velocity on
  62003. * @param velocity velocity to set
  62004. */
  62005. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62006. /**
  62007. * gets the linear velocity
  62008. * @param impostor imposter to get linear velocity from
  62009. * @returns linear velocity
  62010. */
  62011. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62012. /**
  62013. * gets the angular velocity
  62014. * @param impostor imposter to get angular velocity from
  62015. * @returns angular velocity
  62016. */
  62017. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62018. /**
  62019. * Sets the mass of physics body
  62020. * @param impostor imposter to set the mass on
  62021. * @param mass mass to set
  62022. */
  62023. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62024. /**
  62025. * Gets the mass of the physics body
  62026. * @param impostor imposter to get the mass from
  62027. * @returns mass
  62028. */
  62029. getBodyMass(impostor: PhysicsImpostor): number;
  62030. /**
  62031. * Gets friction of the impostor
  62032. * @param impostor impostor to get friction from
  62033. * @returns friction value
  62034. */
  62035. getBodyFriction(impostor: PhysicsImpostor): number;
  62036. /**
  62037. * Sets friction of the impostor
  62038. * @param impostor impostor to set friction on
  62039. * @param friction friction value
  62040. */
  62041. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62042. /**
  62043. * Gets restitution of the impostor
  62044. * @param impostor impostor to get restitution from
  62045. * @returns restitution value
  62046. */
  62047. getBodyRestitution(impostor: PhysicsImpostor): number;
  62048. /**
  62049. * Sets resitution of the impostor
  62050. * @param impostor impostor to set resitution on
  62051. * @param restitution resitution value
  62052. */
  62053. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62054. /**
  62055. * Gets pressure inside the impostor
  62056. * @param impostor impostor to get pressure from
  62057. * @returns pressure value
  62058. */
  62059. getBodyPressure(impostor: PhysicsImpostor): number;
  62060. /**
  62061. * Sets pressure inside a soft body impostor
  62062. * Cloth and rope must remain 0 pressure
  62063. * @param impostor impostor to set pressure on
  62064. * @param pressure pressure value
  62065. */
  62066. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62067. /**
  62068. * Gets stiffness of the impostor
  62069. * @param impostor impostor to get stiffness from
  62070. * @returns pressure value
  62071. */
  62072. getBodyStiffness(impostor: PhysicsImpostor): number;
  62073. /**
  62074. * Sets stiffness of the impostor
  62075. * @param impostor impostor to set stiffness on
  62076. * @param stiffness stiffness value from 0 to 1
  62077. */
  62078. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62079. /**
  62080. * Gets velocityIterations of the impostor
  62081. * @param impostor impostor to get velocity iterations from
  62082. * @returns velocityIterations value
  62083. */
  62084. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62085. /**
  62086. * Sets velocityIterations of the impostor
  62087. * @param impostor impostor to set velocity iterations on
  62088. * @param velocityIterations velocityIterations value
  62089. */
  62090. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62091. /**
  62092. * Gets positionIterations of the impostor
  62093. * @param impostor impostor to get position iterations from
  62094. * @returns positionIterations value
  62095. */
  62096. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62097. /**
  62098. * Sets positionIterations of the impostor
  62099. * @param impostor impostor to set position on
  62100. * @param positionIterations positionIterations value
  62101. */
  62102. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62103. /**
  62104. * Append an anchor to a cloth object
  62105. * @param impostor is the cloth impostor to add anchor to
  62106. * @param otherImpostor is the rigid impostor to anchor to
  62107. * @param width ratio across width from 0 to 1
  62108. * @param height ratio up height from 0 to 1
  62109. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62110. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62111. */
  62112. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62113. /**
  62114. * Append an hook to a rope object
  62115. * @param impostor is the rope impostor to add hook to
  62116. * @param otherImpostor is the rigid impostor to hook to
  62117. * @param length ratio along the rope from 0 to 1
  62118. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62119. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62120. */
  62121. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62122. /**
  62123. * Sleeps the physics body and stops it from being active
  62124. * @param impostor impostor to sleep
  62125. */
  62126. sleepBody(impostor: PhysicsImpostor): void;
  62127. /**
  62128. * Activates the physics body
  62129. * @param impostor impostor to activate
  62130. */
  62131. wakeUpBody(impostor: PhysicsImpostor): void;
  62132. /**
  62133. * Updates the distance parameters of the joint
  62134. * @param joint joint to update
  62135. * @param maxDistance maximum distance of the joint
  62136. * @param minDistance minimum distance of the joint
  62137. */
  62138. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62139. /**
  62140. * Sets a motor on the joint
  62141. * @param joint joint to set motor on
  62142. * @param speed speed of the motor
  62143. * @param maxForce maximum force of the motor
  62144. * @param motorIndex index of the motor
  62145. */
  62146. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62147. /**
  62148. * Sets the motors limit
  62149. * @param joint joint to set limit on
  62150. * @param upperLimit upper limit
  62151. * @param lowerLimit lower limit
  62152. */
  62153. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62154. /**
  62155. * Syncs the position and rotation of a mesh with the impostor
  62156. * @param mesh mesh to sync
  62157. * @param impostor impostor to update the mesh with
  62158. */
  62159. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62160. /**
  62161. * Gets the radius of the impostor
  62162. * @param impostor impostor to get radius from
  62163. * @returns the radius
  62164. */
  62165. getRadius(impostor: PhysicsImpostor): number;
  62166. /**
  62167. * Gets the box size of the impostor
  62168. * @param impostor impostor to get box size from
  62169. * @param result the resulting box size
  62170. */
  62171. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62172. /**
  62173. * Disposes of the impostor
  62174. */
  62175. dispose(): void;
  62176. /**
  62177. * Does a raycast in the physics world
  62178. * @param from when should the ray start?
  62179. * @param to when should the ray end?
  62180. * @returns PhysicsRaycastResult
  62181. */
  62182. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62183. }
  62184. }
  62185. declare module "babylonjs/Probes/reflectionProbe" {
  62186. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62187. import { Vector3 } from "babylonjs/Maths/math.vector";
  62188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62189. import { Nullable } from "babylonjs/types";
  62190. import { Scene } from "babylonjs/scene";
  62191. module "babylonjs/abstractScene" {
  62192. interface AbstractScene {
  62193. /**
  62194. * The list of reflection probes added to the scene
  62195. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62196. */
  62197. reflectionProbes: Array<ReflectionProbe>;
  62198. /**
  62199. * Removes the given reflection probe from this scene.
  62200. * @param toRemove The reflection probe to remove
  62201. * @returns The index of the removed reflection probe
  62202. */
  62203. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62204. /**
  62205. * Adds the given reflection probe to this scene.
  62206. * @param newReflectionProbe The reflection probe to add
  62207. */
  62208. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62209. }
  62210. }
  62211. /**
  62212. * Class used to generate realtime reflection / refraction cube textures
  62213. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62214. */
  62215. export class ReflectionProbe {
  62216. /** defines the name of the probe */
  62217. name: string;
  62218. private _scene;
  62219. private _renderTargetTexture;
  62220. private _projectionMatrix;
  62221. private _viewMatrix;
  62222. private _target;
  62223. private _add;
  62224. private _attachedMesh;
  62225. private _invertYAxis;
  62226. /** Gets or sets probe position (center of the cube map) */
  62227. position: Vector3;
  62228. /**
  62229. * Creates a new reflection probe
  62230. * @param name defines the name of the probe
  62231. * @param size defines the texture resolution (for each face)
  62232. * @param scene defines the hosting scene
  62233. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62234. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62235. */
  62236. constructor(
  62237. /** defines the name of the probe */
  62238. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62239. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62240. get samples(): number;
  62241. set samples(value: number);
  62242. /** Gets or sets the refresh rate to use (on every frame by default) */
  62243. get refreshRate(): number;
  62244. set refreshRate(value: number);
  62245. /**
  62246. * Gets the hosting scene
  62247. * @returns a Scene
  62248. */
  62249. getScene(): Scene;
  62250. /** Gets the internal CubeTexture used to render to */
  62251. get cubeTexture(): RenderTargetTexture;
  62252. /** Gets the list of meshes to render */
  62253. get renderList(): Nullable<AbstractMesh[]>;
  62254. /**
  62255. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62256. * @param mesh defines the mesh to attach to
  62257. */
  62258. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62259. /**
  62260. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62261. * @param renderingGroupId The rendering group id corresponding to its index
  62262. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62263. */
  62264. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62265. /**
  62266. * Clean all associated resources
  62267. */
  62268. dispose(): void;
  62269. /**
  62270. * Converts the reflection probe information to a readable string for debug purpose.
  62271. * @param fullDetails Supports for multiple levels of logging within scene loading
  62272. * @returns the human readable reflection probe info
  62273. */
  62274. toString(fullDetails?: boolean): string;
  62275. /**
  62276. * Get the class name of the relfection probe.
  62277. * @returns "ReflectionProbe"
  62278. */
  62279. getClassName(): string;
  62280. /**
  62281. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62282. * @returns The JSON representation of the texture
  62283. */
  62284. serialize(): any;
  62285. /**
  62286. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62287. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62288. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62289. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62290. * @returns The parsed reflection probe if successful
  62291. */
  62292. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62293. }
  62294. }
  62295. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  62296. /** @hidden */
  62297. export var _BabylonLoaderRegistered: boolean;
  62298. /**
  62299. * Helps setting up some configuration for the babylon file loader.
  62300. */
  62301. export class BabylonFileLoaderConfiguration {
  62302. /**
  62303. * The loader does not allow injecting custom physix engine into the plugins.
  62304. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62305. * So you could set this variable to your engine import to make it work.
  62306. */
  62307. static LoaderInjectedPhysicsEngine: any;
  62308. }
  62309. }
  62310. declare module "babylonjs/Loading/Plugins/index" {
  62311. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  62312. }
  62313. declare module "babylonjs/Loading/index" {
  62314. export * from "babylonjs/Loading/loadingScreen";
  62315. export * from "babylonjs/Loading/Plugins/index";
  62316. export * from "babylonjs/Loading/sceneLoader";
  62317. export * from "babylonjs/Loading/sceneLoaderFlags";
  62318. }
  62319. declare module "babylonjs/Materials/Background/index" {
  62320. export * from "babylonjs/Materials/Background/backgroundMaterial";
  62321. }
  62322. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  62323. import { Scene } from "babylonjs/scene";
  62324. import { Color3 } from "babylonjs/Maths/math.color";
  62325. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62326. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62327. /**
  62328. * The Physically based simple base material of BJS.
  62329. *
  62330. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62331. * It is used as the base class for both the specGloss and metalRough conventions.
  62332. */
  62333. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62334. /**
  62335. * Number of Simultaneous lights allowed on the material.
  62336. */
  62337. maxSimultaneousLights: number;
  62338. /**
  62339. * If sets to true, disables all the lights affecting the material.
  62340. */
  62341. disableLighting: boolean;
  62342. /**
  62343. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62344. */
  62345. environmentTexture: BaseTexture;
  62346. /**
  62347. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62348. */
  62349. invertNormalMapX: boolean;
  62350. /**
  62351. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62352. */
  62353. invertNormalMapY: boolean;
  62354. /**
  62355. * Normal map used in the model.
  62356. */
  62357. normalTexture: BaseTexture;
  62358. /**
  62359. * Emissivie color used to self-illuminate the model.
  62360. */
  62361. emissiveColor: Color3;
  62362. /**
  62363. * Emissivie texture used to self-illuminate the model.
  62364. */
  62365. emissiveTexture: BaseTexture;
  62366. /**
  62367. * Occlusion Channel Strenght.
  62368. */
  62369. occlusionStrength: number;
  62370. /**
  62371. * Occlusion Texture of the material (adding extra occlusion effects).
  62372. */
  62373. occlusionTexture: BaseTexture;
  62374. /**
  62375. * Defines the alpha limits in alpha test mode.
  62376. */
  62377. alphaCutOff: number;
  62378. /**
  62379. * Gets the current double sided mode.
  62380. */
  62381. get doubleSided(): boolean;
  62382. /**
  62383. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62384. */
  62385. set doubleSided(value: boolean);
  62386. /**
  62387. * Stores the pre-calculated light information of a mesh in a texture.
  62388. */
  62389. lightmapTexture: BaseTexture;
  62390. /**
  62391. * If true, the light map contains occlusion information instead of lighting info.
  62392. */
  62393. useLightmapAsShadowmap: boolean;
  62394. /**
  62395. * Instantiates a new PBRMaterial instance.
  62396. *
  62397. * @param name The material name
  62398. * @param scene The scene the material will be use in.
  62399. */
  62400. constructor(name: string, scene: Scene);
  62401. getClassName(): string;
  62402. }
  62403. }
  62404. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  62405. import { Scene } from "babylonjs/scene";
  62406. import { Color3 } from "babylonjs/Maths/math.color";
  62407. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62408. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62409. /**
  62410. * The PBR material of BJS following the metal roughness convention.
  62411. *
  62412. * This fits to the PBR convention in the GLTF definition:
  62413. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62414. */
  62415. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62416. /**
  62417. * The base color has two different interpretations depending on the value of metalness.
  62418. * When the material is a metal, the base color is the specific measured reflectance value
  62419. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62420. * of the material.
  62421. */
  62422. baseColor: Color3;
  62423. /**
  62424. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62425. * well as opacity information in the alpha channel.
  62426. */
  62427. baseTexture: BaseTexture;
  62428. /**
  62429. * Specifies the metallic scalar value of the material.
  62430. * Can also be used to scale the metalness values of the metallic texture.
  62431. */
  62432. metallic: number;
  62433. /**
  62434. * Specifies the roughness scalar value of the material.
  62435. * Can also be used to scale the roughness values of the metallic texture.
  62436. */
  62437. roughness: number;
  62438. /**
  62439. * Texture containing both the metallic value in the B channel and the
  62440. * roughness value in the G channel to keep better precision.
  62441. */
  62442. metallicRoughnessTexture: BaseTexture;
  62443. /**
  62444. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62445. *
  62446. * @param name The material name
  62447. * @param scene The scene the material will be use in.
  62448. */
  62449. constructor(name: string, scene: Scene);
  62450. /**
  62451. * Return the currrent class name of the material.
  62452. */
  62453. getClassName(): string;
  62454. /**
  62455. * Makes a duplicate of the current material.
  62456. * @param name - name to use for the new material.
  62457. */
  62458. clone(name: string): PBRMetallicRoughnessMaterial;
  62459. /**
  62460. * Serialize the material to a parsable JSON object.
  62461. */
  62462. serialize(): any;
  62463. /**
  62464. * Parses a JSON object correponding to the serialize function.
  62465. */
  62466. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62467. }
  62468. }
  62469. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  62470. import { Scene } from "babylonjs/scene";
  62471. import { Color3 } from "babylonjs/Maths/math.color";
  62472. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62473. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62474. /**
  62475. * The PBR material of BJS following the specular glossiness convention.
  62476. *
  62477. * This fits to the PBR convention in the GLTF definition:
  62478. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62479. */
  62480. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62481. /**
  62482. * Specifies the diffuse color of the material.
  62483. */
  62484. diffuseColor: Color3;
  62485. /**
  62486. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62487. * channel.
  62488. */
  62489. diffuseTexture: BaseTexture;
  62490. /**
  62491. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62492. */
  62493. specularColor: Color3;
  62494. /**
  62495. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62496. */
  62497. glossiness: number;
  62498. /**
  62499. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62500. */
  62501. specularGlossinessTexture: BaseTexture;
  62502. /**
  62503. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62504. *
  62505. * @param name The material name
  62506. * @param scene The scene the material will be use in.
  62507. */
  62508. constructor(name: string, scene: Scene);
  62509. /**
  62510. * Return the currrent class name of the material.
  62511. */
  62512. getClassName(): string;
  62513. /**
  62514. * Makes a duplicate of the current material.
  62515. * @param name - name to use for the new material.
  62516. */
  62517. clone(name: string): PBRSpecularGlossinessMaterial;
  62518. /**
  62519. * Serialize the material to a parsable JSON object.
  62520. */
  62521. serialize(): any;
  62522. /**
  62523. * Parses a JSON object correponding to the serialize function.
  62524. */
  62525. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62526. }
  62527. }
  62528. declare module "babylonjs/Materials/PBR/index" {
  62529. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62530. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62531. export * from "babylonjs/Materials/PBR/pbrMaterial";
  62532. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  62533. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  62534. }
  62535. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  62536. import { Nullable } from "babylonjs/types";
  62537. import { Scene } from "babylonjs/scene";
  62538. import { Matrix } from "babylonjs/Maths/math.vector";
  62539. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62540. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62541. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62542. /**
  62543. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62544. * It can help converting any input color in a desired output one. This can then be used to create effects
  62545. * from sepia, black and white to sixties or futuristic rendering...
  62546. *
  62547. * The only supported format is currently 3dl.
  62548. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62549. */
  62550. export class ColorGradingTexture extends BaseTexture {
  62551. /**
  62552. * The texture URL.
  62553. */
  62554. url: string;
  62555. /**
  62556. * Empty line regex stored for GC.
  62557. */
  62558. private static _noneEmptyLineRegex;
  62559. private _textureMatrix;
  62560. private _onLoad;
  62561. /**
  62562. * Instantiates a ColorGradingTexture from the following parameters.
  62563. *
  62564. * @param url The location of the color gradind data (currently only supporting 3dl)
  62565. * @param sceneOrEngine The scene or engine the texture will be used in
  62566. * @param onLoad defines a callback triggered when the texture has been loaded
  62567. */
  62568. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62569. /**
  62570. * Fires the onload event from the constructor if requested.
  62571. */
  62572. private _triggerOnLoad;
  62573. /**
  62574. * Returns the texture matrix used in most of the material.
  62575. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62576. */
  62577. getTextureMatrix(): Matrix;
  62578. /**
  62579. * Occurs when the file being loaded is a .3dl LUT file.
  62580. */
  62581. private load3dlTexture;
  62582. /**
  62583. * Starts the loading process of the texture.
  62584. */
  62585. private loadTexture;
  62586. /**
  62587. * Clones the color gradind texture.
  62588. */
  62589. clone(): ColorGradingTexture;
  62590. /**
  62591. * Called during delayed load for textures.
  62592. */
  62593. delayLoad(): void;
  62594. /**
  62595. * Parses a color grading texture serialized by Babylon.
  62596. * @param parsedTexture The texture information being parsedTexture
  62597. * @param scene The scene to load the texture in
  62598. * @param rootUrl The root url of the data assets to load
  62599. * @return A color gradind texture
  62600. */
  62601. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  62602. /**
  62603. * Serializes the LUT texture to json format.
  62604. */
  62605. serialize(): any;
  62606. }
  62607. }
  62608. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  62609. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62610. import { Scene } from "babylonjs/scene";
  62611. import { Nullable } from "babylonjs/types";
  62612. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62613. /**
  62614. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  62615. */
  62616. export class EquiRectangularCubeTexture extends BaseTexture {
  62617. /** The six faces of the cube. */
  62618. private static _FacesMapping;
  62619. private _noMipmap;
  62620. private _onLoad;
  62621. private _onError;
  62622. /** The size of the cubemap. */
  62623. private _size;
  62624. /** The buffer of the image. */
  62625. private _buffer;
  62626. /** The width of the input image. */
  62627. private _width;
  62628. /** The height of the input image. */
  62629. private _height;
  62630. /** The URL to the image. */
  62631. url: string;
  62632. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  62633. coordinatesMode: number;
  62634. /**
  62635. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  62636. * @param url The location of the image
  62637. * @param scene The scene the texture will be used in
  62638. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62639. * @param noMipmap Forces to not generate the mipmap if true
  62640. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62641. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62642. * @param onLoad — defines a callback called when texture is loaded
  62643. * @param onError — defines a callback called if there is an error
  62644. */
  62645. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  62646. /**
  62647. * Load the image data, by putting the image on a canvas and extracting its buffer.
  62648. */
  62649. private loadImage;
  62650. /**
  62651. * Convert the image buffer into a cubemap and create a CubeTexture.
  62652. */
  62653. private loadTexture;
  62654. /**
  62655. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  62656. * @param buffer The ArrayBuffer that should be converted.
  62657. * @returns The buffer as Float32Array.
  62658. */
  62659. private getFloat32ArrayFromArrayBuffer;
  62660. /**
  62661. * Get the current class name of the texture useful for serialization or dynamic coding.
  62662. * @returns "EquiRectangularCubeTexture"
  62663. */
  62664. getClassName(): string;
  62665. /**
  62666. * Create a clone of the current EquiRectangularCubeTexture and return it.
  62667. * @returns A clone of the current EquiRectangularCubeTexture.
  62668. */
  62669. clone(): EquiRectangularCubeTexture;
  62670. }
  62671. }
  62672. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  62673. import { Nullable } from "babylonjs/types";
  62674. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62675. import { Matrix } from "babylonjs/Maths/math.vector";
  62676. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  62677. import "babylonjs/Engines/Extensions/engine.videoTexture";
  62678. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62679. import { Scene } from "babylonjs/scene";
  62680. /**
  62681. * Defines the options related to the creation of an HtmlElementTexture
  62682. */
  62683. export interface IHtmlElementTextureOptions {
  62684. /**
  62685. * Defines wether mip maps should be created or not.
  62686. */
  62687. generateMipMaps?: boolean;
  62688. /**
  62689. * Defines the sampling mode of the texture.
  62690. */
  62691. samplingMode?: number;
  62692. /**
  62693. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  62694. */
  62695. engine: Nullable<ThinEngine>;
  62696. /**
  62697. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  62698. */
  62699. scene: Nullable<Scene>;
  62700. }
  62701. /**
  62702. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  62703. * To be as efficient as possible depending on your constraints nothing aside the first upload
  62704. * is automatically managed.
  62705. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  62706. * in your application.
  62707. *
  62708. * As the update is not automatic, you need to call them manually.
  62709. */
  62710. export class HtmlElementTexture extends BaseTexture {
  62711. /**
  62712. * The texture URL.
  62713. */
  62714. element: HTMLVideoElement | HTMLCanvasElement;
  62715. private static readonly DefaultOptions;
  62716. private _textureMatrix;
  62717. private _isVideo;
  62718. private _generateMipMaps;
  62719. private _samplingMode;
  62720. /**
  62721. * Instantiates a HtmlElementTexture from the following parameters.
  62722. *
  62723. * @param name Defines the name of the texture
  62724. * @param element Defines the video or canvas the texture is filled with
  62725. * @param options Defines the other none mandatory texture creation options
  62726. */
  62727. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  62728. private _createInternalTexture;
  62729. /**
  62730. * Returns the texture matrix used in most of the material.
  62731. */
  62732. getTextureMatrix(): Matrix;
  62733. /**
  62734. * Updates the content of the texture.
  62735. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  62736. */
  62737. update(invertY?: Nullable<boolean>): void;
  62738. }
  62739. }
  62740. declare module "babylonjs/Misc/tga" {
  62741. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62742. /**
  62743. * Based on jsTGALoader - Javascript loader for TGA file
  62744. * By Vincent Thibault
  62745. * @see http://blog.robrowser.com/javascript-tga-loader.html
  62746. */
  62747. export class TGATools {
  62748. private static _TYPE_INDEXED;
  62749. private static _TYPE_RGB;
  62750. private static _TYPE_GREY;
  62751. private static _TYPE_RLE_INDEXED;
  62752. private static _TYPE_RLE_RGB;
  62753. private static _TYPE_RLE_GREY;
  62754. private static _ORIGIN_MASK;
  62755. private static _ORIGIN_SHIFT;
  62756. private static _ORIGIN_BL;
  62757. private static _ORIGIN_BR;
  62758. private static _ORIGIN_UL;
  62759. private static _ORIGIN_UR;
  62760. /**
  62761. * Gets the header of a TGA file
  62762. * @param data defines the TGA data
  62763. * @returns the header
  62764. */
  62765. static GetTGAHeader(data: Uint8Array): any;
  62766. /**
  62767. * Uploads TGA content to a Babylon Texture
  62768. * @hidden
  62769. */
  62770. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  62771. /** @hidden */
  62772. 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;
  62773. /** @hidden */
  62774. 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;
  62775. /** @hidden */
  62776. 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;
  62777. /** @hidden */
  62778. 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;
  62779. /** @hidden */
  62780. 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;
  62781. /** @hidden */
  62782. 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;
  62783. }
  62784. }
  62785. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  62786. import { Nullable } from "babylonjs/types";
  62787. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62788. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  62789. /**
  62790. * Implementation of the TGA Texture Loader.
  62791. * @hidden
  62792. */
  62793. export class _TGATextureLoader implements IInternalTextureLoader {
  62794. /**
  62795. * Defines wether the loader supports cascade loading the different faces.
  62796. */
  62797. readonly supportCascades: boolean;
  62798. /**
  62799. * This returns if the loader support the current file information.
  62800. * @param extension defines the file extension of the file being loaded
  62801. * @returns true if the loader can load the specified file
  62802. */
  62803. canLoad(extension: string): boolean;
  62804. /**
  62805. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62806. * @param data contains the texture data
  62807. * @param texture defines the BabylonJS internal texture
  62808. * @param createPolynomials will be true if polynomials have been requested
  62809. * @param onLoad defines the callback to trigger once the texture is ready
  62810. * @param onError defines the callback to trigger in case of error
  62811. */
  62812. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62813. /**
  62814. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62815. * @param data contains the texture data
  62816. * @param texture defines the BabylonJS internal texture
  62817. * @param callback defines the method to call once ready to upload
  62818. */
  62819. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62820. }
  62821. }
  62822. declare module "babylonjs/Misc/basis" {
  62823. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62824. /**
  62825. * Info about the .basis files
  62826. */
  62827. class BasisFileInfo {
  62828. /**
  62829. * If the file has alpha
  62830. */
  62831. hasAlpha: boolean;
  62832. /**
  62833. * Info about each image of the basis file
  62834. */
  62835. images: Array<{
  62836. levels: Array<{
  62837. width: number;
  62838. height: number;
  62839. transcodedPixels: ArrayBufferView;
  62840. }>;
  62841. }>;
  62842. }
  62843. /**
  62844. * Result of transcoding a basis file
  62845. */
  62846. class TranscodeResult {
  62847. /**
  62848. * Info about the .basis file
  62849. */
  62850. fileInfo: BasisFileInfo;
  62851. /**
  62852. * Format to use when loading the file
  62853. */
  62854. format: number;
  62855. }
  62856. /**
  62857. * Configuration options for the Basis transcoder
  62858. */
  62859. export class BasisTranscodeConfiguration {
  62860. /**
  62861. * Supported compression formats used to determine the supported output format of the transcoder
  62862. */
  62863. supportedCompressionFormats?: {
  62864. /**
  62865. * etc1 compression format
  62866. */
  62867. etc1?: boolean;
  62868. /**
  62869. * s3tc compression format
  62870. */
  62871. s3tc?: boolean;
  62872. /**
  62873. * pvrtc compression format
  62874. */
  62875. pvrtc?: boolean;
  62876. /**
  62877. * etc2 compression format
  62878. */
  62879. etc2?: boolean;
  62880. };
  62881. /**
  62882. * If mipmap levels should be loaded for transcoded images (Default: true)
  62883. */
  62884. loadMipmapLevels?: boolean;
  62885. /**
  62886. * Index of a single image to load (Default: all images)
  62887. */
  62888. loadSingleImage?: number;
  62889. }
  62890. /**
  62891. * Used to load .Basis files
  62892. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  62893. */
  62894. export class BasisTools {
  62895. private static _IgnoreSupportedFormats;
  62896. /**
  62897. * URL to use when loading the basis transcoder
  62898. */
  62899. static JSModuleURL: string;
  62900. /**
  62901. * URL to use when loading the wasm module for the transcoder
  62902. */
  62903. static WasmModuleURL: string;
  62904. /**
  62905. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  62906. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  62907. * @returns internal format corresponding to the Basis format
  62908. */
  62909. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  62910. private static _WorkerPromise;
  62911. private static _Worker;
  62912. private static _actionId;
  62913. private static _CreateWorkerAsync;
  62914. /**
  62915. * Transcodes a loaded image file to compressed pixel data
  62916. * @param data image data to transcode
  62917. * @param config configuration options for the transcoding
  62918. * @returns a promise resulting in the transcoded image
  62919. */
  62920. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  62921. /**
  62922. * Loads a texture from the transcode result
  62923. * @param texture texture load to
  62924. * @param transcodeResult the result of transcoding the basis file to load from
  62925. */
  62926. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  62927. }
  62928. }
  62929. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  62930. import { Nullable } from "babylonjs/types";
  62931. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62932. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  62933. /**
  62934. * Loader for .basis file format
  62935. */
  62936. export class _BasisTextureLoader implements IInternalTextureLoader {
  62937. /**
  62938. * Defines whether the loader supports cascade loading the different faces.
  62939. */
  62940. readonly supportCascades: boolean;
  62941. /**
  62942. * This returns if the loader support the current file information.
  62943. * @param extension defines the file extension of the file being loaded
  62944. * @returns true if the loader can load the specified file
  62945. */
  62946. canLoad(extension: string): boolean;
  62947. /**
  62948. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62949. * @param data contains the texture data
  62950. * @param texture defines the BabylonJS internal texture
  62951. * @param createPolynomials will be true if polynomials have been requested
  62952. * @param onLoad defines the callback to trigger once the texture is ready
  62953. * @param onError defines the callback to trigger in case of error
  62954. */
  62955. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62956. /**
  62957. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62958. * @param data contains the texture data
  62959. * @param texture defines the BabylonJS internal texture
  62960. * @param callback defines the method to call once ready to upload
  62961. */
  62962. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62963. }
  62964. }
  62965. declare module "babylonjs/Materials/Textures/Loaders/index" {
  62966. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  62967. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  62968. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  62969. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  62970. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  62971. }
  62972. declare module "babylonjs/Materials/Textures/Packer/frame" {
  62973. import { Vector2 } from "babylonjs/Maths/math.vector";
  62974. /**
  62975. * Defines the basic options interface of a TexturePacker Frame
  62976. */
  62977. export interface ITexturePackerFrame {
  62978. /**
  62979. * The frame ID
  62980. */
  62981. id: number;
  62982. /**
  62983. * The frames Scale
  62984. */
  62985. scale: Vector2;
  62986. /**
  62987. * The Frames offset
  62988. */
  62989. offset: Vector2;
  62990. }
  62991. /**
  62992. * This is a support class for frame Data on texture packer sets.
  62993. */
  62994. export class TexturePackerFrame implements ITexturePackerFrame {
  62995. /**
  62996. * The frame ID
  62997. */
  62998. id: number;
  62999. /**
  63000. * The frames Scale
  63001. */
  63002. scale: Vector2;
  63003. /**
  63004. * The Frames offset
  63005. */
  63006. offset: Vector2;
  63007. /**
  63008. * Initializes a texture package frame.
  63009. * @param id The numerical frame identifier
  63010. * @param scale Scalar Vector2 for UV frame
  63011. * @param offset Vector2 for the frame position in UV units.
  63012. * @returns TexturePackerFrame
  63013. */
  63014. constructor(id: number, scale: Vector2, offset: Vector2);
  63015. }
  63016. }
  63017. declare module "babylonjs/Materials/Textures/Packer/packer" {
  63018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63019. import { Scene } from "babylonjs/scene";
  63020. import { Nullable } from "babylonjs/types";
  63021. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  63022. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  63023. /**
  63024. * Defines the basic options interface of a TexturePacker
  63025. */
  63026. export interface ITexturePackerOptions {
  63027. /**
  63028. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63029. */
  63030. map?: string[];
  63031. /**
  63032. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63033. */
  63034. uvsIn?: string;
  63035. /**
  63036. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63037. */
  63038. uvsOut?: string;
  63039. /**
  63040. * number representing the layout style. Defaults to LAYOUT_STRIP
  63041. */
  63042. layout?: number;
  63043. /**
  63044. * number of columns if using custom column count layout(2). This defaults to 4.
  63045. */
  63046. colnum?: number;
  63047. /**
  63048. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63049. */
  63050. updateInputMeshes?: boolean;
  63051. /**
  63052. * boolean flag to dispose all the source textures. Defaults to true.
  63053. */
  63054. disposeSources?: boolean;
  63055. /**
  63056. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63057. */
  63058. fillBlanks?: boolean;
  63059. /**
  63060. * string value representing the context fill style color. Defaults to 'black'.
  63061. */
  63062. customFillColor?: string;
  63063. /**
  63064. * Width and Height Value of each Frame in the TexturePacker Sets
  63065. */
  63066. frameSize?: number;
  63067. /**
  63068. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63069. */
  63070. paddingRatio?: number;
  63071. /**
  63072. * Number that declares the fill method for the padding gutter.
  63073. */
  63074. paddingMode?: number;
  63075. /**
  63076. * If in SUBUV_COLOR padding mode what color to use.
  63077. */
  63078. paddingColor?: Color3 | Color4;
  63079. }
  63080. /**
  63081. * Defines the basic interface of a TexturePacker JSON File
  63082. */
  63083. export interface ITexturePackerJSON {
  63084. /**
  63085. * The frame ID
  63086. */
  63087. name: string;
  63088. /**
  63089. * The base64 channel data
  63090. */
  63091. sets: any;
  63092. /**
  63093. * The options of the Packer
  63094. */
  63095. options: ITexturePackerOptions;
  63096. /**
  63097. * The frame data of the Packer
  63098. */
  63099. frames: Array<number>;
  63100. }
  63101. /**
  63102. * This is a support class that generates a series of packed texture sets.
  63103. * @see https://doc.babylonjs.com/babylon101/materials
  63104. */
  63105. export class TexturePacker {
  63106. /** Packer Layout Constant 0 */
  63107. static readonly LAYOUT_STRIP: number;
  63108. /** Packer Layout Constant 1 */
  63109. static readonly LAYOUT_POWER2: number;
  63110. /** Packer Layout Constant 2 */
  63111. static readonly LAYOUT_COLNUM: number;
  63112. /** Packer Layout Constant 0 */
  63113. static readonly SUBUV_WRAP: number;
  63114. /** Packer Layout Constant 1 */
  63115. static readonly SUBUV_EXTEND: number;
  63116. /** Packer Layout Constant 2 */
  63117. static readonly SUBUV_COLOR: number;
  63118. /** The Name of the Texture Package */
  63119. name: string;
  63120. /** The scene scope of the TexturePacker */
  63121. scene: Scene;
  63122. /** The Meshes to target */
  63123. meshes: AbstractMesh[];
  63124. /** Arguments passed with the Constructor */
  63125. options: ITexturePackerOptions;
  63126. /** The promise that is started upon initialization */
  63127. promise: Nullable<Promise<TexturePacker | string>>;
  63128. /** The Container object for the channel sets that are generated */
  63129. sets: object;
  63130. /** The Container array for the frames that are generated */
  63131. frames: TexturePackerFrame[];
  63132. /** The expected number of textures the system is parsing. */
  63133. private _expecting;
  63134. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63135. private _paddingValue;
  63136. /**
  63137. * Initializes a texture package series from an array of meshes or a single mesh.
  63138. * @param name The name of the package
  63139. * @param meshes The target meshes to compose the package from
  63140. * @param options The arguments that texture packer should follow while building.
  63141. * @param scene The scene which the textures are scoped to.
  63142. * @returns TexturePacker
  63143. */
  63144. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63145. /**
  63146. * Starts the package process
  63147. * @param resolve The promises resolution function
  63148. * @returns TexturePacker
  63149. */
  63150. private _createFrames;
  63151. /**
  63152. * Calculates the Size of the Channel Sets
  63153. * @returns Vector2
  63154. */
  63155. private _calculateSize;
  63156. /**
  63157. * Calculates the UV data for the frames.
  63158. * @param baseSize the base frameSize
  63159. * @param padding the base frame padding
  63160. * @param dtSize size of the Dynamic Texture for that channel
  63161. * @param dtUnits is 1/dtSize
  63162. * @param update flag to update the input meshes
  63163. */
  63164. private _calculateMeshUVFrames;
  63165. /**
  63166. * Calculates the frames Offset.
  63167. * @param index of the frame
  63168. * @returns Vector2
  63169. */
  63170. private _getFrameOffset;
  63171. /**
  63172. * Updates a Mesh to the frame data
  63173. * @param mesh that is the target
  63174. * @param frameID or the frame index
  63175. */
  63176. private _updateMeshUV;
  63177. /**
  63178. * Updates a Meshes materials to use the texture packer channels
  63179. * @param m is the mesh to target
  63180. * @param force all channels on the packer to be set.
  63181. */
  63182. private _updateTextureReferences;
  63183. /**
  63184. * Public method to set a Mesh to a frame
  63185. * @param m that is the target
  63186. * @param frameID or the frame index
  63187. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63188. */
  63189. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63190. /**
  63191. * Starts the async promise to compile the texture packer.
  63192. * @returns Promise<void>
  63193. */
  63194. processAsync(): Promise<void>;
  63195. /**
  63196. * Disposes all textures associated with this packer
  63197. */
  63198. dispose(): void;
  63199. /**
  63200. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63201. * @param imageType is the image type to use.
  63202. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63203. */
  63204. download(imageType?: string, quality?: number): void;
  63205. /**
  63206. * Public method to load a texturePacker JSON file.
  63207. * @param data of the JSON file in string format.
  63208. */
  63209. updateFromJSON(data: string): void;
  63210. }
  63211. }
  63212. declare module "babylonjs/Materials/Textures/Packer/index" {
  63213. export * from "babylonjs/Materials/Textures/Packer/packer";
  63214. export * from "babylonjs/Materials/Textures/Packer/frame";
  63215. }
  63216. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  63217. import { Scene } from "babylonjs/scene";
  63218. import { Texture } from "babylonjs/Materials/Textures/texture";
  63219. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63220. /**
  63221. * 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.
  63222. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63223. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63224. */
  63225. export class CustomProceduralTexture extends ProceduralTexture {
  63226. private _animate;
  63227. private _time;
  63228. private _config;
  63229. private _texturePath;
  63230. /**
  63231. * Instantiates a new Custom Procedural Texture.
  63232. * 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.
  63233. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63234. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63235. * @param name Define the name of the texture
  63236. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63237. * @param size Define the size of the texture to create
  63238. * @param scene Define the scene the texture belongs to
  63239. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63240. * @param generateMipMaps Define if the texture should creates mip maps or not
  63241. */
  63242. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63243. private _loadJson;
  63244. /**
  63245. * Is the texture ready to be used ? (rendered at least once)
  63246. * @returns true if ready, otherwise, false.
  63247. */
  63248. isReady(): boolean;
  63249. /**
  63250. * Render the texture to its associated render target.
  63251. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63252. */
  63253. render(useCameraPostProcess?: boolean): void;
  63254. /**
  63255. * Update the list of dependant textures samplers in the shader.
  63256. */
  63257. updateTextures(): void;
  63258. /**
  63259. * Update the uniform values of the procedural texture in the shader.
  63260. */
  63261. updateShaderUniforms(): void;
  63262. /**
  63263. * Define if the texture animates or not.
  63264. */
  63265. get animate(): boolean;
  63266. set animate(value: boolean);
  63267. }
  63268. }
  63269. declare module "babylonjs/Shaders/noise.fragment" {
  63270. /** @hidden */
  63271. export var noisePixelShader: {
  63272. name: string;
  63273. shader: string;
  63274. };
  63275. }
  63276. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  63277. import { Nullable } from "babylonjs/types";
  63278. import { Scene } from "babylonjs/scene";
  63279. import { Texture } from "babylonjs/Materials/Textures/texture";
  63280. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63281. import "babylonjs/Shaders/noise.fragment";
  63282. /**
  63283. * Class used to generate noise procedural textures
  63284. */
  63285. export class NoiseProceduralTexture extends ProceduralTexture {
  63286. private _time;
  63287. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63288. brightness: number;
  63289. /** Defines the number of octaves to process */
  63290. octaves: number;
  63291. /** Defines the level of persistence (0.8 by default) */
  63292. persistence: number;
  63293. /** Gets or sets animation speed factor (default is 1) */
  63294. animationSpeedFactor: number;
  63295. /**
  63296. * Creates a new NoiseProceduralTexture
  63297. * @param name defines the name fo the texture
  63298. * @param size defines the size of the texture (default is 256)
  63299. * @param scene defines the hosting scene
  63300. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63301. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63302. */
  63303. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63304. private _updateShaderUniforms;
  63305. protected _getDefines(): string;
  63306. /** Generate the current state of the procedural texture */
  63307. render(useCameraPostProcess?: boolean): void;
  63308. /**
  63309. * Serializes this noise procedural texture
  63310. * @returns a serialized noise procedural texture object
  63311. */
  63312. serialize(): any;
  63313. /**
  63314. * Clone the texture.
  63315. * @returns the cloned texture
  63316. */
  63317. clone(): NoiseProceduralTexture;
  63318. /**
  63319. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63320. * @param parsedTexture defines parsed texture data
  63321. * @param scene defines the current scene
  63322. * @param rootUrl defines the root URL containing noise procedural texture information
  63323. * @returns a parsed NoiseProceduralTexture
  63324. */
  63325. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63326. }
  63327. }
  63328. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  63329. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  63330. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  63331. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63332. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  63333. }
  63334. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  63335. import { Nullable } from "babylonjs/types";
  63336. import { Scene } from "babylonjs/scene";
  63337. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  63338. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63339. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63340. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63341. /**
  63342. * Raw cube texture where the raw buffers are passed in
  63343. */
  63344. export class RawCubeTexture extends CubeTexture {
  63345. /**
  63346. * Creates a cube texture where the raw buffers are passed in.
  63347. * @param scene defines the scene the texture is attached to
  63348. * @param data defines the array of data to use to create each face
  63349. * @param size defines the size of the textures
  63350. * @param format defines the format of the data
  63351. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63352. * @param generateMipMaps defines if the engine should generate the mip levels
  63353. * @param invertY defines if data must be stored with Y axis inverted
  63354. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63355. * @param compression defines the compression used (null by default)
  63356. */
  63357. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63358. /**
  63359. * Updates the raw cube texture.
  63360. * @param data defines the data to store
  63361. * @param format defines the data format
  63362. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63363. * @param invertY defines if data must be stored with Y axis inverted
  63364. * @param compression defines the compression used (null by default)
  63365. * @param level defines which level of the texture to update
  63366. */
  63367. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63368. /**
  63369. * Updates a raw cube texture with RGBD encoded data.
  63370. * @param data defines the array of data [mipmap][face] to use to create each face
  63371. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63372. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63373. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63374. * @returns a promsie that resolves when the operation is complete
  63375. */
  63376. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63377. /**
  63378. * Clones the raw cube texture.
  63379. * @return a new cube texture
  63380. */
  63381. clone(): CubeTexture;
  63382. /** @hidden */
  63383. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63384. }
  63385. }
  63386. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  63387. import { Scene } from "babylonjs/scene";
  63388. import { Texture } from "babylonjs/Materials/Textures/texture";
  63389. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63390. /**
  63391. * Class used to store 2D array textures containing user data
  63392. */
  63393. export class RawTexture2DArray extends Texture {
  63394. /** Gets or sets the texture format to use */
  63395. format: number;
  63396. /**
  63397. * Create a new RawTexture2DArray
  63398. * @param data defines the data of the texture
  63399. * @param width defines the width of the texture
  63400. * @param height defines the height of the texture
  63401. * @param depth defines the number of layers of the texture
  63402. * @param format defines the texture format to use
  63403. * @param scene defines the hosting scene
  63404. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63405. * @param invertY defines if texture must be stored with Y axis inverted
  63406. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63407. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63408. */
  63409. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63410. /** Gets or sets the texture format to use */
  63411. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63412. /**
  63413. * Update the texture with new data
  63414. * @param data defines the data to store in the texture
  63415. */
  63416. update(data: ArrayBufferView): void;
  63417. }
  63418. }
  63419. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  63420. import { Scene } from "babylonjs/scene";
  63421. import { Texture } from "babylonjs/Materials/Textures/texture";
  63422. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63423. /**
  63424. * Class used to store 3D textures containing user data
  63425. */
  63426. export class RawTexture3D extends Texture {
  63427. /** Gets or sets the texture format to use */
  63428. format: number;
  63429. /**
  63430. * Create a new RawTexture3D
  63431. * @param data defines the data of the texture
  63432. * @param width defines the width of the texture
  63433. * @param height defines the height of the texture
  63434. * @param depth defines the depth of the texture
  63435. * @param format defines the texture format to use
  63436. * @param scene defines the hosting scene
  63437. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63438. * @param invertY defines if texture must be stored with Y axis inverted
  63439. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63440. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63441. */
  63442. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63443. /** Gets or sets the texture format to use */
  63444. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63445. /**
  63446. * Update the texture with new data
  63447. * @param data defines the data to store in the texture
  63448. */
  63449. update(data: ArrayBufferView): void;
  63450. }
  63451. }
  63452. declare module "babylonjs/Materials/Textures/refractionTexture" {
  63453. import { Scene } from "babylonjs/scene";
  63454. import { Plane } from "babylonjs/Maths/math.plane";
  63455. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63456. /**
  63457. * Creates a refraction texture used by refraction channel of the standard material.
  63458. * It is like a mirror but to see through a material.
  63459. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63460. */
  63461. export class RefractionTexture extends RenderTargetTexture {
  63462. /**
  63463. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63464. * 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.
  63465. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63466. */
  63467. refractionPlane: Plane;
  63468. /**
  63469. * Define how deep under the surface we should see.
  63470. */
  63471. depth: number;
  63472. /**
  63473. * Creates a refraction texture used by refraction channel of the standard material.
  63474. * It is like a mirror but to see through a material.
  63475. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63476. * @param name Define the texture name
  63477. * @param size Define the size of the underlying texture
  63478. * @param scene Define the scene the refraction belongs to
  63479. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63480. */
  63481. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63482. /**
  63483. * Clone the refraction texture.
  63484. * @returns the cloned texture
  63485. */
  63486. clone(): RefractionTexture;
  63487. /**
  63488. * Serialize the texture to a JSON representation you could use in Parse later on
  63489. * @returns the serialized JSON representation
  63490. */
  63491. serialize(): any;
  63492. }
  63493. }
  63494. declare module "babylonjs/Materials/Textures/index" {
  63495. export * from "babylonjs/Materials/Textures/baseTexture";
  63496. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  63497. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  63498. export * from "babylonjs/Materials/Textures/cubeTexture";
  63499. export * from "babylonjs/Materials/Textures/dynamicTexture";
  63500. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  63501. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  63502. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  63503. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  63504. export * from "babylonjs/Materials/Textures/internalTexture";
  63505. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  63506. export * from "babylonjs/Materials/Textures/Loaders/index";
  63507. export * from "babylonjs/Materials/Textures/mirrorTexture";
  63508. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  63509. export * from "babylonjs/Materials/Textures/Packer/index";
  63510. export * from "babylonjs/Materials/Textures/Procedurals/index";
  63511. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  63512. export * from "babylonjs/Materials/Textures/rawTexture";
  63513. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  63514. export * from "babylonjs/Materials/Textures/rawTexture3D";
  63515. export * from "babylonjs/Materials/Textures/refractionTexture";
  63516. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  63517. export * from "babylonjs/Materials/Textures/texture";
  63518. export * from "babylonjs/Materials/Textures/videoTexture";
  63519. }
  63520. declare module "babylonjs/Materials/Node/Enums/index" {
  63521. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  63522. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  63523. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  63524. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  63525. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  63526. }
  63527. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  63528. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63529. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63531. import { Mesh } from "babylonjs/Meshes/mesh";
  63532. import { Effect } from "babylonjs/Materials/effect";
  63533. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63534. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63535. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63536. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63537. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  63538. /**
  63539. * Block used to add support for vertex skinning (bones)
  63540. */
  63541. export class BonesBlock extends NodeMaterialBlock {
  63542. /**
  63543. * Creates a new BonesBlock
  63544. * @param name defines the block name
  63545. */
  63546. constructor(name: string);
  63547. /**
  63548. * Initialize the block and prepare the context for build
  63549. * @param state defines the state that will be used for the build
  63550. */
  63551. initialize(state: NodeMaterialBuildState): void;
  63552. /**
  63553. * Gets the current class name
  63554. * @returns the class name
  63555. */
  63556. getClassName(): string;
  63557. /**
  63558. * Gets the matrix indices input component
  63559. */
  63560. get matricesIndices(): NodeMaterialConnectionPoint;
  63561. /**
  63562. * Gets the matrix weights input component
  63563. */
  63564. get matricesWeights(): NodeMaterialConnectionPoint;
  63565. /**
  63566. * Gets the extra matrix indices input component
  63567. */
  63568. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63569. /**
  63570. * Gets the extra matrix weights input component
  63571. */
  63572. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63573. /**
  63574. * Gets the world input component
  63575. */
  63576. get world(): NodeMaterialConnectionPoint;
  63577. /**
  63578. * Gets the output component
  63579. */
  63580. get output(): NodeMaterialConnectionPoint;
  63581. autoConfigure(material: NodeMaterial): void;
  63582. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63583. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63584. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63585. protected _buildBlock(state: NodeMaterialBuildState): this;
  63586. }
  63587. }
  63588. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  63589. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63590. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63591. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63592. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63593. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63594. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63595. /**
  63596. * Block used to add support for instances
  63597. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63598. */
  63599. export class InstancesBlock extends NodeMaterialBlock {
  63600. /**
  63601. * Creates a new InstancesBlock
  63602. * @param name defines the block name
  63603. */
  63604. constructor(name: string);
  63605. /**
  63606. * Gets the current class name
  63607. * @returns the class name
  63608. */
  63609. getClassName(): string;
  63610. /**
  63611. * Gets the first world row input component
  63612. */
  63613. get world0(): NodeMaterialConnectionPoint;
  63614. /**
  63615. * Gets the second world row input component
  63616. */
  63617. get world1(): NodeMaterialConnectionPoint;
  63618. /**
  63619. * Gets the third world row input component
  63620. */
  63621. get world2(): NodeMaterialConnectionPoint;
  63622. /**
  63623. * Gets the forth world row input component
  63624. */
  63625. get world3(): NodeMaterialConnectionPoint;
  63626. /**
  63627. * Gets the world input component
  63628. */
  63629. get world(): NodeMaterialConnectionPoint;
  63630. /**
  63631. * Gets the output component
  63632. */
  63633. get output(): NodeMaterialConnectionPoint;
  63634. /**
  63635. * Gets the isntanceID component
  63636. */
  63637. get instanceID(): NodeMaterialConnectionPoint;
  63638. autoConfigure(material: NodeMaterial): void;
  63639. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63640. protected _buildBlock(state: NodeMaterialBuildState): this;
  63641. }
  63642. }
  63643. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  63644. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63645. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63646. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63647. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63648. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63649. import { Effect } from "babylonjs/Materials/effect";
  63650. import { Mesh } from "babylonjs/Meshes/mesh";
  63651. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63652. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63653. /**
  63654. * Block used to add morph targets support to vertex shader
  63655. */
  63656. export class MorphTargetsBlock extends NodeMaterialBlock {
  63657. private _repeatableContentAnchor;
  63658. /**
  63659. * Create a new MorphTargetsBlock
  63660. * @param name defines the block name
  63661. */
  63662. constructor(name: string);
  63663. /**
  63664. * Gets the current class name
  63665. * @returns the class name
  63666. */
  63667. getClassName(): string;
  63668. /**
  63669. * Gets the position input component
  63670. */
  63671. get position(): NodeMaterialConnectionPoint;
  63672. /**
  63673. * Gets the normal input component
  63674. */
  63675. get normal(): NodeMaterialConnectionPoint;
  63676. /**
  63677. * Gets the tangent input component
  63678. */
  63679. get tangent(): NodeMaterialConnectionPoint;
  63680. /**
  63681. * Gets the tangent input component
  63682. */
  63683. get uv(): NodeMaterialConnectionPoint;
  63684. /**
  63685. * Gets the position output component
  63686. */
  63687. get positionOutput(): NodeMaterialConnectionPoint;
  63688. /**
  63689. * Gets the normal output component
  63690. */
  63691. get normalOutput(): NodeMaterialConnectionPoint;
  63692. /**
  63693. * Gets the tangent output component
  63694. */
  63695. get tangentOutput(): NodeMaterialConnectionPoint;
  63696. /**
  63697. * Gets the tangent output component
  63698. */
  63699. get uvOutput(): NodeMaterialConnectionPoint;
  63700. initialize(state: NodeMaterialBuildState): void;
  63701. autoConfigure(material: NodeMaterial): void;
  63702. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63703. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63704. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  63705. protected _buildBlock(state: NodeMaterialBuildState): this;
  63706. }
  63707. }
  63708. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  63709. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63710. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63711. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63712. import { Nullable } from "babylonjs/types";
  63713. import { Scene } from "babylonjs/scene";
  63714. import { Effect } from "babylonjs/Materials/effect";
  63715. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63716. import { Mesh } from "babylonjs/Meshes/mesh";
  63717. import { Light } from "babylonjs/Lights/light";
  63718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63719. /**
  63720. * Block used to get data information from a light
  63721. */
  63722. export class LightInformationBlock extends NodeMaterialBlock {
  63723. private _lightDataUniformName;
  63724. private _lightColorUniformName;
  63725. private _lightTypeDefineName;
  63726. /**
  63727. * Gets or sets the light associated with this block
  63728. */
  63729. light: Nullable<Light>;
  63730. /**
  63731. * Creates a new LightInformationBlock
  63732. * @param name defines the block name
  63733. */
  63734. constructor(name: string);
  63735. /**
  63736. * Gets the current class name
  63737. * @returns the class name
  63738. */
  63739. getClassName(): string;
  63740. /**
  63741. * Gets the world position input component
  63742. */
  63743. get worldPosition(): NodeMaterialConnectionPoint;
  63744. /**
  63745. * Gets the direction output component
  63746. */
  63747. get direction(): NodeMaterialConnectionPoint;
  63748. /**
  63749. * Gets the direction output component
  63750. */
  63751. get color(): NodeMaterialConnectionPoint;
  63752. /**
  63753. * Gets the direction output component
  63754. */
  63755. get intensity(): NodeMaterialConnectionPoint;
  63756. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63757. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63758. protected _buildBlock(state: NodeMaterialBuildState): this;
  63759. serialize(): any;
  63760. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63761. }
  63762. }
  63763. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  63764. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  63765. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  63766. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  63767. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  63768. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  63769. }
  63770. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  63771. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63772. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63773. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63775. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63776. import { Effect } from "babylonjs/Materials/effect";
  63777. import { Mesh } from "babylonjs/Meshes/mesh";
  63778. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63779. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  63780. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  63781. /**
  63782. * Block used to add image processing support to fragment shader
  63783. */
  63784. export class ImageProcessingBlock extends NodeMaterialBlock {
  63785. /**
  63786. * Create a new ImageProcessingBlock
  63787. * @param name defines the block name
  63788. */
  63789. constructor(name: string);
  63790. /**
  63791. * Gets the current class name
  63792. * @returns the class name
  63793. */
  63794. getClassName(): string;
  63795. /**
  63796. * Gets the color input component
  63797. */
  63798. get color(): NodeMaterialConnectionPoint;
  63799. /**
  63800. * Gets the output component
  63801. */
  63802. get output(): NodeMaterialConnectionPoint;
  63803. /**
  63804. * Initialize the block and prepare the context for build
  63805. * @param state defines the state that will be used for the build
  63806. */
  63807. initialize(state: NodeMaterialBuildState): void;
  63808. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  63809. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63810. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63811. protected _buildBlock(state: NodeMaterialBuildState): this;
  63812. }
  63813. }
  63814. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  63815. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63816. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63817. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63818. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63820. import { Effect } from "babylonjs/Materials/effect";
  63821. import { Mesh } from "babylonjs/Meshes/mesh";
  63822. import { Scene } from "babylonjs/scene";
  63823. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  63824. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  63825. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  63826. /**
  63827. * Block used to pertub normals based on a normal map
  63828. */
  63829. export class PerturbNormalBlock extends NodeMaterialBlock {
  63830. private _tangentSpaceParameterName;
  63831. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63832. invertX: boolean;
  63833. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  63834. invertY: boolean;
  63835. /**
  63836. * Create a new PerturbNormalBlock
  63837. * @param name defines the block name
  63838. */
  63839. constructor(name: string);
  63840. /**
  63841. * Gets the current class name
  63842. * @returns the class name
  63843. */
  63844. getClassName(): string;
  63845. /**
  63846. * Gets the world position input component
  63847. */
  63848. get worldPosition(): NodeMaterialConnectionPoint;
  63849. /**
  63850. * Gets the world normal input component
  63851. */
  63852. get worldNormal(): NodeMaterialConnectionPoint;
  63853. /**
  63854. * Gets the world tangent input component
  63855. */
  63856. get worldTangent(): NodeMaterialConnectionPoint;
  63857. /**
  63858. * Gets the uv input component
  63859. */
  63860. get uv(): NodeMaterialConnectionPoint;
  63861. /**
  63862. * Gets the normal map color input component
  63863. */
  63864. get normalMapColor(): NodeMaterialConnectionPoint;
  63865. /**
  63866. * Gets the strength input component
  63867. */
  63868. get strength(): NodeMaterialConnectionPoint;
  63869. /**
  63870. * Gets the output component
  63871. */
  63872. get output(): NodeMaterialConnectionPoint;
  63873. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63874. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63875. autoConfigure(material: NodeMaterial): void;
  63876. protected _buildBlock(state: NodeMaterialBuildState): this;
  63877. protected _dumpPropertiesCode(): string;
  63878. serialize(): any;
  63879. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63880. }
  63881. }
  63882. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  63883. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63884. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63885. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63886. /**
  63887. * Block used to discard a pixel if a value is smaller than a cutoff
  63888. */
  63889. export class DiscardBlock extends NodeMaterialBlock {
  63890. /**
  63891. * Create a new DiscardBlock
  63892. * @param name defines the block name
  63893. */
  63894. constructor(name: string);
  63895. /**
  63896. * Gets the current class name
  63897. * @returns the class name
  63898. */
  63899. getClassName(): string;
  63900. /**
  63901. * Gets the color input component
  63902. */
  63903. get value(): NodeMaterialConnectionPoint;
  63904. /**
  63905. * Gets the cutoff input component
  63906. */
  63907. get cutoff(): NodeMaterialConnectionPoint;
  63908. protected _buildBlock(state: NodeMaterialBuildState): this;
  63909. }
  63910. }
  63911. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  63912. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63913. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63914. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63915. /**
  63916. * Block used to test if the fragment shader is front facing
  63917. */
  63918. export class FrontFacingBlock extends NodeMaterialBlock {
  63919. /**
  63920. * Creates a new FrontFacingBlock
  63921. * @param name defines the block name
  63922. */
  63923. constructor(name: string);
  63924. /**
  63925. * Gets the current class name
  63926. * @returns the class name
  63927. */
  63928. getClassName(): string;
  63929. /**
  63930. * Gets the output component
  63931. */
  63932. get output(): NodeMaterialConnectionPoint;
  63933. protected _buildBlock(state: NodeMaterialBuildState): this;
  63934. }
  63935. }
  63936. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  63937. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63938. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63939. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63940. /**
  63941. * Block used to get the derivative value on x and y of a given input
  63942. */
  63943. export class DerivativeBlock extends NodeMaterialBlock {
  63944. /**
  63945. * Create a new DerivativeBlock
  63946. * @param name defines the block name
  63947. */
  63948. constructor(name: string);
  63949. /**
  63950. * Gets the current class name
  63951. * @returns the class name
  63952. */
  63953. getClassName(): string;
  63954. /**
  63955. * Gets the input component
  63956. */
  63957. get input(): NodeMaterialConnectionPoint;
  63958. /**
  63959. * Gets the derivative output on x
  63960. */
  63961. get dx(): NodeMaterialConnectionPoint;
  63962. /**
  63963. * Gets the derivative output on y
  63964. */
  63965. get dy(): NodeMaterialConnectionPoint;
  63966. protected _buildBlock(state: NodeMaterialBuildState): this;
  63967. }
  63968. }
  63969. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  63970. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63971. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63972. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63973. /**
  63974. * Block used to make gl_FragCoord available
  63975. */
  63976. export class FragCoordBlock extends NodeMaterialBlock {
  63977. /**
  63978. * Creates a new FragCoordBlock
  63979. * @param name defines the block name
  63980. */
  63981. constructor(name: string);
  63982. /**
  63983. * Gets the current class name
  63984. * @returns the class name
  63985. */
  63986. getClassName(): string;
  63987. /**
  63988. * Gets the xy component
  63989. */
  63990. get xy(): NodeMaterialConnectionPoint;
  63991. /**
  63992. * Gets the xyz component
  63993. */
  63994. get xyz(): NodeMaterialConnectionPoint;
  63995. /**
  63996. * Gets the xyzw component
  63997. */
  63998. get xyzw(): NodeMaterialConnectionPoint;
  63999. /**
  64000. * Gets the x component
  64001. */
  64002. get x(): NodeMaterialConnectionPoint;
  64003. /**
  64004. * Gets the y component
  64005. */
  64006. get y(): NodeMaterialConnectionPoint;
  64007. /**
  64008. * Gets the z component
  64009. */
  64010. get z(): NodeMaterialConnectionPoint;
  64011. /**
  64012. * Gets the w component
  64013. */
  64014. get output(): NodeMaterialConnectionPoint;
  64015. protected writeOutputs(state: NodeMaterialBuildState): string;
  64016. protected _buildBlock(state: NodeMaterialBuildState): this;
  64017. }
  64018. }
  64019. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  64020. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64021. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64022. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64023. import { Effect } from "babylonjs/Materials/effect";
  64024. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64025. import { Mesh } from "babylonjs/Meshes/mesh";
  64026. /**
  64027. * Block used to get the screen sizes
  64028. */
  64029. export class ScreenSizeBlock extends NodeMaterialBlock {
  64030. private _varName;
  64031. private _scene;
  64032. /**
  64033. * Creates a new ScreenSizeBlock
  64034. * @param name defines the block name
  64035. */
  64036. constructor(name: string);
  64037. /**
  64038. * Gets the current class name
  64039. * @returns the class name
  64040. */
  64041. getClassName(): string;
  64042. /**
  64043. * Gets the xy component
  64044. */
  64045. get xy(): NodeMaterialConnectionPoint;
  64046. /**
  64047. * Gets the x component
  64048. */
  64049. get x(): NodeMaterialConnectionPoint;
  64050. /**
  64051. * Gets the y component
  64052. */
  64053. get y(): NodeMaterialConnectionPoint;
  64054. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64055. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  64056. protected _buildBlock(state: NodeMaterialBuildState): this;
  64057. }
  64058. }
  64059. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  64060. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  64061. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  64062. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  64063. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  64064. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  64065. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  64066. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  64067. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  64068. }
  64069. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  64070. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64071. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64072. import { Mesh } from "babylonjs/Meshes/mesh";
  64073. import { Effect } from "babylonjs/Materials/effect";
  64074. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64076. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64077. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  64078. /**
  64079. * Block used to add support for scene fog
  64080. */
  64081. export class FogBlock extends NodeMaterialBlock {
  64082. private _fogDistanceName;
  64083. private _fogParameters;
  64084. /**
  64085. * Create a new FogBlock
  64086. * @param name defines the block name
  64087. */
  64088. constructor(name: string);
  64089. /**
  64090. * Gets the current class name
  64091. * @returns the class name
  64092. */
  64093. getClassName(): string;
  64094. /**
  64095. * Gets the world position input component
  64096. */
  64097. get worldPosition(): NodeMaterialConnectionPoint;
  64098. /**
  64099. * Gets the view input component
  64100. */
  64101. get view(): NodeMaterialConnectionPoint;
  64102. /**
  64103. * Gets the color input component
  64104. */
  64105. get input(): NodeMaterialConnectionPoint;
  64106. /**
  64107. * Gets the fog color input component
  64108. */
  64109. get fogColor(): NodeMaterialConnectionPoint;
  64110. /**
  64111. * Gets the output component
  64112. */
  64113. get output(): NodeMaterialConnectionPoint;
  64114. autoConfigure(material: NodeMaterial): void;
  64115. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64116. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64117. protected _buildBlock(state: NodeMaterialBuildState): this;
  64118. }
  64119. }
  64120. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  64121. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64122. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64123. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64125. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64126. import { Effect } from "babylonjs/Materials/effect";
  64127. import { Mesh } from "babylonjs/Meshes/mesh";
  64128. import { Light } from "babylonjs/Lights/light";
  64129. import { Nullable } from "babylonjs/types";
  64130. import { Scene } from "babylonjs/scene";
  64131. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  64132. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  64133. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  64134. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64135. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  64136. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  64137. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  64138. /**
  64139. * Block used to add light in the fragment shader
  64140. */
  64141. export class LightBlock extends NodeMaterialBlock {
  64142. private _lightId;
  64143. /**
  64144. * Gets or sets the light associated with this block
  64145. */
  64146. light: Nullable<Light>;
  64147. /**
  64148. * Create a new LightBlock
  64149. * @param name defines the block name
  64150. */
  64151. constructor(name: string);
  64152. /**
  64153. * Gets the current class name
  64154. * @returns the class name
  64155. */
  64156. getClassName(): string;
  64157. /**
  64158. * Gets the world position input component
  64159. */
  64160. get worldPosition(): NodeMaterialConnectionPoint;
  64161. /**
  64162. * Gets the world normal input component
  64163. */
  64164. get worldNormal(): NodeMaterialConnectionPoint;
  64165. /**
  64166. * Gets the camera (or eye) position component
  64167. */
  64168. get cameraPosition(): NodeMaterialConnectionPoint;
  64169. /**
  64170. * Gets the glossiness component
  64171. */
  64172. get glossiness(): NodeMaterialConnectionPoint;
  64173. /**
  64174. * Gets the glossinness power component
  64175. */
  64176. get glossPower(): NodeMaterialConnectionPoint;
  64177. /**
  64178. * Gets the diffuse color component
  64179. */
  64180. get diffuseColor(): NodeMaterialConnectionPoint;
  64181. /**
  64182. * Gets the specular color component
  64183. */
  64184. get specularColor(): NodeMaterialConnectionPoint;
  64185. /**
  64186. * Gets the diffuse output component
  64187. */
  64188. get diffuseOutput(): NodeMaterialConnectionPoint;
  64189. /**
  64190. * Gets the specular output component
  64191. */
  64192. get specularOutput(): NodeMaterialConnectionPoint;
  64193. /**
  64194. * Gets the shadow output component
  64195. */
  64196. get shadow(): NodeMaterialConnectionPoint;
  64197. autoConfigure(material: NodeMaterial): void;
  64198. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64199. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64200. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64201. private _injectVertexCode;
  64202. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64203. serialize(): any;
  64204. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64205. }
  64206. }
  64207. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  64208. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64209. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64210. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64211. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  64212. /**
  64213. * Block used to read a reflection texture from a sampler
  64214. */
  64215. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64216. /**
  64217. * Create a new ReflectionTextureBlock
  64218. * @param name defines the block name
  64219. */
  64220. constructor(name: string);
  64221. /**
  64222. * Gets the current class name
  64223. * @returns the class name
  64224. */
  64225. getClassName(): string;
  64226. /**
  64227. * Gets the world position input component
  64228. */
  64229. get position(): NodeMaterialConnectionPoint;
  64230. /**
  64231. * Gets the world position input component
  64232. */
  64233. get worldPosition(): NodeMaterialConnectionPoint;
  64234. /**
  64235. * Gets the world normal input component
  64236. */
  64237. get worldNormal(): NodeMaterialConnectionPoint;
  64238. /**
  64239. * Gets the world input component
  64240. */
  64241. get world(): NodeMaterialConnectionPoint;
  64242. /**
  64243. * Gets the camera (or eye) position component
  64244. */
  64245. get cameraPosition(): NodeMaterialConnectionPoint;
  64246. /**
  64247. * Gets the view input component
  64248. */
  64249. get view(): NodeMaterialConnectionPoint;
  64250. /**
  64251. * Gets the rgb output component
  64252. */
  64253. get rgb(): NodeMaterialConnectionPoint;
  64254. /**
  64255. * Gets the r output component
  64256. */
  64257. get r(): NodeMaterialConnectionPoint;
  64258. /**
  64259. * Gets the g output component
  64260. */
  64261. get g(): NodeMaterialConnectionPoint;
  64262. /**
  64263. * Gets the b output component
  64264. */
  64265. get b(): NodeMaterialConnectionPoint;
  64266. autoConfigure(material: NodeMaterial): void;
  64267. protected _buildBlock(state: NodeMaterialBuildState): this;
  64268. }
  64269. }
  64270. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  64271. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  64272. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  64273. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  64274. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  64275. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  64276. }
  64277. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  64278. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  64279. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  64280. }
  64281. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  64282. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64283. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64284. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64285. /**
  64286. * Block used to add 2 vectors
  64287. */
  64288. export class AddBlock extends NodeMaterialBlock {
  64289. /**
  64290. * Creates a new AddBlock
  64291. * @param name defines the block name
  64292. */
  64293. constructor(name: string);
  64294. /**
  64295. * Gets the current class name
  64296. * @returns the class name
  64297. */
  64298. getClassName(): string;
  64299. /**
  64300. * Gets the left operand input component
  64301. */
  64302. get left(): NodeMaterialConnectionPoint;
  64303. /**
  64304. * Gets the right operand input component
  64305. */
  64306. get right(): NodeMaterialConnectionPoint;
  64307. /**
  64308. * Gets the output component
  64309. */
  64310. get output(): NodeMaterialConnectionPoint;
  64311. protected _buildBlock(state: NodeMaterialBuildState): this;
  64312. }
  64313. }
  64314. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  64315. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64316. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64317. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64318. /**
  64319. * Block used to scale a vector by a float
  64320. */
  64321. export class ScaleBlock extends NodeMaterialBlock {
  64322. /**
  64323. * Creates a new ScaleBlock
  64324. * @param name defines the block name
  64325. */
  64326. constructor(name: string);
  64327. /**
  64328. * Gets the current class name
  64329. * @returns the class name
  64330. */
  64331. getClassName(): string;
  64332. /**
  64333. * Gets the input component
  64334. */
  64335. get input(): NodeMaterialConnectionPoint;
  64336. /**
  64337. * Gets the factor input component
  64338. */
  64339. get factor(): NodeMaterialConnectionPoint;
  64340. /**
  64341. * Gets the output component
  64342. */
  64343. get output(): NodeMaterialConnectionPoint;
  64344. protected _buildBlock(state: NodeMaterialBuildState): this;
  64345. }
  64346. }
  64347. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  64348. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64349. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64350. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64351. import { Scene } from "babylonjs/scene";
  64352. /**
  64353. * Block used to clamp a float
  64354. */
  64355. export class ClampBlock extends NodeMaterialBlock {
  64356. /** Gets or sets the minimum range */
  64357. minimum: number;
  64358. /** Gets or sets the maximum range */
  64359. maximum: number;
  64360. /**
  64361. * Creates a new ClampBlock
  64362. * @param name defines the block name
  64363. */
  64364. constructor(name: string);
  64365. /**
  64366. * Gets the current class name
  64367. * @returns the class name
  64368. */
  64369. getClassName(): string;
  64370. /**
  64371. * Gets the value input component
  64372. */
  64373. get value(): NodeMaterialConnectionPoint;
  64374. /**
  64375. * Gets the output component
  64376. */
  64377. get output(): NodeMaterialConnectionPoint;
  64378. protected _buildBlock(state: NodeMaterialBuildState): this;
  64379. protected _dumpPropertiesCode(): string;
  64380. serialize(): any;
  64381. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64382. }
  64383. }
  64384. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  64385. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64386. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64387. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64388. /**
  64389. * Block used to apply a cross product between 2 vectors
  64390. */
  64391. export class CrossBlock extends NodeMaterialBlock {
  64392. /**
  64393. * Creates a new CrossBlock
  64394. * @param name defines the block name
  64395. */
  64396. constructor(name: string);
  64397. /**
  64398. * Gets the current class name
  64399. * @returns the class name
  64400. */
  64401. getClassName(): string;
  64402. /**
  64403. * Gets the left operand input component
  64404. */
  64405. get left(): NodeMaterialConnectionPoint;
  64406. /**
  64407. * Gets the right operand input component
  64408. */
  64409. get right(): NodeMaterialConnectionPoint;
  64410. /**
  64411. * Gets the output component
  64412. */
  64413. get output(): NodeMaterialConnectionPoint;
  64414. protected _buildBlock(state: NodeMaterialBuildState): this;
  64415. }
  64416. }
  64417. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  64418. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64419. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64420. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64421. /**
  64422. * Block used to apply a dot product between 2 vectors
  64423. */
  64424. export class DotBlock extends NodeMaterialBlock {
  64425. /**
  64426. * Creates a new DotBlock
  64427. * @param name defines the block name
  64428. */
  64429. constructor(name: string);
  64430. /**
  64431. * Gets the current class name
  64432. * @returns the class name
  64433. */
  64434. getClassName(): string;
  64435. /**
  64436. * Gets the left operand input component
  64437. */
  64438. get left(): NodeMaterialConnectionPoint;
  64439. /**
  64440. * Gets the right operand input component
  64441. */
  64442. get right(): NodeMaterialConnectionPoint;
  64443. /**
  64444. * Gets the output component
  64445. */
  64446. get output(): NodeMaterialConnectionPoint;
  64447. protected _buildBlock(state: NodeMaterialBuildState): this;
  64448. }
  64449. }
  64450. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  64451. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64452. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64453. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64454. /**
  64455. * Block used to normalize a vector
  64456. */
  64457. export class NormalizeBlock extends NodeMaterialBlock {
  64458. /**
  64459. * Creates a new NormalizeBlock
  64460. * @param name defines the block name
  64461. */
  64462. constructor(name: string);
  64463. /**
  64464. * Gets the current class name
  64465. * @returns the class name
  64466. */
  64467. getClassName(): string;
  64468. /**
  64469. * Gets the input component
  64470. */
  64471. get input(): NodeMaterialConnectionPoint;
  64472. /**
  64473. * Gets the output component
  64474. */
  64475. get output(): NodeMaterialConnectionPoint;
  64476. protected _buildBlock(state: NodeMaterialBuildState): this;
  64477. }
  64478. }
  64479. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  64480. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64481. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64482. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64483. import { Scene } from "babylonjs/scene";
  64484. /**
  64485. * Operations supported by the Trigonometry block
  64486. */
  64487. export enum TrigonometryBlockOperations {
  64488. /** Cos */
  64489. Cos = 0,
  64490. /** Sin */
  64491. Sin = 1,
  64492. /** Abs */
  64493. Abs = 2,
  64494. /** Exp */
  64495. Exp = 3,
  64496. /** Exp2 */
  64497. Exp2 = 4,
  64498. /** Round */
  64499. Round = 5,
  64500. /** Floor */
  64501. Floor = 6,
  64502. /** Ceiling */
  64503. Ceiling = 7,
  64504. /** Square root */
  64505. Sqrt = 8,
  64506. /** Log */
  64507. Log = 9,
  64508. /** Tangent */
  64509. Tan = 10,
  64510. /** Arc tangent */
  64511. ArcTan = 11,
  64512. /** Arc cosinus */
  64513. ArcCos = 12,
  64514. /** Arc sinus */
  64515. ArcSin = 13,
  64516. /** Fraction */
  64517. Fract = 14,
  64518. /** Sign */
  64519. Sign = 15,
  64520. /** To radians (from degrees) */
  64521. Radians = 16,
  64522. /** To degrees (from radians) */
  64523. Degrees = 17
  64524. }
  64525. /**
  64526. * Block used to apply trigonometry operation to floats
  64527. */
  64528. export class TrigonometryBlock extends NodeMaterialBlock {
  64529. /**
  64530. * Gets or sets the operation applied by the block
  64531. */
  64532. operation: TrigonometryBlockOperations;
  64533. /**
  64534. * Creates a new TrigonometryBlock
  64535. * @param name defines the block name
  64536. */
  64537. constructor(name: string);
  64538. /**
  64539. * Gets the current class name
  64540. * @returns the class name
  64541. */
  64542. getClassName(): string;
  64543. /**
  64544. * Gets the input component
  64545. */
  64546. get input(): NodeMaterialConnectionPoint;
  64547. /**
  64548. * Gets the output component
  64549. */
  64550. get output(): NodeMaterialConnectionPoint;
  64551. protected _buildBlock(state: NodeMaterialBuildState): this;
  64552. serialize(): any;
  64553. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64554. protected _dumpPropertiesCode(): string;
  64555. }
  64556. }
  64557. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  64558. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64559. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64560. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64561. /**
  64562. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64563. */
  64564. export class ColorMergerBlock extends NodeMaterialBlock {
  64565. /**
  64566. * Create a new ColorMergerBlock
  64567. * @param name defines the block name
  64568. */
  64569. constructor(name: string);
  64570. /**
  64571. * Gets the current class name
  64572. * @returns the class name
  64573. */
  64574. getClassName(): string;
  64575. /**
  64576. * Gets the rgb component (input)
  64577. */
  64578. get rgbIn(): NodeMaterialConnectionPoint;
  64579. /**
  64580. * Gets the r component (input)
  64581. */
  64582. get r(): NodeMaterialConnectionPoint;
  64583. /**
  64584. * Gets the g component (input)
  64585. */
  64586. get g(): NodeMaterialConnectionPoint;
  64587. /**
  64588. * Gets the b component (input)
  64589. */
  64590. get b(): NodeMaterialConnectionPoint;
  64591. /**
  64592. * Gets the a component (input)
  64593. */
  64594. get a(): NodeMaterialConnectionPoint;
  64595. /**
  64596. * Gets the rgba component (output)
  64597. */
  64598. get rgba(): NodeMaterialConnectionPoint;
  64599. /**
  64600. * Gets the rgb component (output)
  64601. */
  64602. get rgbOut(): NodeMaterialConnectionPoint;
  64603. /**
  64604. * Gets the rgb component (output)
  64605. * @deprecated Please use rgbOut instead.
  64606. */
  64607. get rgb(): NodeMaterialConnectionPoint;
  64608. protected _buildBlock(state: NodeMaterialBuildState): this;
  64609. }
  64610. }
  64611. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  64612. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64613. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64614. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64615. /**
  64616. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64617. */
  64618. export class VectorSplitterBlock extends NodeMaterialBlock {
  64619. /**
  64620. * Create a new VectorSplitterBlock
  64621. * @param name defines the block name
  64622. */
  64623. constructor(name: string);
  64624. /**
  64625. * Gets the current class name
  64626. * @returns the class name
  64627. */
  64628. getClassName(): string;
  64629. /**
  64630. * Gets the xyzw component (input)
  64631. */
  64632. get xyzw(): NodeMaterialConnectionPoint;
  64633. /**
  64634. * Gets the xyz component (input)
  64635. */
  64636. get xyzIn(): NodeMaterialConnectionPoint;
  64637. /**
  64638. * Gets the xy component (input)
  64639. */
  64640. get xyIn(): NodeMaterialConnectionPoint;
  64641. /**
  64642. * Gets the xyz component (output)
  64643. */
  64644. get xyzOut(): NodeMaterialConnectionPoint;
  64645. /**
  64646. * Gets the xy component (output)
  64647. */
  64648. get xyOut(): NodeMaterialConnectionPoint;
  64649. /**
  64650. * Gets the x component (output)
  64651. */
  64652. get x(): NodeMaterialConnectionPoint;
  64653. /**
  64654. * Gets the y component (output)
  64655. */
  64656. get y(): NodeMaterialConnectionPoint;
  64657. /**
  64658. * Gets the z component (output)
  64659. */
  64660. get z(): NodeMaterialConnectionPoint;
  64661. /**
  64662. * Gets the w component (output)
  64663. */
  64664. get w(): NodeMaterialConnectionPoint;
  64665. protected _inputRename(name: string): string;
  64666. protected _outputRename(name: string): string;
  64667. protected _buildBlock(state: NodeMaterialBuildState): this;
  64668. }
  64669. }
  64670. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  64671. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64672. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64673. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64674. /**
  64675. * Block used to lerp between 2 values
  64676. */
  64677. export class LerpBlock extends NodeMaterialBlock {
  64678. /**
  64679. * Creates a new LerpBlock
  64680. * @param name defines the block name
  64681. */
  64682. constructor(name: string);
  64683. /**
  64684. * Gets the current class name
  64685. * @returns the class name
  64686. */
  64687. getClassName(): string;
  64688. /**
  64689. * Gets the left operand input component
  64690. */
  64691. get left(): NodeMaterialConnectionPoint;
  64692. /**
  64693. * Gets the right operand input component
  64694. */
  64695. get right(): NodeMaterialConnectionPoint;
  64696. /**
  64697. * Gets the gradient operand input component
  64698. */
  64699. get gradient(): NodeMaterialConnectionPoint;
  64700. /**
  64701. * Gets the output component
  64702. */
  64703. get output(): NodeMaterialConnectionPoint;
  64704. protected _buildBlock(state: NodeMaterialBuildState): this;
  64705. }
  64706. }
  64707. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  64708. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64709. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64710. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64711. /**
  64712. * Block used to divide 2 vectors
  64713. */
  64714. export class DivideBlock extends NodeMaterialBlock {
  64715. /**
  64716. * Creates a new DivideBlock
  64717. * @param name defines the block name
  64718. */
  64719. constructor(name: string);
  64720. /**
  64721. * Gets the current class name
  64722. * @returns the class name
  64723. */
  64724. getClassName(): string;
  64725. /**
  64726. * Gets the left operand input component
  64727. */
  64728. get left(): NodeMaterialConnectionPoint;
  64729. /**
  64730. * Gets the right operand input component
  64731. */
  64732. get right(): NodeMaterialConnectionPoint;
  64733. /**
  64734. * Gets the output component
  64735. */
  64736. get output(): NodeMaterialConnectionPoint;
  64737. protected _buildBlock(state: NodeMaterialBuildState): this;
  64738. }
  64739. }
  64740. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  64741. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64742. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64743. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64744. /**
  64745. * Block used to subtract 2 vectors
  64746. */
  64747. export class SubtractBlock extends NodeMaterialBlock {
  64748. /**
  64749. * Creates a new SubtractBlock
  64750. * @param name defines the block name
  64751. */
  64752. constructor(name: string);
  64753. /**
  64754. * Gets the current class name
  64755. * @returns the class name
  64756. */
  64757. getClassName(): string;
  64758. /**
  64759. * Gets the left operand input component
  64760. */
  64761. get left(): NodeMaterialConnectionPoint;
  64762. /**
  64763. * Gets the right operand input component
  64764. */
  64765. get right(): NodeMaterialConnectionPoint;
  64766. /**
  64767. * Gets the output component
  64768. */
  64769. get output(): NodeMaterialConnectionPoint;
  64770. protected _buildBlock(state: NodeMaterialBuildState): this;
  64771. }
  64772. }
  64773. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  64774. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64775. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64776. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64777. /**
  64778. * Block used to step a value
  64779. */
  64780. export class StepBlock extends NodeMaterialBlock {
  64781. /**
  64782. * Creates a new StepBlock
  64783. * @param name defines the block name
  64784. */
  64785. constructor(name: string);
  64786. /**
  64787. * Gets the current class name
  64788. * @returns the class name
  64789. */
  64790. getClassName(): string;
  64791. /**
  64792. * Gets the value operand input component
  64793. */
  64794. get value(): NodeMaterialConnectionPoint;
  64795. /**
  64796. * Gets the edge operand input component
  64797. */
  64798. get edge(): NodeMaterialConnectionPoint;
  64799. /**
  64800. * Gets the output component
  64801. */
  64802. get output(): NodeMaterialConnectionPoint;
  64803. protected _buildBlock(state: NodeMaterialBuildState): this;
  64804. }
  64805. }
  64806. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  64807. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64808. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64809. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64810. /**
  64811. * Block used to get the opposite (1 - x) of a value
  64812. */
  64813. export class OneMinusBlock extends NodeMaterialBlock {
  64814. /**
  64815. * Creates a new OneMinusBlock
  64816. * @param name defines the block name
  64817. */
  64818. constructor(name: string);
  64819. /**
  64820. * Gets the current class name
  64821. * @returns the class name
  64822. */
  64823. getClassName(): string;
  64824. /**
  64825. * Gets the input component
  64826. */
  64827. get input(): NodeMaterialConnectionPoint;
  64828. /**
  64829. * Gets the output component
  64830. */
  64831. get output(): NodeMaterialConnectionPoint;
  64832. protected _buildBlock(state: NodeMaterialBuildState): this;
  64833. }
  64834. }
  64835. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  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. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64840. /**
  64841. * Block used to get the view direction
  64842. */
  64843. export class ViewDirectionBlock extends NodeMaterialBlock {
  64844. /**
  64845. * Creates a new ViewDirectionBlock
  64846. * @param name defines the block name
  64847. */
  64848. constructor(name: string);
  64849. /**
  64850. * Gets the current class name
  64851. * @returns the class name
  64852. */
  64853. getClassName(): string;
  64854. /**
  64855. * Gets the world position component
  64856. */
  64857. get worldPosition(): NodeMaterialConnectionPoint;
  64858. /**
  64859. * Gets the camera position component
  64860. */
  64861. get cameraPosition(): NodeMaterialConnectionPoint;
  64862. /**
  64863. * Gets the output component
  64864. */
  64865. get output(): NodeMaterialConnectionPoint;
  64866. autoConfigure(material: NodeMaterial): void;
  64867. protected _buildBlock(state: NodeMaterialBuildState): this;
  64868. }
  64869. }
  64870. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  64871. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64872. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64873. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64874. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64875. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  64876. /**
  64877. * Block used to compute fresnel value
  64878. */
  64879. export class FresnelBlock extends NodeMaterialBlock {
  64880. /**
  64881. * Create a new FresnelBlock
  64882. * @param name defines the block name
  64883. */
  64884. constructor(name: string);
  64885. /**
  64886. * Gets the current class name
  64887. * @returns the class name
  64888. */
  64889. getClassName(): string;
  64890. /**
  64891. * Gets the world normal input component
  64892. */
  64893. get worldNormal(): NodeMaterialConnectionPoint;
  64894. /**
  64895. * Gets the view direction input component
  64896. */
  64897. get viewDirection(): NodeMaterialConnectionPoint;
  64898. /**
  64899. * Gets the bias input component
  64900. */
  64901. get bias(): NodeMaterialConnectionPoint;
  64902. /**
  64903. * Gets the camera (or eye) position component
  64904. */
  64905. get power(): NodeMaterialConnectionPoint;
  64906. /**
  64907. * Gets the fresnel output component
  64908. */
  64909. get fresnel(): NodeMaterialConnectionPoint;
  64910. autoConfigure(material: NodeMaterial): void;
  64911. protected _buildBlock(state: NodeMaterialBuildState): this;
  64912. }
  64913. }
  64914. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  64915. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64916. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64917. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64918. /**
  64919. * Block used to get the max of 2 values
  64920. */
  64921. export class MaxBlock extends NodeMaterialBlock {
  64922. /**
  64923. * Creates a new MaxBlock
  64924. * @param name defines the block name
  64925. */
  64926. constructor(name: string);
  64927. /**
  64928. * Gets the current class name
  64929. * @returns the class name
  64930. */
  64931. getClassName(): string;
  64932. /**
  64933. * Gets the left operand input component
  64934. */
  64935. get left(): NodeMaterialConnectionPoint;
  64936. /**
  64937. * Gets the right operand input component
  64938. */
  64939. get right(): NodeMaterialConnectionPoint;
  64940. /**
  64941. * Gets the output component
  64942. */
  64943. get output(): NodeMaterialConnectionPoint;
  64944. protected _buildBlock(state: NodeMaterialBuildState): this;
  64945. }
  64946. }
  64947. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  64948. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64949. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64950. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64951. /**
  64952. * Block used to get the min of 2 values
  64953. */
  64954. export class MinBlock extends NodeMaterialBlock {
  64955. /**
  64956. * Creates a new MinBlock
  64957. * @param name defines the block name
  64958. */
  64959. constructor(name: string);
  64960. /**
  64961. * Gets the current class name
  64962. * @returns the class name
  64963. */
  64964. getClassName(): string;
  64965. /**
  64966. * Gets the left operand input component
  64967. */
  64968. get left(): NodeMaterialConnectionPoint;
  64969. /**
  64970. * Gets the right operand input component
  64971. */
  64972. get right(): NodeMaterialConnectionPoint;
  64973. /**
  64974. * Gets the output component
  64975. */
  64976. get output(): NodeMaterialConnectionPoint;
  64977. protected _buildBlock(state: NodeMaterialBuildState): this;
  64978. }
  64979. }
  64980. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  64981. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64982. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64983. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64984. /**
  64985. * Block used to get the distance between 2 values
  64986. */
  64987. export class DistanceBlock extends NodeMaterialBlock {
  64988. /**
  64989. * Creates a new DistanceBlock
  64990. * @param name defines the block name
  64991. */
  64992. constructor(name: string);
  64993. /**
  64994. * Gets the current class name
  64995. * @returns the class name
  64996. */
  64997. getClassName(): string;
  64998. /**
  64999. * Gets the left operand input component
  65000. */
  65001. get left(): NodeMaterialConnectionPoint;
  65002. /**
  65003. * Gets the right operand input component
  65004. */
  65005. get right(): NodeMaterialConnectionPoint;
  65006. /**
  65007. * Gets the output component
  65008. */
  65009. get output(): NodeMaterialConnectionPoint;
  65010. protected _buildBlock(state: NodeMaterialBuildState): this;
  65011. }
  65012. }
  65013. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  65014. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65015. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65016. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65017. /**
  65018. * Block used to get the length of a vector
  65019. */
  65020. export class LengthBlock extends NodeMaterialBlock {
  65021. /**
  65022. * Creates a new LengthBlock
  65023. * @param name defines the block name
  65024. */
  65025. constructor(name: string);
  65026. /**
  65027. * Gets the current class name
  65028. * @returns the class name
  65029. */
  65030. getClassName(): string;
  65031. /**
  65032. * Gets the value input component
  65033. */
  65034. get value(): NodeMaterialConnectionPoint;
  65035. /**
  65036. * Gets the output component
  65037. */
  65038. get output(): NodeMaterialConnectionPoint;
  65039. protected _buildBlock(state: NodeMaterialBuildState): this;
  65040. }
  65041. }
  65042. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  65043. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65044. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65045. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65046. /**
  65047. * Block used to get negative version of a value (i.e. x * -1)
  65048. */
  65049. export class NegateBlock extends NodeMaterialBlock {
  65050. /**
  65051. * Creates a new NegateBlock
  65052. * @param name defines the block name
  65053. */
  65054. constructor(name: string);
  65055. /**
  65056. * Gets the current class name
  65057. * @returns the class name
  65058. */
  65059. getClassName(): string;
  65060. /**
  65061. * Gets the value input component
  65062. */
  65063. get value(): NodeMaterialConnectionPoint;
  65064. /**
  65065. * Gets the output component
  65066. */
  65067. get output(): NodeMaterialConnectionPoint;
  65068. protected _buildBlock(state: NodeMaterialBuildState): this;
  65069. }
  65070. }
  65071. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  65072. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65073. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65074. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65075. /**
  65076. * Block used to get the value of the first parameter raised to the power of the second
  65077. */
  65078. export class PowBlock extends NodeMaterialBlock {
  65079. /**
  65080. * Creates a new PowBlock
  65081. * @param name defines the block name
  65082. */
  65083. constructor(name: string);
  65084. /**
  65085. * Gets the current class name
  65086. * @returns the class name
  65087. */
  65088. getClassName(): string;
  65089. /**
  65090. * Gets the value operand input component
  65091. */
  65092. get value(): NodeMaterialConnectionPoint;
  65093. /**
  65094. * Gets the power operand input component
  65095. */
  65096. get power(): NodeMaterialConnectionPoint;
  65097. /**
  65098. * Gets the output component
  65099. */
  65100. get output(): NodeMaterialConnectionPoint;
  65101. protected _buildBlock(state: NodeMaterialBuildState): this;
  65102. }
  65103. }
  65104. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  65105. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65106. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65107. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65108. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65109. /**
  65110. * Block used to get a random number
  65111. */
  65112. export class RandomNumberBlock extends NodeMaterialBlock {
  65113. /**
  65114. * Creates a new RandomNumberBlock
  65115. * @param name defines the block name
  65116. */
  65117. constructor(name: string);
  65118. /**
  65119. * Gets the current class name
  65120. * @returns the class name
  65121. */
  65122. getClassName(): string;
  65123. /**
  65124. * Gets the seed input component
  65125. */
  65126. get seed(): NodeMaterialConnectionPoint;
  65127. /**
  65128. * Gets the output component
  65129. */
  65130. get output(): NodeMaterialConnectionPoint;
  65131. protected _buildBlock(state: NodeMaterialBuildState): this;
  65132. }
  65133. }
  65134. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  65135. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65136. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65137. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65138. /**
  65139. * Block used to compute arc tangent of 2 values
  65140. */
  65141. export class ArcTan2Block extends NodeMaterialBlock {
  65142. /**
  65143. * Creates a new ArcTan2Block
  65144. * @param name defines the block name
  65145. */
  65146. constructor(name: string);
  65147. /**
  65148. * Gets the current class name
  65149. * @returns the class name
  65150. */
  65151. getClassName(): string;
  65152. /**
  65153. * Gets the x operand input component
  65154. */
  65155. get x(): NodeMaterialConnectionPoint;
  65156. /**
  65157. * Gets the y operand input component
  65158. */
  65159. get y(): NodeMaterialConnectionPoint;
  65160. /**
  65161. * Gets the output component
  65162. */
  65163. get output(): NodeMaterialConnectionPoint;
  65164. protected _buildBlock(state: NodeMaterialBuildState): this;
  65165. }
  65166. }
  65167. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  65168. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65169. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65170. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65171. /**
  65172. * Block used to smooth step a value
  65173. */
  65174. export class SmoothStepBlock extends NodeMaterialBlock {
  65175. /**
  65176. * Creates a new SmoothStepBlock
  65177. * @param name defines the block name
  65178. */
  65179. constructor(name: string);
  65180. /**
  65181. * Gets the current class name
  65182. * @returns the class name
  65183. */
  65184. getClassName(): string;
  65185. /**
  65186. * Gets the value operand input component
  65187. */
  65188. get value(): NodeMaterialConnectionPoint;
  65189. /**
  65190. * Gets the first edge operand input component
  65191. */
  65192. get edge0(): NodeMaterialConnectionPoint;
  65193. /**
  65194. * Gets the second edge operand input component
  65195. */
  65196. get edge1(): NodeMaterialConnectionPoint;
  65197. /**
  65198. * Gets the output component
  65199. */
  65200. get output(): NodeMaterialConnectionPoint;
  65201. protected _buildBlock(state: NodeMaterialBuildState): this;
  65202. }
  65203. }
  65204. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  65205. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65206. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65207. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65208. /**
  65209. * Block used to get the reciprocal (1 / x) of a value
  65210. */
  65211. export class ReciprocalBlock extends NodeMaterialBlock {
  65212. /**
  65213. * Creates a new ReciprocalBlock
  65214. * @param name defines the block name
  65215. */
  65216. constructor(name: string);
  65217. /**
  65218. * Gets the current class name
  65219. * @returns the class name
  65220. */
  65221. getClassName(): string;
  65222. /**
  65223. * Gets the input component
  65224. */
  65225. get input(): NodeMaterialConnectionPoint;
  65226. /**
  65227. * Gets the output component
  65228. */
  65229. get output(): NodeMaterialConnectionPoint;
  65230. protected _buildBlock(state: NodeMaterialBuildState): this;
  65231. }
  65232. }
  65233. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  65234. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65235. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65236. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65237. /**
  65238. * Block used to replace a color by another one
  65239. */
  65240. export class ReplaceColorBlock extends NodeMaterialBlock {
  65241. /**
  65242. * Creates a new ReplaceColorBlock
  65243. * @param name defines the block name
  65244. */
  65245. constructor(name: string);
  65246. /**
  65247. * Gets the current class name
  65248. * @returns the class name
  65249. */
  65250. getClassName(): string;
  65251. /**
  65252. * Gets the value input component
  65253. */
  65254. get value(): NodeMaterialConnectionPoint;
  65255. /**
  65256. * Gets the reference input component
  65257. */
  65258. get reference(): NodeMaterialConnectionPoint;
  65259. /**
  65260. * Gets the distance input component
  65261. */
  65262. get distance(): NodeMaterialConnectionPoint;
  65263. /**
  65264. * Gets the replacement input component
  65265. */
  65266. get replacement(): NodeMaterialConnectionPoint;
  65267. /**
  65268. * Gets the output component
  65269. */
  65270. get output(): NodeMaterialConnectionPoint;
  65271. protected _buildBlock(state: NodeMaterialBuildState): this;
  65272. }
  65273. }
  65274. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  65275. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65276. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65277. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65278. /**
  65279. * Block used to posterize a value
  65280. * @see https://en.wikipedia.org/wiki/Posterization
  65281. */
  65282. export class PosterizeBlock extends NodeMaterialBlock {
  65283. /**
  65284. * Creates a new PosterizeBlock
  65285. * @param name defines the block name
  65286. */
  65287. constructor(name: string);
  65288. /**
  65289. * Gets the current class name
  65290. * @returns the class name
  65291. */
  65292. getClassName(): string;
  65293. /**
  65294. * Gets the value input component
  65295. */
  65296. get value(): NodeMaterialConnectionPoint;
  65297. /**
  65298. * Gets the steps input component
  65299. */
  65300. get steps(): NodeMaterialConnectionPoint;
  65301. /**
  65302. * Gets the output component
  65303. */
  65304. get output(): NodeMaterialConnectionPoint;
  65305. protected _buildBlock(state: NodeMaterialBuildState): this;
  65306. }
  65307. }
  65308. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  65309. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65310. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65311. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65312. import { Scene } from "babylonjs/scene";
  65313. /**
  65314. * Operations supported by the Wave block
  65315. */
  65316. export enum WaveBlockKind {
  65317. /** SawTooth */
  65318. SawTooth = 0,
  65319. /** Square */
  65320. Square = 1,
  65321. /** Triangle */
  65322. Triangle = 2
  65323. }
  65324. /**
  65325. * Block used to apply wave operation to floats
  65326. */
  65327. export class WaveBlock extends NodeMaterialBlock {
  65328. /**
  65329. * Gets or sets the kibnd of wave to be applied by the block
  65330. */
  65331. kind: WaveBlockKind;
  65332. /**
  65333. * Creates a new WaveBlock
  65334. * @param name defines the block name
  65335. */
  65336. constructor(name: string);
  65337. /**
  65338. * Gets the current class name
  65339. * @returns the class name
  65340. */
  65341. getClassName(): string;
  65342. /**
  65343. * Gets the input component
  65344. */
  65345. get input(): NodeMaterialConnectionPoint;
  65346. /**
  65347. * Gets the output component
  65348. */
  65349. get output(): NodeMaterialConnectionPoint;
  65350. protected _buildBlock(state: NodeMaterialBuildState): this;
  65351. serialize(): any;
  65352. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65353. }
  65354. }
  65355. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  65356. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65357. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65358. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65359. import { Color3 } from "babylonjs/Maths/math.color";
  65360. import { Scene } from "babylonjs/scene";
  65361. /**
  65362. * Class used to store a color step for the GradientBlock
  65363. */
  65364. export class GradientBlockColorStep {
  65365. /**
  65366. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  65367. */
  65368. step: number;
  65369. /**
  65370. * Gets or sets the color associated with this step
  65371. */
  65372. color: Color3;
  65373. /**
  65374. * Creates a new GradientBlockColorStep
  65375. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65376. * @param color defines the color associated with this step
  65377. */
  65378. constructor(
  65379. /**
  65380. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  65381. */
  65382. step: number,
  65383. /**
  65384. * Gets or sets the color associated with this step
  65385. */
  65386. color: Color3);
  65387. }
  65388. /**
  65389. * Block used to return a color from a gradient based on an input value between 0 and 1
  65390. */
  65391. export class GradientBlock extends NodeMaterialBlock {
  65392. /**
  65393. * Gets or sets the list of color steps
  65394. */
  65395. colorSteps: GradientBlockColorStep[];
  65396. /**
  65397. * Creates a new GradientBlock
  65398. * @param name defines the block name
  65399. */
  65400. constructor(name: string);
  65401. /**
  65402. * Gets the current class name
  65403. * @returns the class name
  65404. */
  65405. getClassName(): string;
  65406. /**
  65407. * Gets the gradient input component
  65408. */
  65409. get gradient(): NodeMaterialConnectionPoint;
  65410. /**
  65411. * Gets the output component
  65412. */
  65413. get output(): NodeMaterialConnectionPoint;
  65414. private _writeColorConstant;
  65415. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65416. serialize(): any;
  65417. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65418. protected _dumpPropertiesCode(): string;
  65419. }
  65420. }
  65421. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  65422. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65423. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65424. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65425. /**
  65426. * Block used to normalize lerp between 2 values
  65427. */
  65428. export class NLerpBlock extends NodeMaterialBlock {
  65429. /**
  65430. * Creates a new NLerpBlock
  65431. * @param name defines the block name
  65432. */
  65433. constructor(name: string);
  65434. /**
  65435. * Gets the current class name
  65436. * @returns the class name
  65437. */
  65438. getClassName(): string;
  65439. /**
  65440. * Gets the left operand input component
  65441. */
  65442. get left(): NodeMaterialConnectionPoint;
  65443. /**
  65444. * Gets the right operand input component
  65445. */
  65446. get right(): NodeMaterialConnectionPoint;
  65447. /**
  65448. * Gets the gradient operand input component
  65449. */
  65450. get gradient(): NodeMaterialConnectionPoint;
  65451. /**
  65452. * Gets the output component
  65453. */
  65454. get output(): NodeMaterialConnectionPoint;
  65455. protected _buildBlock(state: NodeMaterialBuildState): this;
  65456. }
  65457. }
  65458. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  65459. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65460. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65461. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65462. import { Scene } from "babylonjs/scene";
  65463. /**
  65464. * block used to Generate a Worley Noise 3D Noise Pattern
  65465. */
  65466. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65467. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65468. manhattanDistance: boolean;
  65469. /**
  65470. * Creates a new WorleyNoise3DBlock
  65471. * @param name defines the block name
  65472. */
  65473. constructor(name: string);
  65474. /**
  65475. * Gets the current class name
  65476. * @returns the class name
  65477. */
  65478. getClassName(): string;
  65479. /**
  65480. * Gets the seed input component
  65481. */
  65482. get seed(): NodeMaterialConnectionPoint;
  65483. /**
  65484. * Gets the jitter input component
  65485. */
  65486. get jitter(): NodeMaterialConnectionPoint;
  65487. /**
  65488. * Gets the output component
  65489. */
  65490. get output(): NodeMaterialConnectionPoint;
  65491. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65492. /**
  65493. * Exposes the properties to the UI?
  65494. */
  65495. protected _dumpPropertiesCode(): string;
  65496. /**
  65497. * Exposes the properties to the Seralize?
  65498. */
  65499. serialize(): any;
  65500. /**
  65501. * Exposes the properties to the deseralize?
  65502. */
  65503. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65504. }
  65505. }
  65506. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  65507. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65508. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65509. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65510. /**
  65511. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65512. */
  65513. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65514. /**
  65515. * Creates a new SimplexPerlin3DBlock
  65516. * @param name defines the block name
  65517. */
  65518. constructor(name: string);
  65519. /**
  65520. * Gets the current class name
  65521. * @returns the class name
  65522. */
  65523. getClassName(): string;
  65524. /**
  65525. * Gets the seed operand input component
  65526. */
  65527. get seed(): NodeMaterialConnectionPoint;
  65528. /**
  65529. * Gets the output component
  65530. */
  65531. get output(): NodeMaterialConnectionPoint;
  65532. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65533. }
  65534. }
  65535. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  65536. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65537. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65538. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65539. /**
  65540. * Block used to blend normals
  65541. */
  65542. export class NormalBlendBlock extends NodeMaterialBlock {
  65543. /**
  65544. * Creates a new NormalBlendBlock
  65545. * @param name defines the block name
  65546. */
  65547. constructor(name: string);
  65548. /**
  65549. * Gets the current class name
  65550. * @returns the class name
  65551. */
  65552. getClassName(): string;
  65553. /**
  65554. * Gets the first input component
  65555. */
  65556. get normalMap0(): NodeMaterialConnectionPoint;
  65557. /**
  65558. * Gets the second input component
  65559. */
  65560. get normalMap1(): NodeMaterialConnectionPoint;
  65561. /**
  65562. * Gets the output component
  65563. */
  65564. get output(): NodeMaterialConnectionPoint;
  65565. protected _buildBlock(state: NodeMaterialBuildState): this;
  65566. }
  65567. }
  65568. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  65569. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65570. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65571. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65572. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65573. /**
  65574. * Block used to rotate a 2d vector by a given angle
  65575. */
  65576. export class Rotate2dBlock extends NodeMaterialBlock {
  65577. /**
  65578. * Creates a new Rotate2dBlock
  65579. * @param name defines the block name
  65580. */
  65581. constructor(name: string);
  65582. /**
  65583. * Gets the current class name
  65584. * @returns the class name
  65585. */
  65586. getClassName(): string;
  65587. /**
  65588. * Gets the input vector
  65589. */
  65590. get input(): NodeMaterialConnectionPoint;
  65591. /**
  65592. * Gets the input angle
  65593. */
  65594. get angle(): NodeMaterialConnectionPoint;
  65595. /**
  65596. * Gets the output component
  65597. */
  65598. get output(): NodeMaterialConnectionPoint;
  65599. autoConfigure(material: NodeMaterial): void;
  65600. protected _buildBlock(state: NodeMaterialBuildState): this;
  65601. }
  65602. }
  65603. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  65604. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65605. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65606. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65607. /**
  65608. * Block used to get the reflected vector from a direction and a normal
  65609. */
  65610. export class ReflectBlock extends NodeMaterialBlock {
  65611. /**
  65612. * Creates a new ReflectBlock
  65613. * @param name defines the block name
  65614. */
  65615. constructor(name: string);
  65616. /**
  65617. * Gets the current class name
  65618. * @returns the class name
  65619. */
  65620. getClassName(): string;
  65621. /**
  65622. * Gets the incident component
  65623. */
  65624. get incident(): NodeMaterialConnectionPoint;
  65625. /**
  65626. * Gets the normal component
  65627. */
  65628. get normal(): NodeMaterialConnectionPoint;
  65629. /**
  65630. * Gets the output component
  65631. */
  65632. get output(): NodeMaterialConnectionPoint;
  65633. protected _buildBlock(state: NodeMaterialBuildState): this;
  65634. }
  65635. }
  65636. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  65637. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65638. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65639. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65640. /**
  65641. * Block used to get the refracted vector from a direction and a normal
  65642. */
  65643. export class RefractBlock extends NodeMaterialBlock {
  65644. /**
  65645. * Creates a new RefractBlock
  65646. * @param name defines the block name
  65647. */
  65648. constructor(name: string);
  65649. /**
  65650. * Gets the current class name
  65651. * @returns the class name
  65652. */
  65653. getClassName(): string;
  65654. /**
  65655. * Gets the incident component
  65656. */
  65657. get incident(): NodeMaterialConnectionPoint;
  65658. /**
  65659. * Gets the normal component
  65660. */
  65661. get normal(): NodeMaterialConnectionPoint;
  65662. /**
  65663. * Gets the index of refraction component
  65664. */
  65665. get ior(): NodeMaterialConnectionPoint;
  65666. /**
  65667. * Gets the output component
  65668. */
  65669. get output(): NodeMaterialConnectionPoint;
  65670. protected _buildBlock(state: NodeMaterialBuildState): this;
  65671. }
  65672. }
  65673. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  65674. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65675. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65676. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65677. /**
  65678. * Block used to desaturate a color
  65679. */
  65680. export class DesaturateBlock extends NodeMaterialBlock {
  65681. /**
  65682. * Creates a new DesaturateBlock
  65683. * @param name defines the block name
  65684. */
  65685. constructor(name: string);
  65686. /**
  65687. * Gets the current class name
  65688. * @returns the class name
  65689. */
  65690. getClassName(): string;
  65691. /**
  65692. * Gets the color operand input component
  65693. */
  65694. get color(): NodeMaterialConnectionPoint;
  65695. /**
  65696. * Gets the level operand input component
  65697. */
  65698. get level(): NodeMaterialConnectionPoint;
  65699. /**
  65700. * Gets the output component
  65701. */
  65702. get output(): NodeMaterialConnectionPoint;
  65703. protected _buildBlock(state: NodeMaterialBuildState): this;
  65704. }
  65705. }
  65706. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  65707. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65708. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65709. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65710. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65711. import { Nullable } from "babylonjs/types";
  65712. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65713. import { Scene } from "babylonjs/scene";
  65714. /**
  65715. * Block used to implement the ambient occlusion module of the PBR material
  65716. */
  65717. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  65718. /**
  65719. * Create a new AmbientOcclusionBlock
  65720. * @param name defines the block name
  65721. */
  65722. constructor(name: string);
  65723. /**
  65724. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  65725. */
  65726. useAmbientInGrayScale: boolean;
  65727. /**
  65728. * Initialize the block and prepare the context for build
  65729. * @param state defines the state that will be used for the build
  65730. */
  65731. initialize(state: NodeMaterialBuildState): void;
  65732. /**
  65733. * Gets the current class name
  65734. * @returns the class name
  65735. */
  65736. getClassName(): string;
  65737. /**
  65738. * Gets the texture input component
  65739. */
  65740. get texture(): NodeMaterialConnectionPoint;
  65741. /**
  65742. * Gets the texture intensity component
  65743. */
  65744. get intensity(): NodeMaterialConnectionPoint;
  65745. /**
  65746. * Gets the direct light intensity input component
  65747. */
  65748. get directLightIntensity(): NodeMaterialConnectionPoint;
  65749. /**
  65750. * Gets the ambient occlusion object output component
  65751. */
  65752. get ambientOcclusion(): NodeMaterialConnectionPoint;
  65753. /**
  65754. * Gets the main code of the block (fragment side)
  65755. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  65756. * @returns the shader code
  65757. */
  65758. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  65759. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65760. protected _buildBlock(state: NodeMaterialBuildState): this;
  65761. protected _dumpPropertiesCode(): string;
  65762. serialize(): any;
  65763. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65764. }
  65765. }
  65766. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  65767. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65768. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65769. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65770. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  65771. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65772. import { Nullable } from "babylonjs/types";
  65773. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65774. import { Mesh } from "babylonjs/Meshes/mesh";
  65775. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65776. import { Effect } from "babylonjs/Materials/effect";
  65777. import { Scene } from "babylonjs/scene";
  65778. /**
  65779. * Block used to implement the reflection module of the PBR material
  65780. */
  65781. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65782. /** @hidden */
  65783. _defineLODReflectionAlpha: string;
  65784. /** @hidden */
  65785. _defineLinearSpecularReflection: string;
  65786. private _vEnvironmentIrradianceName;
  65787. /** @hidden */
  65788. _vReflectionMicrosurfaceInfosName: string;
  65789. /** @hidden */
  65790. _vReflectionInfosName: string;
  65791. /** @hidden */
  65792. _vReflectionFilteringInfoName: string;
  65793. private _scene;
  65794. /**
  65795. * The three properties below are set by the main PBR block prior to calling methods of this class.
  65796. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65797. * It's less burden on the user side in the editor part.
  65798. */
  65799. /** @hidden */
  65800. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65801. /** @hidden */
  65802. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65803. /** @hidden */
  65804. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65805. /**
  65806. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65807. * diffuse part of the IBL.
  65808. */
  65809. useSphericalHarmonics: boolean;
  65810. /**
  65811. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65812. */
  65813. forceIrradianceInFragment: boolean;
  65814. /**
  65815. * Create a new ReflectionBlock
  65816. * @param name defines the block name
  65817. */
  65818. constructor(name: string);
  65819. /**
  65820. * Gets the current class name
  65821. * @returns the class name
  65822. */
  65823. getClassName(): string;
  65824. /**
  65825. * Gets the position input component
  65826. */
  65827. get position(): NodeMaterialConnectionPoint;
  65828. /**
  65829. * Gets the world position input component
  65830. */
  65831. get worldPosition(): NodeMaterialConnectionPoint;
  65832. /**
  65833. * Gets the world normal input component
  65834. */
  65835. get worldNormal(): NodeMaterialConnectionPoint;
  65836. /**
  65837. * Gets the world input component
  65838. */
  65839. get world(): NodeMaterialConnectionPoint;
  65840. /**
  65841. * Gets the camera (or eye) position component
  65842. */
  65843. get cameraPosition(): NodeMaterialConnectionPoint;
  65844. /**
  65845. * Gets the view input component
  65846. */
  65847. get view(): NodeMaterialConnectionPoint;
  65848. /**
  65849. * Gets the color input component
  65850. */
  65851. get color(): NodeMaterialConnectionPoint;
  65852. /**
  65853. * Gets the reflection object output component
  65854. */
  65855. get reflection(): NodeMaterialConnectionPoint;
  65856. /**
  65857. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65858. */
  65859. get hasTexture(): boolean;
  65860. /**
  65861. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65862. */
  65863. get reflectionColor(): string;
  65864. protected _getTexture(): Nullable<BaseTexture>;
  65865. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65866. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65867. /**
  65868. * Gets the code to inject in the vertex shader
  65869. * @param state current state of the node material building
  65870. * @returns the shader code
  65871. */
  65872. handleVertexSide(state: NodeMaterialBuildState): string;
  65873. /**
  65874. * Gets the main code of the block (fragment side)
  65875. * @param state current state of the node material building
  65876. * @param normalVarName name of the existing variable corresponding to the normal
  65877. * @returns the shader code
  65878. */
  65879. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65880. protected _buildBlock(state: NodeMaterialBuildState): this;
  65881. protected _dumpPropertiesCode(): string;
  65882. serialize(): any;
  65883. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65884. }
  65885. }
  65886. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  65887. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65888. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65889. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65890. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65892. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  65893. import { Scene } from "babylonjs/scene";
  65894. import { Nullable } from "babylonjs/types";
  65895. /**
  65896. * Block used to implement the sheen module of the PBR material
  65897. */
  65898. export class SheenBlock extends NodeMaterialBlock {
  65899. /**
  65900. * Create a new SheenBlock
  65901. * @param name defines the block name
  65902. */
  65903. constructor(name: string);
  65904. /**
  65905. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65906. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65907. * making it easier to setup and tweak the effect
  65908. */
  65909. albedoScaling: boolean;
  65910. /**
  65911. * Defines if the sheen is linked to the sheen color.
  65912. */
  65913. linkSheenWithAlbedo: boolean;
  65914. /**
  65915. * Initialize the block and prepare the context for build
  65916. * @param state defines the state that will be used for the build
  65917. */
  65918. initialize(state: NodeMaterialBuildState): void;
  65919. /**
  65920. * Gets the current class name
  65921. * @returns the class name
  65922. */
  65923. getClassName(): string;
  65924. /**
  65925. * Gets the intensity input component
  65926. */
  65927. get intensity(): NodeMaterialConnectionPoint;
  65928. /**
  65929. * Gets the color input component
  65930. */
  65931. get color(): NodeMaterialConnectionPoint;
  65932. /**
  65933. * Gets the roughness input component
  65934. */
  65935. get roughness(): NodeMaterialConnectionPoint;
  65936. /**
  65937. * Gets the sheen object output component
  65938. */
  65939. get sheen(): NodeMaterialConnectionPoint;
  65940. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65941. /**
  65942. * Gets the main code of the block (fragment side)
  65943. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65944. * @returns the shader code
  65945. */
  65946. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65947. protected _buildBlock(state: NodeMaterialBuildState): this;
  65948. protected _dumpPropertiesCode(): string;
  65949. serialize(): any;
  65950. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65951. }
  65952. }
  65953. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  65954. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65955. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65956. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65958. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65959. import { Scene } from "babylonjs/scene";
  65960. import { Nullable } from "babylonjs/types";
  65961. import { Mesh } from "babylonjs/Meshes/mesh";
  65962. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65963. import { Effect } from "babylonjs/Materials/effect";
  65964. /**
  65965. * Block used to implement the reflectivity module of the PBR material
  65966. */
  65967. export class ReflectivityBlock extends NodeMaterialBlock {
  65968. private _metallicReflectanceColor;
  65969. private _metallicF0Factor;
  65970. /** @hidden */
  65971. _vMetallicReflectanceFactorsName: string;
  65972. /**
  65973. * The property below is set by the main PBR block prior to calling methods of this class.
  65974. */
  65975. /** @hidden */
  65976. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  65977. /**
  65978. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  65979. */
  65980. useAmbientOcclusionFromMetallicTextureRed: boolean;
  65981. /**
  65982. * Specifies if the metallic texture contains the metallness information in its blue channel.
  65983. */
  65984. useMetallnessFromMetallicTextureBlue: boolean;
  65985. /**
  65986. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  65987. */
  65988. useRoughnessFromMetallicTextureAlpha: boolean;
  65989. /**
  65990. * Specifies if the metallic texture contains the roughness information in its green channel.
  65991. */
  65992. useRoughnessFromMetallicTextureGreen: boolean;
  65993. /**
  65994. * Create a new ReflectivityBlock
  65995. * @param name defines the block name
  65996. */
  65997. constructor(name: string);
  65998. /**
  65999. * Initialize the block and prepare the context for build
  66000. * @param state defines the state that will be used for the build
  66001. */
  66002. initialize(state: NodeMaterialBuildState): void;
  66003. /**
  66004. * Gets the current class name
  66005. * @returns the class name
  66006. */
  66007. getClassName(): string;
  66008. /**
  66009. * Gets the metallic input component
  66010. */
  66011. get metallic(): NodeMaterialConnectionPoint;
  66012. /**
  66013. * Gets the roughness input component
  66014. */
  66015. get roughness(): NodeMaterialConnectionPoint;
  66016. /**
  66017. * Gets the texture input component
  66018. */
  66019. get texture(): NodeMaterialConnectionPoint;
  66020. /**
  66021. * Gets the reflectivity object output component
  66022. */
  66023. get reflectivity(): NodeMaterialConnectionPoint;
  66024. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66025. /**
  66026. * Gets the main code of the block (fragment side)
  66027. * @param state current state of the node material building
  66028. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  66029. * @returns the shader code
  66030. */
  66031. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  66032. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66033. protected _buildBlock(state: NodeMaterialBuildState): this;
  66034. protected _dumpPropertiesCode(): string;
  66035. serialize(): any;
  66036. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66037. }
  66038. }
  66039. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  66040. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66041. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66042. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66043. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66044. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66045. /**
  66046. * Block used to implement the anisotropy module of the PBR material
  66047. */
  66048. export class AnisotropyBlock extends NodeMaterialBlock {
  66049. /**
  66050. * The two properties below are set by the main PBR block prior to calling methods of this class.
  66051. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66052. * It's less burden on the user side in the editor part.
  66053. */
  66054. /** @hidden */
  66055. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66056. /** @hidden */
  66057. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66058. /**
  66059. * Create a new AnisotropyBlock
  66060. * @param name defines the block name
  66061. */
  66062. constructor(name: string);
  66063. /**
  66064. * Initialize the block and prepare the context for build
  66065. * @param state defines the state that will be used for the build
  66066. */
  66067. initialize(state: NodeMaterialBuildState): void;
  66068. /**
  66069. * Gets the current class name
  66070. * @returns the class name
  66071. */
  66072. getClassName(): string;
  66073. /**
  66074. * Gets the intensity input component
  66075. */
  66076. get intensity(): NodeMaterialConnectionPoint;
  66077. /**
  66078. * Gets the direction input component
  66079. */
  66080. get direction(): NodeMaterialConnectionPoint;
  66081. /**
  66082. * Gets the texture input component
  66083. */
  66084. get texture(): NodeMaterialConnectionPoint;
  66085. /**
  66086. * Gets the uv input component
  66087. */
  66088. get uv(): NodeMaterialConnectionPoint;
  66089. /**
  66090. * Gets the worldTangent input component
  66091. */
  66092. get worldTangent(): NodeMaterialConnectionPoint;
  66093. /**
  66094. * Gets the anisotropy object output component
  66095. */
  66096. get anisotropy(): NodeMaterialConnectionPoint;
  66097. private _generateTBNSpace;
  66098. /**
  66099. * Gets the main code of the block (fragment side)
  66100. * @param state current state of the node material building
  66101. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66102. * @returns the shader code
  66103. */
  66104. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  66105. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66106. protected _buildBlock(state: NodeMaterialBuildState): this;
  66107. }
  66108. }
  66109. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  66110. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66111. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66112. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66113. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66115. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66116. import { Nullable } from "babylonjs/types";
  66117. import { Mesh } from "babylonjs/Meshes/mesh";
  66118. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66119. import { Effect } from "babylonjs/Materials/effect";
  66120. /**
  66121. * Block used to implement the clear coat module of the PBR material
  66122. */
  66123. export class ClearCoatBlock extends NodeMaterialBlock {
  66124. private _scene;
  66125. /**
  66126. * Create a new ClearCoatBlock
  66127. * @param name defines the block name
  66128. */
  66129. constructor(name: string);
  66130. /**
  66131. * Initialize the block and prepare the context for build
  66132. * @param state defines the state that will be used for the build
  66133. */
  66134. initialize(state: NodeMaterialBuildState): void;
  66135. /**
  66136. * Gets the current class name
  66137. * @returns the class name
  66138. */
  66139. getClassName(): string;
  66140. /**
  66141. * Gets the intensity input component
  66142. */
  66143. get intensity(): NodeMaterialConnectionPoint;
  66144. /**
  66145. * Gets the roughness input component
  66146. */
  66147. get roughness(): NodeMaterialConnectionPoint;
  66148. /**
  66149. * Gets the ior input component
  66150. */
  66151. get ior(): NodeMaterialConnectionPoint;
  66152. /**
  66153. * Gets the texture input component
  66154. */
  66155. get texture(): NodeMaterialConnectionPoint;
  66156. /**
  66157. * Gets the bump texture input component
  66158. */
  66159. get bumpTexture(): NodeMaterialConnectionPoint;
  66160. /**
  66161. * Gets the uv input component
  66162. */
  66163. get uv(): NodeMaterialConnectionPoint;
  66164. /**
  66165. * Gets the tint color input component
  66166. */
  66167. get tintColor(): NodeMaterialConnectionPoint;
  66168. /**
  66169. * Gets the tint "at distance" input component
  66170. */
  66171. get tintAtDistance(): NodeMaterialConnectionPoint;
  66172. /**
  66173. * Gets the tint thickness input component
  66174. */
  66175. get tintThickness(): NodeMaterialConnectionPoint;
  66176. /**
  66177. * Gets the world tangent input component
  66178. */
  66179. get worldTangent(): NodeMaterialConnectionPoint;
  66180. /**
  66181. * Gets the clear coat object output component
  66182. */
  66183. get clearcoat(): NodeMaterialConnectionPoint;
  66184. autoConfigure(material: NodeMaterial): void;
  66185. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66186. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66187. private _generateTBNSpace;
  66188. /**
  66189. * Gets the main code of the block (fragment side)
  66190. * @param state current state of the node material building
  66191. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  66192. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66193. * @param worldPosVarName name of the variable holding the world position
  66194. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66195. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  66196. * @param worldNormalVarName name of the variable holding the world normal
  66197. * @returns the shader code
  66198. */
  66199. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66200. protected _buildBlock(state: NodeMaterialBuildState): this;
  66201. }
  66202. }
  66203. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  66204. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66205. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66206. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66207. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66209. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66210. import { Nullable } from "babylonjs/types";
  66211. /**
  66212. * Block used to implement the sub surface module of the PBR material
  66213. */
  66214. export class SubSurfaceBlock extends NodeMaterialBlock {
  66215. /**
  66216. * Create a new SubSurfaceBlock
  66217. * @param name defines the block name
  66218. */
  66219. constructor(name: string);
  66220. /**
  66221. * Stores the intensity of the different subsurface effects in the thickness texture.
  66222. * * the green channel is the translucency intensity.
  66223. * * the blue channel is the scattering intensity.
  66224. * * the alpha channel is the refraction intensity.
  66225. */
  66226. useMaskFromThicknessTexture: boolean;
  66227. /**
  66228. * Initialize the block and prepare the context for build
  66229. * @param state defines the state that will be used for the build
  66230. */
  66231. initialize(state: NodeMaterialBuildState): void;
  66232. /**
  66233. * Gets the current class name
  66234. * @returns the class name
  66235. */
  66236. getClassName(): string;
  66237. /**
  66238. * Gets the min thickness input component
  66239. */
  66240. get minThickness(): NodeMaterialConnectionPoint;
  66241. /**
  66242. * Gets the max thickness input component
  66243. */
  66244. get maxThickness(): NodeMaterialConnectionPoint;
  66245. /**
  66246. * Gets the thickness texture component
  66247. */
  66248. get thicknessTexture(): NodeMaterialConnectionPoint;
  66249. /**
  66250. * Gets the tint color input component
  66251. */
  66252. get tintColor(): NodeMaterialConnectionPoint;
  66253. /**
  66254. * Gets the translucency intensity input component
  66255. */
  66256. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66257. /**
  66258. * Gets the translucency diffusion distance input component
  66259. */
  66260. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  66261. /**
  66262. * Gets the refraction object parameters
  66263. */
  66264. get refraction(): NodeMaterialConnectionPoint;
  66265. /**
  66266. * Gets the sub surface object output component
  66267. */
  66268. get subsurface(): NodeMaterialConnectionPoint;
  66269. autoConfigure(material: NodeMaterial): void;
  66270. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66271. /**
  66272. * Gets the main code of the block (fragment side)
  66273. * @param state current state of the node material building
  66274. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66275. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66276. * @param worldPosVarName name of the variable holding the world position
  66277. * @returns the shader code
  66278. */
  66279. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66280. protected _buildBlock(state: NodeMaterialBuildState): this;
  66281. }
  66282. }
  66283. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  66284. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66285. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66286. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66287. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66288. import { Light } from "babylonjs/Lights/light";
  66289. import { Nullable } from "babylonjs/types";
  66290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66291. import { Effect } from "babylonjs/Materials/effect";
  66292. import { Mesh } from "babylonjs/Meshes/mesh";
  66293. import { Scene } from "babylonjs/scene";
  66294. /**
  66295. * Block used to implement the PBR metallic/roughness model
  66296. */
  66297. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66298. /**
  66299. * Gets or sets the light associated with this block
  66300. */
  66301. light: Nullable<Light>;
  66302. private _lightId;
  66303. private _scene;
  66304. private _environmentBRDFTexture;
  66305. private _environmentBrdfSamplerName;
  66306. private _vNormalWName;
  66307. private _invertNormalName;
  66308. /**
  66309. * Create a new ReflectionBlock
  66310. * @param name defines the block name
  66311. */
  66312. constructor(name: string);
  66313. /**
  66314. * Intensity of the direct lights e.g. the four lights available in your scene.
  66315. * This impacts both the direct diffuse and specular highlights.
  66316. */
  66317. directIntensity: number;
  66318. /**
  66319. * Intensity of the environment e.g. how much the environment will light the object
  66320. * either through harmonics for rough material or through the refelction for shiny ones.
  66321. */
  66322. environmentIntensity: number;
  66323. /**
  66324. * This is a special control allowing the reduction of the specular highlights coming from the
  66325. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66326. */
  66327. specularIntensity: number;
  66328. /**
  66329. * Defines the falloff type used in this material.
  66330. * It by default is Physical.
  66331. */
  66332. lightFalloff: number;
  66333. /**
  66334. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  66335. */
  66336. useAlphaFromAlbedoTexture: boolean;
  66337. /**
  66338. * Specifies that alpha test should be used
  66339. */
  66340. useAlphaTest: boolean;
  66341. /**
  66342. * Defines the alpha limits in alpha test mode.
  66343. */
  66344. alphaTestCutoff: number;
  66345. /**
  66346. * Specifies that alpha blending should be used
  66347. */
  66348. useAlphaBlending: boolean;
  66349. /**
  66350. * Defines if the alpha value should be determined via the rgb values.
  66351. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  66352. */
  66353. opacityRGB: boolean;
  66354. /**
  66355. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66356. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66357. */
  66358. useRadianceOverAlpha: boolean;
  66359. /**
  66360. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66361. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  66362. */
  66363. useSpecularOverAlpha: boolean;
  66364. /**
  66365. * Enables specular anti aliasing in the PBR shader.
  66366. * It will both interacts on the Geometry for analytical and IBL lighting.
  66367. * It also prefilter the roughness map based on the bump values.
  66368. */
  66369. enableSpecularAntiAliasing: boolean;
  66370. /**
  66371. * Enables realtime filtering on the texture.
  66372. */
  66373. realTimeFiltering: boolean;
  66374. /**
  66375. * Quality switch for realtime filtering
  66376. */
  66377. realTimeFilteringQuality: number;
  66378. /**
  66379. * Defines if the material uses energy conservation.
  66380. */
  66381. useEnergyConservation: boolean;
  66382. /**
  66383. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  66384. * too much the area relying on ambient texture to define their ambient occlusion.
  66385. */
  66386. useRadianceOcclusion: boolean;
  66387. /**
  66388. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  66389. * makes the reflect vector face the model (under horizon).
  66390. */
  66391. useHorizonOcclusion: boolean;
  66392. /**
  66393. * If set to true, no lighting calculations will be applied.
  66394. */
  66395. unlit: boolean;
  66396. /**
  66397. * Force normal to face away from face.
  66398. */
  66399. forceNormalForward: boolean;
  66400. /**
  66401. * Defines the material debug mode.
  66402. * It helps seeing only some components of the material while troubleshooting.
  66403. */
  66404. debugMode: number;
  66405. /**
  66406. * Specify from where on screen the debug mode should start.
  66407. * The value goes from -1 (full screen) to 1 (not visible)
  66408. * It helps with side by side comparison against the final render
  66409. * This defaults to 0
  66410. */
  66411. debugLimit: number;
  66412. /**
  66413. * As the default viewing range might not be enough (if the ambient is really small for instance)
  66414. * You can use the factor to better multiply the final value.
  66415. */
  66416. debugFactor: number;
  66417. /**
  66418. * Initialize the block and prepare the context for build
  66419. * @param state defines the state that will be used for the build
  66420. */
  66421. initialize(state: NodeMaterialBuildState): void;
  66422. /**
  66423. * Gets the current class name
  66424. * @returns the class name
  66425. */
  66426. getClassName(): string;
  66427. /**
  66428. * Gets the world position input component
  66429. */
  66430. get worldPosition(): NodeMaterialConnectionPoint;
  66431. /**
  66432. * Gets the world normal input component
  66433. */
  66434. get worldNormal(): NodeMaterialConnectionPoint;
  66435. /**
  66436. * Gets the perturbed normal input component
  66437. */
  66438. get perturbedNormal(): NodeMaterialConnectionPoint;
  66439. /**
  66440. * Gets the camera position input component
  66441. */
  66442. get cameraPosition(): NodeMaterialConnectionPoint;
  66443. /**
  66444. * Gets the base color input component
  66445. */
  66446. get baseColor(): NodeMaterialConnectionPoint;
  66447. /**
  66448. * Gets the opacity texture input component
  66449. */
  66450. get opacityTexture(): NodeMaterialConnectionPoint;
  66451. /**
  66452. * Gets the ambient color input component
  66453. */
  66454. get ambientColor(): NodeMaterialConnectionPoint;
  66455. /**
  66456. * Gets the reflectivity object parameters
  66457. */
  66458. get reflectivity(): NodeMaterialConnectionPoint;
  66459. /**
  66460. * Gets the ambient occlusion object parameters
  66461. */
  66462. get ambientOcclusion(): NodeMaterialConnectionPoint;
  66463. /**
  66464. * Gets the reflection object parameters
  66465. */
  66466. get reflection(): NodeMaterialConnectionPoint;
  66467. /**
  66468. * Gets the sheen object parameters
  66469. */
  66470. get sheen(): NodeMaterialConnectionPoint;
  66471. /**
  66472. * Gets the clear coat object parameters
  66473. */
  66474. get clearcoat(): NodeMaterialConnectionPoint;
  66475. /**
  66476. * Gets the sub surface object parameters
  66477. */
  66478. get subsurface(): NodeMaterialConnectionPoint;
  66479. /**
  66480. * Gets the anisotropy object parameters
  66481. */
  66482. get anisotropy(): NodeMaterialConnectionPoint;
  66483. /**
  66484. * Gets the ambient output component
  66485. */
  66486. get ambient(): NodeMaterialConnectionPoint;
  66487. /**
  66488. * Gets the diffuse output component
  66489. */
  66490. get diffuse(): NodeMaterialConnectionPoint;
  66491. /**
  66492. * Gets the specular output component
  66493. */
  66494. get specular(): NodeMaterialConnectionPoint;
  66495. /**
  66496. * Gets the sheen output component
  66497. */
  66498. get sheenDir(): NodeMaterialConnectionPoint;
  66499. /**
  66500. * Gets the clear coat output component
  66501. */
  66502. get clearcoatDir(): NodeMaterialConnectionPoint;
  66503. /**
  66504. * Gets the indirect diffuse output component
  66505. */
  66506. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66507. /**
  66508. * Gets the indirect specular output component
  66509. */
  66510. get specularIndirect(): NodeMaterialConnectionPoint;
  66511. /**
  66512. * Gets the indirect sheen output component
  66513. */
  66514. get sheenIndirect(): NodeMaterialConnectionPoint;
  66515. /**
  66516. * Gets the indirect clear coat output component
  66517. */
  66518. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66519. /**
  66520. * Gets the refraction output component
  66521. */
  66522. get refraction(): NodeMaterialConnectionPoint;
  66523. /**
  66524. * Gets the global lighting output component
  66525. */
  66526. get lighting(): NodeMaterialConnectionPoint;
  66527. /**
  66528. * Gets the shadow output component
  66529. */
  66530. get shadow(): NodeMaterialConnectionPoint;
  66531. /**
  66532. * Gets the alpha output component
  66533. */
  66534. get alpha(): NodeMaterialConnectionPoint;
  66535. autoConfigure(material: NodeMaterial): void;
  66536. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66537. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66538. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66539. private _injectVertexCode;
  66540. /**
  66541. * Gets the code corresponding to the albedo/opacity module
  66542. * @returns the shader code
  66543. */
  66544. getAlbedoOpacityCode(): string;
  66545. protected _buildBlock(state: NodeMaterialBuildState): this;
  66546. protected _dumpPropertiesCode(): string;
  66547. serialize(): any;
  66548. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66549. }
  66550. }
  66551. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  66552. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  66553. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  66554. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  66555. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  66556. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  66557. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66558. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  66559. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  66560. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  66561. }
  66562. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  66563. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  66564. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  66565. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  66566. }
  66567. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  66568. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66569. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66570. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66571. /**
  66572. * Block used to compute value of one parameter modulo another
  66573. */
  66574. export class ModBlock extends NodeMaterialBlock {
  66575. /**
  66576. * Creates a new ModBlock
  66577. * @param name defines the block name
  66578. */
  66579. constructor(name: string);
  66580. /**
  66581. * Gets the current class name
  66582. * @returns the class name
  66583. */
  66584. getClassName(): string;
  66585. /**
  66586. * Gets the left operand input component
  66587. */
  66588. get left(): NodeMaterialConnectionPoint;
  66589. /**
  66590. * Gets the right operand input component
  66591. */
  66592. get right(): NodeMaterialConnectionPoint;
  66593. /**
  66594. * Gets the output component
  66595. */
  66596. get output(): NodeMaterialConnectionPoint;
  66597. protected _buildBlock(state: NodeMaterialBuildState): this;
  66598. }
  66599. }
  66600. declare module "babylonjs/Materials/Node/Blocks/index" {
  66601. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  66602. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  66603. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  66604. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  66605. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  66606. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  66607. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  66608. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  66609. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  66610. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  66611. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  66612. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  66613. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  66614. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  66615. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  66616. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  66617. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  66618. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  66619. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  66620. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  66621. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  66622. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  66623. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  66624. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  66625. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  66626. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  66627. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  66628. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  66629. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  66630. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  66631. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  66632. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  66633. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  66634. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  66635. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  66636. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  66637. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  66638. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  66639. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  66640. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  66641. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  66642. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  66643. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  66644. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  66645. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  66646. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  66647. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  66648. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  66649. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  66650. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  66651. }
  66652. declare module "babylonjs/Materials/Node/Optimizers/index" {
  66653. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  66654. }
  66655. declare module "babylonjs/Materials/Node/index" {
  66656. export * from "babylonjs/Materials/Node/Enums/index";
  66657. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66658. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  66659. export * from "babylonjs/Materials/Node/nodeMaterial";
  66660. export * from "babylonjs/Materials/Node/Blocks/index";
  66661. export * from "babylonjs/Materials/Node/Optimizers/index";
  66662. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  66663. }
  66664. declare module "babylonjs/Materials/index" {
  66665. export * from "babylonjs/Materials/Background/index";
  66666. export * from "babylonjs/Materials/colorCurves";
  66667. export * from "babylonjs/Materials/iEffectFallbacks";
  66668. export * from "babylonjs/Materials/effectFallbacks";
  66669. export * from "babylonjs/Materials/effect";
  66670. export * from "babylonjs/Materials/fresnelParameters";
  66671. export * from "babylonjs/Materials/imageProcessingConfiguration";
  66672. export * from "babylonjs/Materials/material";
  66673. export * from "babylonjs/Materials/materialDefines";
  66674. export * from "babylonjs/Materials/materialHelper";
  66675. export * from "babylonjs/Materials/multiMaterial";
  66676. export * from "babylonjs/Materials/PBR/index";
  66677. export * from "babylonjs/Materials/pushMaterial";
  66678. export * from "babylonjs/Materials/shaderMaterial";
  66679. export * from "babylonjs/Materials/standardMaterial";
  66680. export * from "babylonjs/Materials/Textures/index";
  66681. export * from "babylonjs/Materials/uniformBuffer";
  66682. export * from "babylonjs/Materials/materialFlags";
  66683. export * from "babylonjs/Materials/Node/index";
  66684. export * from "babylonjs/Materials/effectRenderer";
  66685. export * from "babylonjs/Materials/shadowDepthWrapper";
  66686. }
  66687. declare module "babylonjs/Maths/index" {
  66688. export * from "babylonjs/Maths/math.scalar";
  66689. export * from "babylonjs/Maths/math";
  66690. export * from "babylonjs/Maths/sphericalPolynomial";
  66691. }
  66692. declare module "babylonjs/Misc/workerPool" {
  66693. import { IDisposable } from "babylonjs/scene";
  66694. /**
  66695. * Helper class to push actions to a pool of workers.
  66696. */
  66697. export class WorkerPool implements IDisposable {
  66698. private _workerInfos;
  66699. private _pendingActions;
  66700. /**
  66701. * Constructor
  66702. * @param workers Array of workers to use for actions
  66703. */
  66704. constructor(workers: Array<Worker>);
  66705. /**
  66706. * Terminates all workers and clears any pending actions.
  66707. */
  66708. dispose(): void;
  66709. /**
  66710. * Pushes an action to the worker pool. If all the workers are active, the action will be
  66711. * pended until a worker has completed its action.
  66712. * @param action The action to perform. Call onComplete when the action is complete.
  66713. */
  66714. push(action: (worker: Worker, onComplete: () => void) => void): void;
  66715. private _execute;
  66716. }
  66717. }
  66718. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  66719. import { IDisposable } from "babylonjs/scene";
  66720. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  66721. /**
  66722. * Configuration for Draco compression
  66723. */
  66724. export interface IDracoCompressionConfiguration {
  66725. /**
  66726. * Configuration for the decoder.
  66727. */
  66728. decoder: {
  66729. /**
  66730. * The url to the WebAssembly module.
  66731. */
  66732. wasmUrl?: string;
  66733. /**
  66734. * The url to the WebAssembly binary.
  66735. */
  66736. wasmBinaryUrl?: string;
  66737. /**
  66738. * The url to the fallback JavaScript module.
  66739. */
  66740. fallbackUrl?: string;
  66741. };
  66742. }
  66743. /**
  66744. * Draco compression (https://google.github.io/draco/)
  66745. *
  66746. * This class wraps the Draco module.
  66747. *
  66748. * **Encoder**
  66749. *
  66750. * The encoder is not currently implemented.
  66751. *
  66752. * **Decoder**
  66753. *
  66754. * 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.
  66755. *
  66756. * To update the configuration, use the following code:
  66757. * ```javascript
  66758. * DracoCompression.Configuration = {
  66759. * decoder: {
  66760. * wasmUrl: "<url to the WebAssembly library>",
  66761. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  66762. * fallbackUrl: "<url to the fallback JavaScript library>",
  66763. * }
  66764. * };
  66765. * ```
  66766. *
  66767. * 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.
  66768. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  66769. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  66770. *
  66771. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  66772. * ```javascript
  66773. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  66774. * ```
  66775. *
  66776. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  66777. */
  66778. export class DracoCompression implements IDisposable {
  66779. private _workerPoolPromise?;
  66780. private _decoderModulePromise?;
  66781. /**
  66782. * The configuration. Defaults to the following urls:
  66783. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  66784. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  66785. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  66786. */
  66787. static Configuration: IDracoCompressionConfiguration;
  66788. /**
  66789. * Returns true if the decoder configuration is available.
  66790. */
  66791. static get DecoderAvailable(): boolean;
  66792. /**
  66793. * Default number of workers to create when creating the draco compression object.
  66794. */
  66795. static DefaultNumWorkers: number;
  66796. private static GetDefaultNumWorkers;
  66797. private static _Default;
  66798. /**
  66799. * Default instance for the draco compression object.
  66800. */
  66801. static get Default(): DracoCompression;
  66802. /**
  66803. * Constructor
  66804. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  66805. */
  66806. constructor(numWorkers?: number);
  66807. /**
  66808. * Stop all async operations and release resources.
  66809. */
  66810. dispose(): void;
  66811. /**
  66812. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  66813. * @returns a promise that resolves when ready
  66814. */
  66815. whenReadyAsync(): Promise<void>;
  66816. /**
  66817. * Decode Draco compressed mesh data to vertex data.
  66818. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  66819. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  66820. * @returns A promise that resolves with the decoded vertex data
  66821. */
  66822. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  66823. [kind: string]: number;
  66824. }): Promise<VertexData>;
  66825. }
  66826. }
  66827. declare module "babylonjs/Meshes/Compression/index" {
  66828. export * from "babylonjs/Meshes/Compression/dracoCompression";
  66829. }
  66830. declare module "babylonjs/Meshes/csg" {
  66831. import { Nullable } from "babylonjs/types";
  66832. import { Scene } from "babylonjs/scene";
  66833. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  66834. import { Mesh } from "babylonjs/Meshes/mesh";
  66835. import { Material } from "babylonjs/Materials/material";
  66836. /**
  66837. * Class for building Constructive Solid Geometry
  66838. */
  66839. export class CSG {
  66840. private polygons;
  66841. /**
  66842. * The world matrix
  66843. */
  66844. matrix: Matrix;
  66845. /**
  66846. * Stores the position
  66847. */
  66848. position: Vector3;
  66849. /**
  66850. * Stores the rotation
  66851. */
  66852. rotation: Vector3;
  66853. /**
  66854. * Stores the rotation quaternion
  66855. */
  66856. rotationQuaternion: Nullable<Quaternion>;
  66857. /**
  66858. * Stores the scaling vector
  66859. */
  66860. scaling: Vector3;
  66861. /**
  66862. * Convert the Mesh to CSG
  66863. * @param mesh The Mesh to convert to CSG
  66864. * @returns A new CSG from the Mesh
  66865. */
  66866. static FromMesh(mesh: Mesh): CSG;
  66867. /**
  66868. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  66869. * @param polygons Polygons used to construct a CSG solid
  66870. */
  66871. private static FromPolygons;
  66872. /**
  66873. * Clones, or makes a deep copy, of the CSG
  66874. * @returns A new CSG
  66875. */
  66876. clone(): CSG;
  66877. /**
  66878. * Unions this CSG with another CSG
  66879. * @param csg The CSG to union against this CSG
  66880. * @returns The unioned CSG
  66881. */
  66882. union(csg: CSG): CSG;
  66883. /**
  66884. * Unions this CSG with another CSG in place
  66885. * @param csg The CSG to union against this CSG
  66886. */
  66887. unionInPlace(csg: CSG): void;
  66888. /**
  66889. * Subtracts this CSG with another CSG
  66890. * @param csg The CSG to subtract against this CSG
  66891. * @returns A new CSG
  66892. */
  66893. subtract(csg: CSG): CSG;
  66894. /**
  66895. * Subtracts this CSG with another CSG in place
  66896. * @param csg The CSG to subtact against this CSG
  66897. */
  66898. subtractInPlace(csg: CSG): void;
  66899. /**
  66900. * Intersect this CSG with another CSG
  66901. * @param csg The CSG to intersect against this CSG
  66902. * @returns A new CSG
  66903. */
  66904. intersect(csg: CSG): CSG;
  66905. /**
  66906. * Intersects this CSG with another CSG in place
  66907. * @param csg The CSG to intersect against this CSG
  66908. */
  66909. intersectInPlace(csg: CSG): void;
  66910. /**
  66911. * Return a new CSG solid with solid and empty space switched. This solid is
  66912. * not modified.
  66913. * @returns A new CSG solid with solid and empty space switched
  66914. */
  66915. inverse(): CSG;
  66916. /**
  66917. * Inverses the CSG in place
  66918. */
  66919. inverseInPlace(): void;
  66920. /**
  66921. * This is used to keep meshes transformations so they can be restored
  66922. * when we build back a Babylon Mesh
  66923. * NB : All CSG operations are performed in world coordinates
  66924. * @param csg The CSG to copy the transform attributes from
  66925. * @returns This CSG
  66926. */
  66927. copyTransformAttributes(csg: CSG): CSG;
  66928. /**
  66929. * Build Raw mesh from CSG
  66930. * Coordinates here are in world space
  66931. * @param name The name of the mesh geometry
  66932. * @param scene The Scene
  66933. * @param keepSubMeshes Specifies if the submeshes should be kept
  66934. * @returns A new Mesh
  66935. */
  66936. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66937. /**
  66938. * Build Mesh from CSG taking material and transforms into account
  66939. * @param name The name of the Mesh
  66940. * @param material The material of the Mesh
  66941. * @param scene The Scene
  66942. * @param keepSubMeshes Specifies if submeshes should be kept
  66943. * @returns The new Mesh
  66944. */
  66945. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66946. }
  66947. }
  66948. declare module "babylonjs/Meshes/trailMesh" {
  66949. import { Mesh } from "babylonjs/Meshes/mesh";
  66950. import { Scene } from "babylonjs/scene";
  66951. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66952. /**
  66953. * Class used to create a trail following a mesh
  66954. */
  66955. export class TrailMesh extends Mesh {
  66956. private _generator;
  66957. private _autoStart;
  66958. private _running;
  66959. private _diameter;
  66960. private _length;
  66961. private _sectionPolygonPointsCount;
  66962. private _sectionVectors;
  66963. private _sectionNormalVectors;
  66964. private _beforeRenderObserver;
  66965. /**
  66966. * @constructor
  66967. * @param name The value used by scene.getMeshByName() to do a lookup.
  66968. * @param generator The mesh or transform node to generate a trail.
  66969. * @param scene The scene to add this mesh to.
  66970. * @param diameter Diameter of trailing mesh. Default is 1.
  66971. * @param length Length of trailing mesh. Default is 60.
  66972. * @param autoStart Automatically start trailing mesh. Default true.
  66973. */
  66974. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66975. /**
  66976. * "TrailMesh"
  66977. * @returns "TrailMesh"
  66978. */
  66979. getClassName(): string;
  66980. private _createMesh;
  66981. /**
  66982. * Start trailing mesh.
  66983. */
  66984. start(): void;
  66985. /**
  66986. * Stop trailing mesh.
  66987. */
  66988. stop(): void;
  66989. /**
  66990. * Update trailing mesh geometry.
  66991. */
  66992. update(): void;
  66993. /**
  66994. * Returns a new TrailMesh object.
  66995. * @param name is a string, the name given to the new mesh
  66996. * @param newGenerator use new generator object for cloned trail mesh
  66997. * @returns a new mesh
  66998. */
  66999. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  67000. /**
  67001. * Serializes this trail mesh
  67002. * @param serializationObject object to write serialization to
  67003. */
  67004. serialize(serializationObject: any): void;
  67005. /**
  67006. * Parses a serialized trail mesh
  67007. * @param parsedMesh the serialized mesh
  67008. * @param scene the scene to create the trail mesh in
  67009. * @returns the created trail mesh
  67010. */
  67011. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  67012. }
  67013. }
  67014. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  67015. import { Nullable } from "babylonjs/types";
  67016. import { Scene } from "babylonjs/scene";
  67017. import { Vector4 } from "babylonjs/Maths/math.vector";
  67018. import { Color4 } from "babylonjs/Maths/math.color";
  67019. import { Mesh } from "babylonjs/Meshes/mesh";
  67020. /**
  67021. * Class containing static functions to help procedurally build meshes
  67022. */
  67023. export class TiledBoxBuilder {
  67024. /**
  67025. * Creates a box mesh
  67026. * 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)
  67027. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67029. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67031. * @param name defines the name of the mesh
  67032. * @param options defines the options used to create the mesh
  67033. * @param scene defines the hosting scene
  67034. * @returns the box mesh
  67035. */
  67036. static CreateTiledBox(name: string, options: {
  67037. pattern?: number;
  67038. width?: number;
  67039. height?: number;
  67040. depth?: number;
  67041. tileSize?: number;
  67042. tileWidth?: number;
  67043. tileHeight?: number;
  67044. alignHorizontal?: number;
  67045. alignVertical?: number;
  67046. faceUV?: Vector4[];
  67047. faceColors?: Color4[];
  67048. sideOrientation?: number;
  67049. updatable?: boolean;
  67050. }, scene?: Nullable<Scene>): Mesh;
  67051. }
  67052. }
  67053. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  67054. import { Vector4 } from "babylonjs/Maths/math.vector";
  67055. import { Mesh } from "babylonjs/Meshes/mesh";
  67056. /**
  67057. * Class containing static functions to help procedurally build meshes
  67058. */
  67059. export class TorusKnotBuilder {
  67060. /**
  67061. * Creates a torus knot mesh
  67062. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67063. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67064. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67065. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67066. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67067. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67069. * @param name defines the name of the mesh
  67070. * @param options defines the options used to create the mesh
  67071. * @param scene defines the hosting scene
  67072. * @returns the torus knot mesh
  67073. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67074. */
  67075. static CreateTorusKnot(name: string, options: {
  67076. radius?: number;
  67077. tube?: number;
  67078. radialSegments?: number;
  67079. tubularSegments?: number;
  67080. p?: number;
  67081. q?: number;
  67082. updatable?: boolean;
  67083. sideOrientation?: number;
  67084. frontUVs?: Vector4;
  67085. backUVs?: Vector4;
  67086. }, scene: any): Mesh;
  67087. }
  67088. }
  67089. declare module "babylonjs/Meshes/polygonMesh" {
  67090. import { Scene } from "babylonjs/scene";
  67091. import { Vector2 } from "babylonjs/Maths/math.vector";
  67092. import { Mesh } from "babylonjs/Meshes/mesh";
  67093. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67094. import { Path2 } from "babylonjs/Maths/math.path";
  67095. /**
  67096. * Polygon
  67097. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  67098. */
  67099. export class Polygon {
  67100. /**
  67101. * Creates a rectangle
  67102. * @param xmin bottom X coord
  67103. * @param ymin bottom Y coord
  67104. * @param xmax top X coord
  67105. * @param ymax top Y coord
  67106. * @returns points that make the resulting rectation
  67107. */
  67108. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  67109. /**
  67110. * Creates a circle
  67111. * @param radius radius of circle
  67112. * @param cx scale in x
  67113. * @param cy scale in y
  67114. * @param numberOfSides number of sides that make up the circle
  67115. * @returns points that make the resulting circle
  67116. */
  67117. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  67118. /**
  67119. * Creates a polygon from input string
  67120. * @param input Input polygon data
  67121. * @returns the parsed points
  67122. */
  67123. static Parse(input: string): Vector2[];
  67124. /**
  67125. * Starts building a polygon from x and y coordinates
  67126. * @param x x coordinate
  67127. * @param y y coordinate
  67128. * @returns the started path2
  67129. */
  67130. static StartingAt(x: number, y: number): Path2;
  67131. }
  67132. /**
  67133. * Builds a polygon
  67134. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  67135. */
  67136. export class PolygonMeshBuilder {
  67137. private _points;
  67138. private _outlinepoints;
  67139. private _holes;
  67140. private _name;
  67141. private _scene;
  67142. private _epoints;
  67143. private _eholes;
  67144. private _addToepoint;
  67145. /**
  67146. * Babylon reference to the earcut plugin.
  67147. */
  67148. bjsEarcut: any;
  67149. /**
  67150. * Creates a PolygonMeshBuilder
  67151. * @param name name of the builder
  67152. * @param contours Path of the polygon
  67153. * @param scene scene to add to when creating the mesh
  67154. * @param earcutInjection can be used to inject your own earcut reference
  67155. */
  67156. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  67157. /**
  67158. * Adds a whole within the polygon
  67159. * @param hole Array of points defining the hole
  67160. * @returns this
  67161. */
  67162. addHole(hole: Vector2[]): PolygonMeshBuilder;
  67163. /**
  67164. * Creates the polygon
  67165. * @param updatable If the mesh should be updatable
  67166. * @param depth The depth of the mesh created
  67167. * @returns the created mesh
  67168. */
  67169. build(updatable?: boolean, depth?: number): Mesh;
  67170. /**
  67171. * Creates the polygon
  67172. * @param depth The depth of the mesh created
  67173. * @returns the created VertexData
  67174. */
  67175. buildVertexData(depth?: number): VertexData;
  67176. /**
  67177. * Adds a side to the polygon
  67178. * @param positions points that make the polygon
  67179. * @param normals normals of the polygon
  67180. * @param uvs uvs of the polygon
  67181. * @param indices indices of the polygon
  67182. * @param bounds bounds of the polygon
  67183. * @param points points of the polygon
  67184. * @param depth depth of the polygon
  67185. * @param flip flip of the polygon
  67186. */
  67187. private addSide;
  67188. }
  67189. }
  67190. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  67191. import { Scene } from "babylonjs/scene";
  67192. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67193. import { Color4 } from "babylonjs/Maths/math.color";
  67194. import { Mesh } from "babylonjs/Meshes/mesh";
  67195. import { Nullable } from "babylonjs/types";
  67196. /**
  67197. * Class containing static functions to help procedurally build meshes
  67198. */
  67199. export class PolygonBuilder {
  67200. /**
  67201. * Creates a polygon mesh
  67202. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67203. * * 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
  67204. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  67207. * * Remember you can only change the shape positions, not their number when updating a polygon
  67208. * @param name defines the name of the mesh
  67209. * @param options defines the options used to create the mesh
  67210. * @param scene defines the hosting scene
  67211. * @param earcutInjection can be used to inject your own earcut reference
  67212. * @returns the polygon mesh
  67213. */
  67214. static CreatePolygon(name: string, options: {
  67215. shape: Vector3[];
  67216. holes?: Vector3[][];
  67217. depth?: number;
  67218. faceUV?: Vector4[];
  67219. faceColors?: Color4[];
  67220. updatable?: boolean;
  67221. sideOrientation?: number;
  67222. frontUVs?: Vector4;
  67223. backUVs?: Vector4;
  67224. wrap?: boolean;
  67225. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67226. /**
  67227. * Creates an extruded polygon mesh, with depth in the Y direction.
  67228. * * 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)
  67229. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67230. * @param name defines the name of the mesh
  67231. * @param options defines the options used to create the mesh
  67232. * @param scene defines the hosting scene
  67233. * @param earcutInjection can be used to inject your own earcut reference
  67234. * @returns the polygon mesh
  67235. */
  67236. static ExtrudePolygon(name: string, options: {
  67237. shape: Vector3[];
  67238. holes?: Vector3[][];
  67239. depth?: number;
  67240. faceUV?: Vector4[];
  67241. faceColors?: Color4[];
  67242. updatable?: boolean;
  67243. sideOrientation?: number;
  67244. frontUVs?: Vector4;
  67245. backUVs?: Vector4;
  67246. wrap?: boolean;
  67247. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67248. }
  67249. }
  67250. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  67251. import { Scene } from "babylonjs/scene";
  67252. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67253. import { Mesh } from "babylonjs/Meshes/mesh";
  67254. import { Nullable } from "babylonjs/types";
  67255. /**
  67256. * Class containing static functions to help procedurally build meshes
  67257. */
  67258. export class LatheBuilder {
  67259. /**
  67260. * Creates lathe mesh.
  67261. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67262. * * 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
  67263. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67264. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67265. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67266. * * 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
  67267. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67268. * * 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
  67269. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67270. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67271. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67273. * @param name defines the name of the mesh
  67274. * @param options defines the options used to create the mesh
  67275. * @param scene defines the hosting scene
  67276. * @returns the lathe mesh
  67277. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67278. */
  67279. static CreateLathe(name: string, options: {
  67280. shape: Vector3[];
  67281. radius?: number;
  67282. tessellation?: number;
  67283. clip?: number;
  67284. arc?: number;
  67285. closed?: boolean;
  67286. updatable?: boolean;
  67287. sideOrientation?: number;
  67288. frontUVs?: Vector4;
  67289. backUVs?: Vector4;
  67290. cap?: number;
  67291. invertUV?: boolean;
  67292. }, scene?: Nullable<Scene>): Mesh;
  67293. }
  67294. }
  67295. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  67296. import { Nullable } from "babylonjs/types";
  67297. import { Scene } from "babylonjs/scene";
  67298. import { Vector4 } from "babylonjs/Maths/math.vector";
  67299. import { Mesh } from "babylonjs/Meshes/mesh";
  67300. /**
  67301. * Class containing static functions to help procedurally build meshes
  67302. */
  67303. export class TiledPlaneBuilder {
  67304. /**
  67305. * Creates a tiled plane mesh
  67306. * * The parameter `pattern` will, depending on value, do nothing or
  67307. * * * flip (reflect about central vertical) alternate tiles across and up
  67308. * * * flip every tile on alternate rows
  67309. * * * rotate (180 degs) alternate tiles across and up
  67310. * * * rotate every tile on alternate rows
  67311. * * * flip and rotate alternate tiles across and up
  67312. * * * flip and rotate every tile on alternate rows
  67313. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  67314. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  67315. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67316. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67317. * * 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)
  67318. * * 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)
  67319. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67320. * @param name defines the name of the mesh
  67321. * @param options defines the options used to create the mesh
  67322. * @param scene defines the hosting scene
  67323. * @returns the box mesh
  67324. */
  67325. static CreateTiledPlane(name: string, options: {
  67326. pattern?: number;
  67327. tileSize?: number;
  67328. tileWidth?: number;
  67329. tileHeight?: number;
  67330. size?: number;
  67331. width?: number;
  67332. height?: number;
  67333. alignHorizontal?: number;
  67334. alignVertical?: number;
  67335. sideOrientation?: number;
  67336. frontUVs?: Vector4;
  67337. backUVs?: Vector4;
  67338. updatable?: boolean;
  67339. }, scene?: Nullable<Scene>): Mesh;
  67340. }
  67341. }
  67342. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  67343. import { Nullable } from "babylonjs/types";
  67344. import { Scene } from "babylonjs/scene";
  67345. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67346. import { Mesh } from "babylonjs/Meshes/mesh";
  67347. /**
  67348. * Class containing static functions to help procedurally build meshes
  67349. */
  67350. export class TubeBuilder {
  67351. /**
  67352. * Creates a tube mesh.
  67353. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67354. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67355. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67356. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67357. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67358. * * 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)
  67359. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67360. * * 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
  67361. * * 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
  67362. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67363. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67364. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67366. * @param name defines the name of the mesh
  67367. * @param options defines the options used to create the mesh
  67368. * @param scene defines the hosting scene
  67369. * @returns the tube mesh
  67370. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67371. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67372. */
  67373. static CreateTube(name: string, options: {
  67374. path: Vector3[];
  67375. radius?: number;
  67376. tessellation?: number;
  67377. radiusFunction?: {
  67378. (i: number, distance: number): number;
  67379. };
  67380. cap?: number;
  67381. arc?: number;
  67382. updatable?: boolean;
  67383. sideOrientation?: number;
  67384. frontUVs?: Vector4;
  67385. backUVs?: Vector4;
  67386. instance?: Mesh;
  67387. invertUV?: boolean;
  67388. }, scene?: Nullable<Scene>): Mesh;
  67389. }
  67390. }
  67391. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  67392. import { Scene } from "babylonjs/scene";
  67393. import { Vector4 } from "babylonjs/Maths/math.vector";
  67394. import { Mesh } from "babylonjs/Meshes/mesh";
  67395. import { Nullable } from "babylonjs/types";
  67396. /**
  67397. * Class containing static functions to help procedurally build meshes
  67398. */
  67399. export class IcoSphereBuilder {
  67400. /**
  67401. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67402. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67403. * * 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`)
  67404. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67405. * * 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
  67406. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67407. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67409. * @param name defines the name of the mesh
  67410. * @param options defines the options used to create the mesh
  67411. * @param scene defines the hosting scene
  67412. * @returns the icosahedron mesh
  67413. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67414. */
  67415. static CreateIcoSphere(name: string, options: {
  67416. radius?: number;
  67417. radiusX?: number;
  67418. radiusY?: number;
  67419. radiusZ?: number;
  67420. flat?: boolean;
  67421. subdivisions?: number;
  67422. sideOrientation?: number;
  67423. frontUVs?: Vector4;
  67424. backUVs?: Vector4;
  67425. updatable?: boolean;
  67426. }, scene?: Nullable<Scene>): Mesh;
  67427. }
  67428. }
  67429. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  67430. import { Vector3 } from "babylonjs/Maths/math.vector";
  67431. import { Mesh } from "babylonjs/Meshes/mesh";
  67432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67433. /**
  67434. * Class containing static functions to help procedurally build meshes
  67435. */
  67436. export class DecalBuilder {
  67437. /**
  67438. * Creates a decal mesh.
  67439. * 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
  67440. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67441. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67442. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67443. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67444. * @param name defines the name of the mesh
  67445. * @param sourceMesh defines the mesh where the decal must be applied
  67446. * @param options defines the options used to create the mesh
  67447. * @param scene defines the hosting scene
  67448. * @returns the decal mesh
  67449. * @see https://doc.babylonjs.com/how_to/decals
  67450. */
  67451. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67452. position?: Vector3;
  67453. normal?: Vector3;
  67454. size?: Vector3;
  67455. angle?: number;
  67456. }): Mesh;
  67457. }
  67458. }
  67459. declare module "babylonjs/Meshes/meshBuilder" {
  67460. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  67461. import { Nullable } from "babylonjs/types";
  67462. import { Scene } from "babylonjs/scene";
  67463. import { Mesh } from "babylonjs/Meshes/mesh";
  67464. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  67465. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  67466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67467. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  67468. import { Plane } from "babylonjs/Maths/math.plane";
  67469. /**
  67470. * Class containing static functions to help procedurally build meshes
  67471. */
  67472. export class MeshBuilder {
  67473. /**
  67474. * Creates a box mesh
  67475. * * The parameter `size` sets the size (float) of each box side (default 1)
  67476. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  67477. * * 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)
  67478. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67480. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67482. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67483. * @param name defines the name of the mesh
  67484. * @param options defines the options used to create the mesh
  67485. * @param scene defines the hosting scene
  67486. * @returns the box mesh
  67487. */
  67488. static CreateBox(name: string, options: {
  67489. size?: number;
  67490. width?: number;
  67491. height?: number;
  67492. depth?: number;
  67493. faceUV?: Vector4[];
  67494. faceColors?: Color4[];
  67495. sideOrientation?: number;
  67496. frontUVs?: Vector4;
  67497. backUVs?: Vector4;
  67498. wrap?: boolean;
  67499. topBaseAt?: number;
  67500. bottomBaseAt?: number;
  67501. updatable?: boolean;
  67502. }, scene?: Nullable<Scene>): Mesh;
  67503. /**
  67504. * Creates a tiled box mesh
  67505. * * faceTiles sets the pattern, tile size and number of tiles for a face
  67506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67507. * @param name defines the name of the mesh
  67508. * @param options defines the options used to create the mesh
  67509. * @param scene defines the hosting scene
  67510. * @returns the tiled box mesh
  67511. */
  67512. static CreateTiledBox(name: string, options: {
  67513. pattern?: number;
  67514. size?: number;
  67515. width?: number;
  67516. height?: number;
  67517. depth: number;
  67518. tileSize?: number;
  67519. tileWidth?: number;
  67520. tileHeight?: number;
  67521. faceUV?: Vector4[];
  67522. faceColors?: Color4[];
  67523. alignHorizontal?: number;
  67524. alignVertical?: number;
  67525. sideOrientation?: number;
  67526. updatable?: boolean;
  67527. }, scene?: Nullable<Scene>): Mesh;
  67528. /**
  67529. * Creates a sphere mesh
  67530. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  67531. * * 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`)
  67532. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  67533. * * 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
  67534. * * 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)
  67535. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67536. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67538. * @param name defines the name of the mesh
  67539. * @param options defines the options used to create the mesh
  67540. * @param scene defines the hosting scene
  67541. * @returns the sphere mesh
  67542. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  67543. */
  67544. static CreateSphere(name: string, options: {
  67545. segments?: number;
  67546. diameter?: number;
  67547. diameterX?: number;
  67548. diameterY?: number;
  67549. diameterZ?: number;
  67550. arc?: number;
  67551. slice?: number;
  67552. sideOrientation?: number;
  67553. frontUVs?: Vector4;
  67554. backUVs?: Vector4;
  67555. updatable?: boolean;
  67556. }, scene?: Nullable<Scene>): Mesh;
  67557. /**
  67558. * Creates a plane polygonal mesh. By default, this is a disc
  67559. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  67560. * * 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
  67561. * * 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
  67562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67563. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67565. * @param name defines the name of the mesh
  67566. * @param options defines the options used to create the mesh
  67567. * @param scene defines the hosting scene
  67568. * @returns the plane polygonal mesh
  67569. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  67570. */
  67571. static CreateDisc(name: string, options: {
  67572. radius?: number;
  67573. tessellation?: number;
  67574. arc?: number;
  67575. updatable?: boolean;
  67576. sideOrientation?: number;
  67577. frontUVs?: Vector4;
  67578. backUVs?: Vector4;
  67579. }, scene?: Nullable<Scene>): Mesh;
  67580. /**
  67581. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67582. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67583. * * 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`)
  67584. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67585. * * 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
  67586. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67587. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67589. * @param name defines the name of the mesh
  67590. * @param options defines the options used to create the mesh
  67591. * @param scene defines the hosting scene
  67592. * @returns the icosahedron mesh
  67593. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67594. */
  67595. static CreateIcoSphere(name: string, options: {
  67596. radius?: number;
  67597. radiusX?: number;
  67598. radiusY?: number;
  67599. radiusZ?: number;
  67600. flat?: boolean;
  67601. subdivisions?: number;
  67602. sideOrientation?: number;
  67603. frontUVs?: Vector4;
  67604. backUVs?: Vector4;
  67605. updatable?: boolean;
  67606. }, scene?: Nullable<Scene>): Mesh;
  67607. /**
  67608. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67609. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  67610. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  67611. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  67612. * * 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
  67613. * * 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
  67614. * * 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
  67615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67616. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67617. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67618. * * 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
  67619. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  67620. * * 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
  67621. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  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 ribbon mesh
  67627. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  67628. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67629. */
  67630. static CreateRibbon(name: string, options: {
  67631. pathArray: Vector3[][];
  67632. closeArray?: boolean;
  67633. closePath?: boolean;
  67634. offset?: number;
  67635. updatable?: boolean;
  67636. sideOrientation?: number;
  67637. frontUVs?: Vector4;
  67638. backUVs?: Vector4;
  67639. instance?: Mesh;
  67640. invertUV?: boolean;
  67641. uvs?: Vector2[];
  67642. colors?: Color4[];
  67643. }, scene?: Nullable<Scene>): Mesh;
  67644. /**
  67645. * Creates a cylinder or a cone mesh
  67646. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  67647. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  67648. * * 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.
  67649. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  67650. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  67651. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  67652. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  67653. * * 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).
  67654. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  67655. * * 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).
  67656. * * 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
  67657. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  67658. * * 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
  67659. * * 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.
  67660. * * If `enclose` is false, a ring surface is one element.
  67661. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  67662. * * 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
  67663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67664. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67666. * @param name defines the name of the mesh
  67667. * @param options defines the options used to create the mesh
  67668. * @param scene defines the hosting scene
  67669. * @returns the cylinder mesh
  67670. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  67671. */
  67672. static CreateCylinder(name: string, options: {
  67673. height?: number;
  67674. diameterTop?: number;
  67675. diameterBottom?: number;
  67676. diameter?: number;
  67677. tessellation?: number;
  67678. subdivisions?: number;
  67679. arc?: number;
  67680. faceColors?: Color4[];
  67681. faceUV?: Vector4[];
  67682. updatable?: boolean;
  67683. hasRings?: boolean;
  67684. enclose?: boolean;
  67685. cap?: number;
  67686. sideOrientation?: number;
  67687. frontUVs?: Vector4;
  67688. backUVs?: Vector4;
  67689. }, scene?: Nullable<Scene>): Mesh;
  67690. /**
  67691. * Creates a torus mesh
  67692. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  67693. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  67694. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  67695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67696. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67698. * @param name defines the name of the mesh
  67699. * @param options defines the options used to create the mesh
  67700. * @param scene defines the hosting scene
  67701. * @returns the torus mesh
  67702. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  67703. */
  67704. static CreateTorus(name: string, options: {
  67705. diameter?: number;
  67706. thickness?: number;
  67707. tessellation?: number;
  67708. updatable?: boolean;
  67709. sideOrientation?: number;
  67710. frontUVs?: Vector4;
  67711. backUVs?: Vector4;
  67712. }, scene?: Nullable<Scene>): Mesh;
  67713. /**
  67714. * Creates a torus knot mesh
  67715. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67716. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67717. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67718. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67720. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67722. * @param name defines the name of the mesh
  67723. * @param options defines the options used to create the mesh
  67724. * @param scene defines the hosting scene
  67725. * @returns the torus knot mesh
  67726. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67727. */
  67728. static CreateTorusKnot(name: string, options: {
  67729. radius?: number;
  67730. tube?: number;
  67731. radialSegments?: number;
  67732. tubularSegments?: number;
  67733. p?: number;
  67734. q?: number;
  67735. updatable?: boolean;
  67736. sideOrientation?: number;
  67737. frontUVs?: Vector4;
  67738. backUVs?: Vector4;
  67739. }, scene?: Nullable<Scene>): Mesh;
  67740. /**
  67741. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  67742. * * 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
  67743. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  67744. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  67745. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  67746. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  67747. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  67748. * * 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
  67749. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  67750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67751. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  67752. * @param name defines the name of the new line system
  67753. * @param options defines the options used to create the line system
  67754. * @param scene defines the hosting scene
  67755. * @returns a new line system mesh
  67756. */
  67757. static CreateLineSystem(name: string, options: {
  67758. lines: Vector3[][];
  67759. updatable?: boolean;
  67760. instance?: Nullable<LinesMesh>;
  67761. colors?: Nullable<Color4[][]>;
  67762. useVertexAlpha?: boolean;
  67763. }, scene: Nullable<Scene>): LinesMesh;
  67764. /**
  67765. * Creates a line mesh
  67766. * 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
  67767. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67768. * * The parameter `points` is an array successive Vector3
  67769. * * 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
  67770. * * The optional parameter `colors` is an array of successive Color4, one per line point
  67771. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  67772. * * When updating an instance, remember that only point positions can change, not the number of points
  67773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67774. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  67775. * @param name defines the name of the new line system
  67776. * @param options defines the options used to create the line system
  67777. * @param scene defines the hosting scene
  67778. * @returns a new line mesh
  67779. */
  67780. static CreateLines(name: string, options: {
  67781. points: Vector3[];
  67782. updatable?: boolean;
  67783. instance?: Nullable<LinesMesh>;
  67784. colors?: Color4[];
  67785. useVertexAlpha?: boolean;
  67786. }, scene?: Nullable<Scene>): LinesMesh;
  67787. /**
  67788. * Creates a dashed line mesh
  67789. * * 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
  67790. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67791. * * The parameter `points` is an array successive Vector3
  67792. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  67793. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  67794. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  67795. * * 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
  67796. * * When updating an instance, remember that only point positions can change, not the number of points
  67797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67798. * @param name defines the name of the mesh
  67799. * @param options defines the options used to create the mesh
  67800. * @param scene defines the hosting scene
  67801. * @returns the dashed line mesh
  67802. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  67803. */
  67804. static CreateDashedLines(name: string, options: {
  67805. points: Vector3[];
  67806. dashSize?: number;
  67807. gapSize?: number;
  67808. dashNb?: number;
  67809. updatable?: boolean;
  67810. instance?: LinesMesh;
  67811. }, scene?: Nullable<Scene>): LinesMesh;
  67812. /**
  67813. * 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.
  67814. * * 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.
  67815. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67816. * * 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.
  67817. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  67818. * * 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
  67819. * * 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
  67820. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  67821. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67822. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67823. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  67824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67825. * @param name defines the name of the mesh
  67826. * @param options defines the options used to create the mesh
  67827. * @param scene defines the hosting scene
  67828. * @returns the extruded shape mesh
  67829. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67830. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67831. */
  67832. static ExtrudeShape(name: string, options: {
  67833. shape: Vector3[];
  67834. path: Vector3[];
  67835. scale?: number;
  67836. rotation?: number;
  67837. cap?: number;
  67838. updatable?: boolean;
  67839. sideOrientation?: number;
  67840. frontUVs?: Vector4;
  67841. backUVs?: Vector4;
  67842. instance?: Mesh;
  67843. invertUV?: boolean;
  67844. }, scene?: Nullable<Scene>): Mesh;
  67845. /**
  67846. * Creates an custom extruded shape mesh.
  67847. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  67848. * * 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.
  67849. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67850. * * 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
  67851. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  67852. * * 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
  67853. * * It must returns a float value that will be the scale value applied to the shape on each path point
  67854. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  67855. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  67856. * * 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
  67857. * * 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
  67858. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  67859. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67860. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67861. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67863. * @param name defines the name of the mesh
  67864. * @param options defines the options used to create the mesh
  67865. * @param scene defines the hosting scene
  67866. * @returns the custom extruded shape mesh
  67867. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  67868. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67869. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67870. */
  67871. static ExtrudeShapeCustom(name: string, options: {
  67872. shape: Vector3[];
  67873. path: Vector3[];
  67874. scaleFunction?: any;
  67875. rotationFunction?: any;
  67876. ribbonCloseArray?: boolean;
  67877. ribbonClosePath?: boolean;
  67878. cap?: number;
  67879. updatable?: boolean;
  67880. sideOrientation?: number;
  67881. frontUVs?: Vector4;
  67882. backUVs?: Vector4;
  67883. instance?: Mesh;
  67884. invertUV?: boolean;
  67885. }, scene?: Nullable<Scene>): Mesh;
  67886. /**
  67887. * Creates lathe mesh.
  67888. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67889. * * 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
  67890. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67891. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67892. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67893. * * 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
  67894. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67895. * * 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
  67896. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67897. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67898. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67900. * @param name defines the name of the mesh
  67901. * @param options defines the options used to create the mesh
  67902. * @param scene defines the hosting scene
  67903. * @returns the lathe mesh
  67904. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67905. */
  67906. static CreateLathe(name: string, options: {
  67907. shape: Vector3[];
  67908. radius?: number;
  67909. tessellation?: number;
  67910. clip?: number;
  67911. arc?: number;
  67912. closed?: boolean;
  67913. updatable?: boolean;
  67914. sideOrientation?: number;
  67915. frontUVs?: Vector4;
  67916. backUVs?: Vector4;
  67917. cap?: number;
  67918. invertUV?: boolean;
  67919. }, scene?: Nullable<Scene>): Mesh;
  67920. /**
  67921. * Creates a tiled plane mesh
  67922. * * You can set a limited pattern arrangement with the tiles
  67923. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67924. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67926. * @param name defines the name of the mesh
  67927. * @param options defines the options used to create the mesh
  67928. * @param scene defines the hosting scene
  67929. * @returns the plane mesh
  67930. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67931. */
  67932. static CreateTiledPlane(name: string, options: {
  67933. pattern?: number;
  67934. tileSize?: number;
  67935. tileWidth?: number;
  67936. tileHeight?: number;
  67937. size?: number;
  67938. width?: number;
  67939. height?: number;
  67940. alignHorizontal?: number;
  67941. alignVertical?: number;
  67942. sideOrientation?: number;
  67943. frontUVs?: Vector4;
  67944. backUVs?: Vector4;
  67945. updatable?: boolean;
  67946. }, scene?: Nullable<Scene>): Mesh;
  67947. /**
  67948. * Creates a plane mesh
  67949. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  67950. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  67951. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  67952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67953. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67955. * @param name defines the name of the mesh
  67956. * @param options defines the options used to create the mesh
  67957. * @param scene defines the hosting scene
  67958. * @returns the plane mesh
  67959. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67960. */
  67961. static CreatePlane(name: string, options: {
  67962. size?: number;
  67963. width?: number;
  67964. height?: number;
  67965. sideOrientation?: number;
  67966. frontUVs?: Vector4;
  67967. backUVs?: Vector4;
  67968. updatable?: boolean;
  67969. sourcePlane?: Plane;
  67970. }, scene?: Nullable<Scene>): Mesh;
  67971. /**
  67972. * Creates a ground mesh
  67973. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67974. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67976. * @param name defines the name of the mesh
  67977. * @param options defines the options used to create the mesh
  67978. * @param scene defines the hosting scene
  67979. * @returns the ground mesh
  67980. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67981. */
  67982. static CreateGround(name: string, options: {
  67983. width?: number;
  67984. height?: number;
  67985. subdivisions?: number;
  67986. subdivisionsX?: number;
  67987. subdivisionsY?: number;
  67988. updatable?: boolean;
  67989. }, scene?: Nullable<Scene>): Mesh;
  67990. /**
  67991. * Creates a tiled ground mesh
  67992. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67993. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67994. * * 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
  67995. * * 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
  67996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67997. * @param name defines the name of the mesh
  67998. * @param options defines the options used to create the mesh
  67999. * @param scene defines the hosting scene
  68000. * @returns the tiled ground mesh
  68001. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  68002. */
  68003. static CreateTiledGround(name: string, options: {
  68004. xmin: number;
  68005. zmin: number;
  68006. xmax: number;
  68007. zmax: number;
  68008. subdivisions?: {
  68009. w: number;
  68010. h: number;
  68011. };
  68012. precision?: {
  68013. w: number;
  68014. h: number;
  68015. };
  68016. updatable?: boolean;
  68017. }, scene?: Nullable<Scene>): Mesh;
  68018. /**
  68019. * Creates a ground mesh from a height map
  68020. * * The parameter `url` sets the URL of the height map image resource.
  68021. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  68022. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  68023. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  68024. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  68025. * * 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.
  68026. * * 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).
  68027. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  68028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68029. * @param name defines the name of the mesh
  68030. * @param url defines the url to the height map
  68031. * @param options defines the options used to create the mesh
  68032. * @param scene defines the hosting scene
  68033. * @returns the ground mesh
  68034. * @see https://doc.babylonjs.com/babylon101/height_map
  68035. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  68036. */
  68037. static CreateGroundFromHeightMap(name: string, url: string, options: {
  68038. width?: number;
  68039. height?: number;
  68040. subdivisions?: number;
  68041. minHeight?: number;
  68042. maxHeight?: number;
  68043. colorFilter?: Color3;
  68044. alphaFilter?: number;
  68045. updatable?: boolean;
  68046. onReady?: (mesh: GroundMesh) => void;
  68047. }, scene?: Nullable<Scene>): GroundMesh;
  68048. /**
  68049. * Creates a polygon mesh
  68050. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68051. * * 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
  68052. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68054. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  68055. * * Remember you can only change the shape positions, not their number when updating a polygon
  68056. * @param name defines the name of the mesh
  68057. * @param options defines the options used to create the mesh
  68058. * @param scene defines the hosting scene
  68059. * @param earcutInjection can be used to inject your own earcut reference
  68060. * @returns the polygon mesh
  68061. */
  68062. static CreatePolygon(name: string, options: {
  68063. shape: Vector3[];
  68064. holes?: Vector3[][];
  68065. depth?: number;
  68066. faceUV?: Vector4[];
  68067. faceColors?: Color4[];
  68068. updatable?: boolean;
  68069. sideOrientation?: number;
  68070. frontUVs?: Vector4;
  68071. backUVs?: Vector4;
  68072. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68073. /**
  68074. * Creates an extruded polygon mesh, with depth in the Y direction.
  68075. * * 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)
  68076. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68077. * @param name defines the name of the mesh
  68078. * @param options defines the options used to create the mesh
  68079. * @param scene defines the hosting scene
  68080. * @param earcutInjection can be used to inject your own earcut reference
  68081. * @returns the polygon mesh
  68082. */
  68083. static ExtrudePolygon(name: string, options: {
  68084. shape: Vector3[];
  68085. holes?: Vector3[][];
  68086. depth?: number;
  68087. faceUV?: Vector4[];
  68088. faceColors?: Color4[];
  68089. updatable?: boolean;
  68090. sideOrientation?: number;
  68091. frontUVs?: Vector4;
  68092. backUVs?: Vector4;
  68093. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68094. /**
  68095. * Creates a tube mesh.
  68096. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68097. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68098. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68099. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68100. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68101. * * 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)
  68102. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68103. * * 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
  68104. * * 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
  68105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68106. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68107. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68109. * @param name defines the name of the mesh
  68110. * @param options defines the options used to create the mesh
  68111. * @param scene defines the hosting scene
  68112. * @returns the tube mesh
  68113. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68114. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68115. */
  68116. static CreateTube(name: string, options: {
  68117. path: Vector3[];
  68118. radius?: number;
  68119. tessellation?: number;
  68120. radiusFunction?: {
  68121. (i: number, distance: number): number;
  68122. };
  68123. cap?: number;
  68124. arc?: number;
  68125. updatable?: boolean;
  68126. sideOrientation?: number;
  68127. frontUVs?: Vector4;
  68128. backUVs?: Vector4;
  68129. instance?: Mesh;
  68130. invertUV?: boolean;
  68131. }, scene?: Nullable<Scene>): Mesh;
  68132. /**
  68133. * Creates a polyhedron mesh
  68134. * * 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
  68135. * * The parameter `size` (positive float, default 1) sets the polygon size
  68136. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  68137. * * 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`
  68138. * * 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
  68139. * * 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)`)
  68140. * * 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
  68141. * * 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
  68142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68143. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68145. * @param name defines the name of the mesh
  68146. * @param options defines the options used to create the mesh
  68147. * @param scene defines the hosting scene
  68148. * @returns the polyhedron mesh
  68149. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  68150. */
  68151. static CreatePolyhedron(name: string, options: {
  68152. type?: number;
  68153. size?: number;
  68154. sizeX?: number;
  68155. sizeY?: number;
  68156. sizeZ?: number;
  68157. custom?: any;
  68158. faceUV?: Vector4[];
  68159. faceColors?: Color4[];
  68160. flat?: boolean;
  68161. updatable?: boolean;
  68162. sideOrientation?: number;
  68163. frontUVs?: Vector4;
  68164. backUVs?: Vector4;
  68165. }, scene?: Nullable<Scene>): Mesh;
  68166. /**
  68167. * Creates a decal mesh.
  68168. * 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
  68169. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68170. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68171. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68172. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68173. * @param name defines the name of the mesh
  68174. * @param sourceMesh defines the mesh where the decal must be applied
  68175. * @param options defines the options used to create the mesh
  68176. * @param scene defines the hosting scene
  68177. * @returns the decal mesh
  68178. * @see https://doc.babylonjs.com/how_to/decals
  68179. */
  68180. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68181. position?: Vector3;
  68182. normal?: Vector3;
  68183. size?: Vector3;
  68184. angle?: number;
  68185. }): Mesh;
  68186. }
  68187. }
  68188. declare module "babylonjs/Meshes/meshSimplification" {
  68189. import { Mesh } from "babylonjs/Meshes/mesh";
  68190. /**
  68191. * A simplifier interface for future simplification implementations
  68192. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68193. */
  68194. export interface ISimplifier {
  68195. /**
  68196. * Simplification of a given mesh according to the given settings.
  68197. * Since this requires computation, it is assumed that the function runs async.
  68198. * @param settings The settings of the simplification, including quality and distance
  68199. * @param successCallback A callback that will be called after the mesh was simplified.
  68200. * @param errorCallback in case of an error, this callback will be called. optional.
  68201. */
  68202. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  68203. }
  68204. /**
  68205. * Expected simplification settings.
  68206. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  68207. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68208. */
  68209. export interface ISimplificationSettings {
  68210. /**
  68211. * Gets or sets the expected quality
  68212. */
  68213. quality: number;
  68214. /**
  68215. * Gets or sets the distance when this optimized version should be used
  68216. */
  68217. distance: number;
  68218. /**
  68219. * Gets an already optimized mesh
  68220. */
  68221. optimizeMesh?: boolean;
  68222. }
  68223. /**
  68224. * Class used to specify simplification options
  68225. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68226. */
  68227. export class SimplificationSettings implements ISimplificationSettings {
  68228. /** expected quality */
  68229. quality: number;
  68230. /** distance when this optimized version should be used */
  68231. distance: number;
  68232. /** already optimized mesh */
  68233. optimizeMesh?: boolean | undefined;
  68234. /**
  68235. * Creates a SimplificationSettings
  68236. * @param quality expected quality
  68237. * @param distance distance when this optimized version should be used
  68238. * @param optimizeMesh already optimized mesh
  68239. */
  68240. constructor(
  68241. /** expected quality */
  68242. quality: number,
  68243. /** distance when this optimized version should be used */
  68244. distance: number,
  68245. /** already optimized mesh */
  68246. optimizeMesh?: boolean | undefined);
  68247. }
  68248. /**
  68249. * Interface used to define a simplification task
  68250. */
  68251. export interface ISimplificationTask {
  68252. /**
  68253. * Array of settings
  68254. */
  68255. settings: Array<ISimplificationSettings>;
  68256. /**
  68257. * Simplification type
  68258. */
  68259. simplificationType: SimplificationType;
  68260. /**
  68261. * Mesh to simplify
  68262. */
  68263. mesh: Mesh;
  68264. /**
  68265. * Callback called on success
  68266. */
  68267. successCallback?: () => void;
  68268. /**
  68269. * Defines if parallel processing can be used
  68270. */
  68271. parallelProcessing: boolean;
  68272. }
  68273. /**
  68274. * Queue used to order the simplification tasks
  68275. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68276. */
  68277. export class SimplificationQueue {
  68278. private _simplificationArray;
  68279. /**
  68280. * Gets a boolean indicating that the process is still running
  68281. */
  68282. running: boolean;
  68283. /**
  68284. * Creates a new queue
  68285. */
  68286. constructor();
  68287. /**
  68288. * Adds a new simplification task
  68289. * @param task defines a task to add
  68290. */
  68291. addTask(task: ISimplificationTask): void;
  68292. /**
  68293. * Execute next task
  68294. */
  68295. executeNext(): void;
  68296. /**
  68297. * Execute a simplification task
  68298. * @param task defines the task to run
  68299. */
  68300. runSimplification(task: ISimplificationTask): void;
  68301. private getSimplifier;
  68302. }
  68303. /**
  68304. * The implemented types of simplification
  68305. * At the moment only Quadratic Error Decimation is implemented
  68306. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68307. */
  68308. export enum SimplificationType {
  68309. /** Quadratic error decimation */
  68310. QUADRATIC = 0
  68311. }
  68312. /**
  68313. * An implementation of the Quadratic Error simplification algorithm.
  68314. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  68315. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  68316. * @author RaananW
  68317. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68318. */
  68319. export class QuadraticErrorSimplification implements ISimplifier {
  68320. private _mesh;
  68321. private triangles;
  68322. private vertices;
  68323. private references;
  68324. private _reconstructedMesh;
  68325. /** Gets or sets the number pf sync interations */
  68326. syncIterations: number;
  68327. /** Gets or sets the aggressiveness of the simplifier */
  68328. aggressiveness: number;
  68329. /** Gets or sets the number of allowed iterations for decimation */
  68330. decimationIterations: number;
  68331. /** Gets or sets the espilon to use for bounding box computation */
  68332. boundingBoxEpsilon: number;
  68333. /**
  68334. * Creates a new QuadraticErrorSimplification
  68335. * @param _mesh defines the target mesh
  68336. */
  68337. constructor(_mesh: Mesh);
  68338. /**
  68339. * Simplification of a given mesh according to the given settings.
  68340. * Since this requires computation, it is assumed that the function runs async.
  68341. * @param settings The settings of the simplification, including quality and distance
  68342. * @param successCallback A callback that will be called after the mesh was simplified.
  68343. */
  68344. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  68345. private runDecimation;
  68346. private initWithMesh;
  68347. private init;
  68348. private reconstructMesh;
  68349. private initDecimatedMesh;
  68350. private isFlipped;
  68351. private updateTriangles;
  68352. private identifyBorder;
  68353. private updateMesh;
  68354. private vertexError;
  68355. private calculateError;
  68356. }
  68357. }
  68358. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  68359. import { Scene } from "babylonjs/scene";
  68360. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  68361. import { ISceneComponent } from "babylonjs/sceneComponent";
  68362. module "babylonjs/scene" {
  68363. interface Scene {
  68364. /** @hidden (Backing field) */
  68365. _simplificationQueue: SimplificationQueue;
  68366. /**
  68367. * Gets or sets the simplification queue attached to the scene
  68368. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68369. */
  68370. simplificationQueue: SimplificationQueue;
  68371. }
  68372. }
  68373. module "babylonjs/Meshes/mesh" {
  68374. interface Mesh {
  68375. /**
  68376. * Simplify the mesh according to the given array of settings.
  68377. * Function will return immediately and will simplify async
  68378. * @param settings a collection of simplification settings
  68379. * @param parallelProcessing should all levels calculate parallel or one after the other
  68380. * @param simplificationType the type of simplification to run
  68381. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  68382. * @returns the current mesh
  68383. */
  68384. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  68385. }
  68386. }
  68387. /**
  68388. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  68389. * created in a scene
  68390. */
  68391. export class SimplicationQueueSceneComponent implements ISceneComponent {
  68392. /**
  68393. * The component name helpfull to identify the component in the list of scene components.
  68394. */
  68395. readonly name: string;
  68396. /**
  68397. * The scene the component belongs to.
  68398. */
  68399. scene: Scene;
  68400. /**
  68401. * Creates a new instance of the component for the given scene
  68402. * @param scene Defines the scene to register the component in
  68403. */
  68404. constructor(scene: Scene);
  68405. /**
  68406. * Registers the component in a given scene
  68407. */
  68408. register(): void;
  68409. /**
  68410. * Rebuilds the elements related to this component in case of
  68411. * context lost for instance.
  68412. */
  68413. rebuild(): void;
  68414. /**
  68415. * Disposes the component and the associated ressources
  68416. */
  68417. dispose(): void;
  68418. private _beforeCameraUpdate;
  68419. }
  68420. }
  68421. declare module "babylonjs/Meshes/Builders/index" {
  68422. export * from "babylonjs/Meshes/Builders/boxBuilder";
  68423. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  68424. export * from "babylonjs/Meshes/Builders/discBuilder";
  68425. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  68426. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  68427. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  68428. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  68429. export * from "babylonjs/Meshes/Builders/torusBuilder";
  68430. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  68431. export * from "babylonjs/Meshes/Builders/linesBuilder";
  68432. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  68433. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  68434. export * from "babylonjs/Meshes/Builders/latheBuilder";
  68435. export * from "babylonjs/Meshes/Builders/planeBuilder";
  68436. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  68437. export * from "babylonjs/Meshes/Builders/groundBuilder";
  68438. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  68439. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  68440. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  68441. export * from "babylonjs/Meshes/Builders/decalBuilder";
  68442. }
  68443. declare module "babylonjs/Meshes/thinInstanceMesh" {
  68444. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  68445. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  68446. import { Matrix } from "babylonjs/Maths/math.vector";
  68447. module "babylonjs/Meshes/mesh" {
  68448. interface Mesh {
  68449. /**
  68450. * Creates a new thin instance
  68451. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  68452. * @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
  68453. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  68454. */
  68455. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  68456. /**
  68457. * Adds the transformation (matrix) of the current mesh as a thin instance
  68458. * @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
  68459. * @returns the thin instance index number
  68460. */
  68461. thinInstanceAddSelf(refresh: boolean): number;
  68462. /**
  68463. * Registers a custom attribute to be used with thin instances
  68464. * @param kind name of the attribute
  68465. * @param stride size in floats of the attribute
  68466. */
  68467. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  68468. /**
  68469. * Sets the matrix of a thin instance
  68470. * @param index index of the thin instance
  68471. * @param matrix matrix to set
  68472. * @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
  68473. */
  68474. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  68475. /**
  68476. * Sets the value of a custom attribute for a thin instance
  68477. * @param kind name of the attribute
  68478. * @param index index of the thin instance
  68479. * @param value value to set
  68480. * @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
  68481. */
  68482. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  68483. /**
  68484. * 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.
  68485. */
  68486. thinInstanceCount: number;
  68487. /**
  68488. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  68489. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  68490. * @param buffer buffer to set
  68491. * @param stride size in floats of each value of the buffer
  68492. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  68493. */
  68494. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  68495. /**
  68496. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  68497. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68498. */
  68499. thinInstanceBufferUpdated(kind: string): void;
  68500. /**
  68501. * Refreshes the bounding info, taking into account all the thin instances defined
  68502. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  68503. */
  68504. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  68505. /** @hidden */
  68506. _thinInstanceInitializeUserStorage(): void;
  68507. /** @hidden */
  68508. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  68509. /** @hidden */
  68510. _userThinInstanceBuffersStorage: {
  68511. data: {
  68512. [key: string]: Float32Array;
  68513. };
  68514. sizes: {
  68515. [key: string]: number;
  68516. };
  68517. vertexBuffers: {
  68518. [key: string]: Nullable<VertexBuffer>;
  68519. };
  68520. strides: {
  68521. [key: string]: number;
  68522. };
  68523. };
  68524. }
  68525. }
  68526. }
  68527. declare module "babylonjs/Meshes/index" {
  68528. export * from "babylonjs/Meshes/abstractMesh";
  68529. export * from "babylonjs/Meshes/buffer";
  68530. export * from "babylonjs/Meshes/Compression/index";
  68531. export * from "babylonjs/Meshes/csg";
  68532. export * from "babylonjs/Meshes/geometry";
  68533. export * from "babylonjs/Meshes/groundMesh";
  68534. export * from "babylonjs/Meshes/trailMesh";
  68535. export * from "babylonjs/Meshes/instancedMesh";
  68536. export * from "babylonjs/Meshes/linesMesh";
  68537. export * from "babylonjs/Meshes/mesh";
  68538. export * from "babylonjs/Meshes/mesh.vertexData";
  68539. export * from "babylonjs/Meshes/meshBuilder";
  68540. export * from "babylonjs/Meshes/meshSimplification";
  68541. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  68542. export * from "babylonjs/Meshes/polygonMesh";
  68543. export * from "babylonjs/Meshes/subMesh";
  68544. export * from "babylonjs/Meshes/meshLODLevel";
  68545. export * from "babylonjs/Meshes/transformNode";
  68546. export * from "babylonjs/Meshes/Builders/index";
  68547. export * from "babylonjs/Meshes/dataBuffer";
  68548. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  68549. import "babylonjs/Meshes/thinInstanceMesh";
  68550. export * from "babylonjs/Meshes/thinInstanceMesh";
  68551. }
  68552. declare module "babylonjs/Morph/index" {
  68553. export * from "babylonjs/Morph/morphTarget";
  68554. export * from "babylonjs/Morph/morphTargetManager";
  68555. }
  68556. declare module "babylonjs/Navigation/INavigationEngine" {
  68557. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68558. import { Vector3 } from "babylonjs/Maths/math";
  68559. import { Mesh } from "babylonjs/Meshes/mesh";
  68560. import { Scene } from "babylonjs/scene";
  68561. /**
  68562. * Navigation plugin interface to add navigation constrained by a navigation mesh
  68563. */
  68564. export interface INavigationEnginePlugin {
  68565. /**
  68566. * plugin name
  68567. */
  68568. name: string;
  68569. /**
  68570. * Creates a navigation mesh
  68571. * @param meshes array of all the geometry used to compute the navigatio mesh
  68572. * @param parameters bunch of parameters used to filter geometry
  68573. */
  68574. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68575. /**
  68576. * Create a navigation mesh debug mesh
  68577. * @param scene is where the mesh will be added
  68578. * @returns debug display mesh
  68579. */
  68580. createDebugNavMesh(scene: Scene): Mesh;
  68581. /**
  68582. * Get a navigation mesh constrained position, closest to the parameter position
  68583. * @param position world position
  68584. * @returns the closest point to position constrained by the navigation mesh
  68585. */
  68586. getClosestPoint(position: Vector3): Vector3;
  68587. /**
  68588. * Get a navigation mesh constrained position, closest to the parameter position
  68589. * @param position world position
  68590. * @param result output the closest point to position constrained by the navigation mesh
  68591. */
  68592. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68593. /**
  68594. * Get a navigation mesh constrained position, within a particular radius
  68595. * @param position world position
  68596. * @param maxRadius the maximum distance to the constrained world position
  68597. * @returns the closest point to position constrained by the navigation mesh
  68598. */
  68599. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68600. /**
  68601. * Get a navigation mesh constrained position, within a particular radius
  68602. * @param position world position
  68603. * @param maxRadius the maximum distance to the constrained world position
  68604. * @param result output the closest point to position constrained by the navigation mesh
  68605. */
  68606. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68607. /**
  68608. * Compute the final position from a segment made of destination-position
  68609. * @param position world position
  68610. * @param destination world position
  68611. * @returns the resulting point along the navmesh
  68612. */
  68613. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68614. /**
  68615. * Compute the final position from a segment made of destination-position
  68616. * @param position world position
  68617. * @param destination world position
  68618. * @param result output the resulting point along the navmesh
  68619. */
  68620. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68621. /**
  68622. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68623. * @param start world position
  68624. * @param end world position
  68625. * @returns array containing world position composing the path
  68626. */
  68627. computePath(start: Vector3, end: Vector3): Vector3[];
  68628. /**
  68629. * If this plugin is supported
  68630. * @returns true if plugin is supported
  68631. */
  68632. isSupported(): boolean;
  68633. /**
  68634. * Create a new Crowd so you can add agents
  68635. * @param maxAgents the maximum agent count in the crowd
  68636. * @param maxAgentRadius the maximum radius an agent can have
  68637. * @param scene to attach the crowd to
  68638. * @returns the crowd you can add agents to
  68639. */
  68640. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68641. /**
  68642. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68643. * The queries will try to find a solution within those bounds
  68644. * default is (1,1,1)
  68645. * @param extent x,y,z value that define the extent around the queries point of reference
  68646. */
  68647. setDefaultQueryExtent(extent: Vector3): void;
  68648. /**
  68649. * Get the Bounding box extent specified by setDefaultQueryExtent
  68650. * @returns the box extent values
  68651. */
  68652. getDefaultQueryExtent(): Vector3;
  68653. /**
  68654. * build the navmesh from a previously saved state using getNavmeshData
  68655. * @param data the Uint8Array returned by getNavmeshData
  68656. */
  68657. buildFromNavmeshData(data: Uint8Array): void;
  68658. /**
  68659. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68660. * @returns data the Uint8Array that can be saved and reused
  68661. */
  68662. getNavmeshData(): Uint8Array;
  68663. /**
  68664. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68665. * @param result output the box extent values
  68666. */
  68667. getDefaultQueryExtentToRef(result: Vector3): void;
  68668. /**
  68669. * Release all resources
  68670. */
  68671. dispose(): void;
  68672. }
  68673. /**
  68674. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  68675. */
  68676. export interface ICrowd {
  68677. /**
  68678. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68679. * You can attach anything to that node. The node position is updated in the scene update tick.
  68680. * @param pos world position that will be constrained by the navigation mesh
  68681. * @param parameters agent parameters
  68682. * @param transform hooked to the agent that will be update by the scene
  68683. * @returns agent index
  68684. */
  68685. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68686. /**
  68687. * Returns the agent position in world space
  68688. * @param index agent index returned by addAgent
  68689. * @returns world space position
  68690. */
  68691. getAgentPosition(index: number): Vector3;
  68692. /**
  68693. * Gets the agent position result in world space
  68694. * @param index agent index returned by addAgent
  68695. * @param result output world space position
  68696. */
  68697. getAgentPositionToRef(index: number, result: Vector3): void;
  68698. /**
  68699. * Gets the agent velocity in world space
  68700. * @param index agent index returned by addAgent
  68701. * @returns world space velocity
  68702. */
  68703. getAgentVelocity(index: number): Vector3;
  68704. /**
  68705. * Gets the agent velocity result in world space
  68706. * @param index agent index returned by addAgent
  68707. * @param result output world space velocity
  68708. */
  68709. getAgentVelocityToRef(index: number, result: Vector3): void;
  68710. /**
  68711. * remove a particular agent previously created
  68712. * @param index agent index returned by addAgent
  68713. */
  68714. removeAgent(index: number): void;
  68715. /**
  68716. * get the list of all agents attached to this crowd
  68717. * @returns list of agent indices
  68718. */
  68719. getAgents(): number[];
  68720. /**
  68721. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68722. * @param deltaTime in seconds
  68723. */
  68724. update(deltaTime: number): void;
  68725. /**
  68726. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68727. * @param index agent index returned by addAgent
  68728. * @param destination targeted world position
  68729. */
  68730. agentGoto(index: number, destination: Vector3): void;
  68731. /**
  68732. * Teleport the agent to a new position
  68733. * @param index agent index returned by addAgent
  68734. * @param destination targeted world position
  68735. */
  68736. agentTeleport(index: number, destination: Vector3): void;
  68737. /**
  68738. * Update agent parameters
  68739. * @param index agent index returned by addAgent
  68740. * @param parameters agent parameters
  68741. */
  68742. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68743. /**
  68744. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68745. * The queries will try to find a solution within those bounds
  68746. * default is (1,1,1)
  68747. * @param extent x,y,z value that define the extent around the queries point of reference
  68748. */
  68749. setDefaultQueryExtent(extent: Vector3): void;
  68750. /**
  68751. * Get the Bounding box extent specified by setDefaultQueryExtent
  68752. * @returns the box extent values
  68753. */
  68754. getDefaultQueryExtent(): Vector3;
  68755. /**
  68756. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68757. * @param result output the box extent values
  68758. */
  68759. getDefaultQueryExtentToRef(result: Vector3): void;
  68760. /**
  68761. * Release all resources
  68762. */
  68763. dispose(): void;
  68764. }
  68765. /**
  68766. * Configures an agent
  68767. */
  68768. export interface IAgentParameters {
  68769. /**
  68770. * Agent radius. [Limit: >= 0]
  68771. */
  68772. radius: number;
  68773. /**
  68774. * Agent height. [Limit: > 0]
  68775. */
  68776. height: number;
  68777. /**
  68778. * Maximum allowed acceleration. [Limit: >= 0]
  68779. */
  68780. maxAcceleration: number;
  68781. /**
  68782. * Maximum allowed speed. [Limit: >= 0]
  68783. */
  68784. maxSpeed: number;
  68785. /**
  68786. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  68787. */
  68788. collisionQueryRange: number;
  68789. /**
  68790. * The path visibility optimization range. [Limit: > 0]
  68791. */
  68792. pathOptimizationRange: number;
  68793. /**
  68794. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  68795. */
  68796. separationWeight: number;
  68797. }
  68798. /**
  68799. * Configures the navigation mesh creation
  68800. */
  68801. export interface INavMeshParameters {
  68802. /**
  68803. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  68804. */
  68805. cs: number;
  68806. /**
  68807. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  68808. */
  68809. ch: number;
  68810. /**
  68811. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  68812. */
  68813. walkableSlopeAngle: number;
  68814. /**
  68815. * Minimum floor to 'ceiling' height that will still allow the floor area to
  68816. * be considered walkable. [Limit: >= 3] [Units: vx]
  68817. */
  68818. walkableHeight: number;
  68819. /**
  68820. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  68821. */
  68822. walkableClimb: number;
  68823. /**
  68824. * The distance to erode/shrink the walkable area of the heightfield away from
  68825. * obstructions. [Limit: >=0] [Units: vx]
  68826. */
  68827. walkableRadius: number;
  68828. /**
  68829. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  68830. */
  68831. maxEdgeLen: number;
  68832. /**
  68833. * The maximum distance a simplfied contour's border edges should deviate
  68834. * the original raw contour. [Limit: >=0] [Units: vx]
  68835. */
  68836. maxSimplificationError: number;
  68837. /**
  68838. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  68839. */
  68840. minRegionArea: number;
  68841. /**
  68842. * Any regions with a span count smaller than this value will, if possible,
  68843. * be merged with larger regions. [Limit: >=0] [Units: vx]
  68844. */
  68845. mergeRegionArea: number;
  68846. /**
  68847. * The maximum number of vertices allowed for polygons generated during the
  68848. * contour to polygon conversion process. [Limit: >= 3]
  68849. */
  68850. maxVertsPerPoly: number;
  68851. /**
  68852. * Sets the sampling distance to use when generating the detail mesh.
  68853. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  68854. */
  68855. detailSampleDist: number;
  68856. /**
  68857. * The maximum distance the detail mesh surface should deviate from heightfield
  68858. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  68859. */
  68860. detailSampleMaxError: number;
  68861. }
  68862. }
  68863. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  68864. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  68865. import { Mesh } from "babylonjs/Meshes/mesh";
  68866. import { Scene } from "babylonjs/scene";
  68867. import { Vector3 } from "babylonjs/Maths/math";
  68868. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68869. /**
  68870. * RecastJS navigation plugin
  68871. */
  68872. export class RecastJSPlugin implements INavigationEnginePlugin {
  68873. /**
  68874. * Reference to the Recast library
  68875. */
  68876. bjsRECAST: any;
  68877. /**
  68878. * plugin name
  68879. */
  68880. name: string;
  68881. /**
  68882. * the first navmesh created. We might extend this to support multiple navmeshes
  68883. */
  68884. navMesh: any;
  68885. /**
  68886. * Initializes the recastJS plugin
  68887. * @param recastInjection can be used to inject your own recast reference
  68888. */
  68889. constructor(recastInjection?: any);
  68890. /**
  68891. * Creates a navigation mesh
  68892. * @param meshes array of all the geometry used to compute the navigatio mesh
  68893. * @param parameters bunch of parameters used to filter geometry
  68894. */
  68895. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68896. /**
  68897. * Create a navigation mesh debug mesh
  68898. * @param scene is where the mesh will be added
  68899. * @returns debug display mesh
  68900. */
  68901. createDebugNavMesh(scene: Scene): Mesh;
  68902. /**
  68903. * Get a navigation mesh constrained position, closest to the parameter position
  68904. * @param position world position
  68905. * @returns the closest point to position constrained by the navigation mesh
  68906. */
  68907. getClosestPoint(position: Vector3): Vector3;
  68908. /**
  68909. * Get a navigation mesh constrained position, closest to the parameter position
  68910. * @param position world position
  68911. * @param result output the closest point to position constrained by the navigation mesh
  68912. */
  68913. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68914. /**
  68915. * Get a navigation mesh constrained position, within a particular radius
  68916. * @param position world position
  68917. * @param maxRadius the maximum distance to the constrained world position
  68918. * @returns the closest point to position constrained by the navigation mesh
  68919. */
  68920. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68921. /**
  68922. * Get a navigation mesh constrained position, within a particular radius
  68923. * @param position world position
  68924. * @param maxRadius the maximum distance to the constrained world position
  68925. * @param result output the closest point to position constrained by the navigation mesh
  68926. */
  68927. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68928. /**
  68929. * Compute the final position from a segment made of destination-position
  68930. * @param position world position
  68931. * @param destination world position
  68932. * @returns the resulting point along the navmesh
  68933. */
  68934. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68935. /**
  68936. * Compute the final position from a segment made of destination-position
  68937. * @param position world position
  68938. * @param destination world position
  68939. * @param result output the resulting point along the navmesh
  68940. */
  68941. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68942. /**
  68943. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68944. * @param start world position
  68945. * @param end world position
  68946. * @returns array containing world position composing the path
  68947. */
  68948. computePath(start: Vector3, end: Vector3): Vector3[];
  68949. /**
  68950. * Create a new Crowd so you can add agents
  68951. * @param maxAgents the maximum agent count in the crowd
  68952. * @param maxAgentRadius the maximum radius an agent can have
  68953. * @param scene to attach the crowd to
  68954. * @returns the crowd you can add agents to
  68955. */
  68956. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68957. /**
  68958. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68959. * The queries will try to find a solution within those bounds
  68960. * default is (1,1,1)
  68961. * @param extent x,y,z value that define the extent around the queries point of reference
  68962. */
  68963. setDefaultQueryExtent(extent: Vector3): void;
  68964. /**
  68965. * Get the Bounding box extent specified by setDefaultQueryExtent
  68966. * @returns the box extent values
  68967. */
  68968. getDefaultQueryExtent(): Vector3;
  68969. /**
  68970. * build the navmesh from a previously saved state using getNavmeshData
  68971. * @param data the Uint8Array returned by getNavmeshData
  68972. */
  68973. buildFromNavmeshData(data: Uint8Array): void;
  68974. /**
  68975. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68976. * @returns data the Uint8Array that can be saved and reused
  68977. */
  68978. getNavmeshData(): Uint8Array;
  68979. /**
  68980. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68981. * @param result output the box extent values
  68982. */
  68983. getDefaultQueryExtentToRef(result: Vector3): void;
  68984. /**
  68985. * Disposes
  68986. */
  68987. dispose(): void;
  68988. /**
  68989. * If this plugin is supported
  68990. * @returns true if plugin is supported
  68991. */
  68992. isSupported(): boolean;
  68993. }
  68994. /**
  68995. * Recast detour crowd implementation
  68996. */
  68997. export class RecastJSCrowd implements ICrowd {
  68998. /**
  68999. * Recast/detour plugin
  69000. */
  69001. bjsRECASTPlugin: RecastJSPlugin;
  69002. /**
  69003. * Link to the detour crowd
  69004. */
  69005. recastCrowd: any;
  69006. /**
  69007. * One transform per agent
  69008. */
  69009. transforms: TransformNode[];
  69010. /**
  69011. * All agents created
  69012. */
  69013. agents: number[];
  69014. /**
  69015. * Link to the scene is kept to unregister the crowd from the scene
  69016. */
  69017. private _scene;
  69018. /**
  69019. * Observer for crowd updates
  69020. */
  69021. private _onBeforeAnimationsObserver;
  69022. /**
  69023. * Constructor
  69024. * @param plugin recastJS plugin
  69025. * @param maxAgents the maximum agent count in the crowd
  69026. * @param maxAgentRadius the maximum radius an agent can have
  69027. * @param scene to attach the crowd to
  69028. * @returns the crowd you can add agents to
  69029. */
  69030. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  69031. /**
  69032. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69033. * You can attach anything to that node. The node position is updated in the scene update tick.
  69034. * @param pos world position that will be constrained by the navigation mesh
  69035. * @param parameters agent parameters
  69036. * @param transform hooked to the agent that will be update by the scene
  69037. * @returns agent index
  69038. */
  69039. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69040. /**
  69041. * Returns the agent position in world space
  69042. * @param index agent index returned by addAgent
  69043. * @returns world space position
  69044. */
  69045. getAgentPosition(index: number): Vector3;
  69046. /**
  69047. * Returns the agent position result in world space
  69048. * @param index agent index returned by addAgent
  69049. * @param result output world space position
  69050. */
  69051. getAgentPositionToRef(index: number, result: Vector3): void;
  69052. /**
  69053. * Returns the agent velocity in world space
  69054. * @param index agent index returned by addAgent
  69055. * @returns world space velocity
  69056. */
  69057. getAgentVelocity(index: number): Vector3;
  69058. /**
  69059. * Returns the agent velocity result in world space
  69060. * @param index agent index returned by addAgent
  69061. * @param result output world space velocity
  69062. */
  69063. getAgentVelocityToRef(index: number, result: Vector3): void;
  69064. /**
  69065. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69066. * @param index agent index returned by addAgent
  69067. * @param destination targeted world position
  69068. */
  69069. agentGoto(index: number, destination: Vector3): void;
  69070. /**
  69071. * Teleport the agent to a new position
  69072. * @param index agent index returned by addAgent
  69073. * @param destination targeted world position
  69074. */
  69075. agentTeleport(index: number, destination: Vector3): void;
  69076. /**
  69077. * Update agent parameters
  69078. * @param index agent index returned by addAgent
  69079. * @param parameters agent parameters
  69080. */
  69081. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69082. /**
  69083. * remove a particular agent previously created
  69084. * @param index agent index returned by addAgent
  69085. */
  69086. removeAgent(index: number): void;
  69087. /**
  69088. * get the list of all agents attached to this crowd
  69089. * @returns list of agent indices
  69090. */
  69091. getAgents(): number[];
  69092. /**
  69093. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69094. * @param deltaTime in seconds
  69095. */
  69096. update(deltaTime: number): void;
  69097. /**
  69098. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69099. * The queries will try to find a solution within those bounds
  69100. * default is (1,1,1)
  69101. * @param extent x,y,z value that define the extent around the queries point of reference
  69102. */
  69103. setDefaultQueryExtent(extent: Vector3): void;
  69104. /**
  69105. * Get the Bounding box extent specified by setDefaultQueryExtent
  69106. * @returns the box extent values
  69107. */
  69108. getDefaultQueryExtent(): Vector3;
  69109. /**
  69110. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69111. * @param result output the box extent values
  69112. */
  69113. getDefaultQueryExtentToRef(result: Vector3): void;
  69114. /**
  69115. * Release all resources
  69116. */
  69117. dispose(): void;
  69118. }
  69119. }
  69120. declare module "babylonjs/Navigation/Plugins/index" {
  69121. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  69122. }
  69123. declare module "babylonjs/Navigation/index" {
  69124. export * from "babylonjs/Navigation/INavigationEngine";
  69125. export * from "babylonjs/Navigation/Plugins/index";
  69126. }
  69127. declare module "babylonjs/Offline/database" {
  69128. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  69129. /**
  69130. * Class used to enable access to IndexedDB
  69131. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69132. */
  69133. export class Database implements IOfflineProvider {
  69134. private _callbackManifestChecked;
  69135. private _currentSceneUrl;
  69136. private _db;
  69137. private _enableSceneOffline;
  69138. private _enableTexturesOffline;
  69139. private _manifestVersionFound;
  69140. private _mustUpdateRessources;
  69141. private _hasReachedQuota;
  69142. private _isSupported;
  69143. private _idbFactory;
  69144. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  69145. private static IsUASupportingBlobStorage;
  69146. /**
  69147. * Gets a boolean indicating if Database storate is enabled (off by default)
  69148. */
  69149. static IDBStorageEnabled: boolean;
  69150. /**
  69151. * Gets a boolean indicating if scene must be saved in the database
  69152. */
  69153. get enableSceneOffline(): boolean;
  69154. /**
  69155. * Gets a boolean indicating if textures must be saved in the database
  69156. */
  69157. get enableTexturesOffline(): boolean;
  69158. /**
  69159. * Creates a new Database
  69160. * @param urlToScene defines the url to load the scene
  69161. * @param callbackManifestChecked defines the callback to use when manifest is checked
  69162. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  69163. */
  69164. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  69165. private static _ParseURL;
  69166. private static _ReturnFullUrlLocation;
  69167. private _checkManifestFile;
  69168. /**
  69169. * Open the database and make it available
  69170. * @param successCallback defines the callback to call on success
  69171. * @param errorCallback defines the callback to call on error
  69172. */
  69173. open(successCallback: () => void, errorCallback: () => void): void;
  69174. /**
  69175. * Loads an image from the database
  69176. * @param url defines the url to load from
  69177. * @param image defines the target DOM image
  69178. */
  69179. loadImage(url: string, image: HTMLImageElement): void;
  69180. private _loadImageFromDBAsync;
  69181. private _saveImageIntoDBAsync;
  69182. private _checkVersionFromDB;
  69183. private _loadVersionFromDBAsync;
  69184. private _saveVersionIntoDBAsync;
  69185. /**
  69186. * Loads a file from database
  69187. * @param url defines the URL to load from
  69188. * @param sceneLoaded defines a callback to call on success
  69189. * @param progressCallBack defines a callback to call when progress changed
  69190. * @param errorCallback defines a callback to call on error
  69191. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69192. */
  69193. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69194. private _loadFileAsync;
  69195. private _saveFileAsync;
  69196. /**
  69197. * Validates if xhr data is correct
  69198. * @param xhr defines the request to validate
  69199. * @param dataType defines the expected data type
  69200. * @returns true if data is correct
  69201. */
  69202. private static _ValidateXHRData;
  69203. }
  69204. }
  69205. declare module "babylonjs/Offline/index" {
  69206. export * from "babylonjs/Offline/database";
  69207. export * from "babylonjs/Offline/IOfflineProvider";
  69208. }
  69209. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  69210. /** @hidden */
  69211. export var gpuUpdateParticlesPixelShader: {
  69212. name: string;
  69213. shader: string;
  69214. };
  69215. }
  69216. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  69217. /** @hidden */
  69218. export var gpuUpdateParticlesVertexShader: {
  69219. name: string;
  69220. shader: string;
  69221. };
  69222. }
  69223. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  69224. /** @hidden */
  69225. export var clipPlaneFragmentDeclaration2: {
  69226. name: string;
  69227. shader: string;
  69228. };
  69229. }
  69230. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  69231. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  69232. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  69233. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69234. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  69235. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  69236. /** @hidden */
  69237. export var gpuRenderParticlesPixelShader: {
  69238. name: string;
  69239. shader: string;
  69240. };
  69241. }
  69242. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  69243. /** @hidden */
  69244. export var clipPlaneVertexDeclaration2: {
  69245. name: string;
  69246. shader: string;
  69247. };
  69248. }
  69249. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  69250. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  69251. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  69252. /** @hidden */
  69253. export var gpuRenderParticlesVertexShader: {
  69254. name: string;
  69255. shader: string;
  69256. };
  69257. }
  69258. declare module "babylonjs/Particles/gpuParticleSystem" {
  69259. import { Nullable } from "babylonjs/types";
  69260. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  69261. import { Observable } from "babylonjs/Misc/observable";
  69262. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69263. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69264. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  69265. import { Scene, IDisposable } from "babylonjs/scene";
  69266. import { Effect } from "babylonjs/Materials/effect";
  69267. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  69268. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69269. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  69270. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  69271. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  69272. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  69273. /**
  69274. * This represents a GPU particle system in Babylon
  69275. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  69276. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  69277. */
  69278. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  69279. /**
  69280. * The layer mask we are rendering the particles through.
  69281. */
  69282. layerMask: number;
  69283. private _capacity;
  69284. private _activeCount;
  69285. private _currentActiveCount;
  69286. private _accumulatedCount;
  69287. private _renderEffect;
  69288. private _updateEffect;
  69289. private _buffer0;
  69290. private _buffer1;
  69291. private _spriteBuffer;
  69292. private _updateVAO;
  69293. private _renderVAO;
  69294. private _targetIndex;
  69295. private _sourceBuffer;
  69296. private _targetBuffer;
  69297. private _engine;
  69298. private _currentRenderId;
  69299. private _started;
  69300. private _stopped;
  69301. private _timeDelta;
  69302. private _randomTexture;
  69303. private _randomTexture2;
  69304. private _attributesStrideSize;
  69305. private _updateEffectOptions;
  69306. private _randomTextureSize;
  69307. private _actualFrame;
  69308. private _customEffect;
  69309. private readonly _rawTextureWidth;
  69310. /**
  69311. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  69312. */
  69313. static get IsSupported(): boolean;
  69314. /**
  69315. * An event triggered when the system is disposed.
  69316. */
  69317. onDisposeObservable: Observable<IParticleSystem>;
  69318. /**
  69319. * Gets the maximum number of particles active at the same time.
  69320. * @returns The max number of active particles.
  69321. */
  69322. getCapacity(): number;
  69323. /**
  69324. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  69325. * to override the particles.
  69326. */
  69327. forceDepthWrite: boolean;
  69328. /**
  69329. * Gets or set the number of active particles
  69330. */
  69331. get activeParticleCount(): number;
  69332. set activeParticleCount(value: number);
  69333. private _preWarmDone;
  69334. /**
  69335. * Specifies if the particles are updated in emitter local space or world space.
  69336. */
  69337. isLocal: boolean;
  69338. /**
  69339. * Is this system ready to be used/rendered
  69340. * @return true if the system is ready
  69341. */
  69342. isReady(): boolean;
  69343. /**
  69344. * Gets if the system has been started. (Note: this will still be true after stop is called)
  69345. * @returns True if it has been started, otherwise false.
  69346. */
  69347. isStarted(): boolean;
  69348. /**
  69349. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  69350. * @returns True if it has been stopped, otherwise false.
  69351. */
  69352. isStopped(): boolean;
  69353. /**
  69354. * Gets a boolean indicating that the system is stopping
  69355. * @returns true if the system is currently stopping
  69356. */
  69357. isStopping(): boolean;
  69358. /**
  69359. * Gets the number of particles active at the same time.
  69360. * @returns The number of active particles.
  69361. */
  69362. getActiveCount(): number;
  69363. /**
  69364. * Starts the particle system and begins to emit
  69365. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  69366. */
  69367. start(delay?: number): void;
  69368. /**
  69369. * Stops the particle system.
  69370. */
  69371. stop(): void;
  69372. /**
  69373. * Remove all active particles
  69374. */
  69375. reset(): void;
  69376. /**
  69377. * Returns the string "GPUParticleSystem"
  69378. * @returns a string containing the class name
  69379. */
  69380. getClassName(): string;
  69381. /**
  69382. * Gets the custom effect used to render the particles
  69383. * @param blendMode Blend mode for which the effect should be retrieved
  69384. * @returns The effect
  69385. */
  69386. getCustomEffect(blendMode?: number): Nullable<Effect>;
  69387. /**
  69388. * Sets the custom effect used to render the particles
  69389. * @param effect The effect to set
  69390. * @param blendMode Blend mode for which the effect should be set
  69391. */
  69392. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  69393. /** @hidden */
  69394. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  69395. /**
  69396. * Observable that will be called just before the particles are drawn
  69397. */
  69398. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  69399. /**
  69400. * Gets the name of the particle vertex shader
  69401. */
  69402. get vertexShaderName(): string;
  69403. private _colorGradientsTexture;
  69404. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  69405. /**
  69406. * Adds a new color gradient
  69407. * @param gradient defines the gradient to use (between 0 and 1)
  69408. * @param color1 defines the color to affect to the specified gradient
  69409. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  69410. * @returns the current particle system
  69411. */
  69412. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  69413. private _refreshColorGradient;
  69414. /** Force the system to rebuild all gradients that need to be resync */
  69415. forceRefreshGradients(): void;
  69416. /**
  69417. * Remove a specific color gradient
  69418. * @param gradient defines the gradient to remove
  69419. * @returns the current particle system
  69420. */
  69421. removeColorGradient(gradient: number): GPUParticleSystem;
  69422. private _angularSpeedGradientsTexture;
  69423. private _sizeGradientsTexture;
  69424. private _velocityGradientsTexture;
  69425. private _limitVelocityGradientsTexture;
  69426. private _dragGradientsTexture;
  69427. private _addFactorGradient;
  69428. /**
  69429. * Adds a new size gradient
  69430. * @param gradient defines the gradient to use (between 0 and 1)
  69431. * @param factor defines the size factor to affect to the specified gradient
  69432. * @returns the current particle system
  69433. */
  69434. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  69435. /**
  69436. * Remove a specific size gradient
  69437. * @param gradient defines the gradient to remove
  69438. * @returns the current particle system
  69439. */
  69440. removeSizeGradient(gradient: number): GPUParticleSystem;
  69441. private _refreshFactorGradient;
  69442. /**
  69443. * Adds a new angular speed gradient
  69444. * @param gradient defines the gradient to use (between 0 and 1)
  69445. * @param factor defines the angular speed to affect to the specified gradient
  69446. * @returns the current particle system
  69447. */
  69448. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  69449. /**
  69450. * Remove a specific angular speed gradient
  69451. * @param gradient defines the gradient to remove
  69452. * @returns the current particle system
  69453. */
  69454. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  69455. /**
  69456. * Adds a new velocity gradient
  69457. * @param gradient defines the gradient to use (between 0 and 1)
  69458. * @param factor defines the velocity to affect to the specified gradient
  69459. * @returns the current particle system
  69460. */
  69461. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69462. /**
  69463. * Remove a specific velocity gradient
  69464. * @param gradient defines the gradient to remove
  69465. * @returns the current particle system
  69466. */
  69467. removeVelocityGradient(gradient: number): GPUParticleSystem;
  69468. /**
  69469. * Adds a new limit velocity gradient
  69470. * @param gradient defines the gradient to use (between 0 and 1)
  69471. * @param factor defines the limit velocity value to affect to the specified gradient
  69472. * @returns the current particle system
  69473. */
  69474. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69475. /**
  69476. * Remove a specific limit velocity gradient
  69477. * @param gradient defines the gradient to remove
  69478. * @returns the current particle system
  69479. */
  69480. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  69481. /**
  69482. * Adds a new drag gradient
  69483. * @param gradient defines the gradient to use (between 0 and 1)
  69484. * @param factor defines the drag value to affect to the specified gradient
  69485. * @returns the current particle system
  69486. */
  69487. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  69488. /**
  69489. * Remove a specific drag gradient
  69490. * @param gradient defines the gradient to remove
  69491. * @returns the current particle system
  69492. */
  69493. removeDragGradient(gradient: number): GPUParticleSystem;
  69494. /**
  69495. * Not supported by GPUParticleSystem
  69496. * @param gradient defines the gradient to use (between 0 and 1)
  69497. * @param factor defines the emit rate value to affect to the specified gradient
  69498. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69499. * @returns the current particle system
  69500. */
  69501. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69502. /**
  69503. * Not supported by GPUParticleSystem
  69504. * @param gradient defines the gradient to remove
  69505. * @returns the current particle system
  69506. */
  69507. removeEmitRateGradient(gradient: number): IParticleSystem;
  69508. /**
  69509. * Not supported by GPUParticleSystem
  69510. * @param gradient defines the gradient to use (between 0 and 1)
  69511. * @param factor defines the start size value to affect to the specified gradient
  69512. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69513. * @returns the current particle system
  69514. */
  69515. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69516. /**
  69517. * Not supported by GPUParticleSystem
  69518. * @param gradient defines the gradient to remove
  69519. * @returns the current particle system
  69520. */
  69521. removeStartSizeGradient(gradient: number): IParticleSystem;
  69522. /**
  69523. * Not supported by GPUParticleSystem
  69524. * @param gradient defines the gradient to use (between 0 and 1)
  69525. * @param min defines the color remap minimal range
  69526. * @param max defines the color remap maximal range
  69527. * @returns the current particle system
  69528. */
  69529. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69530. /**
  69531. * Not supported by GPUParticleSystem
  69532. * @param gradient defines the gradient to remove
  69533. * @returns the current particle system
  69534. */
  69535. removeColorRemapGradient(): IParticleSystem;
  69536. /**
  69537. * Not supported by GPUParticleSystem
  69538. * @param gradient defines the gradient to use (between 0 and 1)
  69539. * @param min defines the alpha remap minimal range
  69540. * @param max defines the alpha remap maximal range
  69541. * @returns the current particle system
  69542. */
  69543. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69544. /**
  69545. * Not supported by GPUParticleSystem
  69546. * @param gradient defines the gradient to remove
  69547. * @returns the current particle system
  69548. */
  69549. removeAlphaRemapGradient(): IParticleSystem;
  69550. /**
  69551. * Not supported by GPUParticleSystem
  69552. * @param gradient defines the gradient to use (between 0 and 1)
  69553. * @param color defines the color to affect to the specified gradient
  69554. * @returns the current particle system
  69555. */
  69556. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  69557. /**
  69558. * Not supported by GPUParticleSystem
  69559. * @param gradient defines the gradient to remove
  69560. * @returns the current particle system
  69561. */
  69562. removeRampGradient(): IParticleSystem;
  69563. /**
  69564. * Not supported by GPUParticleSystem
  69565. * @returns the list of ramp gradients
  69566. */
  69567. getRampGradients(): Nullable<Array<Color3Gradient>>;
  69568. /**
  69569. * Not supported by GPUParticleSystem
  69570. * Gets or sets a boolean indicating that ramp gradients must be used
  69571. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  69572. */
  69573. get useRampGradients(): boolean;
  69574. set useRampGradients(value: boolean);
  69575. /**
  69576. * Not supported by GPUParticleSystem
  69577. * @param gradient defines the gradient to use (between 0 and 1)
  69578. * @param factor defines the life time factor to affect to the specified gradient
  69579. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69580. * @returns the current particle system
  69581. */
  69582. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69583. /**
  69584. * Not supported by GPUParticleSystem
  69585. * @param gradient defines the gradient to remove
  69586. * @returns the current particle system
  69587. */
  69588. removeLifeTimeGradient(gradient: number): IParticleSystem;
  69589. /**
  69590. * Instantiates a GPU particle system.
  69591. * 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.
  69592. * @param name The name of the particle system
  69593. * @param options The options used to create the system
  69594. * @param scene The scene the particle system belongs to
  69595. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  69596. * @param customEffect a custom effect used to change the way particles are rendered by default
  69597. */
  69598. constructor(name: string, options: Partial<{
  69599. capacity: number;
  69600. randomTextureSize: number;
  69601. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  69602. protected _reset(): void;
  69603. private _createUpdateVAO;
  69604. private _createRenderVAO;
  69605. private _initialize;
  69606. /** @hidden */
  69607. _recreateUpdateEffect(): void;
  69608. private _getEffect;
  69609. /**
  69610. * Fill the defines array according to the current settings of the particle system
  69611. * @param defines Array to be updated
  69612. * @param blendMode blend mode to take into account when updating the array
  69613. */
  69614. fillDefines(defines: Array<string>, blendMode?: number): void;
  69615. /**
  69616. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  69617. * @param uniforms Uniforms array to fill
  69618. * @param attributes Attributes array to fill
  69619. * @param samplers Samplers array to fill
  69620. */
  69621. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  69622. /** @hidden */
  69623. _recreateRenderEffect(): Effect;
  69624. /**
  69625. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  69626. * @param preWarm defines if we are in the pre-warmimg phase
  69627. */
  69628. animate(preWarm?: boolean): void;
  69629. private _createFactorGradientTexture;
  69630. private _createSizeGradientTexture;
  69631. private _createAngularSpeedGradientTexture;
  69632. private _createVelocityGradientTexture;
  69633. private _createLimitVelocityGradientTexture;
  69634. private _createDragGradientTexture;
  69635. private _createColorGradientTexture;
  69636. /**
  69637. * Renders the particle system in its current state
  69638. * @param preWarm defines if the system should only update the particles but not render them
  69639. * @returns the current number of particles
  69640. */
  69641. render(preWarm?: boolean): number;
  69642. /**
  69643. * Rebuilds the particle system
  69644. */
  69645. rebuild(): void;
  69646. private _releaseBuffers;
  69647. private _releaseVAOs;
  69648. /**
  69649. * Disposes the particle system and free the associated resources
  69650. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  69651. */
  69652. dispose(disposeTexture?: boolean): void;
  69653. /**
  69654. * Clones the particle system.
  69655. * @param name The name of the cloned object
  69656. * @param newEmitter The new emitter to use
  69657. * @returns the cloned particle system
  69658. */
  69659. clone(name: string, newEmitter: any): GPUParticleSystem;
  69660. /**
  69661. * Serializes the particle system to a JSON object
  69662. * @param serializeTexture defines if the texture must be serialized as well
  69663. * @returns the JSON object
  69664. */
  69665. serialize(serializeTexture?: boolean): any;
  69666. /**
  69667. * Parses a JSON object to create a GPU particle system.
  69668. * @param parsedParticleSystem The JSON object to parse
  69669. * @param scene The scene to create the particle system in
  69670. * @param rootUrl The root url to use to load external dependencies like texture
  69671. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  69672. * @returns the parsed GPU particle system
  69673. */
  69674. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  69675. }
  69676. }
  69677. declare module "babylonjs/Particles/particleSystemSet" {
  69678. import { Nullable } from "babylonjs/types";
  69679. import { Color3 } from "babylonjs/Maths/math.color";
  69680. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69682. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69683. import { Scene, IDisposable } from "babylonjs/scene";
  69684. /**
  69685. * Represents a set of particle systems working together to create a specific effect
  69686. */
  69687. export class ParticleSystemSet implements IDisposable {
  69688. /**
  69689. * Gets or sets base Assets URL
  69690. */
  69691. static BaseAssetsUrl: string;
  69692. private _emitterCreationOptions;
  69693. private _emitterNode;
  69694. /**
  69695. * Gets the particle system list
  69696. */
  69697. systems: IParticleSystem[];
  69698. /**
  69699. * Gets the emitter node used with this set
  69700. */
  69701. get emitterNode(): Nullable<TransformNode>;
  69702. /**
  69703. * Creates a new emitter mesh as a sphere
  69704. * @param options defines the options used to create the sphere
  69705. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  69706. * @param scene defines the hosting scene
  69707. */
  69708. setEmitterAsSphere(options: {
  69709. diameter: number;
  69710. segments: number;
  69711. color: Color3;
  69712. }, renderingGroupId: number, scene: Scene): void;
  69713. /**
  69714. * Starts all particle systems of the set
  69715. * @param emitter defines an optional mesh to use as emitter for the particle systems
  69716. */
  69717. start(emitter?: AbstractMesh): void;
  69718. /**
  69719. * Release all associated resources
  69720. */
  69721. dispose(): void;
  69722. /**
  69723. * Serialize the set into a JSON compatible object
  69724. * @param serializeTexture defines if the texture must be serialized as well
  69725. * @returns a JSON compatible representation of the set
  69726. */
  69727. serialize(serializeTexture?: boolean): any;
  69728. /**
  69729. * Parse a new ParticleSystemSet from a serialized source
  69730. * @param data defines a JSON compatible representation of the set
  69731. * @param scene defines the hosting scene
  69732. * @param gpu defines if we want GPU particles or CPU particles
  69733. * @returns a new ParticleSystemSet
  69734. */
  69735. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  69736. }
  69737. }
  69738. declare module "babylonjs/Particles/particleHelper" {
  69739. import { Nullable } from "babylonjs/types";
  69740. import { Scene } from "babylonjs/scene";
  69741. import { Vector3 } from "babylonjs/Maths/math.vector";
  69742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69743. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69744. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  69745. /**
  69746. * This class is made for on one-liner static method to help creating particle system set.
  69747. */
  69748. export class ParticleHelper {
  69749. /**
  69750. * Gets or sets base Assets URL
  69751. */
  69752. static BaseAssetsUrl: string;
  69753. /** Define the Url to load snippets */
  69754. static SnippetUrl: string;
  69755. /**
  69756. * Create a default particle system that you can tweak
  69757. * @param emitter defines the emitter to use
  69758. * @param capacity defines the system capacity (default is 500 particles)
  69759. * @param scene defines the hosting scene
  69760. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  69761. * @returns the new Particle system
  69762. */
  69763. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  69764. /**
  69765. * This is the main static method (one-liner) of this helper to create different particle systems
  69766. * @param type This string represents the type to the particle system to create
  69767. * @param scene The scene where the particle system should live
  69768. * @param gpu If the system will use gpu
  69769. * @returns the ParticleSystemSet created
  69770. */
  69771. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  69772. /**
  69773. * Static function used to export a particle system to a ParticleSystemSet variable.
  69774. * Please note that the emitter shape is not exported
  69775. * @param systems defines the particle systems to export
  69776. * @returns the created particle system set
  69777. */
  69778. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  69779. /**
  69780. * Creates a particle system from a snippet saved in a remote file
  69781. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  69782. * @param url defines the url to load from
  69783. * @param scene defines the hosting scene
  69784. * @param gpu If the system will use gpu
  69785. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69786. * @returns a promise that will resolve to the new particle system
  69787. */
  69788. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69789. /**
  69790. * Creates a particle system from a snippet saved by the particle system editor
  69791. * @param snippetId defines the snippet to load
  69792. * @param scene defines the hosting scene
  69793. * @param gpu If the system will use gpu
  69794. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69795. * @returns a promise that will resolve to the new particle system
  69796. */
  69797. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69798. }
  69799. }
  69800. declare module "babylonjs/Particles/particleSystemComponent" {
  69801. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69802. import { Effect } from "babylonjs/Materials/effect";
  69803. import "babylonjs/Shaders/particles.vertex";
  69804. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  69805. module "babylonjs/Engines/engine" {
  69806. interface Engine {
  69807. /**
  69808. * Create an effect to use with particle systems.
  69809. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  69810. * the particle system for which you want to create a custom effect in the last parameter
  69811. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  69812. * @param uniformsNames defines a list of attribute names
  69813. * @param samplers defines an array of string used to represent textures
  69814. * @param defines defines the string containing the defines to use to compile the shaders
  69815. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  69816. * @param onCompiled defines a function to call when the effect creation is successful
  69817. * @param onError defines a function to call when the effect creation has failed
  69818. * @param particleSystem the particle system you want to create the effect for
  69819. * @returns the new Effect
  69820. */
  69821. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  69822. }
  69823. }
  69824. module "babylonjs/Meshes/mesh" {
  69825. interface Mesh {
  69826. /**
  69827. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  69828. * @returns an array of IParticleSystem
  69829. */
  69830. getEmittedParticleSystems(): IParticleSystem[];
  69831. /**
  69832. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  69833. * @returns an array of IParticleSystem
  69834. */
  69835. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  69836. }
  69837. }
  69838. }
  69839. declare module "babylonjs/Particles/pointsCloudSystem" {
  69840. import { Color4 } from "babylonjs/Maths/math";
  69841. import { Mesh } from "babylonjs/Meshes/mesh";
  69842. import { Scene, IDisposable } from "babylonjs/scene";
  69843. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  69844. /** Defines the 4 color options */
  69845. export enum PointColor {
  69846. /** color value */
  69847. Color = 2,
  69848. /** uv value */
  69849. UV = 1,
  69850. /** random value */
  69851. Random = 0,
  69852. /** stated value */
  69853. Stated = 3
  69854. }
  69855. /**
  69856. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  69857. * 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.
  69858. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  69859. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  69860. *
  69861. * Full documentation here : TO BE ENTERED
  69862. */
  69863. export class PointsCloudSystem implements IDisposable {
  69864. /**
  69865. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  69866. * Example : var p = SPS.particles[i];
  69867. */
  69868. particles: CloudPoint[];
  69869. /**
  69870. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  69871. */
  69872. nbParticles: number;
  69873. /**
  69874. * This a counter for your own usage. It's not set by any SPS functions.
  69875. */
  69876. counter: number;
  69877. /**
  69878. * The PCS name. This name is also given to the underlying mesh.
  69879. */
  69880. name: string;
  69881. /**
  69882. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  69883. */
  69884. mesh: Mesh;
  69885. /**
  69886. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  69887. * Please read :
  69888. */
  69889. vars: any;
  69890. /**
  69891. * @hidden
  69892. */
  69893. _size: number;
  69894. private _scene;
  69895. private _promises;
  69896. private _positions;
  69897. private _indices;
  69898. private _normals;
  69899. private _colors;
  69900. private _uvs;
  69901. private _indices32;
  69902. private _positions32;
  69903. private _colors32;
  69904. private _uvs32;
  69905. private _updatable;
  69906. private _isVisibilityBoxLocked;
  69907. private _alwaysVisible;
  69908. private _groups;
  69909. private _groupCounter;
  69910. private _computeParticleColor;
  69911. private _computeParticleTexture;
  69912. private _computeParticleRotation;
  69913. private _computeBoundingBox;
  69914. private _isReady;
  69915. /**
  69916. * Creates a PCS (Points Cloud System) object
  69917. * @param name (String) is the PCS name, this will be the underlying mesh name
  69918. * @param pointSize (number) is the size for each point
  69919. * @param scene (Scene) is the scene in which the PCS is added
  69920. * @param options defines the options of the PCS e.g.
  69921. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  69922. */
  69923. constructor(name: string, pointSize: number, scene: Scene, options?: {
  69924. updatable?: boolean;
  69925. });
  69926. /**
  69927. * Builds the PCS underlying mesh. Returns a standard Mesh.
  69928. * If no points were added to the PCS, the returned mesh is just a single point.
  69929. * @returns a promise for the created mesh
  69930. */
  69931. buildMeshAsync(): Promise<Mesh>;
  69932. /**
  69933. * @hidden
  69934. */
  69935. private _buildMesh;
  69936. private _addParticle;
  69937. private _randomUnitVector;
  69938. private _getColorIndicesForCoord;
  69939. private _setPointsColorOrUV;
  69940. private _colorFromTexture;
  69941. private _calculateDensity;
  69942. /**
  69943. * Adds points to the PCS in random positions within a unit sphere
  69944. * @param nb (positive integer) the number of particles to be created from this model
  69945. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  69946. * @returns the number of groups in the system
  69947. */
  69948. addPoints(nb: number, pointFunction?: any): number;
  69949. /**
  69950. * Adds points to the PCS from the surface of the model shape
  69951. * @param mesh is any Mesh object that will be used as a surface model for the points
  69952. * @param nb (positive integer) the number of particles to be created from this model
  69953. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69954. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69955. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69956. * @returns the number of groups in the system
  69957. */
  69958. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69959. /**
  69960. * Adds points to the PCS inside the model shape
  69961. * @param mesh is any Mesh object that will be used as a surface model for the points
  69962. * @param nb (positive integer) the number of particles to be created from this model
  69963. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69964. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69965. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69966. * @returns the number of groups in the system
  69967. */
  69968. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69969. /**
  69970. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  69971. * This method calls `updateParticle()` for each particle of the SPS.
  69972. * For an animated SPS, it is usually called within the render loop.
  69973. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  69974. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  69975. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  69976. * @returns the PCS.
  69977. */
  69978. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  69979. /**
  69980. * Disposes the PCS.
  69981. */
  69982. dispose(): void;
  69983. /**
  69984. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  69985. * doc :
  69986. * @returns the PCS.
  69987. */
  69988. refreshVisibleSize(): PointsCloudSystem;
  69989. /**
  69990. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  69991. * @param size the size (float) of the visibility box
  69992. * note : this doesn't lock the PCS mesh bounding box.
  69993. * doc :
  69994. */
  69995. setVisibilityBox(size: number): void;
  69996. /**
  69997. * Gets whether the PCS is always visible or not
  69998. * doc :
  69999. */
  70000. get isAlwaysVisible(): boolean;
  70001. /**
  70002. * Sets the PCS as always visible or not
  70003. * doc :
  70004. */
  70005. set isAlwaysVisible(val: boolean);
  70006. /**
  70007. * Tells to `setParticles()` to compute the particle rotations or not
  70008. * Default value : false. The PCS is faster when it's set to false
  70009. * Note : particle rotations are only applied to parent particles
  70010. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  70011. */
  70012. set computeParticleRotation(val: boolean);
  70013. /**
  70014. * Tells to `setParticles()` to compute the particle colors or not.
  70015. * Default value : true. The PCS is faster when it's set to false.
  70016. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70017. */
  70018. set computeParticleColor(val: boolean);
  70019. set computeParticleTexture(val: boolean);
  70020. /**
  70021. * Gets if `setParticles()` computes the particle colors or not.
  70022. * Default value : false. The PCS is faster when it's set to false.
  70023. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70024. */
  70025. get computeParticleColor(): boolean;
  70026. /**
  70027. * Gets if `setParticles()` computes the particle textures or not.
  70028. * Default value : false. The PCS is faster when it's set to false.
  70029. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  70030. */
  70031. get computeParticleTexture(): boolean;
  70032. /**
  70033. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  70034. */
  70035. set computeBoundingBox(val: boolean);
  70036. /**
  70037. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  70038. */
  70039. get computeBoundingBox(): boolean;
  70040. /**
  70041. * This function does nothing. It may be overwritten to set all the particle first values.
  70042. * The PCS doesn't call this function, you may have to call it by your own.
  70043. * doc :
  70044. */
  70045. initParticles(): void;
  70046. /**
  70047. * This function does nothing. It may be overwritten to recycle a particle
  70048. * The PCS doesn't call this function, you can to call it
  70049. * doc :
  70050. * @param particle The particle to recycle
  70051. * @returns the recycled particle
  70052. */
  70053. recycleParticle(particle: CloudPoint): CloudPoint;
  70054. /**
  70055. * Updates a particle : this function should be overwritten by the user.
  70056. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  70057. * doc :
  70058. * @example : just set a particle position or velocity and recycle conditions
  70059. * @param particle The particle to update
  70060. * @returns the updated particle
  70061. */
  70062. updateParticle(particle: CloudPoint): CloudPoint;
  70063. /**
  70064. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  70065. * This does nothing and may be overwritten by the user.
  70066. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70067. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70068. * @param update the boolean update value actually passed to setParticles()
  70069. */
  70070. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70071. /**
  70072. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  70073. * This will be passed three parameters.
  70074. * This does nothing and may be overwritten by the user.
  70075. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70076. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70077. * @param update the boolean update value actually passed to setParticles()
  70078. */
  70079. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70080. }
  70081. }
  70082. declare module "babylonjs/Particles/cloudPoint" {
  70083. import { Nullable } from "babylonjs/types";
  70084. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  70085. import { Mesh } from "babylonjs/Meshes/mesh";
  70086. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  70087. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  70088. /**
  70089. * Represents one particle of a points cloud system.
  70090. */
  70091. export class CloudPoint {
  70092. /**
  70093. * particle global index
  70094. */
  70095. idx: number;
  70096. /**
  70097. * The color of the particle
  70098. */
  70099. color: Nullable<Color4>;
  70100. /**
  70101. * The world space position of the particle.
  70102. */
  70103. position: Vector3;
  70104. /**
  70105. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  70106. */
  70107. rotation: Vector3;
  70108. /**
  70109. * The world space rotation quaternion of the particle.
  70110. */
  70111. rotationQuaternion: Nullable<Quaternion>;
  70112. /**
  70113. * The uv of the particle.
  70114. */
  70115. uv: Nullable<Vector2>;
  70116. /**
  70117. * The current speed of the particle.
  70118. */
  70119. velocity: Vector3;
  70120. /**
  70121. * The pivot point in the particle local space.
  70122. */
  70123. pivot: Vector3;
  70124. /**
  70125. * Must the particle be translated from its pivot point in its local space ?
  70126. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  70127. * Default : false
  70128. */
  70129. translateFromPivot: boolean;
  70130. /**
  70131. * Index of this particle in the global "positions" array (Internal use)
  70132. * @hidden
  70133. */
  70134. _pos: number;
  70135. /**
  70136. * @hidden Index of this particle in the global "indices" array (Internal use)
  70137. */
  70138. _ind: number;
  70139. /**
  70140. * Group this particle belongs to
  70141. */
  70142. _group: PointsGroup;
  70143. /**
  70144. * Group id of this particle
  70145. */
  70146. groupId: number;
  70147. /**
  70148. * Index of the particle in its group id (Internal use)
  70149. */
  70150. idxInGroup: number;
  70151. /**
  70152. * @hidden Particle BoundingInfo object (Internal use)
  70153. */
  70154. _boundingInfo: BoundingInfo;
  70155. /**
  70156. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  70157. */
  70158. _pcs: PointsCloudSystem;
  70159. /**
  70160. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  70161. */
  70162. _stillInvisible: boolean;
  70163. /**
  70164. * @hidden Last computed particle rotation matrix
  70165. */
  70166. _rotationMatrix: number[];
  70167. /**
  70168. * Parent particle Id, if any.
  70169. * Default null.
  70170. */
  70171. parentId: Nullable<number>;
  70172. /**
  70173. * @hidden Internal global position in the PCS.
  70174. */
  70175. _globalPosition: Vector3;
  70176. /**
  70177. * Creates a Point Cloud object.
  70178. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  70179. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  70180. * @param group (PointsGroup) is the group the particle belongs to
  70181. * @param groupId (integer) is the group identifier in the PCS.
  70182. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  70183. * @param pcs defines the PCS it is associated to
  70184. */
  70185. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  70186. /**
  70187. * get point size
  70188. */
  70189. get size(): Vector3;
  70190. /**
  70191. * Set point size
  70192. */
  70193. set size(scale: Vector3);
  70194. /**
  70195. * Legacy support, changed quaternion to rotationQuaternion
  70196. */
  70197. get quaternion(): Nullable<Quaternion>;
  70198. /**
  70199. * Legacy support, changed quaternion to rotationQuaternion
  70200. */
  70201. set quaternion(q: Nullable<Quaternion>);
  70202. /**
  70203. * Returns a boolean. True if the particle intersects a mesh, else false
  70204. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  70205. * @param target is the object (point or mesh) what the intersection is computed against
  70206. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  70207. * @returns true if it intersects
  70208. */
  70209. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  70210. /**
  70211. * get the rotation matrix of the particle
  70212. * @hidden
  70213. */
  70214. getRotationMatrix(m: Matrix): void;
  70215. }
  70216. /**
  70217. * Represents a group of points in a points cloud system
  70218. * * PCS internal tool, don't use it manually.
  70219. */
  70220. export class PointsGroup {
  70221. /**
  70222. * The group id
  70223. * @hidden
  70224. */
  70225. groupID: number;
  70226. /**
  70227. * image data for group (internal use)
  70228. * @hidden
  70229. */
  70230. _groupImageData: Nullable<ArrayBufferView>;
  70231. /**
  70232. * Image Width (internal use)
  70233. * @hidden
  70234. */
  70235. _groupImgWidth: number;
  70236. /**
  70237. * Image Height (internal use)
  70238. * @hidden
  70239. */
  70240. _groupImgHeight: number;
  70241. /**
  70242. * Custom position function (internal use)
  70243. * @hidden
  70244. */
  70245. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  70246. /**
  70247. * density per facet for surface points
  70248. * @hidden
  70249. */
  70250. _groupDensity: number[];
  70251. /**
  70252. * Only when points are colored by texture carries pointer to texture list array
  70253. * @hidden
  70254. */
  70255. _textureNb: number;
  70256. /**
  70257. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  70258. * PCS internal tool, don't use it manually.
  70259. * @hidden
  70260. */
  70261. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  70262. }
  70263. }
  70264. declare module "babylonjs/Particles/index" {
  70265. export * from "babylonjs/Particles/baseParticleSystem";
  70266. export * from "babylonjs/Particles/EmitterTypes/index";
  70267. export * from "babylonjs/Particles/gpuParticleSystem";
  70268. export * from "babylonjs/Particles/IParticleSystem";
  70269. export * from "babylonjs/Particles/particle";
  70270. export * from "babylonjs/Particles/particleHelper";
  70271. export * from "babylonjs/Particles/particleSystem";
  70272. import "babylonjs/Particles/particleSystemComponent";
  70273. export * from "babylonjs/Particles/particleSystemComponent";
  70274. export * from "babylonjs/Particles/particleSystemSet";
  70275. export * from "babylonjs/Particles/solidParticle";
  70276. export * from "babylonjs/Particles/solidParticleSystem";
  70277. export * from "babylonjs/Particles/cloudPoint";
  70278. export * from "babylonjs/Particles/pointsCloudSystem";
  70279. export * from "babylonjs/Particles/subEmitter";
  70280. }
  70281. declare module "babylonjs/Physics/physicsEngineComponent" {
  70282. import { Nullable } from "babylonjs/types";
  70283. import { Observable, Observer } from "babylonjs/Misc/observable";
  70284. import { Vector3 } from "babylonjs/Maths/math.vector";
  70285. import { Mesh } from "babylonjs/Meshes/mesh";
  70286. import { ISceneComponent } from "babylonjs/sceneComponent";
  70287. import { Scene } from "babylonjs/scene";
  70288. import { Node } from "babylonjs/node";
  70289. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  70290. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70291. module "babylonjs/scene" {
  70292. interface Scene {
  70293. /** @hidden (Backing field) */
  70294. _physicsEngine: Nullable<IPhysicsEngine>;
  70295. /** @hidden */
  70296. _physicsTimeAccumulator: number;
  70297. /**
  70298. * Gets the current physics engine
  70299. * @returns a IPhysicsEngine or null if none attached
  70300. */
  70301. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  70302. /**
  70303. * Enables physics to the current scene
  70304. * @param gravity defines the scene's gravity for the physics engine
  70305. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  70306. * @return a boolean indicating if the physics engine was initialized
  70307. */
  70308. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  70309. /**
  70310. * Disables and disposes the physics engine associated with the scene
  70311. */
  70312. disablePhysicsEngine(): void;
  70313. /**
  70314. * Gets a boolean indicating if there is an active physics engine
  70315. * @returns a boolean indicating if there is an active physics engine
  70316. */
  70317. isPhysicsEnabled(): boolean;
  70318. /**
  70319. * Deletes a physics compound impostor
  70320. * @param compound defines the compound to delete
  70321. */
  70322. deleteCompoundImpostor(compound: any): void;
  70323. /**
  70324. * An event triggered when physic simulation is about to be run
  70325. */
  70326. onBeforePhysicsObservable: Observable<Scene>;
  70327. /**
  70328. * An event triggered when physic simulation has been done
  70329. */
  70330. onAfterPhysicsObservable: Observable<Scene>;
  70331. }
  70332. }
  70333. module "babylonjs/Meshes/abstractMesh" {
  70334. interface AbstractMesh {
  70335. /** @hidden */
  70336. _physicsImpostor: Nullable<PhysicsImpostor>;
  70337. /**
  70338. * Gets or sets impostor used for physic simulation
  70339. * @see http://doc.babylonjs.com/features/physics_engine
  70340. */
  70341. physicsImpostor: Nullable<PhysicsImpostor>;
  70342. /**
  70343. * Gets the current physics impostor
  70344. * @see http://doc.babylonjs.com/features/physics_engine
  70345. * @returns a physics impostor or null
  70346. */
  70347. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  70348. /** Apply a physic impulse to the mesh
  70349. * @param force defines the force to apply
  70350. * @param contactPoint defines where to apply the force
  70351. * @returns the current mesh
  70352. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  70353. */
  70354. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  70355. /**
  70356. * Creates a physic joint between two meshes
  70357. * @param otherMesh defines the other mesh to use
  70358. * @param pivot1 defines the pivot to use on this mesh
  70359. * @param pivot2 defines the pivot to use on the other mesh
  70360. * @param options defines additional options (can be plugin dependent)
  70361. * @returns the current mesh
  70362. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  70363. */
  70364. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  70365. /** @hidden */
  70366. _disposePhysicsObserver: Nullable<Observer<Node>>;
  70367. }
  70368. }
  70369. /**
  70370. * Defines the physics engine scene component responsible to manage a physics engine
  70371. */
  70372. export class PhysicsEngineSceneComponent implements ISceneComponent {
  70373. /**
  70374. * The component name helpful to identify the component in the list of scene components.
  70375. */
  70376. readonly name: string;
  70377. /**
  70378. * The scene the component belongs to.
  70379. */
  70380. scene: Scene;
  70381. /**
  70382. * Creates a new instance of the component for the given scene
  70383. * @param scene Defines the scene to register the component in
  70384. */
  70385. constructor(scene: Scene);
  70386. /**
  70387. * Registers the component in a given scene
  70388. */
  70389. register(): void;
  70390. /**
  70391. * Rebuilds the elements related to this component in case of
  70392. * context lost for instance.
  70393. */
  70394. rebuild(): void;
  70395. /**
  70396. * Disposes the component and the associated ressources
  70397. */
  70398. dispose(): void;
  70399. }
  70400. }
  70401. declare module "babylonjs/Physics/physicsHelper" {
  70402. import { Nullable } from "babylonjs/types";
  70403. import { Vector3 } from "babylonjs/Maths/math.vector";
  70404. import { Mesh } from "babylonjs/Meshes/mesh";
  70405. import { Scene } from "babylonjs/scene";
  70406. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70407. /**
  70408. * A helper for physics simulations
  70409. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70410. */
  70411. export class PhysicsHelper {
  70412. private _scene;
  70413. private _physicsEngine;
  70414. /**
  70415. * Initializes the Physics helper
  70416. * @param scene Babylon.js scene
  70417. */
  70418. constructor(scene: Scene);
  70419. /**
  70420. * Applies a radial explosion impulse
  70421. * @param origin the origin of the explosion
  70422. * @param radiusOrEventOptions the radius or the options of radial explosion
  70423. * @param strength the explosion strength
  70424. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70425. * @returns A physics radial explosion event, or null
  70426. */
  70427. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70428. /**
  70429. * Applies a radial explosion force
  70430. * @param origin the origin of the explosion
  70431. * @param radiusOrEventOptions the radius or the options of radial explosion
  70432. * @param strength the explosion strength
  70433. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70434. * @returns A physics radial explosion event, or null
  70435. */
  70436. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70437. /**
  70438. * Creates a gravitational field
  70439. * @param origin the origin of the explosion
  70440. * @param radiusOrEventOptions the radius or the options of radial explosion
  70441. * @param strength the explosion strength
  70442. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70443. * @returns A physics gravitational field event, or null
  70444. */
  70445. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  70446. /**
  70447. * Creates a physics updraft event
  70448. * @param origin the origin of the updraft
  70449. * @param radiusOrEventOptions the radius or the options of the updraft
  70450. * @param strength the strength of the updraft
  70451. * @param height the height of the updraft
  70452. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  70453. * @returns A physics updraft event, or null
  70454. */
  70455. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  70456. /**
  70457. * Creates a physics vortex event
  70458. * @param origin the of the vortex
  70459. * @param radiusOrEventOptions the radius or the options of the vortex
  70460. * @param strength the strength of the vortex
  70461. * @param height the height of the vortex
  70462. * @returns a Physics vortex event, or null
  70463. * A physics vortex event or null
  70464. */
  70465. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  70466. }
  70467. /**
  70468. * Represents a physics radial explosion event
  70469. */
  70470. class PhysicsRadialExplosionEvent {
  70471. private _scene;
  70472. private _options;
  70473. private _sphere;
  70474. private _dataFetched;
  70475. /**
  70476. * Initializes a radial explosioin event
  70477. * @param _scene BabylonJS scene
  70478. * @param _options The options for the vortex event
  70479. */
  70480. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  70481. /**
  70482. * Returns the data related to the radial explosion event (sphere).
  70483. * @returns The radial explosion event data
  70484. */
  70485. getData(): PhysicsRadialExplosionEventData;
  70486. /**
  70487. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  70488. * @param impostor A physics imposter
  70489. * @param origin the origin of the explosion
  70490. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  70491. */
  70492. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  70493. /**
  70494. * Triggers affecterd impostors callbacks
  70495. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  70496. */
  70497. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  70498. /**
  70499. * Disposes the sphere.
  70500. * @param force Specifies if the sphere should be disposed by force
  70501. */
  70502. dispose(force?: boolean): void;
  70503. /*** Helpers ***/
  70504. private _prepareSphere;
  70505. private _intersectsWithSphere;
  70506. }
  70507. /**
  70508. * Represents a gravitational field event
  70509. */
  70510. class PhysicsGravitationalFieldEvent {
  70511. private _physicsHelper;
  70512. private _scene;
  70513. private _origin;
  70514. private _options;
  70515. private _tickCallback;
  70516. private _sphere;
  70517. private _dataFetched;
  70518. /**
  70519. * Initializes the physics gravitational field event
  70520. * @param _physicsHelper A physics helper
  70521. * @param _scene BabylonJS scene
  70522. * @param _origin The origin position of the gravitational field event
  70523. * @param _options The options for the vortex event
  70524. */
  70525. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  70526. /**
  70527. * Returns the data related to the gravitational field event (sphere).
  70528. * @returns A gravitational field event
  70529. */
  70530. getData(): PhysicsGravitationalFieldEventData;
  70531. /**
  70532. * Enables the gravitational field.
  70533. */
  70534. enable(): void;
  70535. /**
  70536. * Disables the gravitational field.
  70537. */
  70538. disable(): void;
  70539. /**
  70540. * Disposes the sphere.
  70541. * @param force The force to dispose from the gravitational field event
  70542. */
  70543. dispose(force?: boolean): void;
  70544. private _tick;
  70545. }
  70546. /**
  70547. * Represents a physics updraft event
  70548. */
  70549. class PhysicsUpdraftEvent {
  70550. private _scene;
  70551. private _origin;
  70552. private _options;
  70553. private _physicsEngine;
  70554. private _originTop;
  70555. private _originDirection;
  70556. private _tickCallback;
  70557. private _cylinder;
  70558. private _cylinderPosition;
  70559. private _dataFetched;
  70560. /**
  70561. * Initializes the physics updraft event
  70562. * @param _scene BabylonJS scene
  70563. * @param _origin The origin position of the updraft
  70564. * @param _options The options for the updraft event
  70565. */
  70566. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  70567. /**
  70568. * Returns the data related to the updraft event (cylinder).
  70569. * @returns A physics updraft event
  70570. */
  70571. getData(): PhysicsUpdraftEventData;
  70572. /**
  70573. * Enables the updraft.
  70574. */
  70575. enable(): void;
  70576. /**
  70577. * Disables the updraft.
  70578. */
  70579. disable(): void;
  70580. /**
  70581. * Disposes the cylinder.
  70582. * @param force Specifies if the updraft should be disposed by force
  70583. */
  70584. dispose(force?: boolean): void;
  70585. private getImpostorHitData;
  70586. private _tick;
  70587. /*** Helpers ***/
  70588. private _prepareCylinder;
  70589. private _intersectsWithCylinder;
  70590. }
  70591. /**
  70592. * Represents a physics vortex event
  70593. */
  70594. class PhysicsVortexEvent {
  70595. private _scene;
  70596. private _origin;
  70597. private _options;
  70598. private _physicsEngine;
  70599. private _originTop;
  70600. private _tickCallback;
  70601. private _cylinder;
  70602. private _cylinderPosition;
  70603. private _dataFetched;
  70604. /**
  70605. * Initializes the physics vortex event
  70606. * @param _scene The BabylonJS scene
  70607. * @param _origin The origin position of the vortex
  70608. * @param _options The options for the vortex event
  70609. */
  70610. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  70611. /**
  70612. * Returns the data related to the vortex event (cylinder).
  70613. * @returns The physics vortex event data
  70614. */
  70615. getData(): PhysicsVortexEventData;
  70616. /**
  70617. * Enables the vortex.
  70618. */
  70619. enable(): void;
  70620. /**
  70621. * Disables the cortex.
  70622. */
  70623. disable(): void;
  70624. /**
  70625. * Disposes the sphere.
  70626. * @param force
  70627. */
  70628. dispose(force?: boolean): void;
  70629. private getImpostorHitData;
  70630. private _tick;
  70631. /*** Helpers ***/
  70632. private _prepareCylinder;
  70633. private _intersectsWithCylinder;
  70634. }
  70635. /**
  70636. * Options fot the radial explosion event
  70637. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70638. */
  70639. export class PhysicsRadialExplosionEventOptions {
  70640. /**
  70641. * The radius of the sphere for the radial explosion.
  70642. */
  70643. radius: number;
  70644. /**
  70645. * The strenth of the explosion.
  70646. */
  70647. strength: number;
  70648. /**
  70649. * The strenght of the force in correspondence to the distance of the affected object
  70650. */
  70651. falloff: PhysicsRadialImpulseFalloff;
  70652. /**
  70653. * Sphere options for the radial explosion.
  70654. */
  70655. sphere: {
  70656. segments: number;
  70657. diameter: number;
  70658. };
  70659. /**
  70660. * Sphere options for the radial explosion.
  70661. */
  70662. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  70663. }
  70664. /**
  70665. * Options fot the updraft event
  70666. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70667. */
  70668. export class PhysicsUpdraftEventOptions {
  70669. /**
  70670. * The radius of the cylinder for the vortex
  70671. */
  70672. radius: number;
  70673. /**
  70674. * The strenth of the updraft.
  70675. */
  70676. strength: number;
  70677. /**
  70678. * The height of the cylinder for the updraft.
  70679. */
  70680. height: number;
  70681. /**
  70682. * The mode for the the updraft.
  70683. */
  70684. updraftMode: PhysicsUpdraftMode;
  70685. }
  70686. /**
  70687. * Options fot the vortex event
  70688. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70689. */
  70690. export class PhysicsVortexEventOptions {
  70691. /**
  70692. * The radius of the cylinder for the vortex
  70693. */
  70694. radius: number;
  70695. /**
  70696. * The strenth of the vortex.
  70697. */
  70698. strength: number;
  70699. /**
  70700. * The height of the cylinder for the vortex.
  70701. */
  70702. height: number;
  70703. /**
  70704. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  70705. */
  70706. centripetalForceThreshold: number;
  70707. /**
  70708. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  70709. */
  70710. centripetalForceMultiplier: number;
  70711. /**
  70712. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  70713. */
  70714. centrifugalForceMultiplier: number;
  70715. /**
  70716. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  70717. */
  70718. updraftForceMultiplier: number;
  70719. }
  70720. /**
  70721. * The strenght of the force in correspondence to the distance of the affected object
  70722. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70723. */
  70724. export enum PhysicsRadialImpulseFalloff {
  70725. /** Defines that impulse is constant in strength across it's whole radius */
  70726. Constant = 0,
  70727. /** Defines that impulse gets weaker if it's further from the origin */
  70728. Linear = 1
  70729. }
  70730. /**
  70731. * The strength of the force in correspondence to the distance of the affected object
  70732. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70733. */
  70734. export enum PhysicsUpdraftMode {
  70735. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  70736. Center = 0,
  70737. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  70738. Perpendicular = 1
  70739. }
  70740. /**
  70741. * Interface for a physics hit data
  70742. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70743. */
  70744. export interface PhysicsHitData {
  70745. /**
  70746. * The force applied at the contact point
  70747. */
  70748. force: Vector3;
  70749. /**
  70750. * The contact point
  70751. */
  70752. contactPoint: Vector3;
  70753. /**
  70754. * The distance from the origin to the contact point
  70755. */
  70756. distanceFromOrigin: number;
  70757. }
  70758. /**
  70759. * Interface for radial explosion event data
  70760. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70761. */
  70762. export interface PhysicsRadialExplosionEventData {
  70763. /**
  70764. * A sphere used for the radial explosion event
  70765. */
  70766. sphere: Mesh;
  70767. }
  70768. /**
  70769. * Interface for gravitational field event data
  70770. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70771. */
  70772. export interface PhysicsGravitationalFieldEventData {
  70773. /**
  70774. * A sphere mesh used for the gravitational field event
  70775. */
  70776. sphere: Mesh;
  70777. }
  70778. /**
  70779. * Interface for updraft event data
  70780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70781. */
  70782. export interface PhysicsUpdraftEventData {
  70783. /**
  70784. * A cylinder used for the updraft event
  70785. */
  70786. cylinder: Mesh;
  70787. }
  70788. /**
  70789. * Interface for vortex event data
  70790. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70791. */
  70792. export interface PhysicsVortexEventData {
  70793. /**
  70794. * A cylinder used for the vortex event
  70795. */
  70796. cylinder: Mesh;
  70797. }
  70798. /**
  70799. * Interface for an affected physics impostor
  70800. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70801. */
  70802. export interface PhysicsAffectedImpostorWithData {
  70803. /**
  70804. * The impostor affected by the effect
  70805. */
  70806. impostor: PhysicsImpostor;
  70807. /**
  70808. * The data about the hit/horce from the explosion
  70809. */
  70810. hitData: PhysicsHitData;
  70811. }
  70812. }
  70813. declare module "babylonjs/Physics/Plugins/index" {
  70814. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  70815. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  70816. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  70817. }
  70818. declare module "babylonjs/Physics/index" {
  70819. export * from "babylonjs/Physics/IPhysicsEngine";
  70820. export * from "babylonjs/Physics/physicsEngine";
  70821. export * from "babylonjs/Physics/physicsEngineComponent";
  70822. export * from "babylonjs/Physics/physicsHelper";
  70823. export * from "babylonjs/Physics/physicsImpostor";
  70824. export * from "babylonjs/Physics/physicsJoint";
  70825. export * from "babylonjs/Physics/Plugins/index";
  70826. }
  70827. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  70828. /** @hidden */
  70829. export var blackAndWhitePixelShader: {
  70830. name: string;
  70831. shader: string;
  70832. };
  70833. }
  70834. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  70835. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70836. import { Camera } from "babylonjs/Cameras/camera";
  70837. import { Engine } from "babylonjs/Engines/engine";
  70838. import "babylonjs/Shaders/blackAndWhite.fragment";
  70839. /**
  70840. * Post process used to render in black and white
  70841. */
  70842. export class BlackAndWhitePostProcess extends PostProcess {
  70843. /**
  70844. * Linear about to convert he result to black and white (default: 1)
  70845. */
  70846. degree: number;
  70847. /**
  70848. * Creates a black and white post process
  70849. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  70850. * @param name The name of the effect.
  70851. * @param options The required width/height ratio to downsize to before computing the render pass.
  70852. * @param camera The camera to apply the render pass to.
  70853. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70854. * @param engine The engine which the post process will be applied. (default: current engine)
  70855. * @param reusable If the post process can be reused on the same frame. (default: false)
  70856. */
  70857. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70858. }
  70859. }
  70860. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  70861. import { Nullable } from "babylonjs/types";
  70862. import { Camera } from "babylonjs/Cameras/camera";
  70863. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70864. import { Engine } from "babylonjs/Engines/engine";
  70865. /**
  70866. * This represents a set of one or more post processes in Babylon.
  70867. * A post process can be used to apply a shader to a texture after it is rendered.
  70868. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70869. */
  70870. export class PostProcessRenderEffect {
  70871. private _postProcesses;
  70872. private _getPostProcesses;
  70873. private _singleInstance;
  70874. private _cameras;
  70875. private _indicesForCamera;
  70876. /**
  70877. * Name of the effect
  70878. * @hidden
  70879. */
  70880. _name: string;
  70881. /**
  70882. * Instantiates a post process render effect.
  70883. * A post process can be used to apply a shader to a texture after it is rendered.
  70884. * @param engine The engine the effect is tied to
  70885. * @param name The name of the effect
  70886. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  70887. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  70888. */
  70889. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  70890. /**
  70891. * Checks if all the post processes in the effect are supported.
  70892. */
  70893. get isSupported(): boolean;
  70894. /**
  70895. * Updates the current state of the effect
  70896. * @hidden
  70897. */
  70898. _update(): void;
  70899. /**
  70900. * Attaches the effect on cameras
  70901. * @param cameras The camera to attach to.
  70902. * @hidden
  70903. */
  70904. _attachCameras(cameras: Camera): void;
  70905. /**
  70906. * Attaches the effect on cameras
  70907. * @param cameras The camera to attach to.
  70908. * @hidden
  70909. */
  70910. _attachCameras(cameras: Camera[]): void;
  70911. /**
  70912. * Detaches the effect on cameras
  70913. * @param cameras The camera to detatch from.
  70914. * @hidden
  70915. */
  70916. _detachCameras(cameras: Camera): void;
  70917. /**
  70918. * Detatches the effect on cameras
  70919. * @param cameras The camera to detatch from.
  70920. * @hidden
  70921. */
  70922. _detachCameras(cameras: Camera[]): void;
  70923. /**
  70924. * Enables the effect on given cameras
  70925. * @param cameras The camera to enable.
  70926. * @hidden
  70927. */
  70928. _enable(cameras: Camera): void;
  70929. /**
  70930. * Enables the effect on given cameras
  70931. * @param cameras The camera to enable.
  70932. * @hidden
  70933. */
  70934. _enable(cameras: Nullable<Camera[]>): void;
  70935. /**
  70936. * Disables the effect on the given cameras
  70937. * @param cameras The camera to disable.
  70938. * @hidden
  70939. */
  70940. _disable(cameras: Camera): void;
  70941. /**
  70942. * Disables the effect on the given cameras
  70943. * @param cameras The camera to disable.
  70944. * @hidden
  70945. */
  70946. _disable(cameras: Nullable<Camera[]>): void;
  70947. /**
  70948. * Gets a list of the post processes contained in the effect.
  70949. * @param camera The camera to get the post processes on.
  70950. * @returns The list of the post processes in the effect.
  70951. */
  70952. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  70953. }
  70954. }
  70955. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  70956. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70957. /** @hidden */
  70958. export var extractHighlightsPixelShader: {
  70959. name: string;
  70960. shader: string;
  70961. };
  70962. }
  70963. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  70964. import { Nullable } from "babylonjs/types";
  70965. import { Camera } from "babylonjs/Cameras/camera";
  70966. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70967. import { Engine } from "babylonjs/Engines/engine";
  70968. import "babylonjs/Shaders/extractHighlights.fragment";
  70969. /**
  70970. * 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.
  70971. */
  70972. export class ExtractHighlightsPostProcess extends PostProcess {
  70973. /**
  70974. * The luminance threshold, pixels below this value will be set to black.
  70975. */
  70976. threshold: number;
  70977. /** @hidden */
  70978. _exposure: number;
  70979. /**
  70980. * Post process which has the input texture to be used when performing highlight extraction
  70981. * @hidden
  70982. */
  70983. _inputPostProcess: Nullable<PostProcess>;
  70984. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70985. }
  70986. }
  70987. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  70988. /** @hidden */
  70989. export var bloomMergePixelShader: {
  70990. name: string;
  70991. shader: string;
  70992. };
  70993. }
  70994. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  70995. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70996. import { Nullable } from "babylonjs/types";
  70997. import { Engine } from "babylonjs/Engines/engine";
  70998. import { Camera } from "babylonjs/Cameras/camera";
  70999. import "babylonjs/Shaders/bloomMerge.fragment";
  71000. /**
  71001. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71002. */
  71003. export class BloomMergePostProcess extends PostProcess {
  71004. /** Weight of the bloom to be added to the original input. */
  71005. weight: number;
  71006. /**
  71007. * Creates a new instance of @see BloomMergePostProcess
  71008. * @param name The name of the effect.
  71009. * @param originalFromInput Post process which's input will be used for the merge.
  71010. * @param blurred Blurred highlights post process which's output will be used.
  71011. * @param weight Weight of the bloom to be added to the original input.
  71012. * @param options The required width/height ratio to downsize to before computing the render pass.
  71013. * @param camera The camera to apply the render pass to.
  71014. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71015. * @param engine The engine which the post process will be applied. (default: current engine)
  71016. * @param reusable If the post process can be reused on the same frame. (default: false)
  71017. * @param textureType Type of textures used when performing the post process. (default: 0)
  71018. * @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)
  71019. */
  71020. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  71021. /** Weight of the bloom to be added to the original input. */
  71022. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71023. }
  71024. }
  71025. declare module "babylonjs/PostProcesses/bloomEffect" {
  71026. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71027. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71028. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  71029. import { Camera } from "babylonjs/Cameras/camera";
  71030. import { Scene } from "babylonjs/scene";
  71031. /**
  71032. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  71033. */
  71034. export class BloomEffect extends PostProcessRenderEffect {
  71035. private bloomScale;
  71036. /**
  71037. * @hidden Internal
  71038. */
  71039. _effects: Array<PostProcess>;
  71040. /**
  71041. * @hidden Internal
  71042. */
  71043. _downscale: ExtractHighlightsPostProcess;
  71044. private _blurX;
  71045. private _blurY;
  71046. private _merge;
  71047. /**
  71048. * The luminance threshold to find bright areas of the image to bloom.
  71049. */
  71050. get threshold(): number;
  71051. set threshold(value: number);
  71052. /**
  71053. * The strength of the bloom.
  71054. */
  71055. get weight(): number;
  71056. set weight(value: number);
  71057. /**
  71058. * Specifies the size of the bloom blur kernel, relative to the final output size
  71059. */
  71060. get kernel(): number;
  71061. set kernel(value: number);
  71062. /**
  71063. * Creates a new instance of @see BloomEffect
  71064. * @param scene The scene the effect belongs to.
  71065. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  71066. * @param bloomKernel The size of the kernel to be used when applying the blur.
  71067. * @param bloomWeight The the strength of bloom.
  71068. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71069. * @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)
  71070. */
  71071. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  71072. /**
  71073. * Disposes each of the internal effects for a given camera.
  71074. * @param camera The camera to dispose the effect on.
  71075. */
  71076. disposeEffects(camera: Camera): void;
  71077. /**
  71078. * @hidden Internal
  71079. */
  71080. _updateEffects(): void;
  71081. /**
  71082. * Internal
  71083. * @returns if all the contained post processes are ready.
  71084. * @hidden
  71085. */
  71086. _isReady(): boolean;
  71087. }
  71088. }
  71089. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  71090. /** @hidden */
  71091. export var chromaticAberrationPixelShader: {
  71092. name: string;
  71093. shader: string;
  71094. };
  71095. }
  71096. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  71097. import { Vector2 } from "babylonjs/Maths/math.vector";
  71098. import { Nullable } from "babylonjs/types";
  71099. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71100. import { Camera } from "babylonjs/Cameras/camera";
  71101. import { Engine } from "babylonjs/Engines/engine";
  71102. import "babylonjs/Shaders/chromaticAberration.fragment";
  71103. /**
  71104. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  71105. */
  71106. export class ChromaticAberrationPostProcess extends PostProcess {
  71107. /**
  71108. * The amount of seperation of rgb channels (default: 30)
  71109. */
  71110. aberrationAmount: number;
  71111. /**
  71112. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  71113. */
  71114. radialIntensity: number;
  71115. /**
  71116. * 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))
  71117. */
  71118. direction: Vector2;
  71119. /**
  71120. * 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))
  71121. */
  71122. centerPosition: Vector2;
  71123. /**
  71124. * Creates a new instance ChromaticAberrationPostProcess
  71125. * @param name The name of the effect.
  71126. * @param screenWidth The width of the screen to apply the effect on.
  71127. * @param screenHeight The height of the screen to apply the effect on.
  71128. * @param options The required width/height ratio to downsize to before computing the render pass.
  71129. * @param camera The camera to apply the render pass to.
  71130. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71131. * @param engine The engine which the post process will be applied. (default: current engine)
  71132. * @param reusable If the post process can be reused on the same frame. (default: false)
  71133. * @param textureType Type of textures used when performing the post process. (default: 0)
  71134. * @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)
  71135. */
  71136. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71137. }
  71138. }
  71139. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  71140. /** @hidden */
  71141. export var circleOfConfusionPixelShader: {
  71142. name: string;
  71143. shader: string;
  71144. };
  71145. }
  71146. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  71147. import { Nullable } from "babylonjs/types";
  71148. import { Engine } from "babylonjs/Engines/engine";
  71149. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71150. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71151. import { Camera } from "babylonjs/Cameras/camera";
  71152. import "babylonjs/Shaders/circleOfConfusion.fragment";
  71153. /**
  71154. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  71155. */
  71156. export class CircleOfConfusionPostProcess extends PostProcess {
  71157. /**
  71158. * 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.
  71159. */
  71160. lensSize: number;
  71161. /**
  71162. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71163. */
  71164. fStop: number;
  71165. /**
  71166. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71167. */
  71168. focusDistance: number;
  71169. /**
  71170. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  71171. */
  71172. focalLength: number;
  71173. private _depthTexture;
  71174. /**
  71175. * Creates a new instance CircleOfConfusionPostProcess
  71176. * @param name The name of the effect.
  71177. * @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.
  71178. * @param options The required width/height ratio to downsize to before computing the render pass.
  71179. * @param camera The camera to apply the render pass to.
  71180. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71181. * @param engine The engine which the post process will be applied. (default: current engine)
  71182. * @param reusable If the post process can be reused on the same frame. (default: false)
  71183. * @param textureType Type of textures used when performing the post process. (default: 0)
  71184. * @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)
  71185. */
  71186. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71187. /**
  71188. * 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.
  71189. */
  71190. set depthTexture(value: RenderTargetTexture);
  71191. }
  71192. }
  71193. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  71194. /** @hidden */
  71195. export var colorCorrectionPixelShader: {
  71196. name: string;
  71197. shader: string;
  71198. };
  71199. }
  71200. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  71201. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71202. import { Engine } from "babylonjs/Engines/engine";
  71203. import { Camera } from "babylonjs/Cameras/camera";
  71204. import "babylonjs/Shaders/colorCorrection.fragment";
  71205. /**
  71206. *
  71207. * This post-process allows the modification of rendered colors by using
  71208. * a 'look-up table' (LUT). This effect is also called Color Grading.
  71209. *
  71210. * The object needs to be provided an url to a texture containing the color
  71211. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  71212. * Use an image editing software to tweak the LUT to match your needs.
  71213. *
  71214. * For an example of a color LUT, see here:
  71215. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  71216. * For explanations on color grading, see here:
  71217. * @see http://udn.epicgames.com/Three/ColorGrading.html
  71218. *
  71219. */
  71220. export class ColorCorrectionPostProcess extends PostProcess {
  71221. private _colorTableTexture;
  71222. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71223. }
  71224. }
  71225. declare module "babylonjs/Shaders/convolution.fragment" {
  71226. /** @hidden */
  71227. export var convolutionPixelShader: {
  71228. name: string;
  71229. shader: string;
  71230. };
  71231. }
  71232. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  71233. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71234. import { Nullable } from "babylonjs/types";
  71235. import { Camera } from "babylonjs/Cameras/camera";
  71236. import { Engine } from "babylonjs/Engines/engine";
  71237. import "babylonjs/Shaders/convolution.fragment";
  71238. /**
  71239. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  71240. * input texture to perform effects such as edge detection or sharpening
  71241. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71242. */
  71243. export class ConvolutionPostProcess extends PostProcess {
  71244. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71245. kernel: number[];
  71246. /**
  71247. * Creates a new instance ConvolutionPostProcess
  71248. * @param name The name of the effect.
  71249. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  71250. * @param options The required width/height ratio to downsize to before computing the render pass.
  71251. * @param camera The camera to apply the render pass to.
  71252. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71253. * @param engine The engine which the post process will be applied. (default: current engine)
  71254. * @param reusable If the post process can be reused on the same frame. (default: false)
  71255. * @param textureType Type of textures used when performing the post process. (default: 0)
  71256. */
  71257. constructor(name: string,
  71258. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71259. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71260. /**
  71261. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71262. */
  71263. static EdgeDetect0Kernel: number[];
  71264. /**
  71265. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71266. */
  71267. static EdgeDetect1Kernel: number[];
  71268. /**
  71269. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71270. */
  71271. static EdgeDetect2Kernel: number[];
  71272. /**
  71273. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71274. */
  71275. static SharpenKernel: number[];
  71276. /**
  71277. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71278. */
  71279. static EmbossKernel: number[];
  71280. /**
  71281. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71282. */
  71283. static GaussianKernel: number[];
  71284. }
  71285. }
  71286. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  71287. import { Nullable } from "babylonjs/types";
  71288. import { Vector2 } from "babylonjs/Maths/math.vector";
  71289. import { Camera } from "babylonjs/Cameras/camera";
  71290. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71291. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  71292. import { Engine } from "babylonjs/Engines/engine";
  71293. import { Scene } from "babylonjs/scene";
  71294. /**
  71295. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  71296. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  71297. * based on samples that have a large difference in distance than the center pixel.
  71298. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  71299. */
  71300. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  71301. direction: Vector2;
  71302. /**
  71303. * Creates a new instance CircleOfConfusionPostProcess
  71304. * @param name The name of the effect.
  71305. * @param scene The scene the effect belongs to.
  71306. * @param direction The direction the blur should be applied.
  71307. * @param kernel The size of the kernel used to blur.
  71308. * @param options The required width/height ratio to downsize to before computing the render pass.
  71309. * @param camera The camera to apply the render pass to.
  71310. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  71311. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  71312. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71313. * @param engine The engine which the post process will be applied. (default: current engine)
  71314. * @param reusable If the post process can be reused on the same frame. (default: false)
  71315. * @param textureType Type of textures used when performing the post process. (default: 0)
  71316. * @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)
  71317. */
  71318. 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);
  71319. }
  71320. }
  71321. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  71322. /** @hidden */
  71323. export var depthOfFieldMergePixelShader: {
  71324. name: string;
  71325. shader: string;
  71326. };
  71327. }
  71328. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  71329. import { Nullable } from "babylonjs/types";
  71330. import { Camera } from "babylonjs/Cameras/camera";
  71331. import { Effect } from "babylonjs/Materials/effect";
  71332. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71333. import { Engine } from "babylonjs/Engines/engine";
  71334. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  71335. /**
  71336. * Options to be set when merging outputs from the default pipeline.
  71337. */
  71338. export class DepthOfFieldMergePostProcessOptions {
  71339. /**
  71340. * The original image to merge on top of
  71341. */
  71342. originalFromInput: PostProcess;
  71343. /**
  71344. * Parameters to perform the merge of the depth of field effect
  71345. */
  71346. depthOfField?: {
  71347. circleOfConfusion: PostProcess;
  71348. blurSteps: Array<PostProcess>;
  71349. };
  71350. /**
  71351. * Parameters to perform the merge of bloom effect
  71352. */
  71353. bloom?: {
  71354. blurred: PostProcess;
  71355. weight: number;
  71356. };
  71357. }
  71358. /**
  71359. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71360. */
  71361. export class DepthOfFieldMergePostProcess extends PostProcess {
  71362. private blurSteps;
  71363. /**
  71364. * Creates a new instance of DepthOfFieldMergePostProcess
  71365. * @param name The name of the effect.
  71366. * @param originalFromInput Post process which's input will be used for the merge.
  71367. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  71368. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  71369. * @param options The required width/height ratio to downsize to before computing the render pass.
  71370. * @param camera The camera to apply the render pass to.
  71371. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71372. * @param engine The engine which the post process will be applied. (default: current engine)
  71373. * @param reusable If the post process can be reused on the same frame. (default: false)
  71374. * @param textureType Type of textures used when performing the post process. (default: 0)
  71375. * @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)
  71376. */
  71377. 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);
  71378. /**
  71379. * Updates the effect with the current post process compile time values and recompiles the shader.
  71380. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71381. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71382. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71383. * @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
  71384. * @param onCompiled Called when the shader has been compiled.
  71385. * @param onError Called if there is an error when compiling a shader.
  71386. */
  71387. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71388. }
  71389. }
  71390. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  71391. import { Nullable } from "babylonjs/types";
  71392. import { Camera } from "babylonjs/Cameras/camera";
  71393. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71394. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71395. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71396. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  71397. import { Scene } from "babylonjs/scene";
  71398. /**
  71399. * Specifies the level of max blur that should be applied when using the depth of field effect
  71400. */
  71401. export enum DepthOfFieldEffectBlurLevel {
  71402. /**
  71403. * Subtle blur
  71404. */
  71405. Low = 0,
  71406. /**
  71407. * Medium blur
  71408. */
  71409. Medium = 1,
  71410. /**
  71411. * Large blur
  71412. */
  71413. High = 2
  71414. }
  71415. /**
  71416. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  71417. */
  71418. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  71419. private _circleOfConfusion;
  71420. /**
  71421. * @hidden Internal, blurs from high to low
  71422. */
  71423. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  71424. private _depthOfFieldBlurY;
  71425. private _dofMerge;
  71426. /**
  71427. * @hidden Internal post processes in depth of field effect
  71428. */
  71429. _effects: Array<PostProcess>;
  71430. /**
  71431. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  71432. */
  71433. set focalLength(value: number);
  71434. get focalLength(): number;
  71435. /**
  71436. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71437. */
  71438. set fStop(value: number);
  71439. get fStop(): number;
  71440. /**
  71441. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71442. */
  71443. set focusDistance(value: number);
  71444. get focusDistance(): number;
  71445. /**
  71446. * 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.
  71447. */
  71448. set lensSize(value: number);
  71449. get lensSize(): number;
  71450. /**
  71451. * Creates a new instance DepthOfFieldEffect
  71452. * @param scene The scene the effect belongs to.
  71453. * @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.
  71454. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71455. * @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)
  71456. */
  71457. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  71458. /**
  71459. * Get the current class name of the current effet
  71460. * @returns "DepthOfFieldEffect"
  71461. */
  71462. getClassName(): string;
  71463. /**
  71464. * 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.
  71465. */
  71466. set depthTexture(value: RenderTargetTexture);
  71467. /**
  71468. * Disposes each of the internal effects for a given camera.
  71469. * @param camera The camera to dispose the effect on.
  71470. */
  71471. disposeEffects(camera: Camera): void;
  71472. /**
  71473. * @hidden Internal
  71474. */
  71475. _updateEffects(): void;
  71476. /**
  71477. * Internal
  71478. * @returns if all the contained post processes are ready.
  71479. * @hidden
  71480. */
  71481. _isReady(): boolean;
  71482. }
  71483. }
  71484. declare module "babylonjs/Shaders/displayPass.fragment" {
  71485. /** @hidden */
  71486. export var displayPassPixelShader: {
  71487. name: string;
  71488. shader: string;
  71489. };
  71490. }
  71491. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  71492. import { Nullable } from "babylonjs/types";
  71493. import { Camera } from "babylonjs/Cameras/camera";
  71494. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71495. import { Engine } from "babylonjs/Engines/engine";
  71496. import "babylonjs/Shaders/displayPass.fragment";
  71497. /**
  71498. * DisplayPassPostProcess which produces an output the same as it's input
  71499. */
  71500. export class DisplayPassPostProcess extends PostProcess {
  71501. /**
  71502. * Creates the DisplayPassPostProcess
  71503. * @param name The name of the effect.
  71504. * @param options The required width/height ratio to downsize to before computing the render pass.
  71505. * @param camera The camera to apply the render pass to.
  71506. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71507. * @param engine The engine which the post process will be applied. (default: current engine)
  71508. * @param reusable If the post process can be reused on the same frame. (default: false)
  71509. */
  71510. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71511. }
  71512. }
  71513. declare module "babylonjs/Shaders/filter.fragment" {
  71514. /** @hidden */
  71515. export var filterPixelShader: {
  71516. name: string;
  71517. shader: string;
  71518. };
  71519. }
  71520. declare module "babylonjs/PostProcesses/filterPostProcess" {
  71521. import { Nullable } from "babylonjs/types";
  71522. import { Matrix } from "babylonjs/Maths/math.vector";
  71523. import { Camera } from "babylonjs/Cameras/camera";
  71524. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71525. import { Engine } from "babylonjs/Engines/engine";
  71526. import "babylonjs/Shaders/filter.fragment";
  71527. /**
  71528. * Applies a kernel filter to the image
  71529. */
  71530. export class FilterPostProcess extends PostProcess {
  71531. /** The matrix to be applied to the image */
  71532. kernelMatrix: Matrix;
  71533. /**
  71534. *
  71535. * @param name The name of the effect.
  71536. * @param kernelMatrix The matrix to be applied to the image
  71537. * @param options The required width/height ratio to downsize to before computing the render pass.
  71538. * @param camera The camera to apply the render pass to.
  71539. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71540. * @param engine The engine which the post process will be applied. (default: current engine)
  71541. * @param reusable If the post process can be reused on the same frame. (default: false)
  71542. */
  71543. constructor(name: string,
  71544. /** The matrix to be applied to the image */
  71545. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71546. }
  71547. }
  71548. declare module "babylonjs/Shaders/fxaa.fragment" {
  71549. /** @hidden */
  71550. export var fxaaPixelShader: {
  71551. name: string;
  71552. shader: string;
  71553. };
  71554. }
  71555. declare module "babylonjs/Shaders/fxaa.vertex" {
  71556. /** @hidden */
  71557. export var fxaaVertexShader: {
  71558. name: string;
  71559. shader: string;
  71560. };
  71561. }
  71562. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  71563. import { Nullable } from "babylonjs/types";
  71564. import { Camera } from "babylonjs/Cameras/camera";
  71565. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71566. import { Engine } from "babylonjs/Engines/engine";
  71567. import "babylonjs/Shaders/fxaa.fragment";
  71568. import "babylonjs/Shaders/fxaa.vertex";
  71569. /**
  71570. * Fxaa post process
  71571. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  71572. */
  71573. export class FxaaPostProcess extends PostProcess {
  71574. /** @hidden */
  71575. texelWidth: number;
  71576. /** @hidden */
  71577. texelHeight: number;
  71578. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71579. private _getDefines;
  71580. }
  71581. }
  71582. declare module "babylonjs/Shaders/grain.fragment" {
  71583. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71584. /** @hidden */
  71585. export var grainPixelShader: {
  71586. name: string;
  71587. shader: string;
  71588. };
  71589. }
  71590. declare module "babylonjs/PostProcesses/grainPostProcess" {
  71591. import { Nullable } from "babylonjs/types";
  71592. import { Camera } from "babylonjs/Cameras/camera";
  71593. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71594. import { Engine } from "babylonjs/Engines/engine";
  71595. import "babylonjs/Shaders/grain.fragment";
  71596. /**
  71597. * The GrainPostProcess adds noise to the image at mid luminance levels
  71598. */
  71599. export class GrainPostProcess extends PostProcess {
  71600. /**
  71601. * The intensity of the grain added (default: 30)
  71602. */
  71603. intensity: number;
  71604. /**
  71605. * If the grain should be randomized on every frame
  71606. */
  71607. animated: boolean;
  71608. /**
  71609. * Creates a new instance of @see GrainPostProcess
  71610. * @param name The name of the effect.
  71611. * @param options The required width/height ratio to downsize to before computing the render pass.
  71612. * @param camera The camera to apply the render pass to.
  71613. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71614. * @param engine The engine which the post process will be applied. (default: current engine)
  71615. * @param reusable If the post process can be reused on the same frame. (default: false)
  71616. * @param textureType Type of textures used when performing the post process. (default: 0)
  71617. * @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)
  71618. */
  71619. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71620. }
  71621. }
  71622. declare module "babylonjs/Shaders/highlights.fragment" {
  71623. /** @hidden */
  71624. export var highlightsPixelShader: {
  71625. name: string;
  71626. shader: string;
  71627. };
  71628. }
  71629. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  71630. import { Nullable } from "babylonjs/types";
  71631. import { Camera } from "babylonjs/Cameras/camera";
  71632. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71633. import { Engine } from "babylonjs/Engines/engine";
  71634. import "babylonjs/Shaders/highlights.fragment";
  71635. /**
  71636. * Extracts highlights from the image
  71637. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71638. */
  71639. export class HighlightsPostProcess extends PostProcess {
  71640. /**
  71641. * Extracts highlights from the image
  71642. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71643. * @param name The name of the effect.
  71644. * @param options The required width/height ratio to downsize to before computing the render pass.
  71645. * @param camera The camera to apply the render pass to.
  71646. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71647. * @param engine The engine which the post process will be applied. (default: current engine)
  71648. * @param reusable If the post process can be reused on the same frame. (default: false)
  71649. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  71650. */
  71651. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71652. }
  71653. }
  71654. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  71655. /** @hidden */
  71656. export var mrtFragmentDeclaration: {
  71657. name: string;
  71658. shader: string;
  71659. };
  71660. }
  71661. declare module "babylonjs/Shaders/geometry.fragment" {
  71662. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  71663. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  71664. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  71665. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  71666. /** @hidden */
  71667. export var geometryPixelShader: {
  71668. name: string;
  71669. shader: string;
  71670. };
  71671. }
  71672. declare module "babylonjs/Shaders/geometry.vertex" {
  71673. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  71674. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  71675. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  71676. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  71677. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  71678. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  71679. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  71680. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  71681. /** @hidden */
  71682. export var geometryVertexShader: {
  71683. name: string;
  71684. shader: string;
  71685. };
  71686. }
  71687. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  71688. import { Matrix } from "babylonjs/Maths/math.vector";
  71689. import { SubMesh } from "babylonjs/Meshes/subMesh";
  71690. import { Mesh } from "babylonjs/Meshes/mesh";
  71691. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  71692. import { Effect } from "babylonjs/Materials/effect";
  71693. import { Scene } from "babylonjs/scene";
  71694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71695. import "babylonjs/Shaders/geometry.fragment";
  71696. import "babylonjs/Shaders/geometry.vertex";
  71697. /** @hidden */
  71698. interface ISavedTransformationMatrix {
  71699. world: Matrix;
  71700. viewProjection: Matrix;
  71701. }
  71702. /**
  71703. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  71704. */
  71705. export class GeometryBufferRenderer {
  71706. /**
  71707. * Constant used to retrieve the position texture index in the G-Buffer textures array
  71708. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  71709. */
  71710. static readonly POSITION_TEXTURE_TYPE: number;
  71711. /**
  71712. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  71713. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  71714. */
  71715. static readonly VELOCITY_TEXTURE_TYPE: number;
  71716. /**
  71717. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  71718. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  71719. */
  71720. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  71721. /**
  71722. * Dictionary used to store the previous transformation matrices of each rendered mesh
  71723. * in order to compute objects velocities when enableVelocity is set to "true"
  71724. * @hidden
  71725. */
  71726. _previousTransformationMatrices: {
  71727. [index: number]: ISavedTransformationMatrix;
  71728. };
  71729. /**
  71730. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  71731. * in order to compute objects velocities when enableVelocity is set to "true"
  71732. * @hidden
  71733. */
  71734. _previousBonesTransformationMatrices: {
  71735. [index: number]: Float32Array;
  71736. };
  71737. /**
  71738. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  71739. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  71740. */
  71741. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  71742. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  71743. renderTransparentMeshes: boolean;
  71744. private _scene;
  71745. private _multiRenderTarget;
  71746. private _ratio;
  71747. private _enablePosition;
  71748. private _enableVelocity;
  71749. private _enableReflectivity;
  71750. private _positionIndex;
  71751. private _velocityIndex;
  71752. private _reflectivityIndex;
  71753. protected _effect: Effect;
  71754. protected _cachedDefines: string;
  71755. /**
  71756. * Set the render list (meshes to be rendered) used in the G buffer.
  71757. */
  71758. set renderList(meshes: Mesh[]);
  71759. /**
  71760. * Gets wether or not G buffer are supported by the running hardware.
  71761. * This requires draw buffer supports
  71762. */
  71763. get isSupported(): boolean;
  71764. /**
  71765. * Returns the index of the given texture type in the G-Buffer textures array
  71766. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  71767. * @returns the index of the given texture type in the G-Buffer textures array
  71768. */
  71769. getTextureIndex(textureType: number): number;
  71770. /**
  71771. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  71772. */
  71773. get enablePosition(): boolean;
  71774. /**
  71775. * Sets whether or not objects positions are enabled for the G buffer.
  71776. */
  71777. set enablePosition(enable: boolean);
  71778. /**
  71779. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  71780. */
  71781. get enableVelocity(): boolean;
  71782. /**
  71783. * Sets wether or not objects velocities are enabled for the G buffer.
  71784. */
  71785. set enableVelocity(enable: boolean);
  71786. /**
  71787. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  71788. */
  71789. get enableReflectivity(): boolean;
  71790. /**
  71791. * Sets wether or not objects roughness are enabled for the G buffer.
  71792. */
  71793. set enableReflectivity(enable: boolean);
  71794. /**
  71795. * Gets the scene associated with the buffer.
  71796. */
  71797. get scene(): Scene;
  71798. /**
  71799. * Gets the ratio used by the buffer during its creation.
  71800. * How big is the buffer related to the main canvas.
  71801. */
  71802. get ratio(): number;
  71803. /** @hidden */
  71804. static _SceneComponentInitialization: (scene: Scene) => void;
  71805. /**
  71806. * Creates a new G Buffer for the scene
  71807. * @param scene The scene the buffer belongs to
  71808. * @param ratio How big is the buffer related to the main canvas.
  71809. */
  71810. constructor(scene: Scene, ratio?: number);
  71811. /**
  71812. * Checks wether everything is ready to render a submesh to the G buffer.
  71813. * @param subMesh the submesh to check readiness for
  71814. * @param useInstances is the mesh drawn using instance or not
  71815. * @returns true if ready otherwise false
  71816. */
  71817. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71818. /**
  71819. * Gets the current underlying G Buffer.
  71820. * @returns the buffer
  71821. */
  71822. getGBuffer(): MultiRenderTarget;
  71823. /**
  71824. * Gets the number of samples used to render the buffer (anti aliasing).
  71825. */
  71826. get samples(): number;
  71827. /**
  71828. * Sets the number of samples used to render the buffer (anti aliasing).
  71829. */
  71830. set samples(value: number);
  71831. /**
  71832. * Disposes the renderer and frees up associated resources.
  71833. */
  71834. dispose(): void;
  71835. protected _createRenderTargets(): void;
  71836. private _copyBonesTransformationMatrices;
  71837. }
  71838. }
  71839. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  71840. import { Nullable } from "babylonjs/types";
  71841. import { Scene } from "babylonjs/scene";
  71842. import { ISceneComponent } from "babylonjs/sceneComponent";
  71843. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  71844. module "babylonjs/scene" {
  71845. interface Scene {
  71846. /** @hidden (Backing field) */
  71847. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71848. /**
  71849. * Gets or Sets the current geometry buffer associated to the scene.
  71850. */
  71851. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71852. /**
  71853. * Enables a GeometryBufferRender and associates it with the scene
  71854. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  71855. * @returns the GeometryBufferRenderer
  71856. */
  71857. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  71858. /**
  71859. * Disables the GeometryBufferRender associated with the scene
  71860. */
  71861. disableGeometryBufferRenderer(): void;
  71862. }
  71863. }
  71864. /**
  71865. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71866. * in several rendering techniques.
  71867. */
  71868. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  71869. /**
  71870. * The component name helpful to identify the component in the list of scene components.
  71871. */
  71872. readonly name: string;
  71873. /**
  71874. * The scene the component belongs to.
  71875. */
  71876. scene: Scene;
  71877. /**
  71878. * Creates a new instance of the component for the given scene
  71879. * @param scene Defines the scene to register the component in
  71880. */
  71881. constructor(scene: Scene);
  71882. /**
  71883. * Registers the component in a given scene
  71884. */
  71885. register(): void;
  71886. /**
  71887. * Rebuilds the elements related to this component in case of
  71888. * context lost for instance.
  71889. */
  71890. rebuild(): void;
  71891. /**
  71892. * Disposes the component and the associated ressources
  71893. */
  71894. dispose(): void;
  71895. private _gatherRenderTargets;
  71896. }
  71897. }
  71898. declare module "babylonjs/Shaders/motionBlur.fragment" {
  71899. /** @hidden */
  71900. export var motionBlurPixelShader: {
  71901. name: string;
  71902. shader: string;
  71903. };
  71904. }
  71905. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  71906. import { Nullable } from "babylonjs/types";
  71907. import { Camera } from "babylonjs/Cameras/camera";
  71908. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71909. import { Scene } from "babylonjs/scene";
  71910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71911. import "babylonjs/Animations/animatable";
  71912. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  71913. import "babylonjs/Shaders/motionBlur.fragment";
  71914. import { Engine } from "babylonjs/Engines/engine";
  71915. /**
  71916. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  71917. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  71918. * As an example, all you have to do is to create the post-process:
  71919. * var mb = new BABYLON.MotionBlurPostProcess(
  71920. * 'mb', // The name of the effect.
  71921. * scene, // The scene containing the objects to blur according to their velocity.
  71922. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  71923. * camera // The camera to apply the render pass to.
  71924. * );
  71925. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  71926. */
  71927. export class MotionBlurPostProcess extends PostProcess {
  71928. /**
  71929. * Defines how much the image is blurred by the movement. Default value is equal to 1
  71930. */
  71931. motionStrength: number;
  71932. /**
  71933. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  71934. */
  71935. get motionBlurSamples(): number;
  71936. /**
  71937. * Sets the number of iterations to be used for motion blur quality
  71938. */
  71939. set motionBlurSamples(samples: number);
  71940. private _motionBlurSamples;
  71941. private _geometryBufferRenderer;
  71942. /**
  71943. * Creates a new instance MotionBlurPostProcess
  71944. * @param name The name of the effect.
  71945. * @param scene The scene containing the objects to blur according to their velocity.
  71946. * @param options The required width/height ratio to downsize to before computing the render pass.
  71947. * @param camera The camera to apply the render pass to.
  71948. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71949. * @param engine The engine which the post process will be applied. (default: current engine)
  71950. * @param reusable If the post process can be reused on the same frame. (default: false)
  71951. * @param textureType Type of textures used when performing the post process. (default: 0)
  71952. * @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)
  71953. */
  71954. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71955. /**
  71956. * Excludes the given skinned mesh from computing bones velocities.
  71957. * 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.
  71958. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  71959. */
  71960. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71961. /**
  71962. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  71963. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  71964. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  71965. */
  71966. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71967. /**
  71968. * Disposes the post process.
  71969. * @param camera The camera to dispose the post process on.
  71970. */
  71971. dispose(camera?: Camera): void;
  71972. }
  71973. }
  71974. declare module "babylonjs/Shaders/refraction.fragment" {
  71975. /** @hidden */
  71976. export var refractionPixelShader: {
  71977. name: string;
  71978. shader: string;
  71979. };
  71980. }
  71981. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  71982. import { Color3 } from "babylonjs/Maths/math.color";
  71983. import { Camera } from "babylonjs/Cameras/camera";
  71984. import { Texture } from "babylonjs/Materials/Textures/texture";
  71985. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71986. import { Engine } from "babylonjs/Engines/engine";
  71987. import "babylonjs/Shaders/refraction.fragment";
  71988. /**
  71989. * Post process which applies a refractin texture
  71990. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71991. */
  71992. export class RefractionPostProcess extends PostProcess {
  71993. /** the base color of the refraction (used to taint the rendering) */
  71994. color: Color3;
  71995. /** simulated refraction depth */
  71996. depth: number;
  71997. /** the coefficient of the base color (0 to remove base color tainting) */
  71998. colorLevel: number;
  71999. private _refTexture;
  72000. private _ownRefractionTexture;
  72001. /**
  72002. * Gets or sets the refraction texture
  72003. * Please note that you are responsible for disposing the texture if you set it manually
  72004. */
  72005. get refractionTexture(): Texture;
  72006. set refractionTexture(value: Texture);
  72007. /**
  72008. * Initializes the RefractionPostProcess
  72009. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72010. * @param name The name of the effect.
  72011. * @param refractionTextureUrl Url of the refraction texture to use
  72012. * @param color the base color of the refraction (used to taint the rendering)
  72013. * @param depth simulated refraction depth
  72014. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  72015. * @param camera The camera to apply the render pass to.
  72016. * @param options The required width/height ratio to downsize to before computing the render pass.
  72017. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72018. * @param engine The engine which the post process will be applied. (default: current engine)
  72019. * @param reusable If the post process can be reused on the same frame. (default: false)
  72020. */
  72021. constructor(name: string, refractionTextureUrl: string,
  72022. /** the base color of the refraction (used to taint the rendering) */
  72023. color: Color3,
  72024. /** simulated refraction depth */
  72025. depth: number,
  72026. /** the coefficient of the base color (0 to remove base color tainting) */
  72027. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72028. /**
  72029. * Disposes of the post process
  72030. * @param camera Camera to dispose post process on
  72031. */
  72032. dispose(camera: Camera): void;
  72033. }
  72034. }
  72035. declare module "babylonjs/Shaders/sharpen.fragment" {
  72036. /** @hidden */
  72037. export var sharpenPixelShader: {
  72038. name: string;
  72039. shader: string;
  72040. };
  72041. }
  72042. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  72043. import { Nullable } from "babylonjs/types";
  72044. import { Camera } from "babylonjs/Cameras/camera";
  72045. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72046. import "babylonjs/Shaders/sharpen.fragment";
  72047. import { Engine } from "babylonjs/Engines/engine";
  72048. /**
  72049. * The SharpenPostProcess applies a sharpen kernel to every pixel
  72050. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72051. */
  72052. export class SharpenPostProcess extends PostProcess {
  72053. /**
  72054. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  72055. */
  72056. colorAmount: number;
  72057. /**
  72058. * How much sharpness should be applied (default: 0.3)
  72059. */
  72060. edgeAmount: number;
  72061. /**
  72062. * Creates a new instance ConvolutionPostProcess
  72063. * @param name The name of the effect.
  72064. * @param options The required width/height ratio to downsize to before computing the render pass.
  72065. * @param camera The camera to apply the render pass to.
  72066. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72067. * @param engine The engine which the post process will be applied. (default: current engine)
  72068. * @param reusable If the post process can be reused on the same frame. (default: false)
  72069. * @param textureType Type of textures used when performing the post process. (default: 0)
  72070. * @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)
  72071. */
  72072. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72073. }
  72074. }
  72075. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  72076. import { Nullable } from "babylonjs/types";
  72077. import { Camera } from "babylonjs/Cameras/camera";
  72078. import { Engine } from "babylonjs/Engines/engine";
  72079. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72080. import { IInspectable } from "babylonjs/Misc/iInspectable";
  72081. /**
  72082. * PostProcessRenderPipeline
  72083. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72084. */
  72085. export class PostProcessRenderPipeline {
  72086. private engine;
  72087. private _renderEffects;
  72088. private _renderEffectsForIsolatedPass;
  72089. /**
  72090. * List of inspectable custom properties (used by the Inspector)
  72091. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72092. */
  72093. inspectableCustomProperties: IInspectable[];
  72094. /**
  72095. * @hidden
  72096. */
  72097. protected _cameras: Camera[];
  72098. /** @hidden */
  72099. _name: string;
  72100. /**
  72101. * Gets pipeline name
  72102. */
  72103. get name(): string;
  72104. /** Gets the list of attached cameras */
  72105. get cameras(): Camera[];
  72106. /**
  72107. * Initializes a PostProcessRenderPipeline
  72108. * @param engine engine to add the pipeline to
  72109. * @param name name of the pipeline
  72110. */
  72111. constructor(engine: Engine, name: string);
  72112. /**
  72113. * Gets the class name
  72114. * @returns "PostProcessRenderPipeline"
  72115. */
  72116. getClassName(): string;
  72117. /**
  72118. * If all the render effects in the pipeline are supported
  72119. */
  72120. get isSupported(): boolean;
  72121. /**
  72122. * Adds an effect to the pipeline
  72123. * @param renderEffect the effect to add
  72124. */
  72125. addEffect(renderEffect: PostProcessRenderEffect): void;
  72126. /** @hidden */
  72127. _rebuild(): void;
  72128. /** @hidden */
  72129. _enableEffect(renderEffectName: string, cameras: Camera): void;
  72130. /** @hidden */
  72131. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  72132. /** @hidden */
  72133. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72134. /** @hidden */
  72135. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72136. /** @hidden */
  72137. _attachCameras(cameras: Camera, unique: boolean): void;
  72138. /** @hidden */
  72139. _attachCameras(cameras: Camera[], unique: boolean): void;
  72140. /** @hidden */
  72141. _detachCameras(cameras: Camera): void;
  72142. /** @hidden */
  72143. _detachCameras(cameras: Nullable<Camera[]>): void;
  72144. /** @hidden */
  72145. _update(): void;
  72146. /** @hidden */
  72147. _reset(): void;
  72148. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  72149. /**
  72150. * Disposes of the pipeline
  72151. */
  72152. dispose(): void;
  72153. }
  72154. }
  72155. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  72156. import { Camera } from "babylonjs/Cameras/camera";
  72157. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72158. /**
  72159. * PostProcessRenderPipelineManager class
  72160. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72161. */
  72162. export class PostProcessRenderPipelineManager {
  72163. private _renderPipelines;
  72164. /**
  72165. * Initializes a PostProcessRenderPipelineManager
  72166. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72167. */
  72168. constructor();
  72169. /**
  72170. * Gets the list of supported render pipelines
  72171. */
  72172. get supportedPipelines(): PostProcessRenderPipeline[];
  72173. /**
  72174. * Adds a pipeline to the manager
  72175. * @param renderPipeline The pipeline to add
  72176. */
  72177. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  72178. /**
  72179. * Attaches a camera to the pipeline
  72180. * @param renderPipelineName The name of the pipeline to attach to
  72181. * @param cameras the camera to attach
  72182. * @param unique if the camera can be attached multiple times to the pipeline
  72183. */
  72184. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  72185. /**
  72186. * Detaches a camera from the pipeline
  72187. * @param renderPipelineName The name of the pipeline to detach from
  72188. * @param cameras the camera to detach
  72189. */
  72190. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  72191. /**
  72192. * Enables an effect by name on a pipeline
  72193. * @param renderPipelineName the name of the pipeline to enable the effect in
  72194. * @param renderEffectName the name of the effect to enable
  72195. * @param cameras the cameras that the effect should be enabled on
  72196. */
  72197. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72198. /**
  72199. * Disables an effect by name on a pipeline
  72200. * @param renderPipelineName the name of the pipeline to disable the effect in
  72201. * @param renderEffectName the name of the effect to disable
  72202. * @param cameras the cameras that the effect should be disabled on
  72203. */
  72204. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72205. /**
  72206. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  72207. */
  72208. update(): void;
  72209. /** @hidden */
  72210. _rebuild(): void;
  72211. /**
  72212. * Disposes of the manager and pipelines
  72213. */
  72214. dispose(): void;
  72215. }
  72216. }
  72217. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  72218. import { ISceneComponent } from "babylonjs/sceneComponent";
  72219. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  72220. import { Scene } from "babylonjs/scene";
  72221. module "babylonjs/scene" {
  72222. interface Scene {
  72223. /** @hidden (Backing field) */
  72224. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72225. /**
  72226. * Gets the postprocess render pipeline manager
  72227. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72228. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72229. */
  72230. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72231. }
  72232. }
  72233. /**
  72234. * Defines the Render Pipeline scene component responsible to rendering pipelines
  72235. */
  72236. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  72237. /**
  72238. * The component name helpfull to identify the component in the list of scene components.
  72239. */
  72240. readonly name: string;
  72241. /**
  72242. * The scene the component belongs to.
  72243. */
  72244. scene: Scene;
  72245. /**
  72246. * Creates a new instance of the component for the given scene
  72247. * @param scene Defines the scene to register the component in
  72248. */
  72249. constructor(scene: Scene);
  72250. /**
  72251. * Registers the component in a given scene
  72252. */
  72253. register(): void;
  72254. /**
  72255. * Rebuilds the elements related to this component in case of
  72256. * context lost for instance.
  72257. */
  72258. rebuild(): void;
  72259. /**
  72260. * Disposes the component and the associated ressources
  72261. */
  72262. dispose(): void;
  72263. private _gatherRenderTargets;
  72264. }
  72265. }
  72266. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  72267. import { Nullable } from "babylonjs/types";
  72268. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72269. import { Camera } from "babylonjs/Cameras/camera";
  72270. import { IDisposable } from "babylonjs/scene";
  72271. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  72272. import { Scene } from "babylonjs/scene";
  72273. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  72274. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  72275. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  72276. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  72277. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  72278. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72279. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  72280. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72281. import { Animation } from "babylonjs/Animations/animation";
  72282. /**
  72283. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  72284. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72285. */
  72286. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72287. private _scene;
  72288. private _camerasToBeAttached;
  72289. /**
  72290. * ID of the sharpen post process,
  72291. */
  72292. private readonly SharpenPostProcessId;
  72293. /**
  72294. * @ignore
  72295. * ID of the image processing post process;
  72296. */
  72297. readonly ImageProcessingPostProcessId: string;
  72298. /**
  72299. * @ignore
  72300. * ID of the Fast Approximate Anti-Aliasing post process;
  72301. */
  72302. readonly FxaaPostProcessId: string;
  72303. /**
  72304. * ID of the chromatic aberration post process,
  72305. */
  72306. private readonly ChromaticAberrationPostProcessId;
  72307. /**
  72308. * ID of the grain post process
  72309. */
  72310. private readonly GrainPostProcessId;
  72311. /**
  72312. * Sharpen post process which will apply a sharpen convolution to enhance edges
  72313. */
  72314. sharpen: SharpenPostProcess;
  72315. private _sharpenEffect;
  72316. private bloom;
  72317. /**
  72318. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  72319. */
  72320. depthOfField: DepthOfFieldEffect;
  72321. /**
  72322. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72323. */
  72324. fxaa: FxaaPostProcess;
  72325. /**
  72326. * Image post processing pass used to perform operations such as tone mapping or color grading.
  72327. */
  72328. imageProcessing: ImageProcessingPostProcess;
  72329. /**
  72330. * Chromatic aberration post process which will shift rgb colors in the image
  72331. */
  72332. chromaticAberration: ChromaticAberrationPostProcess;
  72333. private _chromaticAberrationEffect;
  72334. /**
  72335. * Grain post process which add noise to the image
  72336. */
  72337. grain: GrainPostProcess;
  72338. private _grainEffect;
  72339. /**
  72340. * Glow post process which adds a glow to emissive areas of the image
  72341. */
  72342. private _glowLayer;
  72343. /**
  72344. * Animations which can be used to tweak settings over a period of time
  72345. */
  72346. animations: Animation[];
  72347. private _imageProcessingConfigurationObserver;
  72348. private _sharpenEnabled;
  72349. private _bloomEnabled;
  72350. private _depthOfFieldEnabled;
  72351. private _depthOfFieldBlurLevel;
  72352. private _fxaaEnabled;
  72353. private _imageProcessingEnabled;
  72354. private _defaultPipelineTextureType;
  72355. private _bloomScale;
  72356. private _chromaticAberrationEnabled;
  72357. private _grainEnabled;
  72358. private _buildAllowed;
  72359. /**
  72360. * Gets active scene
  72361. */
  72362. get scene(): Scene;
  72363. /**
  72364. * Enable or disable the sharpen process from the pipeline
  72365. */
  72366. set sharpenEnabled(enabled: boolean);
  72367. get sharpenEnabled(): boolean;
  72368. private _resizeObserver;
  72369. private _hardwareScaleLevel;
  72370. private _bloomKernel;
  72371. /**
  72372. * Specifies the size of the bloom blur kernel, relative to the final output size
  72373. */
  72374. get bloomKernel(): number;
  72375. set bloomKernel(value: number);
  72376. /**
  72377. * Specifies the weight of the bloom in the final rendering
  72378. */
  72379. private _bloomWeight;
  72380. /**
  72381. * Specifies the luma threshold for the area that will be blurred by the bloom
  72382. */
  72383. private _bloomThreshold;
  72384. private _hdr;
  72385. /**
  72386. * The strength of the bloom.
  72387. */
  72388. set bloomWeight(value: number);
  72389. get bloomWeight(): number;
  72390. /**
  72391. * The strength of the bloom.
  72392. */
  72393. set bloomThreshold(value: number);
  72394. get bloomThreshold(): number;
  72395. /**
  72396. * The scale of the bloom, lower value will provide better performance.
  72397. */
  72398. set bloomScale(value: number);
  72399. get bloomScale(): number;
  72400. /**
  72401. * Enable or disable the bloom from the pipeline
  72402. */
  72403. set bloomEnabled(enabled: boolean);
  72404. get bloomEnabled(): boolean;
  72405. private _rebuildBloom;
  72406. /**
  72407. * If the depth of field is enabled.
  72408. */
  72409. get depthOfFieldEnabled(): boolean;
  72410. set depthOfFieldEnabled(enabled: boolean);
  72411. /**
  72412. * Blur level of the depth of field effect. (Higher blur will effect performance)
  72413. */
  72414. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  72415. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  72416. /**
  72417. * If the anti aliasing is enabled.
  72418. */
  72419. set fxaaEnabled(enabled: boolean);
  72420. get fxaaEnabled(): boolean;
  72421. private _samples;
  72422. /**
  72423. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72424. */
  72425. set samples(sampleCount: number);
  72426. get samples(): number;
  72427. /**
  72428. * If image processing is enabled.
  72429. */
  72430. set imageProcessingEnabled(enabled: boolean);
  72431. get imageProcessingEnabled(): boolean;
  72432. /**
  72433. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  72434. */
  72435. set glowLayerEnabled(enabled: boolean);
  72436. get glowLayerEnabled(): boolean;
  72437. /**
  72438. * Gets the glow layer (or null if not defined)
  72439. */
  72440. get glowLayer(): Nullable<GlowLayer>;
  72441. /**
  72442. * Enable or disable the chromaticAberration process from the pipeline
  72443. */
  72444. set chromaticAberrationEnabled(enabled: boolean);
  72445. get chromaticAberrationEnabled(): boolean;
  72446. /**
  72447. * Enable or disable the grain process from the pipeline
  72448. */
  72449. set grainEnabled(enabled: boolean);
  72450. get grainEnabled(): boolean;
  72451. /**
  72452. * @constructor
  72453. * @param name - The rendering pipeline name (default: "")
  72454. * @param hdr - If high dynamic range textures should be used (default: true)
  72455. * @param scene - The scene linked to this pipeline (default: the last created scene)
  72456. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  72457. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  72458. */
  72459. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  72460. /**
  72461. * Get the class name
  72462. * @returns "DefaultRenderingPipeline"
  72463. */
  72464. getClassName(): string;
  72465. /**
  72466. * Force the compilation of the entire pipeline.
  72467. */
  72468. prepare(): void;
  72469. private _hasCleared;
  72470. private _prevPostProcess;
  72471. private _prevPrevPostProcess;
  72472. private _setAutoClearAndTextureSharing;
  72473. private _depthOfFieldSceneObserver;
  72474. private _buildPipeline;
  72475. private _disposePostProcesses;
  72476. /**
  72477. * Adds a camera to the pipeline
  72478. * @param camera the camera to be added
  72479. */
  72480. addCamera(camera: Camera): void;
  72481. /**
  72482. * Removes a camera from the pipeline
  72483. * @param camera the camera to remove
  72484. */
  72485. removeCamera(camera: Camera): void;
  72486. /**
  72487. * Dispose of the pipeline and stop all post processes
  72488. */
  72489. dispose(): void;
  72490. /**
  72491. * Serialize the rendering pipeline (Used when exporting)
  72492. * @returns the serialized object
  72493. */
  72494. serialize(): any;
  72495. /**
  72496. * Parse the serialized pipeline
  72497. * @param source Source pipeline.
  72498. * @param scene The scene to load the pipeline to.
  72499. * @param rootUrl The URL of the serialized pipeline.
  72500. * @returns An instantiated pipeline from the serialized object.
  72501. */
  72502. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  72503. }
  72504. }
  72505. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  72506. /** @hidden */
  72507. export var lensHighlightsPixelShader: {
  72508. name: string;
  72509. shader: string;
  72510. };
  72511. }
  72512. declare module "babylonjs/Shaders/depthOfField.fragment" {
  72513. /** @hidden */
  72514. export var depthOfFieldPixelShader: {
  72515. name: string;
  72516. shader: string;
  72517. };
  72518. }
  72519. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  72520. import { Camera } from "babylonjs/Cameras/camera";
  72521. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72522. import { Scene } from "babylonjs/scene";
  72523. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72524. import "babylonjs/Shaders/chromaticAberration.fragment";
  72525. import "babylonjs/Shaders/lensHighlights.fragment";
  72526. import "babylonjs/Shaders/depthOfField.fragment";
  72527. /**
  72528. * BABYLON.JS Chromatic Aberration GLSL Shader
  72529. * Author: Olivier Guyot
  72530. * Separates very slightly R, G and B colors on the edges of the screen
  72531. * Inspired by Francois Tarlier & Martins Upitis
  72532. */
  72533. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  72534. /**
  72535. * @ignore
  72536. * The chromatic aberration PostProcess id in the pipeline
  72537. */
  72538. LensChromaticAberrationEffect: string;
  72539. /**
  72540. * @ignore
  72541. * The highlights enhancing PostProcess id in the pipeline
  72542. */
  72543. HighlightsEnhancingEffect: string;
  72544. /**
  72545. * @ignore
  72546. * The depth-of-field PostProcess id in the pipeline
  72547. */
  72548. LensDepthOfFieldEffect: string;
  72549. private _scene;
  72550. private _depthTexture;
  72551. private _grainTexture;
  72552. private _chromaticAberrationPostProcess;
  72553. private _highlightsPostProcess;
  72554. private _depthOfFieldPostProcess;
  72555. private _edgeBlur;
  72556. private _grainAmount;
  72557. private _chromaticAberration;
  72558. private _distortion;
  72559. private _highlightsGain;
  72560. private _highlightsThreshold;
  72561. private _dofDistance;
  72562. private _dofAperture;
  72563. private _dofDarken;
  72564. private _dofPentagon;
  72565. private _blurNoise;
  72566. /**
  72567. * @constructor
  72568. *
  72569. * Effect parameters are as follow:
  72570. * {
  72571. * chromatic_aberration: number; // from 0 to x (1 for realism)
  72572. * edge_blur: number; // from 0 to x (1 for realism)
  72573. * distortion: number; // from 0 to x (1 for realism)
  72574. * grain_amount: number; // from 0 to 1
  72575. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  72576. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  72577. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  72578. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  72579. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  72580. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  72581. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  72582. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  72583. * }
  72584. * Note: if an effect parameter is unset, effect is disabled
  72585. *
  72586. * @param name The rendering pipeline name
  72587. * @param parameters - An object containing all parameters (see above)
  72588. * @param scene The scene linked to this pipeline
  72589. * @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)
  72590. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72591. */
  72592. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  72593. /**
  72594. * Get the class name
  72595. * @returns "LensRenderingPipeline"
  72596. */
  72597. getClassName(): string;
  72598. /**
  72599. * Gets associated scene
  72600. */
  72601. get scene(): Scene;
  72602. /**
  72603. * Gets or sets the edge blur
  72604. */
  72605. get edgeBlur(): number;
  72606. set edgeBlur(value: number);
  72607. /**
  72608. * Gets or sets the grain amount
  72609. */
  72610. get grainAmount(): number;
  72611. set grainAmount(value: number);
  72612. /**
  72613. * Gets or sets the chromatic aberration amount
  72614. */
  72615. get chromaticAberration(): number;
  72616. set chromaticAberration(value: number);
  72617. /**
  72618. * Gets or sets the depth of field aperture
  72619. */
  72620. get dofAperture(): number;
  72621. set dofAperture(value: number);
  72622. /**
  72623. * Gets or sets the edge distortion
  72624. */
  72625. get edgeDistortion(): number;
  72626. set edgeDistortion(value: number);
  72627. /**
  72628. * Gets or sets the depth of field distortion
  72629. */
  72630. get dofDistortion(): number;
  72631. set dofDistortion(value: number);
  72632. /**
  72633. * Gets or sets the darken out of focus amount
  72634. */
  72635. get darkenOutOfFocus(): number;
  72636. set darkenOutOfFocus(value: number);
  72637. /**
  72638. * Gets or sets a boolean indicating if blur noise is enabled
  72639. */
  72640. get blurNoise(): boolean;
  72641. set blurNoise(value: boolean);
  72642. /**
  72643. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  72644. */
  72645. get pentagonBokeh(): boolean;
  72646. set pentagonBokeh(value: boolean);
  72647. /**
  72648. * Gets or sets the highlight grain amount
  72649. */
  72650. get highlightsGain(): number;
  72651. set highlightsGain(value: number);
  72652. /**
  72653. * Gets or sets the highlight threshold
  72654. */
  72655. get highlightsThreshold(): number;
  72656. set highlightsThreshold(value: number);
  72657. /**
  72658. * Sets the amount of blur at the edges
  72659. * @param amount blur amount
  72660. */
  72661. setEdgeBlur(amount: number): void;
  72662. /**
  72663. * Sets edge blur to 0
  72664. */
  72665. disableEdgeBlur(): void;
  72666. /**
  72667. * Sets the amout of grain
  72668. * @param amount Amount of grain
  72669. */
  72670. setGrainAmount(amount: number): void;
  72671. /**
  72672. * Set grain amount to 0
  72673. */
  72674. disableGrain(): void;
  72675. /**
  72676. * Sets the chromatic aberration amount
  72677. * @param amount amount of chromatic aberration
  72678. */
  72679. setChromaticAberration(amount: number): void;
  72680. /**
  72681. * Sets chromatic aberration amount to 0
  72682. */
  72683. disableChromaticAberration(): void;
  72684. /**
  72685. * Sets the EdgeDistortion amount
  72686. * @param amount amount of EdgeDistortion
  72687. */
  72688. setEdgeDistortion(amount: number): void;
  72689. /**
  72690. * Sets edge distortion to 0
  72691. */
  72692. disableEdgeDistortion(): void;
  72693. /**
  72694. * Sets the FocusDistance amount
  72695. * @param amount amount of FocusDistance
  72696. */
  72697. setFocusDistance(amount: number): void;
  72698. /**
  72699. * Disables depth of field
  72700. */
  72701. disableDepthOfField(): void;
  72702. /**
  72703. * Sets the Aperture amount
  72704. * @param amount amount of Aperture
  72705. */
  72706. setAperture(amount: number): void;
  72707. /**
  72708. * Sets the DarkenOutOfFocus amount
  72709. * @param amount amount of DarkenOutOfFocus
  72710. */
  72711. setDarkenOutOfFocus(amount: number): void;
  72712. private _pentagonBokehIsEnabled;
  72713. /**
  72714. * Creates a pentagon bokeh effect
  72715. */
  72716. enablePentagonBokeh(): void;
  72717. /**
  72718. * Disables the pentagon bokeh effect
  72719. */
  72720. disablePentagonBokeh(): void;
  72721. /**
  72722. * Enables noise blur
  72723. */
  72724. enableNoiseBlur(): void;
  72725. /**
  72726. * Disables noise blur
  72727. */
  72728. disableNoiseBlur(): void;
  72729. /**
  72730. * Sets the HighlightsGain amount
  72731. * @param amount amount of HighlightsGain
  72732. */
  72733. setHighlightsGain(amount: number): void;
  72734. /**
  72735. * Sets the HighlightsThreshold amount
  72736. * @param amount amount of HighlightsThreshold
  72737. */
  72738. setHighlightsThreshold(amount: number): void;
  72739. /**
  72740. * Disables highlights
  72741. */
  72742. disableHighlights(): void;
  72743. /**
  72744. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  72745. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  72746. */
  72747. dispose(disableDepthRender?: boolean): void;
  72748. private _createChromaticAberrationPostProcess;
  72749. private _createHighlightsPostProcess;
  72750. private _createDepthOfFieldPostProcess;
  72751. private _createGrainTexture;
  72752. }
  72753. }
  72754. declare module "babylonjs/Shaders/ssao2.fragment" {
  72755. /** @hidden */
  72756. export var ssao2PixelShader: {
  72757. name: string;
  72758. shader: string;
  72759. };
  72760. }
  72761. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  72762. /** @hidden */
  72763. export var ssaoCombinePixelShader: {
  72764. name: string;
  72765. shader: string;
  72766. };
  72767. }
  72768. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  72769. import { Camera } from "babylonjs/Cameras/camera";
  72770. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72771. import { Scene } from "babylonjs/scene";
  72772. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72773. import "babylonjs/Shaders/ssao2.fragment";
  72774. import "babylonjs/Shaders/ssaoCombine.fragment";
  72775. /**
  72776. * Render pipeline to produce ssao effect
  72777. */
  72778. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  72779. /**
  72780. * @ignore
  72781. * The PassPostProcess id in the pipeline that contains the original scene color
  72782. */
  72783. SSAOOriginalSceneColorEffect: string;
  72784. /**
  72785. * @ignore
  72786. * The SSAO PostProcess id in the pipeline
  72787. */
  72788. SSAORenderEffect: string;
  72789. /**
  72790. * @ignore
  72791. * The horizontal blur PostProcess id in the pipeline
  72792. */
  72793. SSAOBlurHRenderEffect: string;
  72794. /**
  72795. * @ignore
  72796. * The vertical blur PostProcess id in the pipeline
  72797. */
  72798. SSAOBlurVRenderEffect: string;
  72799. /**
  72800. * @ignore
  72801. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72802. */
  72803. SSAOCombineRenderEffect: string;
  72804. /**
  72805. * The output strength of the SSAO post-process. Default value is 1.0.
  72806. */
  72807. totalStrength: number;
  72808. /**
  72809. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  72810. */
  72811. maxZ: number;
  72812. /**
  72813. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  72814. */
  72815. minZAspect: number;
  72816. private _samples;
  72817. /**
  72818. * Number of samples used for the SSAO calculations. Default value is 8
  72819. */
  72820. set samples(n: number);
  72821. get samples(): number;
  72822. private _textureSamples;
  72823. /**
  72824. * Number of samples to use for antialiasing
  72825. */
  72826. set textureSamples(n: number);
  72827. get textureSamples(): number;
  72828. /**
  72829. * Ratio object used for SSAO ratio and blur ratio
  72830. */
  72831. private _ratio;
  72832. /**
  72833. * Dynamically generated sphere sampler.
  72834. */
  72835. private _sampleSphere;
  72836. /**
  72837. * Blur filter offsets
  72838. */
  72839. private _samplerOffsets;
  72840. private _expensiveBlur;
  72841. /**
  72842. * If bilateral blur should be used
  72843. */
  72844. set expensiveBlur(b: boolean);
  72845. get expensiveBlur(): boolean;
  72846. /**
  72847. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  72848. */
  72849. radius: number;
  72850. /**
  72851. * The base color of the SSAO post-process
  72852. * The final result is "base + ssao" between [0, 1]
  72853. */
  72854. base: number;
  72855. /**
  72856. * Support test.
  72857. */
  72858. static get IsSupported(): boolean;
  72859. private _scene;
  72860. private _depthTexture;
  72861. private _normalTexture;
  72862. private _randomTexture;
  72863. private _originalColorPostProcess;
  72864. private _ssaoPostProcess;
  72865. private _blurHPostProcess;
  72866. private _blurVPostProcess;
  72867. private _ssaoCombinePostProcess;
  72868. /**
  72869. * Gets active scene
  72870. */
  72871. get scene(): Scene;
  72872. /**
  72873. * @constructor
  72874. * @param name The rendering pipeline name
  72875. * @param scene The scene linked to this pipeline
  72876. * @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 }
  72877. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72878. */
  72879. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72880. /**
  72881. * Get the class name
  72882. * @returns "SSAO2RenderingPipeline"
  72883. */
  72884. getClassName(): string;
  72885. /**
  72886. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72887. */
  72888. dispose(disableGeometryBufferRenderer?: boolean): void;
  72889. private _createBlurPostProcess;
  72890. /** @hidden */
  72891. _rebuild(): void;
  72892. private _bits;
  72893. private _radicalInverse_VdC;
  72894. private _hammersley;
  72895. private _hemisphereSample_uniform;
  72896. private _generateHemisphere;
  72897. private _createSSAOPostProcess;
  72898. private _createSSAOCombinePostProcess;
  72899. private _createRandomTexture;
  72900. /**
  72901. * Serialize the rendering pipeline (Used when exporting)
  72902. * @returns the serialized object
  72903. */
  72904. serialize(): any;
  72905. /**
  72906. * Parse the serialized pipeline
  72907. * @param source Source pipeline.
  72908. * @param scene The scene to load the pipeline to.
  72909. * @param rootUrl The URL of the serialized pipeline.
  72910. * @returns An instantiated pipeline from the serialized object.
  72911. */
  72912. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  72913. }
  72914. }
  72915. declare module "babylonjs/Shaders/ssao.fragment" {
  72916. /** @hidden */
  72917. export var ssaoPixelShader: {
  72918. name: string;
  72919. shader: string;
  72920. };
  72921. }
  72922. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  72923. import { Camera } from "babylonjs/Cameras/camera";
  72924. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72925. import { Scene } from "babylonjs/scene";
  72926. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72927. import "babylonjs/Shaders/ssao.fragment";
  72928. import "babylonjs/Shaders/ssaoCombine.fragment";
  72929. /**
  72930. * Render pipeline to produce ssao effect
  72931. */
  72932. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  72933. /**
  72934. * @ignore
  72935. * The PassPostProcess id in the pipeline that contains the original scene color
  72936. */
  72937. SSAOOriginalSceneColorEffect: string;
  72938. /**
  72939. * @ignore
  72940. * The SSAO PostProcess id in the pipeline
  72941. */
  72942. SSAORenderEffect: string;
  72943. /**
  72944. * @ignore
  72945. * The horizontal blur PostProcess id in the pipeline
  72946. */
  72947. SSAOBlurHRenderEffect: string;
  72948. /**
  72949. * @ignore
  72950. * The vertical blur PostProcess id in the pipeline
  72951. */
  72952. SSAOBlurVRenderEffect: string;
  72953. /**
  72954. * @ignore
  72955. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72956. */
  72957. SSAOCombineRenderEffect: string;
  72958. /**
  72959. * The output strength of the SSAO post-process. Default value is 1.0.
  72960. */
  72961. totalStrength: number;
  72962. /**
  72963. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  72964. */
  72965. radius: number;
  72966. /**
  72967. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  72968. * Must not be equal to fallOff and superior to fallOff.
  72969. * Default value is 0.0075
  72970. */
  72971. area: number;
  72972. /**
  72973. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  72974. * Must not be equal to area and inferior to area.
  72975. * Default value is 0.000001
  72976. */
  72977. fallOff: number;
  72978. /**
  72979. * The base color of the SSAO post-process
  72980. * The final result is "base + ssao" between [0, 1]
  72981. */
  72982. base: number;
  72983. private _scene;
  72984. private _depthTexture;
  72985. private _randomTexture;
  72986. private _originalColorPostProcess;
  72987. private _ssaoPostProcess;
  72988. private _blurHPostProcess;
  72989. private _blurVPostProcess;
  72990. private _ssaoCombinePostProcess;
  72991. private _firstUpdate;
  72992. /**
  72993. * Gets active scene
  72994. */
  72995. get scene(): Scene;
  72996. /**
  72997. * @constructor
  72998. * @param name - The rendering pipeline name
  72999. * @param scene - The scene linked to this pipeline
  73000. * @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 }
  73001. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  73002. */
  73003. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  73004. /**
  73005. * Get the class name
  73006. * @returns "SSAORenderingPipeline"
  73007. */
  73008. getClassName(): string;
  73009. /**
  73010. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73011. */
  73012. dispose(disableDepthRender?: boolean): void;
  73013. private _createBlurPostProcess;
  73014. /** @hidden */
  73015. _rebuild(): void;
  73016. private _createSSAOPostProcess;
  73017. private _createSSAOCombinePostProcess;
  73018. private _createRandomTexture;
  73019. }
  73020. }
  73021. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  73022. /** @hidden */
  73023. export var screenSpaceReflectionPixelShader: {
  73024. name: string;
  73025. shader: string;
  73026. };
  73027. }
  73028. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  73029. import { Nullable } from "babylonjs/types";
  73030. import { Camera } from "babylonjs/Cameras/camera";
  73031. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73032. import { Scene } from "babylonjs/scene";
  73033. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  73034. import { Engine } from "babylonjs/Engines/engine";
  73035. /**
  73036. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  73037. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  73038. */
  73039. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  73040. /**
  73041. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  73042. */
  73043. threshold: number;
  73044. /**
  73045. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  73046. */
  73047. strength: number;
  73048. /**
  73049. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  73050. */
  73051. reflectionSpecularFalloffExponent: number;
  73052. /**
  73053. * 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]
  73054. */
  73055. step: number;
  73056. /**
  73057. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  73058. */
  73059. roughnessFactor: number;
  73060. private _geometryBufferRenderer;
  73061. private _enableSmoothReflections;
  73062. private _reflectionSamples;
  73063. private _smoothSteps;
  73064. /**
  73065. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  73066. * @param name The name of the effect.
  73067. * @param scene The scene containing the objects to calculate reflections.
  73068. * @param options The required width/height ratio to downsize to before computing the render pass.
  73069. * @param camera The camera to apply the render pass to.
  73070. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73071. * @param engine The engine which the post process will be applied. (default: current engine)
  73072. * @param reusable If the post process can be reused on the same frame. (default: false)
  73073. * @param textureType Type of textures used when performing the post process. (default: 0)
  73074. * @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)
  73075. */
  73076. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73077. /**
  73078. * Gets wether or not smoothing reflections is enabled.
  73079. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  73080. */
  73081. get enableSmoothReflections(): boolean;
  73082. /**
  73083. * Sets wether or not smoothing reflections is enabled.
  73084. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  73085. */
  73086. set enableSmoothReflections(enabled: boolean);
  73087. /**
  73088. * Gets the number of samples taken while computing reflections. More samples count is high,
  73089. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  73090. */
  73091. get reflectionSamples(): number;
  73092. /**
  73093. * Sets the number of samples taken while computing reflections. More samples count is high,
  73094. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  73095. */
  73096. set reflectionSamples(samples: number);
  73097. /**
  73098. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  73099. * more the post-process will require GPU power and can generate a drop in FPS.
  73100. * Default value (5.0) work pretty well in all cases but can be adjusted.
  73101. */
  73102. get smoothSteps(): number;
  73103. set smoothSteps(steps: number);
  73104. private _updateEffectDefines;
  73105. }
  73106. }
  73107. declare module "babylonjs/Shaders/standard.fragment" {
  73108. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  73109. /** @hidden */
  73110. export var standardPixelShader: {
  73111. name: string;
  73112. shader: string;
  73113. };
  73114. }
  73115. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  73116. import { Nullable } from "babylonjs/types";
  73117. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  73118. import { Camera } from "babylonjs/Cameras/camera";
  73119. import { Texture } from "babylonjs/Materials/Textures/texture";
  73120. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73121. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73122. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73123. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  73124. import { IDisposable } from "babylonjs/scene";
  73125. import { SpotLight } from "babylonjs/Lights/spotLight";
  73126. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  73127. import { Scene } from "babylonjs/scene";
  73128. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  73129. import { Animation } from "babylonjs/Animations/animation";
  73130. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73131. import "babylonjs/Shaders/standard.fragment";
  73132. /**
  73133. * Standard rendering pipeline
  73134. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73135. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  73136. */
  73137. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73138. /**
  73139. * Public members
  73140. */
  73141. /**
  73142. * Post-process which contains the original scene color before the pipeline applies all the effects
  73143. */
  73144. originalPostProcess: Nullable<PostProcess>;
  73145. /**
  73146. * Post-process used to down scale an image x4
  73147. */
  73148. downSampleX4PostProcess: Nullable<PostProcess>;
  73149. /**
  73150. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  73151. */
  73152. brightPassPostProcess: Nullable<PostProcess>;
  73153. /**
  73154. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  73155. */
  73156. blurHPostProcesses: PostProcess[];
  73157. /**
  73158. * Post-process array storing all the vertical blur post-processes used by the pipeline
  73159. */
  73160. blurVPostProcesses: PostProcess[];
  73161. /**
  73162. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  73163. */
  73164. textureAdderPostProcess: Nullable<PostProcess>;
  73165. /**
  73166. * Post-process used to create volumetric lighting effect
  73167. */
  73168. volumetricLightPostProcess: Nullable<PostProcess>;
  73169. /**
  73170. * Post-process used to smooth the previous volumetric light post-process on the X axis
  73171. */
  73172. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  73173. /**
  73174. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  73175. */
  73176. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  73177. /**
  73178. * Post-process used to merge the volumetric light effect and the real scene color
  73179. */
  73180. volumetricLightMergePostProces: Nullable<PostProcess>;
  73181. /**
  73182. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  73183. */
  73184. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  73185. /**
  73186. * Base post-process used to calculate the average luminance of the final image for HDR
  73187. */
  73188. luminancePostProcess: Nullable<PostProcess>;
  73189. /**
  73190. * Post-processes used to create down sample post-processes in order to get
  73191. * the average luminance of the final image for HDR
  73192. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  73193. */
  73194. luminanceDownSamplePostProcesses: PostProcess[];
  73195. /**
  73196. * Post-process used to create a HDR effect (light adaptation)
  73197. */
  73198. hdrPostProcess: Nullable<PostProcess>;
  73199. /**
  73200. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  73201. */
  73202. textureAdderFinalPostProcess: Nullable<PostProcess>;
  73203. /**
  73204. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  73205. */
  73206. lensFlareFinalPostProcess: Nullable<PostProcess>;
  73207. /**
  73208. * Post-process used to merge the final HDR post-process and the real scene color
  73209. */
  73210. hdrFinalPostProcess: Nullable<PostProcess>;
  73211. /**
  73212. * Post-process used to create a lens flare effect
  73213. */
  73214. lensFlarePostProcess: Nullable<PostProcess>;
  73215. /**
  73216. * Post-process that merges the result of the lens flare post-process and the real scene color
  73217. */
  73218. lensFlareComposePostProcess: Nullable<PostProcess>;
  73219. /**
  73220. * Post-process used to create a motion blur effect
  73221. */
  73222. motionBlurPostProcess: Nullable<PostProcess>;
  73223. /**
  73224. * Post-process used to create a depth of field effect
  73225. */
  73226. depthOfFieldPostProcess: Nullable<PostProcess>;
  73227. /**
  73228. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  73229. */
  73230. fxaaPostProcess: Nullable<FxaaPostProcess>;
  73231. /**
  73232. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  73233. */
  73234. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  73235. /**
  73236. * Represents the brightness threshold in order to configure the illuminated surfaces
  73237. */
  73238. brightThreshold: number;
  73239. /**
  73240. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  73241. */
  73242. blurWidth: number;
  73243. /**
  73244. * Sets if the blur for highlighted surfaces must be only horizontal
  73245. */
  73246. horizontalBlur: boolean;
  73247. /**
  73248. * Gets the overall exposure used by the pipeline
  73249. */
  73250. get exposure(): number;
  73251. /**
  73252. * Sets the overall exposure used by the pipeline
  73253. */
  73254. set exposure(value: number);
  73255. /**
  73256. * Texture used typically to simulate "dirty" on camera lens
  73257. */
  73258. lensTexture: Nullable<Texture>;
  73259. /**
  73260. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  73261. */
  73262. volumetricLightCoefficient: number;
  73263. /**
  73264. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  73265. */
  73266. volumetricLightPower: number;
  73267. /**
  73268. * Used the set the blur intensity to smooth the volumetric lights
  73269. */
  73270. volumetricLightBlurScale: number;
  73271. /**
  73272. * Light (spot or directional) used to generate the volumetric lights rays
  73273. * The source light must have a shadow generate so the pipeline can get its
  73274. * depth map
  73275. */
  73276. sourceLight: Nullable<SpotLight | DirectionalLight>;
  73277. /**
  73278. * For eye adaptation, represents the minimum luminance the eye can see
  73279. */
  73280. hdrMinimumLuminance: number;
  73281. /**
  73282. * For eye adaptation, represents the decrease luminance speed
  73283. */
  73284. hdrDecreaseRate: number;
  73285. /**
  73286. * For eye adaptation, represents the increase luminance speed
  73287. */
  73288. hdrIncreaseRate: number;
  73289. /**
  73290. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73291. */
  73292. get hdrAutoExposure(): boolean;
  73293. /**
  73294. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73295. */
  73296. set hdrAutoExposure(value: boolean);
  73297. /**
  73298. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  73299. */
  73300. lensColorTexture: Nullable<Texture>;
  73301. /**
  73302. * The overall strengh for the lens flare effect
  73303. */
  73304. lensFlareStrength: number;
  73305. /**
  73306. * Dispersion coefficient for lens flare ghosts
  73307. */
  73308. lensFlareGhostDispersal: number;
  73309. /**
  73310. * Main lens flare halo width
  73311. */
  73312. lensFlareHaloWidth: number;
  73313. /**
  73314. * Based on the lens distortion effect, defines how much the lens flare result
  73315. * is distorted
  73316. */
  73317. lensFlareDistortionStrength: number;
  73318. /**
  73319. * Configures the blur intensity used for for lens flare (halo)
  73320. */
  73321. lensFlareBlurWidth: number;
  73322. /**
  73323. * Lens star texture must be used to simulate rays on the flares and is available
  73324. * in the documentation
  73325. */
  73326. lensStarTexture: Nullable<Texture>;
  73327. /**
  73328. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  73329. * flare effect by taking account of the dirt texture
  73330. */
  73331. lensFlareDirtTexture: Nullable<Texture>;
  73332. /**
  73333. * Represents the focal length for the depth of field effect
  73334. */
  73335. depthOfFieldDistance: number;
  73336. /**
  73337. * Represents the blur intensity for the blurred part of the depth of field effect
  73338. */
  73339. depthOfFieldBlurWidth: number;
  73340. /**
  73341. * Gets how much the image is blurred by the movement while using the motion blur post-process
  73342. */
  73343. get motionStrength(): number;
  73344. /**
  73345. * Sets how much the image is blurred by the movement while using the motion blur post-process
  73346. */
  73347. set motionStrength(strength: number);
  73348. /**
  73349. * Gets wether or not the motion blur post-process is object based or screen based.
  73350. */
  73351. get objectBasedMotionBlur(): boolean;
  73352. /**
  73353. * Sets wether or not the motion blur post-process should be object based or screen based
  73354. */
  73355. set objectBasedMotionBlur(value: boolean);
  73356. /**
  73357. * List of animations for the pipeline (IAnimatable implementation)
  73358. */
  73359. animations: Animation[];
  73360. /**
  73361. * Private members
  73362. */
  73363. private _scene;
  73364. private _currentDepthOfFieldSource;
  73365. private _basePostProcess;
  73366. private _fixedExposure;
  73367. private _currentExposure;
  73368. private _hdrAutoExposure;
  73369. private _hdrCurrentLuminance;
  73370. private _motionStrength;
  73371. private _isObjectBasedMotionBlur;
  73372. private _floatTextureType;
  73373. private _camerasToBeAttached;
  73374. private _ratio;
  73375. private _bloomEnabled;
  73376. private _depthOfFieldEnabled;
  73377. private _vlsEnabled;
  73378. private _lensFlareEnabled;
  73379. private _hdrEnabled;
  73380. private _motionBlurEnabled;
  73381. private _fxaaEnabled;
  73382. private _screenSpaceReflectionsEnabled;
  73383. private _motionBlurSamples;
  73384. private _volumetricLightStepsCount;
  73385. private _samples;
  73386. /**
  73387. * @ignore
  73388. * Specifies if the bloom pipeline is enabled
  73389. */
  73390. get BloomEnabled(): boolean;
  73391. set BloomEnabled(enabled: boolean);
  73392. /**
  73393. * @ignore
  73394. * Specifies if the depth of field pipeline is enabed
  73395. */
  73396. get DepthOfFieldEnabled(): boolean;
  73397. set DepthOfFieldEnabled(enabled: boolean);
  73398. /**
  73399. * @ignore
  73400. * Specifies if the lens flare pipeline is enabed
  73401. */
  73402. get LensFlareEnabled(): boolean;
  73403. set LensFlareEnabled(enabled: boolean);
  73404. /**
  73405. * @ignore
  73406. * Specifies if the HDR pipeline is enabled
  73407. */
  73408. get HDREnabled(): boolean;
  73409. set HDREnabled(enabled: boolean);
  73410. /**
  73411. * @ignore
  73412. * Specifies if the volumetric lights scattering effect is enabled
  73413. */
  73414. get VLSEnabled(): boolean;
  73415. set VLSEnabled(enabled: boolean);
  73416. /**
  73417. * @ignore
  73418. * Specifies if the motion blur effect is enabled
  73419. */
  73420. get MotionBlurEnabled(): boolean;
  73421. set MotionBlurEnabled(enabled: boolean);
  73422. /**
  73423. * Specifies if anti-aliasing is enabled
  73424. */
  73425. get fxaaEnabled(): boolean;
  73426. set fxaaEnabled(enabled: boolean);
  73427. /**
  73428. * Specifies if screen space reflections are enabled.
  73429. */
  73430. get screenSpaceReflectionsEnabled(): boolean;
  73431. set screenSpaceReflectionsEnabled(enabled: boolean);
  73432. /**
  73433. * Specifies the number of steps used to calculate the volumetric lights
  73434. * Typically in interval [50, 200]
  73435. */
  73436. get volumetricLightStepsCount(): number;
  73437. set volumetricLightStepsCount(count: number);
  73438. /**
  73439. * Specifies the number of samples used for the motion blur effect
  73440. * Typically in interval [16, 64]
  73441. */
  73442. get motionBlurSamples(): number;
  73443. set motionBlurSamples(samples: number);
  73444. /**
  73445. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73446. */
  73447. get samples(): number;
  73448. set samples(sampleCount: number);
  73449. /**
  73450. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73451. * @constructor
  73452. * @param name The rendering pipeline name
  73453. * @param scene The scene linked to this pipeline
  73454. * @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)
  73455. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  73456. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73457. */
  73458. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  73459. private _buildPipeline;
  73460. private _createDownSampleX4PostProcess;
  73461. private _createBrightPassPostProcess;
  73462. private _createBlurPostProcesses;
  73463. private _createTextureAdderPostProcess;
  73464. private _createVolumetricLightPostProcess;
  73465. private _createLuminancePostProcesses;
  73466. private _createHdrPostProcess;
  73467. private _createLensFlarePostProcess;
  73468. private _createDepthOfFieldPostProcess;
  73469. private _createMotionBlurPostProcess;
  73470. private _getDepthTexture;
  73471. private _disposePostProcesses;
  73472. /**
  73473. * Dispose of the pipeline and stop all post processes
  73474. */
  73475. dispose(): void;
  73476. /**
  73477. * Serialize the rendering pipeline (Used when exporting)
  73478. * @returns the serialized object
  73479. */
  73480. serialize(): any;
  73481. /**
  73482. * Parse the serialized pipeline
  73483. * @param source Source pipeline.
  73484. * @param scene The scene to load the pipeline to.
  73485. * @param rootUrl The URL of the serialized pipeline.
  73486. * @returns An instantiated pipeline from the serialized object.
  73487. */
  73488. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  73489. /**
  73490. * Luminance steps
  73491. */
  73492. static LuminanceSteps: number;
  73493. }
  73494. }
  73495. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  73496. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  73497. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  73498. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  73499. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  73500. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  73501. }
  73502. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  73503. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  73504. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73505. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73506. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  73507. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73508. }
  73509. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  73510. /** @hidden */
  73511. export var stereoscopicInterlacePixelShader: {
  73512. name: string;
  73513. shader: string;
  73514. };
  73515. }
  73516. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  73517. import { Camera } from "babylonjs/Cameras/camera";
  73518. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73519. import { Engine } from "babylonjs/Engines/engine";
  73520. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  73521. /**
  73522. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  73523. */
  73524. export class StereoscopicInterlacePostProcessI extends PostProcess {
  73525. private _stepSize;
  73526. private _passedProcess;
  73527. /**
  73528. * Initializes a StereoscopicInterlacePostProcessI
  73529. * @param name The name of the effect.
  73530. * @param rigCameras The rig cameras to be appled to the post process
  73531. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  73532. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  73533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73534. * @param engine The engine which the post process will be applied. (default: current engine)
  73535. * @param reusable If the post process can be reused on the same frame. (default: false)
  73536. */
  73537. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73538. }
  73539. /**
  73540. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  73541. */
  73542. export class StereoscopicInterlacePostProcess extends PostProcess {
  73543. private _stepSize;
  73544. private _passedProcess;
  73545. /**
  73546. * Initializes a StereoscopicInterlacePostProcess
  73547. * @param name The name of the effect.
  73548. * @param rigCameras The rig cameras to be appled to the post process
  73549. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  73550. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73551. * @param engine The engine which the post process will be applied. (default: current engine)
  73552. * @param reusable If the post process can be reused on the same frame. (default: false)
  73553. */
  73554. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73555. }
  73556. }
  73557. declare module "babylonjs/Shaders/tonemap.fragment" {
  73558. /** @hidden */
  73559. export var tonemapPixelShader: {
  73560. name: string;
  73561. shader: string;
  73562. };
  73563. }
  73564. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  73565. import { Camera } from "babylonjs/Cameras/camera";
  73566. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73567. import "babylonjs/Shaders/tonemap.fragment";
  73568. import { Engine } from "babylonjs/Engines/engine";
  73569. /** Defines operator used for tonemapping */
  73570. export enum TonemappingOperator {
  73571. /** Hable */
  73572. Hable = 0,
  73573. /** Reinhard */
  73574. Reinhard = 1,
  73575. /** HejiDawson */
  73576. HejiDawson = 2,
  73577. /** Photographic */
  73578. Photographic = 3
  73579. }
  73580. /**
  73581. * Defines a post process to apply tone mapping
  73582. */
  73583. export class TonemapPostProcess extends PostProcess {
  73584. private _operator;
  73585. /** Defines the required exposure adjustement */
  73586. exposureAdjustment: number;
  73587. /**
  73588. * Creates a new TonemapPostProcess
  73589. * @param name defines the name of the postprocess
  73590. * @param _operator defines the operator to use
  73591. * @param exposureAdjustment defines the required exposure adjustement
  73592. * @param camera defines the camera to use (can be null)
  73593. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  73594. * @param engine defines the hosting engine (can be ignore if camera is set)
  73595. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  73596. */
  73597. constructor(name: string, _operator: TonemappingOperator,
  73598. /** Defines the required exposure adjustement */
  73599. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  73600. }
  73601. }
  73602. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  73603. /** @hidden */
  73604. export var volumetricLightScatteringPixelShader: {
  73605. name: string;
  73606. shader: string;
  73607. };
  73608. }
  73609. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  73610. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73611. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73612. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73613. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73614. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73615. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73616. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73617. /** @hidden */
  73618. export var volumetricLightScatteringPassVertexShader: {
  73619. name: string;
  73620. shader: string;
  73621. };
  73622. }
  73623. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  73624. /** @hidden */
  73625. export var volumetricLightScatteringPassPixelShader: {
  73626. name: string;
  73627. shader: string;
  73628. };
  73629. }
  73630. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  73631. import { Vector3 } from "babylonjs/Maths/math.vector";
  73632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73633. import { Mesh } from "babylonjs/Meshes/mesh";
  73634. import { Camera } from "babylonjs/Cameras/camera";
  73635. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73636. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73637. import { Scene } from "babylonjs/scene";
  73638. import "babylonjs/Meshes/Builders/planeBuilder";
  73639. import "babylonjs/Shaders/depth.vertex";
  73640. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  73641. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  73642. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  73643. import { Engine } from "babylonjs/Engines/engine";
  73644. /**
  73645. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  73646. */
  73647. export class VolumetricLightScatteringPostProcess extends PostProcess {
  73648. private _volumetricLightScatteringPass;
  73649. private _volumetricLightScatteringRTT;
  73650. private _viewPort;
  73651. private _screenCoordinates;
  73652. private _cachedDefines;
  73653. /**
  73654. * If not undefined, the mesh position is computed from the attached node position
  73655. */
  73656. attachedNode: {
  73657. position: Vector3;
  73658. };
  73659. /**
  73660. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  73661. */
  73662. customMeshPosition: Vector3;
  73663. /**
  73664. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  73665. */
  73666. useCustomMeshPosition: boolean;
  73667. /**
  73668. * If the post-process should inverse the light scattering direction
  73669. */
  73670. invert: boolean;
  73671. /**
  73672. * The internal mesh used by the post-process
  73673. */
  73674. mesh: Mesh;
  73675. /**
  73676. * @hidden
  73677. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  73678. */
  73679. get useDiffuseColor(): boolean;
  73680. set useDiffuseColor(useDiffuseColor: boolean);
  73681. /**
  73682. * Array containing the excluded meshes not rendered in the internal pass
  73683. */
  73684. excludedMeshes: AbstractMesh[];
  73685. /**
  73686. * Controls the overall intensity of the post-process
  73687. */
  73688. exposure: number;
  73689. /**
  73690. * Dissipates each sample's contribution in range [0, 1]
  73691. */
  73692. decay: number;
  73693. /**
  73694. * Controls the overall intensity of each sample
  73695. */
  73696. weight: number;
  73697. /**
  73698. * Controls the density of each sample
  73699. */
  73700. density: number;
  73701. /**
  73702. * @constructor
  73703. * @param name The post-process name
  73704. * @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)
  73705. * @param camera The camera that the post-process will be attached to
  73706. * @param mesh The mesh used to create the light scattering
  73707. * @param samples The post-process quality, default 100
  73708. * @param samplingModeThe post-process filtering mode
  73709. * @param engine The babylon engine
  73710. * @param reusable If the post-process is reusable
  73711. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  73712. */
  73713. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  73714. /**
  73715. * Returns the string "VolumetricLightScatteringPostProcess"
  73716. * @returns "VolumetricLightScatteringPostProcess"
  73717. */
  73718. getClassName(): string;
  73719. private _isReady;
  73720. /**
  73721. * Sets the new light position for light scattering effect
  73722. * @param position The new custom light position
  73723. */
  73724. setCustomMeshPosition(position: Vector3): void;
  73725. /**
  73726. * Returns the light position for light scattering effect
  73727. * @return Vector3 The custom light position
  73728. */
  73729. getCustomMeshPosition(): Vector3;
  73730. /**
  73731. * Disposes the internal assets and detaches the post-process from the camera
  73732. */
  73733. dispose(camera: Camera): void;
  73734. /**
  73735. * Returns the render target texture used by the post-process
  73736. * @return the render target texture used by the post-process
  73737. */
  73738. getPass(): RenderTargetTexture;
  73739. private _meshExcluded;
  73740. private _createPass;
  73741. private _updateMeshScreenCoordinates;
  73742. /**
  73743. * Creates a default mesh for the Volumeric Light Scattering post-process
  73744. * @param name The mesh name
  73745. * @param scene The scene where to create the mesh
  73746. * @return the default mesh
  73747. */
  73748. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  73749. }
  73750. }
  73751. declare module "babylonjs/PostProcesses/index" {
  73752. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  73753. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  73754. export * from "babylonjs/PostProcesses/bloomEffect";
  73755. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  73756. export * from "babylonjs/PostProcesses/blurPostProcess";
  73757. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  73758. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  73759. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  73760. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  73761. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73762. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  73763. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  73764. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  73765. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  73766. export * from "babylonjs/PostProcesses/filterPostProcess";
  73767. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  73768. export * from "babylonjs/PostProcesses/grainPostProcess";
  73769. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  73770. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  73771. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  73772. export * from "babylonjs/PostProcesses/passPostProcess";
  73773. export * from "babylonjs/PostProcesses/postProcess";
  73774. export * from "babylonjs/PostProcesses/postProcessManager";
  73775. export * from "babylonjs/PostProcesses/refractionPostProcess";
  73776. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  73777. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  73778. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  73779. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  73780. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  73781. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  73782. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  73783. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  73784. }
  73785. declare module "babylonjs/Probes/index" {
  73786. export * from "babylonjs/Probes/reflectionProbe";
  73787. }
  73788. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  73789. import { Scene } from "babylonjs/scene";
  73790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73791. import { SmartArray } from "babylonjs/Misc/smartArray";
  73792. import { ISceneComponent } from "babylonjs/sceneComponent";
  73793. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  73794. import "babylonjs/Meshes/Builders/boxBuilder";
  73795. import "babylonjs/Shaders/color.fragment";
  73796. import "babylonjs/Shaders/color.vertex";
  73797. import { Color3 } from "babylonjs/Maths/math.color";
  73798. import { Observable } from "babylonjs/Misc/observable";
  73799. module "babylonjs/scene" {
  73800. interface Scene {
  73801. /** @hidden (Backing field) */
  73802. _boundingBoxRenderer: BoundingBoxRenderer;
  73803. /** @hidden (Backing field) */
  73804. _forceShowBoundingBoxes: boolean;
  73805. /**
  73806. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  73807. */
  73808. forceShowBoundingBoxes: boolean;
  73809. /**
  73810. * Gets the bounding box renderer associated with the scene
  73811. * @returns a BoundingBoxRenderer
  73812. */
  73813. getBoundingBoxRenderer(): BoundingBoxRenderer;
  73814. }
  73815. }
  73816. module "babylonjs/Meshes/abstractMesh" {
  73817. interface AbstractMesh {
  73818. /** @hidden (Backing field) */
  73819. _showBoundingBox: boolean;
  73820. /**
  73821. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  73822. */
  73823. showBoundingBox: boolean;
  73824. }
  73825. }
  73826. /**
  73827. * Component responsible of rendering the bounding box of the meshes in a scene.
  73828. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  73829. */
  73830. export class BoundingBoxRenderer implements ISceneComponent {
  73831. /**
  73832. * The component name helpfull to identify the component in the list of scene components.
  73833. */
  73834. readonly name: string;
  73835. /**
  73836. * The scene the component belongs to.
  73837. */
  73838. scene: Scene;
  73839. /**
  73840. * Color of the bounding box lines placed in front of an object
  73841. */
  73842. frontColor: Color3;
  73843. /**
  73844. * Color of the bounding box lines placed behind an object
  73845. */
  73846. backColor: Color3;
  73847. /**
  73848. * Defines if the renderer should show the back lines or not
  73849. */
  73850. showBackLines: boolean;
  73851. /**
  73852. * Observable raised before rendering a bounding box
  73853. */
  73854. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  73855. /**
  73856. * Observable raised after rendering a bounding box
  73857. */
  73858. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  73859. /**
  73860. * @hidden
  73861. */
  73862. renderList: SmartArray<BoundingBox>;
  73863. private _colorShader;
  73864. private _vertexBuffers;
  73865. private _indexBuffer;
  73866. private _fillIndexBuffer;
  73867. private _fillIndexData;
  73868. /**
  73869. * Instantiates a new bounding box renderer in a scene.
  73870. * @param scene the scene the renderer renders in
  73871. */
  73872. constructor(scene: Scene);
  73873. /**
  73874. * Registers the component in a given scene
  73875. */
  73876. register(): void;
  73877. private _evaluateSubMesh;
  73878. private _activeMesh;
  73879. private _prepareRessources;
  73880. private _createIndexBuffer;
  73881. /**
  73882. * Rebuilds the elements related to this component in case of
  73883. * context lost for instance.
  73884. */
  73885. rebuild(): void;
  73886. /**
  73887. * @hidden
  73888. */
  73889. reset(): void;
  73890. /**
  73891. * Render the bounding boxes of a specific rendering group
  73892. * @param renderingGroupId defines the rendering group to render
  73893. */
  73894. render(renderingGroupId: number): void;
  73895. /**
  73896. * In case of occlusion queries, we can render the occlusion bounding box through this method
  73897. * @param mesh Define the mesh to render the occlusion bounding box for
  73898. */
  73899. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  73900. /**
  73901. * Dispose and release the resources attached to this renderer.
  73902. */
  73903. dispose(): void;
  73904. }
  73905. }
  73906. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  73907. import { Nullable } from "babylonjs/types";
  73908. import { Scene } from "babylonjs/scene";
  73909. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  73910. import { Camera } from "babylonjs/Cameras/camera";
  73911. import { ISceneComponent } from "babylonjs/sceneComponent";
  73912. module "babylonjs/scene" {
  73913. interface Scene {
  73914. /** @hidden (Backing field) */
  73915. _depthRenderer: {
  73916. [id: string]: DepthRenderer;
  73917. };
  73918. /**
  73919. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  73920. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  73921. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  73922. * @returns the created depth renderer
  73923. */
  73924. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  73925. /**
  73926. * Disables a depth renderer for a given camera
  73927. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  73928. */
  73929. disableDepthRenderer(camera?: Nullable<Camera>): void;
  73930. }
  73931. }
  73932. /**
  73933. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  73934. * in several rendering techniques.
  73935. */
  73936. export class DepthRendererSceneComponent implements ISceneComponent {
  73937. /**
  73938. * The component name helpfull to identify the component in the list of scene components.
  73939. */
  73940. readonly name: string;
  73941. /**
  73942. * The scene the component belongs to.
  73943. */
  73944. scene: Scene;
  73945. /**
  73946. * Creates a new instance of the component for the given scene
  73947. * @param scene Defines the scene to register the component in
  73948. */
  73949. constructor(scene: Scene);
  73950. /**
  73951. * Registers the component in a given scene
  73952. */
  73953. register(): void;
  73954. /**
  73955. * Rebuilds the elements related to this component in case of
  73956. * context lost for instance.
  73957. */
  73958. rebuild(): void;
  73959. /**
  73960. * Disposes the component and the associated ressources
  73961. */
  73962. dispose(): void;
  73963. private _gatherRenderTargets;
  73964. private _gatherActiveCameraRenderTargets;
  73965. }
  73966. }
  73967. declare module "babylonjs/Shaders/outline.fragment" {
  73968. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  73969. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  73970. /** @hidden */
  73971. export var outlinePixelShader: {
  73972. name: string;
  73973. shader: string;
  73974. };
  73975. }
  73976. declare module "babylonjs/Shaders/outline.vertex" {
  73977. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73978. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73979. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73980. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73981. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  73982. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73983. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73984. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73985. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  73986. /** @hidden */
  73987. export var outlineVertexShader: {
  73988. name: string;
  73989. shader: string;
  73990. };
  73991. }
  73992. declare module "babylonjs/Rendering/outlineRenderer" {
  73993. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73994. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  73995. import { Scene } from "babylonjs/scene";
  73996. import { ISceneComponent } from "babylonjs/sceneComponent";
  73997. import "babylonjs/Shaders/outline.fragment";
  73998. import "babylonjs/Shaders/outline.vertex";
  73999. module "babylonjs/scene" {
  74000. interface Scene {
  74001. /** @hidden */
  74002. _outlineRenderer: OutlineRenderer;
  74003. /**
  74004. * Gets the outline renderer associated with the scene
  74005. * @returns a OutlineRenderer
  74006. */
  74007. getOutlineRenderer(): OutlineRenderer;
  74008. }
  74009. }
  74010. module "babylonjs/Meshes/abstractMesh" {
  74011. interface AbstractMesh {
  74012. /** @hidden (Backing field) */
  74013. _renderOutline: boolean;
  74014. /**
  74015. * Gets or sets a boolean indicating if the outline must be rendered as well
  74016. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  74017. */
  74018. renderOutline: boolean;
  74019. /** @hidden (Backing field) */
  74020. _renderOverlay: boolean;
  74021. /**
  74022. * Gets or sets a boolean indicating if the overlay must be rendered as well
  74023. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  74024. */
  74025. renderOverlay: boolean;
  74026. }
  74027. }
  74028. /**
  74029. * This class is responsible to draw bothe outline/overlay of meshes.
  74030. * It should not be used directly but through the available method on mesh.
  74031. */
  74032. export class OutlineRenderer implements ISceneComponent {
  74033. /**
  74034. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  74035. */
  74036. private static _StencilReference;
  74037. /**
  74038. * The name of the component. Each component must have a unique name.
  74039. */
  74040. name: string;
  74041. /**
  74042. * The scene the component belongs to.
  74043. */
  74044. scene: Scene;
  74045. /**
  74046. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  74047. */
  74048. zOffset: number;
  74049. private _engine;
  74050. private _effect;
  74051. private _cachedDefines;
  74052. private _savedDepthWrite;
  74053. /**
  74054. * Instantiates a new outline renderer. (There could be only one per scene).
  74055. * @param scene Defines the scene it belongs to
  74056. */
  74057. constructor(scene: Scene);
  74058. /**
  74059. * Register the component to one instance of a scene.
  74060. */
  74061. register(): void;
  74062. /**
  74063. * Rebuilds the elements related to this component in case of
  74064. * context lost for instance.
  74065. */
  74066. rebuild(): void;
  74067. /**
  74068. * Disposes the component and the associated ressources.
  74069. */
  74070. dispose(): void;
  74071. /**
  74072. * Renders the outline in the canvas.
  74073. * @param subMesh Defines the sumesh to render
  74074. * @param batch Defines the batch of meshes in case of instances
  74075. * @param useOverlay Defines if the rendering is for the overlay or the outline
  74076. */
  74077. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  74078. /**
  74079. * Returns whether or not the outline renderer is ready for a given submesh.
  74080. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  74081. * @param subMesh Defines the submesh to check readyness for
  74082. * @param useInstances Defines wheter wee are trying to render instances or not
  74083. * @returns true if ready otherwise false
  74084. */
  74085. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74086. private _beforeRenderingMesh;
  74087. private _afterRenderingMesh;
  74088. }
  74089. }
  74090. declare module "babylonjs/Rendering/index" {
  74091. export * from "babylonjs/Rendering/boundingBoxRenderer";
  74092. export * from "babylonjs/Rendering/depthRenderer";
  74093. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  74094. export * from "babylonjs/Rendering/edgesRenderer";
  74095. export * from "babylonjs/Rendering/geometryBufferRenderer";
  74096. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  74097. export * from "babylonjs/Rendering/outlineRenderer";
  74098. export * from "babylonjs/Rendering/renderingGroup";
  74099. export * from "babylonjs/Rendering/renderingManager";
  74100. export * from "babylonjs/Rendering/utilityLayerRenderer";
  74101. }
  74102. declare module "babylonjs/Sprites/ISprites" {
  74103. /**
  74104. * Defines the basic options interface of a Sprite Frame Source Size.
  74105. */
  74106. export interface ISpriteJSONSpriteSourceSize {
  74107. /**
  74108. * number of the original width of the Frame
  74109. */
  74110. w: number;
  74111. /**
  74112. * number of the original height of the Frame
  74113. */
  74114. h: number;
  74115. }
  74116. /**
  74117. * Defines the basic options interface of a Sprite Frame Data.
  74118. */
  74119. export interface ISpriteJSONSpriteFrameData {
  74120. /**
  74121. * number of the x offset of the Frame
  74122. */
  74123. x: number;
  74124. /**
  74125. * number of the y offset of the Frame
  74126. */
  74127. y: number;
  74128. /**
  74129. * number of the width of the Frame
  74130. */
  74131. w: number;
  74132. /**
  74133. * number of the height of the Frame
  74134. */
  74135. h: number;
  74136. }
  74137. /**
  74138. * Defines the basic options interface of a JSON Sprite.
  74139. */
  74140. export interface ISpriteJSONSprite {
  74141. /**
  74142. * string name of the Frame
  74143. */
  74144. filename: string;
  74145. /**
  74146. * ISpriteJSONSpriteFrame basic object of the frame data
  74147. */
  74148. frame: ISpriteJSONSpriteFrameData;
  74149. /**
  74150. * boolean to flag is the frame was rotated.
  74151. */
  74152. rotated: boolean;
  74153. /**
  74154. * boolean to flag is the frame was trimmed.
  74155. */
  74156. trimmed: boolean;
  74157. /**
  74158. * ISpriteJSONSpriteFrame basic object of the source data
  74159. */
  74160. spriteSourceSize: ISpriteJSONSpriteFrameData;
  74161. /**
  74162. * ISpriteJSONSpriteFrame basic object of the source data
  74163. */
  74164. sourceSize: ISpriteJSONSpriteSourceSize;
  74165. }
  74166. /**
  74167. * Defines the basic options interface of a JSON atlas.
  74168. */
  74169. export interface ISpriteJSONAtlas {
  74170. /**
  74171. * Array of objects that contain the frame data.
  74172. */
  74173. frames: Array<ISpriteJSONSprite>;
  74174. /**
  74175. * object basic object containing the sprite meta data.
  74176. */
  74177. meta?: object;
  74178. }
  74179. }
  74180. declare module "babylonjs/Shaders/spriteMap.fragment" {
  74181. /** @hidden */
  74182. export var spriteMapPixelShader: {
  74183. name: string;
  74184. shader: string;
  74185. };
  74186. }
  74187. declare module "babylonjs/Shaders/spriteMap.vertex" {
  74188. /** @hidden */
  74189. export var spriteMapVertexShader: {
  74190. name: string;
  74191. shader: string;
  74192. };
  74193. }
  74194. declare module "babylonjs/Sprites/spriteMap" {
  74195. import { IDisposable, Scene } from "babylonjs/scene";
  74196. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  74197. import { Texture } from "babylonjs/Materials/Textures/texture";
  74198. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  74199. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  74200. import "babylonjs/Meshes/Builders/planeBuilder";
  74201. import "babylonjs/Shaders/spriteMap.fragment";
  74202. import "babylonjs/Shaders/spriteMap.vertex";
  74203. /**
  74204. * Defines the basic options interface of a SpriteMap
  74205. */
  74206. export interface ISpriteMapOptions {
  74207. /**
  74208. * Vector2 of the number of cells in the grid.
  74209. */
  74210. stageSize?: Vector2;
  74211. /**
  74212. * Vector2 of the size of the output plane in World Units.
  74213. */
  74214. outputSize?: Vector2;
  74215. /**
  74216. * Vector3 of the position of the output plane in World Units.
  74217. */
  74218. outputPosition?: Vector3;
  74219. /**
  74220. * Vector3 of the rotation of the output plane.
  74221. */
  74222. outputRotation?: Vector3;
  74223. /**
  74224. * number of layers that the system will reserve in resources.
  74225. */
  74226. layerCount?: number;
  74227. /**
  74228. * number of max animation frames a single cell will reserve in resources.
  74229. */
  74230. maxAnimationFrames?: number;
  74231. /**
  74232. * number cell index of the base tile when the system compiles.
  74233. */
  74234. baseTile?: number;
  74235. /**
  74236. * boolean flip the sprite after its been repositioned by the framing data.
  74237. */
  74238. flipU?: boolean;
  74239. /**
  74240. * Vector3 scalar of the global RGB values of the SpriteMap.
  74241. */
  74242. colorMultiply?: Vector3;
  74243. }
  74244. /**
  74245. * Defines the IDisposable interface in order to be cleanable from resources.
  74246. */
  74247. export interface ISpriteMap extends IDisposable {
  74248. /**
  74249. * String name of the SpriteMap.
  74250. */
  74251. name: string;
  74252. /**
  74253. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  74254. */
  74255. atlasJSON: ISpriteJSONAtlas;
  74256. /**
  74257. * Texture of the SpriteMap.
  74258. */
  74259. spriteSheet: Texture;
  74260. /**
  74261. * The parameters to initialize the SpriteMap with.
  74262. */
  74263. options: ISpriteMapOptions;
  74264. }
  74265. /**
  74266. * Class used to manage a grid restricted sprite deployment on an Output plane.
  74267. */
  74268. export class SpriteMap implements ISpriteMap {
  74269. /** The Name of the spriteMap */
  74270. name: string;
  74271. /** The JSON file with the frame and meta data */
  74272. atlasJSON: ISpriteJSONAtlas;
  74273. /** The systems Sprite Sheet Texture */
  74274. spriteSheet: Texture;
  74275. /** Arguments passed with the Constructor */
  74276. options: ISpriteMapOptions;
  74277. /** Public Sprite Storage array, parsed from atlasJSON */
  74278. sprites: Array<ISpriteJSONSprite>;
  74279. /** Returns the Number of Sprites in the System */
  74280. get spriteCount(): number;
  74281. /** Returns the Position of Output Plane*/
  74282. get position(): Vector3;
  74283. /** Returns the Position of Output Plane*/
  74284. set position(v: Vector3);
  74285. /** Returns the Rotation of Output Plane*/
  74286. get rotation(): Vector3;
  74287. /** Returns the Rotation of Output Plane*/
  74288. set rotation(v: Vector3);
  74289. /** Sets the AnimationMap*/
  74290. get animationMap(): RawTexture;
  74291. /** Sets the AnimationMap*/
  74292. set animationMap(v: RawTexture);
  74293. /** Scene that the SpriteMap was created in */
  74294. private _scene;
  74295. /** Texture Buffer of Float32 that holds tile frame data*/
  74296. private _frameMap;
  74297. /** Texture Buffers of Float32 that holds tileMap data*/
  74298. private _tileMaps;
  74299. /** Texture Buffer of Float32 that holds Animation Data*/
  74300. private _animationMap;
  74301. /** Custom ShaderMaterial Central to the System*/
  74302. private _material;
  74303. /** Custom ShaderMaterial Central to the System*/
  74304. private _output;
  74305. /** Systems Time Ticker*/
  74306. private _time;
  74307. /**
  74308. * Creates a new SpriteMap
  74309. * @param name defines the SpriteMaps Name
  74310. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  74311. * @param spriteSheet is the Texture that the Sprites are on.
  74312. * @param options a basic deployment configuration
  74313. * @param scene The Scene that the map is deployed on
  74314. */
  74315. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  74316. /**
  74317. * Returns tileID location
  74318. * @returns Vector2 the cell position ID
  74319. */
  74320. getTileID(): Vector2;
  74321. /**
  74322. * Gets the UV location of the mouse over the SpriteMap.
  74323. * @returns Vector2 the UV position of the mouse interaction
  74324. */
  74325. getMousePosition(): Vector2;
  74326. /**
  74327. * Creates the "frame" texture Buffer
  74328. * -------------------------------------
  74329. * Structure of frames
  74330. * "filename": "Falling-Water-2.png",
  74331. * "frame": {"x":69,"y":103,"w":24,"h":32},
  74332. * "rotated": true,
  74333. * "trimmed": true,
  74334. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  74335. * "sourceSize": {"w":32,"h":32}
  74336. * @returns RawTexture of the frameMap
  74337. */
  74338. private _createFrameBuffer;
  74339. /**
  74340. * Creates the tileMap texture Buffer
  74341. * @param buffer normally and array of numbers, or a false to generate from scratch
  74342. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  74343. * @returns RawTexture of the tileMap
  74344. */
  74345. private _createTileBuffer;
  74346. /**
  74347. * Modifies the data of the tileMaps
  74348. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  74349. * @param pos is the iVector2 Coordinates of the Tile
  74350. * @param tile The SpriteIndex of the new Tile
  74351. */
  74352. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  74353. /**
  74354. * Creates the animationMap texture Buffer
  74355. * @param buffer normally and array of numbers, or a false to generate from scratch
  74356. * @returns RawTexture of the animationMap
  74357. */
  74358. private _createTileAnimationBuffer;
  74359. /**
  74360. * Modifies the data of the animationMap
  74361. * @param cellID is the Index of the Sprite
  74362. * @param _frame is the target Animation frame
  74363. * @param toCell is the Target Index of the next frame of the animation
  74364. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  74365. * @param speed is a global scalar of the time variable on the map.
  74366. */
  74367. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  74368. /**
  74369. * Exports the .tilemaps file
  74370. */
  74371. saveTileMaps(): void;
  74372. /**
  74373. * Imports the .tilemaps file
  74374. * @param url of the .tilemaps file
  74375. */
  74376. loadTileMaps(url: string): void;
  74377. /**
  74378. * Release associated resources
  74379. */
  74380. dispose(): void;
  74381. }
  74382. }
  74383. declare module "babylonjs/Sprites/spritePackedManager" {
  74384. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  74385. import { Scene } from "babylonjs/scene";
  74386. /**
  74387. * Class used to manage multiple sprites of different sizes on the same spritesheet
  74388. * @see http://doc.babylonjs.com/babylon101/sprites
  74389. */
  74390. export class SpritePackedManager extends SpriteManager {
  74391. /** defines the packed manager's name */
  74392. name: string;
  74393. /**
  74394. * Creates a new sprite manager from a packed sprite sheet
  74395. * @param name defines the manager's name
  74396. * @param imgUrl defines the sprite sheet url
  74397. * @param capacity defines the maximum allowed number of sprites
  74398. * @param scene defines the hosting scene
  74399. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  74400. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  74401. * @param samplingMode defines the smapling mode to use with spritesheet
  74402. * @param fromPacked set to true; do not alter
  74403. */
  74404. constructor(
  74405. /** defines the packed manager's name */
  74406. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  74407. }
  74408. }
  74409. declare module "babylonjs/Sprites/index" {
  74410. export * from "babylonjs/Sprites/sprite";
  74411. export * from "babylonjs/Sprites/ISprites";
  74412. export * from "babylonjs/Sprites/spriteManager";
  74413. export * from "babylonjs/Sprites/spriteMap";
  74414. export * from "babylonjs/Sprites/spritePackedManager";
  74415. export * from "babylonjs/Sprites/spriteSceneComponent";
  74416. }
  74417. declare module "babylonjs/States/index" {
  74418. export * from "babylonjs/States/alphaCullingState";
  74419. export * from "babylonjs/States/depthCullingState";
  74420. export * from "babylonjs/States/stencilState";
  74421. }
  74422. declare module "babylonjs/Misc/assetsManager" {
  74423. import { Scene } from "babylonjs/scene";
  74424. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74425. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  74426. import { Skeleton } from "babylonjs/Bones/skeleton";
  74427. import { Observable } from "babylonjs/Misc/observable";
  74428. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  74429. import { Texture } from "babylonjs/Materials/Textures/texture";
  74430. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  74431. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  74432. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  74433. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  74434. /**
  74435. * Defines the list of states available for a task inside a AssetsManager
  74436. */
  74437. export enum AssetTaskState {
  74438. /**
  74439. * Initialization
  74440. */
  74441. INIT = 0,
  74442. /**
  74443. * Running
  74444. */
  74445. RUNNING = 1,
  74446. /**
  74447. * Done
  74448. */
  74449. DONE = 2,
  74450. /**
  74451. * Error
  74452. */
  74453. ERROR = 3
  74454. }
  74455. /**
  74456. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  74457. */
  74458. export abstract class AbstractAssetTask {
  74459. /**
  74460. * Task name
  74461. */ name: string;
  74462. /**
  74463. * Callback called when the task is successful
  74464. */
  74465. onSuccess: (task: any) => void;
  74466. /**
  74467. * Callback called when the task is not successful
  74468. */
  74469. onError: (task: any, message?: string, exception?: any) => void;
  74470. /**
  74471. * Creates a new AssetsManager
  74472. * @param name defines the name of the task
  74473. */
  74474. constructor(
  74475. /**
  74476. * Task name
  74477. */ name: string);
  74478. private _isCompleted;
  74479. private _taskState;
  74480. private _errorObject;
  74481. /**
  74482. * Get if the task is completed
  74483. */
  74484. get isCompleted(): boolean;
  74485. /**
  74486. * Gets the current state of the task
  74487. */
  74488. get taskState(): AssetTaskState;
  74489. /**
  74490. * Gets the current error object (if task is in error)
  74491. */
  74492. get errorObject(): {
  74493. message?: string;
  74494. exception?: any;
  74495. };
  74496. /**
  74497. * Internal only
  74498. * @hidden
  74499. */
  74500. _setErrorObject(message?: string, exception?: any): void;
  74501. /**
  74502. * Execute the current task
  74503. * @param scene defines the scene where you want your assets to be loaded
  74504. * @param onSuccess is a callback called when the task is successfully executed
  74505. * @param onError is a callback called if an error occurs
  74506. */
  74507. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74508. /**
  74509. * Execute the current task
  74510. * @param scene defines the scene where you want your assets to be loaded
  74511. * @param onSuccess is a callback called when the task is successfully executed
  74512. * @param onError is a callback called if an error occurs
  74513. */
  74514. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74515. /**
  74516. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  74517. * This can be used with failed tasks that have the reason for failure fixed.
  74518. */
  74519. reset(): void;
  74520. private onErrorCallback;
  74521. private onDoneCallback;
  74522. }
  74523. /**
  74524. * Define the interface used by progress events raised during assets loading
  74525. */
  74526. export interface IAssetsProgressEvent {
  74527. /**
  74528. * Defines the number of remaining tasks to process
  74529. */
  74530. remainingCount: number;
  74531. /**
  74532. * Defines the total number of tasks
  74533. */
  74534. totalCount: number;
  74535. /**
  74536. * Defines the task that was just processed
  74537. */
  74538. task: AbstractAssetTask;
  74539. }
  74540. /**
  74541. * Class used to share progress information about assets loading
  74542. */
  74543. export class AssetsProgressEvent implements IAssetsProgressEvent {
  74544. /**
  74545. * Defines the number of remaining tasks to process
  74546. */
  74547. remainingCount: number;
  74548. /**
  74549. * Defines the total number of tasks
  74550. */
  74551. totalCount: number;
  74552. /**
  74553. * Defines the task that was just processed
  74554. */
  74555. task: AbstractAssetTask;
  74556. /**
  74557. * Creates a AssetsProgressEvent
  74558. * @param remainingCount defines the number of remaining tasks to process
  74559. * @param totalCount defines the total number of tasks
  74560. * @param task defines the task that was just processed
  74561. */
  74562. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  74563. }
  74564. /**
  74565. * Define a task used by AssetsManager to load meshes
  74566. */
  74567. export class MeshAssetTask extends AbstractAssetTask {
  74568. /**
  74569. * Defines the name of the task
  74570. */
  74571. name: string;
  74572. /**
  74573. * Defines the list of mesh's names you want to load
  74574. */
  74575. meshesNames: any;
  74576. /**
  74577. * Defines the root url to use as a base to load your meshes and associated resources
  74578. */
  74579. rootUrl: string;
  74580. /**
  74581. * Defines the filename or File of the scene to load from
  74582. */
  74583. sceneFilename: string | File;
  74584. /**
  74585. * Gets the list of loaded meshes
  74586. */
  74587. loadedMeshes: Array<AbstractMesh>;
  74588. /**
  74589. * Gets the list of loaded particle systems
  74590. */
  74591. loadedParticleSystems: Array<IParticleSystem>;
  74592. /**
  74593. * Gets the list of loaded skeletons
  74594. */
  74595. loadedSkeletons: Array<Skeleton>;
  74596. /**
  74597. * Gets the list of loaded animation groups
  74598. */
  74599. loadedAnimationGroups: Array<AnimationGroup>;
  74600. /**
  74601. * Callback called when the task is successful
  74602. */
  74603. onSuccess: (task: MeshAssetTask) => void;
  74604. /**
  74605. * Callback called when the task is successful
  74606. */
  74607. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  74608. /**
  74609. * Creates a new MeshAssetTask
  74610. * @param name defines the name of the task
  74611. * @param meshesNames defines the list of mesh's names you want to load
  74612. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74613. * @param sceneFilename defines the filename or File of the scene to load from
  74614. */
  74615. constructor(
  74616. /**
  74617. * Defines the name of the task
  74618. */
  74619. name: string,
  74620. /**
  74621. * Defines the list of mesh's names you want to load
  74622. */
  74623. meshesNames: any,
  74624. /**
  74625. * Defines the root url to use as a base to load your meshes and associated resources
  74626. */
  74627. rootUrl: string,
  74628. /**
  74629. * Defines the filename or File of the scene to load from
  74630. */
  74631. sceneFilename: string | File);
  74632. /**
  74633. * Execute the current task
  74634. * @param scene defines the scene where you want your assets to be loaded
  74635. * @param onSuccess is a callback called when the task is successfully executed
  74636. * @param onError is a callback called if an error occurs
  74637. */
  74638. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74639. }
  74640. /**
  74641. * Define a task used by AssetsManager to load text content
  74642. */
  74643. export class TextFileAssetTask extends AbstractAssetTask {
  74644. /**
  74645. * Defines the name of the task
  74646. */
  74647. name: string;
  74648. /**
  74649. * Defines the location of the file to load
  74650. */
  74651. url: string;
  74652. /**
  74653. * Gets the loaded text string
  74654. */
  74655. text: string;
  74656. /**
  74657. * Callback called when the task is successful
  74658. */
  74659. onSuccess: (task: TextFileAssetTask) => void;
  74660. /**
  74661. * Callback called when the task is successful
  74662. */
  74663. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  74664. /**
  74665. * Creates a new TextFileAssetTask object
  74666. * @param name defines the name of the task
  74667. * @param url defines the location of the file to load
  74668. */
  74669. constructor(
  74670. /**
  74671. * Defines the name of the task
  74672. */
  74673. name: string,
  74674. /**
  74675. * Defines the location of the file to load
  74676. */
  74677. url: string);
  74678. /**
  74679. * Execute the current task
  74680. * @param scene defines the scene where you want your assets to be loaded
  74681. * @param onSuccess is a callback called when the task is successfully executed
  74682. * @param onError is a callback called if an error occurs
  74683. */
  74684. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74685. }
  74686. /**
  74687. * Define a task used by AssetsManager to load binary data
  74688. */
  74689. export class BinaryFileAssetTask extends AbstractAssetTask {
  74690. /**
  74691. * Defines the name of the task
  74692. */
  74693. name: string;
  74694. /**
  74695. * Defines the location of the file to load
  74696. */
  74697. url: string;
  74698. /**
  74699. * Gets the lodaded data (as an array buffer)
  74700. */
  74701. data: ArrayBuffer;
  74702. /**
  74703. * Callback called when the task is successful
  74704. */
  74705. onSuccess: (task: BinaryFileAssetTask) => void;
  74706. /**
  74707. * Callback called when the task is successful
  74708. */
  74709. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  74710. /**
  74711. * Creates a new BinaryFileAssetTask object
  74712. * @param name defines the name of the new task
  74713. * @param url defines the location of the file to load
  74714. */
  74715. constructor(
  74716. /**
  74717. * Defines the name of the task
  74718. */
  74719. name: string,
  74720. /**
  74721. * Defines the location of the file to load
  74722. */
  74723. url: string);
  74724. /**
  74725. * Execute the current task
  74726. * @param scene defines the scene where you want your assets to be loaded
  74727. * @param onSuccess is a callback called when the task is successfully executed
  74728. * @param onError is a callback called if an error occurs
  74729. */
  74730. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74731. }
  74732. /**
  74733. * Define a task used by AssetsManager to load images
  74734. */
  74735. export class ImageAssetTask extends AbstractAssetTask {
  74736. /**
  74737. * Defines the name of the task
  74738. */
  74739. name: string;
  74740. /**
  74741. * Defines the location of the image to load
  74742. */
  74743. url: string;
  74744. /**
  74745. * Gets the loaded images
  74746. */
  74747. image: HTMLImageElement;
  74748. /**
  74749. * Callback called when the task is successful
  74750. */
  74751. onSuccess: (task: ImageAssetTask) => void;
  74752. /**
  74753. * Callback called when the task is successful
  74754. */
  74755. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  74756. /**
  74757. * Creates a new ImageAssetTask
  74758. * @param name defines the name of the task
  74759. * @param url defines the location of the image to load
  74760. */
  74761. constructor(
  74762. /**
  74763. * Defines the name of the task
  74764. */
  74765. name: string,
  74766. /**
  74767. * Defines the location of the image to load
  74768. */
  74769. url: string);
  74770. /**
  74771. * Execute the current task
  74772. * @param scene defines the scene where you want your assets to be loaded
  74773. * @param onSuccess is a callback called when the task is successfully executed
  74774. * @param onError is a callback called if an error occurs
  74775. */
  74776. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74777. }
  74778. /**
  74779. * Defines the interface used by texture loading tasks
  74780. */
  74781. export interface ITextureAssetTask<TEX extends BaseTexture> {
  74782. /**
  74783. * Gets the loaded texture
  74784. */
  74785. texture: TEX;
  74786. }
  74787. /**
  74788. * Define a task used by AssetsManager to load 2D textures
  74789. */
  74790. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  74791. /**
  74792. * Defines the name of the task
  74793. */
  74794. name: string;
  74795. /**
  74796. * Defines the location of the file to load
  74797. */
  74798. url: string;
  74799. /**
  74800. * Defines if mipmap should not be generated (default is false)
  74801. */
  74802. noMipmap?: boolean | undefined;
  74803. /**
  74804. * Defines if texture must be inverted on Y axis (default is true)
  74805. */
  74806. invertY: boolean;
  74807. /**
  74808. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74809. */
  74810. samplingMode: number;
  74811. /**
  74812. * Gets the loaded texture
  74813. */
  74814. texture: Texture;
  74815. /**
  74816. * Callback called when the task is successful
  74817. */
  74818. onSuccess: (task: TextureAssetTask) => void;
  74819. /**
  74820. * Callback called when the task is successful
  74821. */
  74822. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  74823. /**
  74824. * Creates a new TextureAssetTask object
  74825. * @param name defines the name of the task
  74826. * @param url defines the location of the file to load
  74827. * @param noMipmap defines if mipmap should not be generated (default is false)
  74828. * @param invertY defines if texture must be inverted on Y axis (default is true)
  74829. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74830. */
  74831. constructor(
  74832. /**
  74833. * Defines the name of the task
  74834. */
  74835. name: string,
  74836. /**
  74837. * Defines the location of the file to load
  74838. */
  74839. url: string,
  74840. /**
  74841. * Defines if mipmap should not be generated (default is false)
  74842. */
  74843. noMipmap?: boolean | undefined,
  74844. /**
  74845. * Defines if texture must be inverted on Y axis (default is true)
  74846. */
  74847. invertY?: boolean,
  74848. /**
  74849. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74850. */
  74851. samplingMode?: number);
  74852. /**
  74853. * Execute the current task
  74854. * @param scene defines the scene where you want your assets to be loaded
  74855. * @param onSuccess is a callback called when the task is successfully executed
  74856. * @param onError is a callback called if an error occurs
  74857. */
  74858. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74859. }
  74860. /**
  74861. * Define a task used by AssetsManager to load cube textures
  74862. */
  74863. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  74864. /**
  74865. * Defines the name of the task
  74866. */
  74867. name: string;
  74868. /**
  74869. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74870. */
  74871. url: string;
  74872. /**
  74873. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74874. */
  74875. extensions?: string[] | undefined;
  74876. /**
  74877. * Defines if mipmaps should not be generated (default is false)
  74878. */
  74879. noMipmap?: boolean | undefined;
  74880. /**
  74881. * Defines the explicit list of files (undefined by default)
  74882. */
  74883. files?: string[] | undefined;
  74884. /**
  74885. * Gets the loaded texture
  74886. */
  74887. texture: CubeTexture;
  74888. /**
  74889. * Callback called when the task is successful
  74890. */
  74891. onSuccess: (task: CubeTextureAssetTask) => void;
  74892. /**
  74893. * Callback called when the task is successful
  74894. */
  74895. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  74896. /**
  74897. * Creates a new CubeTextureAssetTask
  74898. * @param name defines the name of the task
  74899. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74900. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74901. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74902. * @param files defines the explicit list of files (undefined by default)
  74903. */
  74904. constructor(
  74905. /**
  74906. * Defines the name of the task
  74907. */
  74908. name: string,
  74909. /**
  74910. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74911. */
  74912. url: string,
  74913. /**
  74914. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74915. */
  74916. extensions?: string[] | undefined,
  74917. /**
  74918. * Defines if mipmaps should not be generated (default is false)
  74919. */
  74920. noMipmap?: boolean | undefined,
  74921. /**
  74922. * Defines the explicit list of files (undefined by default)
  74923. */
  74924. files?: string[] | undefined);
  74925. /**
  74926. * Execute the current task
  74927. * @param scene defines the scene where you want your assets to be loaded
  74928. * @param onSuccess is a callback called when the task is successfully executed
  74929. * @param onError is a callback called if an error occurs
  74930. */
  74931. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74932. }
  74933. /**
  74934. * Define a task used by AssetsManager to load HDR cube textures
  74935. */
  74936. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  74937. /**
  74938. * Defines the name of the task
  74939. */
  74940. name: string;
  74941. /**
  74942. * Defines the location of the file to load
  74943. */
  74944. url: string;
  74945. /**
  74946. * Defines the desired size (the more it increases the longer the generation will be)
  74947. */
  74948. size: number;
  74949. /**
  74950. * Defines if mipmaps should not be generated (default is false)
  74951. */
  74952. noMipmap: boolean;
  74953. /**
  74954. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74955. */
  74956. generateHarmonics: boolean;
  74957. /**
  74958. * 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)
  74959. */
  74960. gammaSpace: boolean;
  74961. /**
  74962. * Internal Use Only
  74963. */
  74964. reserved: boolean;
  74965. /**
  74966. * Gets the loaded texture
  74967. */
  74968. texture: HDRCubeTexture;
  74969. /**
  74970. * Callback called when the task is successful
  74971. */
  74972. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  74973. /**
  74974. * Callback called when the task is successful
  74975. */
  74976. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  74977. /**
  74978. * Creates a new HDRCubeTextureAssetTask object
  74979. * @param name defines the name of the task
  74980. * @param url defines the location of the file to load
  74981. * @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.
  74982. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74983. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74984. * @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)
  74985. * @param reserved Internal use only
  74986. */
  74987. constructor(
  74988. /**
  74989. * Defines the name of the task
  74990. */
  74991. name: string,
  74992. /**
  74993. * Defines the location of the file to load
  74994. */
  74995. url: string,
  74996. /**
  74997. * Defines the desired size (the more it increases the longer the generation will be)
  74998. */
  74999. size: number,
  75000. /**
  75001. * Defines if mipmaps should not be generated (default is false)
  75002. */
  75003. noMipmap?: boolean,
  75004. /**
  75005. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75006. */
  75007. generateHarmonics?: boolean,
  75008. /**
  75009. * 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)
  75010. */
  75011. gammaSpace?: boolean,
  75012. /**
  75013. * Internal Use Only
  75014. */
  75015. reserved?: boolean);
  75016. /**
  75017. * Execute the current task
  75018. * @param scene defines the scene where you want your assets to be loaded
  75019. * @param onSuccess is a callback called when the task is successfully executed
  75020. * @param onError is a callback called if an error occurs
  75021. */
  75022. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75023. }
  75024. /**
  75025. * Define a task used by AssetsManager to load Equirectangular cube textures
  75026. */
  75027. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  75028. /**
  75029. * Defines the name of the task
  75030. */
  75031. name: string;
  75032. /**
  75033. * Defines the location of the file to load
  75034. */
  75035. url: string;
  75036. /**
  75037. * Defines the desired size (the more it increases the longer the generation will be)
  75038. */
  75039. size: number;
  75040. /**
  75041. * Defines if mipmaps should not be generated (default is false)
  75042. */
  75043. noMipmap: boolean;
  75044. /**
  75045. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  75046. * but the standard material would require them in Gamma space) (default is true)
  75047. */
  75048. gammaSpace: boolean;
  75049. /**
  75050. * Gets the loaded texture
  75051. */
  75052. texture: EquiRectangularCubeTexture;
  75053. /**
  75054. * Callback called when the task is successful
  75055. */
  75056. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  75057. /**
  75058. * Callback called when the task is successful
  75059. */
  75060. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  75061. /**
  75062. * Creates a new EquiRectangularCubeTextureAssetTask object
  75063. * @param name defines the name of the task
  75064. * @param url defines the location of the file to load
  75065. * @param size defines the desired size (the more it increases the longer the generation will be)
  75066. * If the size is omitted this implies you are using a preprocessed cubemap.
  75067. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75068. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  75069. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  75070. * (default is true)
  75071. */
  75072. constructor(
  75073. /**
  75074. * Defines the name of the task
  75075. */
  75076. name: string,
  75077. /**
  75078. * Defines the location of the file to load
  75079. */
  75080. url: string,
  75081. /**
  75082. * Defines the desired size (the more it increases the longer the generation will be)
  75083. */
  75084. size: number,
  75085. /**
  75086. * Defines if mipmaps should not be generated (default is false)
  75087. */
  75088. noMipmap?: boolean,
  75089. /**
  75090. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  75091. * but the standard material would require them in Gamma space) (default is true)
  75092. */
  75093. gammaSpace?: boolean);
  75094. /**
  75095. * Execute the current task
  75096. * @param scene defines the scene where you want your assets to be loaded
  75097. * @param onSuccess is a callback called when the task is successfully executed
  75098. * @param onError is a callback called if an error occurs
  75099. */
  75100. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75101. }
  75102. /**
  75103. * This class can be used to easily import assets into a scene
  75104. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  75105. */
  75106. export class AssetsManager {
  75107. private _scene;
  75108. private _isLoading;
  75109. protected _tasks: AbstractAssetTask[];
  75110. protected _waitingTasksCount: number;
  75111. protected _totalTasksCount: number;
  75112. /**
  75113. * Callback called when all tasks are processed
  75114. */
  75115. onFinish: (tasks: AbstractAssetTask[]) => void;
  75116. /**
  75117. * Callback called when a task is successful
  75118. */
  75119. onTaskSuccess: (task: AbstractAssetTask) => void;
  75120. /**
  75121. * Callback called when a task had an error
  75122. */
  75123. onTaskError: (task: AbstractAssetTask) => void;
  75124. /**
  75125. * Callback called when a task is done (whatever the result is)
  75126. */
  75127. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  75128. /**
  75129. * Observable called when all tasks are processed
  75130. */
  75131. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  75132. /**
  75133. * Observable called when a task had an error
  75134. */
  75135. onTaskErrorObservable: Observable<AbstractAssetTask>;
  75136. /**
  75137. * Observable called when all tasks were executed
  75138. */
  75139. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  75140. /**
  75141. * Observable called when a task is done (whatever the result is)
  75142. */
  75143. onProgressObservable: Observable<IAssetsProgressEvent>;
  75144. /**
  75145. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  75146. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  75147. */
  75148. useDefaultLoadingScreen: boolean;
  75149. /**
  75150. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  75151. * when all assets have been downloaded.
  75152. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  75153. */
  75154. autoHideLoadingUI: boolean;
  75155. /**
  75156. * Creates a new AssetsManager
  75157. * @param scene defines the scene to work on
  75158. */
  75159. constructor(scene: Scene);
  75160. /**
  75161. * Add a MeshAssetTask to the list of active tasks
  75162. * @param taskName defines the name of the new task
  75163. * @param meshesNames defines the name of meshes to load
  75164. * @param rootUrl defines the root url to use to locate files
  75165. * @param sceneFilename defines the filename of the scene file
  75166. * @returns a new MeshAssetTask object
  75167. */
  75168. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  75169. /**
  75170. * Add a TextFileAssetTask to the list of active tasks
  75171. * @param taskName defines the name of the new task
  75172. * @param url defines the url of the file to load
  75173. * @returns a new TextFileAssetTask object
  75174. */
  75175. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  75176. /**
  75177. * Add a BinaryFileAssetTask to the list of active tasks
  75178. * @param taskName defines the name of the new task
  75179. * @param url defines the url of the file to load
  75180. * @returns a new BinaryFileAssetTask object
  75181. */
  75182. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  75183. /**
  75184. * Add a ImageAssetTask to the list of active tasks
  75185. * @param taskName defines the name of the new task
  75186. * @param url defines the url of the file to load
  75187. * @returns a new ImageAssetTask object
  75188. */
  75189. addImageTask(taskName: string, url: string): ImageAssetTask;
  75190. /**
  75191. * Add a TextureAssetTask to the list of active tasks
  75192. * @param taskName defines the name of the new task
  75193. * @param url defines the url of the file to load
  75194. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75195. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  75196. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  75197. * @returns a new TextureAssetTask object
  75198. */
  75199. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  75200. /**
  75201. * Add a CubeTextureAssetTask to the list of active tasks
  75202. * @param taskName defines the name of the new task
  75203. * @param url defines the url of the file to load
  75204. * @param extensions defines the extension to use to load the cube map (can be null)
  75205. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75206. * @param files defines the list of files to load (can be null)
  75207. * @returns a new CubeTextureAssetTask object
  75208. */
  75209. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  75210. /**
  75211. *
  75212. * Add a HDRCubeTextureAssetTask to the list of active tasks
  75213. * @param taskName defines the name of the new task
  75214. * @param url defines the url of the file to load
  75215. * @param size defines the size you want for the cubemap (can be null)
  75216. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75217. * @param generateHarmonics defines if you want to automatically generate (true by default)
  75218. * @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)
  75219. * @param reserved Internal use only
  75220. * @returns a new HDRCubeTextureAssetTask object
  75221. */
  75222. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  75223. /**
  75224. *
  75225. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  75226. * @param taskName defines the name of the new task
  75227. * @param url defines the url of the file to load
  75228. * @param size defines the size you want for the cubemap (can be null)
  75229. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75230. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  75231. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  75232. * @returns a new EquiRectangularCubeTextureAssetTask object
  75233. */
  75234. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  75235. /**
  75236. * Remove a task from the assets manager.
  75237. * @param task the task to remove
  75238. */
  75239. removeTask(task: AbstractAssetTask): void;
  75240. private _decreaseWaitingTasksCount;
  75241. private _runTask;
  75242. /**
  75243. * Reset the AssetsManager and remove all tasks
  75244. * @return the current instance of the AssetsManager
  75245. */
  75246. reset(): AssetsManager;
  75247. /**
  75248. * Start the loading process
  75249. * @return the current instance of the AssetsManager
  75250. */
  75251. load(): AssetsManager;
  75252. /**
  75253. * Start the loading process as an async operation
  75254. * @return a promise returning the list of failed tasks
  75255. */
  75256. loadAsync(): Promise<void>;
  75257. }
  75258. }
  75259. declare module "babylonjs/Misc/deferred" {
  75260. /**
  75261. * Wrapper class for promise with external resolve and reject.
  75262. */
  75263. export class Deferred<T> {
  75264. /**
  75265. * The promise associated with this deferred object.
  75266. */
  75267. readonly promise: Promise<T>;
  75268. private _resolve;
  75269. private _reject;
  75270. /**
  75271. * The resolve method of the promise associated with this deferred object.
  75272. */
  75273. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  75274. /**
  75275. * The reject method of the promise associated with this deferred object.
  75276. */
  75277. get reject(): (reason?: any) => void;
  75278. /**
  75279. * Constructor for this deferred object.
  75280. */
  75281. constructor();
  75282. }
  75283. }
  75284. declare module "babylonjs/Misc/meshExploder" {
  75285. import { Mesh } from "babylonjs/Meshes/mesh";
  75286. /**
  75287. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  75288. */
  75289. export class MeshExploder {
  75290. private _centerMesh;
  75291. private _meshes;
  75292. private _meshesOrigins;
  75293. private _toCenterVectors;
  75294. private _scaledDirection;
  75295. private _newPosition;
  75296. private _centerPosition;
  75297. /**
  75298. * Explodes meshes from a center mesh.
  75299. * @param meshes The meshes to explode.
  75300. * @param centerMesh The mesh to be center of explosion.
  75301. */
  75302. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  75303. private _setCenterMesh;
  75304. /**
  75305. * Get class name
  75306. * @returns "MeshExploder"
  75307. */
  75308. getClassName(): string;
  75309. /**
  75310. * "Exploded meshes"
  75311. * @returns Array of meshes with the centerMesh at index 0.
  75312. */
  75313. getMeshes(): Array<Mesh>;
  75314. /**
  75315. * Explodes meshes giving a specific direction
  75316. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  75317. */
  75318. explode(direction?: number): void;
  75319. }
  75320. }
  75321. declare module "babylonjs/Misc/filesInput" {
  75322. import { Engine } from "babylonjs/Engines/engine";
  75323. import { Scene } from "babylonjs/scene";
  75324. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  75325. /**
  75326. * Class used to help managing file picking and drag'n'drop
  75327. */
  75328. export class FilesInput {
  75329. /**
  75330. * List of files ready to be loaded
  75331. */
  75332. static get FilesToLoad(): {
  75333. [key: string]: File;
  75334. };
  75335. /**
  75336. * Callback called when a file is processed
  75337. */
  75338. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  75339. private _engine;
  75340. private _currentScene;
  75341. private _sceneLoadedCallback;
  75342. private _progressCallback;
  75343. private _additionalRenderLoopLogicCallback;
  75344. private _textureLoadingCallback;
  75345. private _startingProcessingFilesCallback;
  75346. private _onReloadCallback;
  75347. private _errorCallback;
  75348. private _elementToMonitor;
  75349. private _sceneFileToLoad;
  75350. private _filesToLoad;
  75351. /**
  75352. * Creates a new FilesInput
  75353. * @param engine defines the rendering engine
  75354. * @param scene defines the hosting scene
  75355. * @param sceneLoadedCallback callback called when scene is loaded
  75356. * @param progressCallback callback called to track progress
  75357. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  75358. * @param textureLoadingCallback callback called when a texture is loading
  75359. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  75360. * @param onReloadCallback callback called when a reload is requested
  75361. * @param errorCallback callback call if an error occurs
  75362. */
  75363. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: (files?: File[]) => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  75364. private _dragEnterHandler;
  75365. private _dragOverHandler;
  75366. private _dropHandler;
  75367. /**
  75368. * Calls this function to listen to drag'n'drop events on a specific DOM element
  75369. * @param elementToMonitor defines the DOM element to track
  75370. */
  75371. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  75372. /**
  75373. * Release all associated resources
  75374. */
  75375. dispose(): void;
  75376. private renderFunction;
  75377. private drag;
  75378. private drop;
  75379. private _traverseFolder;
  75380. private _processFiles;
  75381. /**
  75382. * Load files from a drop event
  75383. * @param event defines the drop event to use as source
  75384. */
  75385. loadFiles(event: any): void;
  75386. private _processReload;
  75387. /**
  75388. * Reload the current scene from the loaded files
  75389. */
  75390. reload(): void;
  75391. }
  75392. }
  75393. declare module "babylonjs/Misc/HighDynamicRange/index" {
  75394. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  75395. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  75396. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  75397. }
  75398. declare module "babylonjs/Misc/sceneOptimizer" {
  75399. import { Scene, IDisposable } from "babylonjs/scene";
  75400. import { Observable } from "babylonjs/Misc/observable";
  75401. /**
  75402. * Defines the root class used to create scene optimization to use with SceneOptimizer
  75403. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75404. */
  75405. export class SceneOptimization {
  75406. /**
  75407. * Defines the priority of this optimization (0 by default which means first in the list)
  75408. */
  75409. priority: number;
  75410. /**
  75411. * Gets a string describing the action executed by the current optimization
  75412. * @returns description string
  75413. */
  75414. getDescription(): string;
  75415. /**
  75416. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75417. * @param scene defines the current scene where to apply this optimization
  75418. * @param optimizer defines the current optimizer
  75419. * @returns true if everything that can be done was applied
  75420. */
  75421. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75422. /**
  75423. * Creates the SceneOptimization object
  75424. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75425. * @param desc defines the description associated with the optimization
  75426. */
  75427. constructor(
  75428. /**
  75429. * Defines the priority of this optimization (0 by default which means first in the list)
  75430. */
  75431. priority?: number);
  75432. }
  75433. /**
  75434. * Defines an optimization used to reduce the size of render target textures
  75435. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75436. */
  75437. export class TextureOptimization extends SceneOptimization {
  75438. /**
  75439. * Defines the priority of this optimization (0 by default which means first in the list)
  75440. */
  75441. priority: number;
  75442. /**
  75443. * 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
  75444. */
  75445. maximumSize: number;
  75446. /**
  75447. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75448. */
  75449. step: number;
  75450. /**
  75451. * Gets a string describing the action executed by the current optimization
  75452. * @returns description string
  75453. */
  75454. getDescription(): string;
  75455. /**
  75456. * Creates the TextureOptimization object
  75457. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75458. * @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
  75459. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75460. */
  75461. constructor(
  75462. /**
  75463. * Defines the priority of this optimization (0 by default which means first in the list)
  75464. */
  75465. priority?: number,
  75466. /**
  75467. * 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
  75468. */
  75469. maximumSize?: number,
  75470. /**
  75471. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75472. */
  75473. step?: number);
  75474. /**
  75475. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75476. * @param scene defines the current scene where to apply this optimization
  75477. * @param optimizer defines the current optimizer
  75478. * @returns true if everything that can be done was applied
  75479. */
  75480. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75481. }
  75482. /**
  75483. * Defines an optimization used to increase or decrease the rendering resolution
  75484. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75485. */
  75486. export class HardwareScalingOptimization extends SceneOptimization {
  75487. /**
  75488. * Defines the priority of this optimization (0 by default which means first in the list)
  75489. */
  75490. priority: number;
  75491. /**
  75492. * Defines the maximum scale to use (2 by default)
  75493. */
  75494. maximumScale: number;
  75495. /**
  75496. * Defines the step to use between two passes (0.5 by default)
  75497. */
  75498. step: number;
  75499. private _currentScale;
  75500. private _directionOffset;
  75501. /**
  75502. * Gets a string describing the action executed by the current optimization
  75503. * @return description string
  75504. */
  75505. getDescription(): string;
  75506. /**
  75507. * Creates the HardwareScalingOptimization object
  75508. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75509. * @param maximumScale defines the maximum scale to use (2 by default)
  75510. * @param step defines the step to use between two passes (0.5 by default)
  75511. */
  75512. constructor(
  75513. /**
  75514. * Defines the priority of this optimization (0 by default which means first in the list)
  75515. */
  75516. priority?: number,
  75517. /**
  75518. * Defines the maximum scale to use (2 by default)
  75519. */
  75520. maximumScale?: number,
  75521. /**
  75522. * Defines the step to use between two passes (0.5 by default)
  75523. */
  75524. step?: number);
  75525. /**
  75526. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75527. * @param scene defines the current scene where to apply this optimization
  75528. * @param optimizer defines the current optimizer
  75529. * @returns true if everything that can be done was applied
  75530. */
  75531. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75532. }
  75533. /**
  75534. * Defines an optimization used to remove shadows
  75535. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75536. */
  75537. export class ShadowsOptimization extends SceneOptimization {
  75538. /**
  75539. * Gets a string describing the action executed by the current optimization
  75540. * @return description string
  75541. */
  75542. getDescription(): string;
  75543. /**
  75544. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75545. * @param scene defines the current scene where to apply this optimization
  75546. * @param optimizer defines the current optimizer
  75547. * @returns true if everything that can be done was applied
  75548. */
  75549. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75550. }
  75551. /**
  75552. * Defines an optimization used to turn post-processes off
  75553. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75554. */
  75555. export class PostProcessesOptimization extends SceneOptimization {
  75556. /**
  75557. * Gets a string describing the action executed by the current optimization
  75558. * @return description string
  75559. */
  75560. getDescription(): string;
  75561. /**
  75562. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75563. * @param scene defines the current scene where to apply this optimization
  75564. * @param optimizer defines the current optimizer
  75565. * @returns true if everything that can be done was applied
  75566. */
  75567. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75568. }
  75569. /**
  75570. * Defines an optimization used to turn lens flares off
  75571. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75572. */
  75573. export class LensFlaresOptimization extends SceneOptimization {
  75574. /**
  75575. * Gets a string describing the action executed by the current optimization
  75576. * @return description string
  75577. */
  75578. getDescription(): string;
  75579. /**
  75580. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75581. * @param scene defines the current scene where to apply this optimization
  75582. * @param optimizer defines the current optimizer
  75583. * @returns true if everything that can be done was applied
  75584. */
  75585. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75586. }
  75587. /**
  75588. * Defines an optimization based on user defined callback.
  75589. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75590. */
  75591. export class CustomOptimization extends SceneOptimization {
  75592. /**
  75593. * Callback called to apply the custom optimization.
  75594. */
  75595. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  75596. /**
  75597. * Callback called to get custom description
  75598. */
  75599. onGetDescription: () => string;
  75600. /**
  75601. * Gets a string describing the action executed by the current optimization
  75602. * @returns description string
  75603. */
  75604. getDescription(): string;
  75605. /**
  75606. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75607. * @param scene defines the current scene where to apply this optimization
  75608. * @param optimizer defines the current optimizer
  75609. * @returns true if everything that can be done was applied
  75610. */
  75611. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75612. }
  75613. /**
  75614. * Defines an optimization used to turn particles off
  75615. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75616. */
  75617. export class ParticlesOptimization extends SceneOptimization {
  75618. /**
  75619. * Gets a string describing the action executed by the current optimization
  75620. * @return description string
  75621. */
  75622. getDescription(): string;
  75623. /**
  75624. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75625. * @param scene defines the current scene where to apply this optimization
  75626. * @param optimizer defines the current optimizer
  75627. * @returns true if everything that can be done was applied
  75628. */
  75629. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75630. }
  75631. /**
  75632. * Defines an optimization used to turn render targets off
  75633. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75634. */
  75635. export class RenderTargetsOptimization extends SceneOptimization {
  75636. /**
  75637. * Gets a string describing the action executed by the current optimization
  75638. * @return description string
  75639. */
  75640. getDescription(): string;
  75641. /**
  75642. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75643. * @param scene defines the current scene where to apply this optimization
  75644. * @param optimizer defines the current optimizer
  75645. * @returns true if everything that can be done was applied
  75646. */
  75647. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75648. }
  75649. /**
  75650. * Defines an optimization used to merge meshes with compatible materials
  75651. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75652. */
  75653. export class MergeMeshesOptimization extends SceneOptimization {
  75654. private static _UpdateSelectionTree;
  75655. /**
  75656. * Gets or sets a boolean which defines if optimization octree has to be updated
  75657. */
  75658. static get UpdateSelectionTree(): boolean;
  75659. /**
  75660. * Gets or sets a boolean which defines if optimization octree has to be updated
  75661. */
  75662. static set UpdateSelectionTree(value: boolean);
  75663. /**
  75664. * Gets a string describing the action executed by the current optimization
  75665. * @return description string
  75666. */
  75667. getDescription(): string;
  75668. private _canBeMerged;
  75669. /**
  75670. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75671. * @param scene defines the current scene where to apply this optimization
  75672. * @param optimizer defines the current optimizer
  75673. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  75674. * @returns true if everything that can be done was applied
  75675. */
  75676. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  75677. }
  75678. /**
  75679. * Defines a list of options used by SceneOptimizer
  75680. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75681. */
  75682. export class SceneOptimizerOptions {
  75683. /**
  75684. * Defines the target frame rate to reach (60 by default)
  75685. */
  75686. targetFrameRate: number;
  75687. /**
  75688. * Defines the interval between two checkes (2000ms by default)
  75689. */
  75690. trackerDuration: number;
  75691. /**
  75692. * Gets the list of optimizations to apply
  75693. */
  75694. optimizations: SceneOptimization[];
  75695. /**
  75696. * Creates a new list of options used by SceneOptimizer
  75697. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  75698. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  75699. */
  75700. constructor(
  75701. /**
  75702. * Defines the target frame rate to reach (60 by default)
  75703. */
  75704. targetFrameRate?: number,
  75705. /**
  75706. * Defines the interval between two checkes (2000ms by default)
  75707. */
  75708. trackerDuration?: number);
  75709. /**
  75710. * Add a new optimization
  75711. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  75712. * @returns the current SceneOptimizerOptions
  75713. */
  75714. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  75715. /**
  75716. * Add a new custom optimization
  75717. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  75718. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  75719. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75720. * @returns the current SceneOptimizerOptions
  75721. */
  75722. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  75723. /**
  75724. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  75725. * @param targetFrameRate defines the target frame rate (60 by default)
  75726. * @returns a SceneOptimizerOptions object
  75727. */
  75728. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75729. /**
  75730. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  75731. * @param targetFrameRate defines the target frame rate (60 by default)
  75732. * @returns a SceneOptimizerOptions object
  75733. */
  75734. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75735. /**
  75736. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  75737. * @param targetFrameRate defines the target frame rate (60 by default)
  75738. * @returns a SceneOptimizerOptions object
  75739. */
  75740. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75741. }
  75742. /**
  75743. * Class used to run optimizations in order to reach a target frame rate
  75744. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75745. */
  75746. export class SceneOptimizer implements IDisposable {
  75747. private _isRunning;
  75748. private _options;
  75749. private _scene;
  75750. private _currentPriorityLevel;
  75751. private _targetFrameRate;
  75752. private _trackerDuration;
  75753. private _currentFrameRate;
  75754. private _sceneDisposeObserver;
  75755. private _improvementMode;
  75756. /**
  75757. * Defines an observable called when the optimizer reaches the target frame rate
  75758. */
  75759. onSuccessObservable: Observable<SceneOptimizer>;
  75760. /**
  75761. * Defines an observable called when the optimizer enables an optimization
  75762. */
  75763. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  75764. /**
  75765. * Defines an observable called when the optimizer is not able to reach the target frame rate
  75766. */
  75767. onFailureObservable: Observable<SceneOptimizer>;
  75768. /**
  75769. * Gets a boolean indicating if the optimizer is in improvement mode
  75770. */
  75771. get isInImprovementMode(): boolean;
  75772. /**
  75773. * Gets the current priority level (0 at start)
  75774. */
  75775. get currentPriorityLevel(): number;
  75776. /**
  75777. * Gets the current frame rate checked by the SceneOptimizer
  75778. */
  75779. get currentFrameRate(): number;
  75780. /**
  75781. * Gets or sets the current target frame rate (60 by default)
  75782. */
  75783. get targetFrameRate(): number;
  75784. /**
  75785. * Gets or sets the current target frame rate (60 by default)
  75786. */
  75787. set targetFrameRate(value: number);
  75788. /**
  75789. * Gets or sets the current interval between two checks (every 2000ms by default)
  75790. */
  75791. get trackerDuration(): number;
  75792. /**
  75793. * Gets or sets the current interval between two checks (every 2000ms by default)
  75794. */
  75795. set trackerDuration(value: number);
  75796. /**
  75797. * Gets the list of active optimizations
  75798. */
  75799. get optimizations(): SceneOptimization[];
  75800. /**
  75801. * Creates a new SceneOptimizer
  75802. * @param scene defines the scene to work on
  75803. * @param options defines the options to use with the SceneOptimizer
  75804. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  75805. * @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)
  75806. */
  75807. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  75808. /**
  75809. * Stops the current optimizer
  75810. */
  75811. stop(): void;
  75812. /**
  75813. * Reset the optimizer to initial step (current priority level = 0)
  75814. */
  75815. reset(): void;
  75816. /**
  75817. * Start the optimizer. By default it will try to reach a specific framerate
  75818. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  75819. */
  75820. start(): void;
  75821. private _checkCurrentState;
  75822. /**
  75823. * Release all resources
  75824. */
  75825. dispose(): void;
  75826. /**
  75827. * Helper function to create a SceneOptimizer with one single line of code
  75828. * @param scene defines the scene to work on
  75829. * @param options defines the options to use with the SceneOptimizer
  75830. * @param onSuccess defines a callback to call on success
  75831. * @param onFailure defines a callback to call on failure
  75832. * @returns the new SceneOptimizer object
  75833. */
  75834. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  75835. }
  75836. }
  75837. declare module "babylonjs/Misc/sceneSerializer" {
  75838. import { Scene } from "babylonjs/scene";
  75839. /**
  75840. * Class used to serialize a scene into a string
  75841. */
  75842. export class SceneSerializer {
  75843. /**
  75844. * Clear cache used by a previous serialization
  75845. */
  75846. static ClearCache(): void;
  75847. /**
  75848. * Serialize a scene into a JSON compatible object
  75849. * @param scene defines the scene to serialize
  75850. * @returns a JSON compatible object
  75851. */
  75852. static Serialize(scene: Scene): any;
  75853. /**
  75854. * Serialize a mesh into a JSON compatible object
  75855. * @param toSerialize defines the mesh to serialize
  75856. * @param withParents defines if parents must be serialized as well
  75857. * @param withChildren defines if children must be serialized as well
  75858. * @returns a JSON compatible object
  75859. */
  75860. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  75861. }
  75862. }
  75863. declare module "babylonjs/Misc/textureTools" {
  75864. import { Texture } from "babylonjs/Materials/Textures/texture";
  75865. /**
  75866. * Class used to host texture specific utilities
  75867. */
  75868. export class TextureTools {
  75869. /**
  75870. * Uses the GPU to create a copy texture rescaled at a given size
  75871. * @param texture Texture to copy from
  75872. * @param width defines the desired width
  75873. * @param height defines the desired height
  75874. * @param useBilinearMode defines if bilinear mode has to be used
  75875. * @return the generated texture
  75876. */
  75877. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  75878. }
  75879. }
  75880. declare module "babylonjs/Misc/videoRecorder" {
  75881. import { Nullable } from "babylonjs/types";
  75882. import { Engine } from "babylonjs/Engines/engine";
  75883. /**
  75884. * This represents the different options available for the video capture.
  75885. */
  75886. export interface VideoRecorderOptions {
  75887. /** Defines the mime type of the video. */
  75888. mimeType: string;
  75889. /** Defines the FPS the video should be recorded at. */
  75890. fps: number;
  75891. /** Defines the chunk size for the recording data. */
  75892. recordChunckSize: number;
  75893. /** The audio tracks to attach to the recording. */
  75894. audioTracks?: MediaStreamTrack[];
  75895. }
  75896. /**
  75897. * This can help with recording videos from BabylonJS.
  75898. * This is based on the available WebRTC functionalities of the browser.
  75899. *
  75900. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  75901. */
  75902. export class VideoRecorder {
  75903. private static readonly _defaultOptions;
  75904. /**
  75905. * Returns whether or not the VideoRecorder is available in your browser.
  75906. * @param engine Defines the Babylon Engine.
  75907. * @returns true if supported otherwise false.
  75908. */
  75909. static IsSupported(engine: Engine): boolean;
  75910. private readonly _options;
  75911. private _canvas;
  75912. private _mediaRecorder;
  75913. private _recordedChunks;
  75914. private _fileName;
  75915. private _resolve;
  75916. private _reject;
  75917. /**
  75918. * True when a recording is already in progress.
  75919. */
  75920. get isRecording(): boolean;
  75921. /**
  75922. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  75923. * @param engine Defines the BabylonJS Engine you wish to record.
  75924. * @param options Defines options that can be used to customize the capture.
  75925. */
  75926. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  75927. /**
  75928. * Stops the current recording before the default capture timeout passed in the startRecording function.
  75929. */
  75930. stopRecording(): void;
  75931. /**
  75932. * Starts recording the canvas for a max duration specified in parameters.
  75933. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  75934. * If null no automatic download will start and you can rely on the promise to get the data back.
  75935. * @param maxDuration Defines the maximum recording time in seconds.
  75936. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  75937. * @return A promise callback at the end of the recording with the video data in Blob.
  75938. */
  75939. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  75940. /**
  75941. * Releases internal resources used during the recording.
  75942. */
  75943. dispose(): void;
  75944. private _handleDataAvailable;
  75945. private _handleError;
  75946. private _handleStop;
  75947. }
  75948. }
  75949. declare module "babylonjs/Misc/screenshotTools" {
  75950. import { Camera } from "babylonjs/Cameras/camera";
  75951. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  75952. import { Engine } from "babylonjs/Engines/engine";
  75953. /**
  75954. * Class containing a set of static utilities functions for screenshots
  75955. */
  75956. export class ScreenshotTools {
  75957. /**
  75958. * Captures a screenshot of the current rendering
  75959. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  75960. * @param engine defines the rendering engine
  75961. * @param camera defines the source camera
  75962. * @param size This parameter can be set to a single number or to an object with the
  75963. * following (optional) properties: precision, width, height. If a single number is passed,
  75964. * it will be used for both width and height. If an object is passed, the screenshot size
  75965. * will be derived from the parameters. The precision property is a multiplier allowing
  75966. * rendering at a higher or lower resolution
  75967. * @param successCallback defines the callback receives a single parameter which contains the
  75968. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75969. * src parameter of an <img> to display it
  75970. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75971. * Check your browser for supported MIME types
  75972. */
  75973. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  75974. /**
  75975. * Captures a screenshot of the current rendering
  75976. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  75977. * @param engine defines the rendering engine
  75978. * @param camera defines the source camera
  75979. * @param size This parameter can be set to a single number or to an object with the
  75980. * following (optional) properties: precision, width, height. If a single number is passed,
  75981. * it will be used for both width and height. If an object is passed, the screenshot size
  75982. * will be derived from the parameters. The precision property is a multiplier allowing
  75983. * rendering at a higher or lower resolution
  75984. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75985. * Check your browser for supported MIME types
  75986. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75987. * to the src parameter of an <img> to display it
  75988. */
  75989. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  75990. /**
  75991. * Generates an image screenshot from the specified camera.
  75992. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  75993. * @param engine The engine to use for rendering
  75994. * @param camera The camera to use for rendering
  75995. * @param size This parameter can be set to a single number or to an object with the
  75996. * following (optional) properties: precision, width, height. If a single number is passed,
  75997. * it will be used for both width and height. If an object is passed, the screenshot size
  75998. * will be derived from the parameters. The precision property is a multiplier allowing
  75999. * rendering at a higher or lower resolution
  76000. * @param successCallback The callback receives a single parameter which contains the
  76001. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  76002. * src parameter of an <img> to display it
  76003. * @param mimeType The MIME type of the screenshot image (default: image/png).
  76004. * Check your browser for supported MIME types
  76005. * @param samples Texture samples (default: 1)
  76006. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  76007. * @param fileName A name for for the downloaded file.
  76008. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  76009. */
  76010. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  76011. /**
  76012. * Generates an image screenshot from the specified camera.
  76013. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  76014. * @param engine The engine to use for rendering
  76015. * @param camera The camera to use for rendering
  76016. * @param size This parameter can be set to a single number or to an object with the
  76017. * following (optional) properties: precision, width, height. If a single number is passed,
  76018. * it will be used for both width and height. If an object is passed, the screenshot size
  76019. * will be derived from the parameters. The precision property is a multiplier allowing
  76020. * rendering at a higher or lower resolution
  76021. * @param mimeType The MIME type of the screenshot image (default: image/png).
  76022. * Check your browser for supported MIME types
  76023. * @param samples Texture samples (default: 1)
  76024. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  76025. * @param fileName A name for for the downloaded file.
  76026. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  76027. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  76028. * to the src parameter of an <img> to display it
  76029. */
  76030. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  76031. /**
  76032. * Gets height and width for screenshot size
  76033. * @private
  76034. */
  76035. private static _getScreenshotSize;
  76036. }
  76037. }
  76038. declare module "babylonjs/Misc/dataReader" {
  76039. /**
  76040. * Interface for a data buffer
  76041. */
  76042. export interface IDataBuffer {
  76043. /**
  76044. * Reads bytes from the data buffer.
  76045. * @param byteOffset The byte offset to read
  76046. * @param byteLength The byte length to read
  76047. * @returns A promise that resolves when the bytes are read
  76048. */
  76049. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  76050. /**
  76051. * The byte length of the buffer.
  76052. */
  76053. readonly byteLength: number;
  76054. }
  76055. /**
  76056. * Utility class for reading from a data buffer
  76057. */
  76058. export class DataReader {
  76059. /**
  76060. * The data buffer associated with this data reader.
  76061. */
  76062. readonly buffer: IDataBuffer;
  76063. /**
  76064. * The current byte offset from the beginning of the data buffer.
  76065. */
  76066. byteOffset: number;
  76067. private _dataView;
  76068. private _dataByteOffset;
  76069. /**
  76070. * Constructor
  76071. * @param buffer The buffer to read
  76072. */
  76073. constructor(buffer: IDataBuffer);
  76074. /**
  76075. * Loads the given byte length.
  76076. * @param byteLength The byte length to load
  76077. * @returns A promise that resolves when the load is complete
  76078. */
  76079. loadAsync(byteLength: number): Promise<void>;
  76080. /**
  76081. * Read a unsigned 32-bit integer from the currently loaded data range.
  76082. * @returns The 32-bit integer read
  76083. */
  76084. readUint32(): number;
  76085. /**
  76086. * Read a byte array from the currently loaded data range.
  76087. * @param byteLength The byte length to read
  76088. * @returns The byte array read
  76089. */
  76090. readUint8Array(byteLength: number): Uint8Array;
  76091. /**
  76092. * Read a string from the currently loaded data range.
  76093. * @param byteLength The byte length to read
  76094. * @returns The string read
  76095. */
  76096. readString(byteLength: number): string;
  76097. /**
  76098. * Skips the given byte length the currently loaded data range.
  76099. * @param byteLength The byte length to skip
  76100. */
  76101. skipBytes(byteLength: number): void;
  76102. }
  76103. }
  76104. declare module "babylonjs/Misc/dataStorage" {
  76105. /**
  76106. * Class for storing data to local storage if available or in-memory storage otherwise
  76107. */
  76108. export class DataStorage {
  76109. private static _Storage;
  76110. private static _GetStorage;
  76111. /**
  76112. * Reads a string from the data storage
  76113. * @param key The key to read
  76114. * @param defaultValue The value if the key doesn't exist
  76115. * @returns The string value
  76116. */
  76117. static ReadString(key: string, defaultValue: string): string;
  76118. /**
  76119. * Writes a string to the data storage
  76120. * @param key The key to write
  76121. * @param value The value to write
  76122. */
  76123. static WriteString(key: string, value: string): void;
  76124. /**
  76125. * Reads a boolean from the data storage
  76126. * @param key The key to read
  76127. * @param defaultValue The value if the key doesn't exist
  76128. * @returns The boolean value
  76129. */
  76130. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  76131. /**
  76132. * Writes a boolean to the data storage
  76133. * @param key The key to write
  76134. * @param value The value to write
  76135. */
  76136. static WriteBoolean(key: string, value: boolean): void;
  76137. /**
  76138. * Reads a number from the data storage
  76139. * @param key The key to read
  76140. * @param defaultValue The value if the key doesn't exist
  76141. * @returns The number value
  76142. */
  76143. static ReadNumber(key: string, defaultValue: number): number;
  76144. /**
  76145. * Writes a number to the data storage
  76146. * @param key The key to write
  76147. * @param value The value to write
  76148. */
  76149. static WriteNumber(key: string, value: number): void;
  76150. }
  76151. }
  76152. declare module "babylonjs/Misc/index" {
  76153. export * from "babylonjs/Misc/andOrNotEvaluator";
  76154. export * from "babylonjs/Misc/assetsManager";
  76155. export * from "babylonjs/Misc/basis";
  76156. export * from "babylonjs/Misc/dds";
  76157. export * from "babylonjs/Misc/decorators";
  76158. export * from "babylonjs/Misc/deferred";
  76159. export * from "babylonjs/Misc/environmentTextureTools";
  76160. export * from "babylonjs/Misc/meshExploder";
  76161. export * from "babylonjs/Misc/filesInput";
  76162. export * from "babylonjs/Misc/HighDynamicRange/index";
  76163. export * from "babylonjs/Misc/khronosTextureContainer";
  76164. export * from "babylonjs/Misc/observable";
  76165. export * from "babylonjs/Misc/performanceMonitor";
  76166. export * from "babylonjs/Misc/promise";
  76167. export * from "babylonjs/Misc/sceneOptimizer";
  76168. export * from "babylonjs/Misc/sceneSerializer";
  76169. export * from "babylonjs/Misc/smartArray";
  76170. export * from "babylonjs/Misc/stringDictionary";
  76171. export * from "babylonjs/Misc/tags";
  76172. export * from "babylonjs/Misc/textureTools";
  76173. export * from "babylonjs/Misc/tga";
  76174. export * from "babylonjs/Misc/tools";
  76175. export * from "babylonjs/Misc/videoRecorder";
  76176. export * from "babylonjs/Misc/virtualJoystick";
  76177. export * from "babylonjs/Misc/workerPool";
  76178. export * from "babylonjs/Misc/logger";
  76179. export * from "babylonjs/Misc/typeStore";
  76180. export * from "babylonjs/Misc/filesInputStore";
  76181. export * from "babylonjs/Misc/deepCopier";
  76182. export * from "babylonjs/Misc/pivotTools";
  76183. export * from "babylonjs/Misc/precisionDate";
  76184. export * from "babylonjs/Misc/screenshotTools";
  76185. export * from "babylonjs/Misc/typeStore";
  76186. export * from "babylonjs/Misc/webRequest";
  76187. export * from "babylonjs/Misc/iInspectable";
  76188. export * from "babylonjs/Misc/brdfTextureTools";
  76189. export * from "babylonjs/Misc/rgbdTextureTools";
  76190. export * from "babylonjs/Misc/gradients";
  76191. export * from "babylonjs/Misc/perfCounter";
  76192. export * from "babylonjs/Misc/fileRequest";
  76193. export * from "babylonjs/Misc/customAnimationFrameRequester";
  76194. export * from "babylonjs/Misc/retryStrategy";
  76195. export * from "babylonjs/Misc/interfaces/screenshotSize";
  76196. export * from "babylonjs/Misc/canvasGenerator";
  76197. export * from "babylonjs/Misc/fileTools";
  76198. export * from "babylonjs/Misc/stringTools";
  76199. export * from "babylonjs/Misc/dataReader";
  76200. export * from "babylonjs/Misc/minMaxReducer";
  76201. export * from "babylonjs/Misc/depthReducer";
  76202. export * from "babylonjs/Misc/dataStorage";
  76203. }
  76204. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  76205. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  76206. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76207. import { Observable } from "babylonjs/Misc/observable";
  76208. import { Matrix } from "babylonjs/Maths/math.vector";
  76209. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76210. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76211. /**
  76212. * An interface for all Hit test features
  76213. */
  76214. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  76215. /**
  76216. * Triggered when new babylon (transformed) hit test results are available
  76217. */
  76218. onHitTestResultObservable: Observable<T[]>;
  76219. }
  76220. /**
  76221. * Options used for hit testing
  76222. */
  76223. export interface IWebXRLegacyHitTestOptions {
  76224. /**
  76225. * Only test when user interacted with the scene. Default - hit test every frame
  76226. */
  76227. testOnPointerDownOnly?: boolean;
  76228. /**
  76229. * The node to use to transform the local results to world coordinates
  76230. */
  76231. worldParentNode?: TransformNode;
  76232. }
  76233. /**
  76234. * Interface defining the babylon result of raycasting/hit-test
  76235. */
  76236. export interface IWebXRLegacyHitResult {
  76237. /**
  76238. * Transformation matrix that can be applied to a node that will put it in the hit point location
  76239. */
  76240. transformationMatrix: Matrix;
  76241. /**
  76242. * The native hit test result
  76243. */
  76244. xrHitResult: XRHitResult | XRHitTestResult;
  76245. }
  76246. /**
  76247. * The currently-working hit-test module.
  76248. * Hit test (or Ray-casting) is used to interact with the real world.
  76249. * For further information read here - https://github.com/immersive-web/hit-test
  76250. */
  76251. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  76252. /**
  76253. * options to use when constructing this feature
  76254. */
  76255. readonly options: IWebXRLegacyHitTestOptions;
  76256. private _direction;
  76257. private _mat;
  76258. private _onSelectEnabled;
  76259. private _origin;
  76260. /**
  76261. * The module's name
  76262. */
  76263. static readonly Name: string;
  76264. /**
  76265. * The (Babylon) version of this module.
  76266. * This is an integer representing the implementation version.
  76267. * This number does not correspond to the WebXR specs version
  76268. */
  76269. static readonly Version: number;
  76270. /**
  76271. * Populated with the last native XR Hit Results
  76272. */
  76273. lastNativeXRHitResults: XRHitResult[];
  76274. /**
  76275. * Triggered when new babylon (transformed) hit test results are available
  76276. */
  76277. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  76278. /**
  76279. * Creates a new instance of the (legacy version) hit test feature
  76280. * @param _xrSessionManager an instance of WebXRSessionManager
  76281. * @param options options to use when constructing this feature
  76282. */
  76283. constructor(_xrSessionManager: WebXRSessionManager,
  76284. /**
  76285. * options to use when constructing this feature
  76286. */
  76287. options?: IWebXRLegacyHitTestOptions);
  76288. /**
  76289. * execute a hit test with an XR Ray
  76290. *
  76291. * @param xrSession a native xrSession that will execute this hit test
  76292. * @param xrRay the ray (position and direction) to use for ray-casting
  76293. * @param referenceSpace native XR reference space to use for the hit-test
  76294. * @param filter filter function that will filter the results
  76295. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76296. */
  76297. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  76298. /**
  76299. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  76300. * @param event the (select) event to use to select with
  76301. * @param referenceSpace the reference space to use for this hit test
  76302. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76303. */
  76304. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76305. /**
  76306. * attach this feature
  76307. * Will usually be called by the features manager
  76308. *
  76309. * @returns true if successful.
  76310. */
  76311. attach(): boolean;
  76312. /**
  76313. * detach this feature.
  76314. * Will usually be called by the features manager
  76315. *
  76316. * @returns true if successful.
  76317. */
  76318. detach(): boolean;
  76319. /**
  76320. * Dispose this feature and all of the resources attached
  76321. */
  76322. dispose(): void;
  76323. protected _onXRFrame(frame: XRFrame): void;
  76324. private _onHitTestResults;
  76325. private _onSelect;
  76326. }
  76327. }
  76328. declare module "babylonjs/XR/features/WebXRHitTest" {
  76329. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76330. import { Observable } from "babylonjs/Misc/observable";
  76331. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  76332. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76333. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  76334. /**
  76335. * Options used for hit testing (version 2)
  76336. */
  76337. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  76338. /**
  76339. * Do not create a permanent hit test. Will usually be used when only
  76340. * transient inputs are needed.
  76341. */
  76342. disablePermanentHitTest?: boolean;
  76343. /**
  76344. * Enable transient (for example touch-based) hit test inspections
  76345. */
  76346. enableTransientHitTest?: boolean;
  76347. /**
  76348. * Offset ray for the permanent hit test
  76349. */
  76350. offsetRay?: Vector3;
  76351. /**
  76352. * Offset ray for the transient hit test
  76353. */
  76354. transientOffsetRay?: Vector3;
  76355. /**
  76356. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  76357. */
  76358. useReferenceSpace?: boolean;
  76359. }
  76360. /**
  76361. * Interface defining the babylon result of hit-test
  76362. */
  76363. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  76364. /**
  76365. * The input source that generated this hit test (if transient)
  76366. */
  76367. inputSource?: XRInputSource;
  76368. /**
  76369. * Is this a transient hit test
  76370. */
  76371. isTransient?: boolean;
  76372. /**
  76373. * Position of the hit test result
  76374. */
  76375. position: Vector3;
  76376. /**
  76377. * Rotation of the hit test result
  76378. */
  76379. rotationQuaternion: Quaternion;
  76380. /**
  76381. * The native hit test result
  76382. */
  76383. xrHitResult: XRHitTestResult;
  76384. }
  76385. /**
  76386. * The currently-working hit-test module.
  76387. * Hit test (or Ray-casting) is used to interact with the real world.
  76388. * For further information read here - https://github.com/immersive-web/hit-test
  76389. *
  76390. * Tested on chrome (mobile) 80.
  76391. */
  76392. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  76393. /**
  76394. * options to use when constructing this feature
  76395. */
  76396. readonly options: IWebXRHitTestOptions;
  76397. private _tmpMat;
  76398. private _tmpPos;
  76399. private _tmpQuat;
  76400. private _transientXrHitTestSource;
  76401. private _xrHitTestSource;
  76402. private initHitTestSource;
  76403. /**
  76404. * The module's name
  76405. */
  76406. static readonly Name: string;
  76407. /**
  76408. * The (Babylon) version of this module.
  76409. * This is an integer representing the implementation version.
  76410. * This number does not correspond to the WebXR specs version
  76411. */
  76412. static readonly Version: number;
  76413. /**
  76414. * When set to true, each hit test will have its own position/rotation objects
  76415. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  76416. * the developers will clone them or copy them as they see fit.
  76417. */
  76418. autoCloneTransformation: boolean;
  76419. /**
  76420. * Triggered when new babylon (transformed) hit test results are available
  76421. */
  76422. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  76423. /**
  76424. * Use this to temporarily pause hit test checks.
  76425. */
  76426. paused: boolean;
  76427. /**
  76428. * Creates a new instance of the hit test feature
  76429. * @param _xrSessionManager an instance of WebXRSessionManager
  76430. * @param options options to use when constructing this feature
  76431. */
  76432. constructor(_xrSessionManager: WebXRSessionManager,
  76433. /**
  76434. * options to use when constructing this feature
  76435. */
  76436. options?: IWebXRHitTestOptions);
  76437. /**
  76438. * attach this feature
  76439. * Will usually be called by the features manager
  76440. *
  76441. * @returns true if successful.
  76442. */
  76443. attach(): boolean;
  76444. /**
  76445. * detach this feature.
  76446. * Will usually be called by the features manager
  76447. *
  76448. * @returns true if successful.
  76449. */
  76450. detach(): boolean;
  76451. /**
  76452. * Dispose this feature and all of the resources attached
  76453. */
  76454. dispose(): void;
  76455. protected _onXRFrame(frame: XRFrame): void;
  76456. private _processWebXRHitTestResult;
  76457. }
  76458. }
  76459. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  76460. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76461. import { Observable } from "babylonjs/Misc/observable";
  76462. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  76463. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76464. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76465. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  76466. /**
  76467. * Configuration options of the anchor system
  76468. */
  76469. export interface IWebXRAnchorSystemOptions {
  76470. /**
  76471. * a node that will be used to convert local to world coordinates
  76472. */
  76473. worldParentNode?: TransformNode;
  76474. /**
  76475. * If set to true a reference of the created anchors will be kept until the next session starts
  76476. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  76477. */
  76478. doNotRemoveAnchorsOnSessionEnded?: boolean;
  76479. }
  76480. /**
  76481. * A babylon container for an XR Anchor
  76482. */
  76483. export interface IWebXRAnchor {
  76484. /**
  76485. * A babylon-assigned ID for this anchor
  76486. */
  76487. id: number;
  76488. /**
  76489. * Transformation matrix to apply to an object attached to this anchor
  76490. */
  76491. transformationMatrix: Matrix;
  76492. /**
  76493. * The native anchor object
  76494. */
  76495. xrAnchor: XRAnchor;
  76496. /**
  76497. * if defined, this object will be constantly updated by the anchor's position and rotation
  76498. */
  76499. attachedNode?: TransformNode;
  76500. }
  76501. /**
  76502. * An implementation of the anchor system for WebXR.
  76503. * For further information see https://github.com/immersive-web/anchors/
  76504. */
  76505. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  76506. private _options;
  76507. private _lastFrameDetected;
  76508. private _trackedAnchors;
  76509. private _referenceSpaceForFrameAnchors;
  76510. private _futureAnchors;
  76511. /**
  76512. * The module's name
  76513. */
  76514. static readonly Name: string;
  76515. /**
  76516. * The (Babylon) version of this module.
  76517. * This is an integer representing the implementation version.
  76518. * This number does not correspond to the WebXR specs version
  76519. */
  76520. static readonly Version: number;
  76521. /**
  76522. * Observers registered here will be executed when a new anchor was added to the session
  76523. */
  76524. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  76525. /**
  76526. * Observers registered here will be executed when an anchor was removed from the session
  76527. */
  76528. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  76529. /**
  76530. * Observers registered here will be executed when an existing anchor updates
  76531. * This can execute N times every frame
  76532. */
  76533. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  76534. /**
  76535. * Set the reference space to use for anchor creation, when not using a hit test.
  76536. * Will default to the session's reference space if not defined
  76537. */
  76538. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  76539. /**
  76540. * constructs a new anchor system
  76541. * @param _xrSessionManager an instance of WebXRSessionManager
  76542. * @param _options configuration object for this feature
  76543. */
  76544. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  76545. private _tmpVector;
  76546. private _tmpQuaternion;
  76547. private _populateTmpTransformation;
  76548. /**
  76549. * Create a new anchor point using a hit test result at a specific point in the scene
  76550. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76551. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76552. *
  76553. * @param hitTestResult The hit test result to use for this anchor creation
  76554. * @param position an optional position offset for this anchor
  76555. * @param rotationQuaternion an optional rotation offset for this anchor
  76556. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  76557. */
  76558. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  76559. /**
  76560. * Add a new anchor at a specific position and rotation
  76561. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  76562. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  76563. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76564. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76565. *
  76566. * @param position the position in which to add an anchor
  76567. * @param rotationQuaternion an optional rotation for the anchor transformation
  76568. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  76569. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  76570. */
  76571. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  76572. /**
  76573. * detach this feature.
  76574. * Will usually be called by the features manager
  76575. *
  76576. * @returns true if successful.
  76577. */
  76578. detach(): boolean;
  76579. /**
  76580. * Dispose this feature and all of the resources attached
  76581. */
  76582. dispose(): void;
  76583. protected _onXRFrame(frame: XRFrame): void;
  76584. /**
  76585. * avoiding using Array.find for global support.
  76586. * @param xrAnchor the plane to find in the array
  76587. */
  76588. private _findIndexInAnchorArray;
  76589. private _updateAnchorWithXRFrame;
  76590. private _createAnchorAtTransformation;
  76591. }
  76592. }
  76593. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  76594. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76595. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76596. import { Observable } from "babylonjs/Misc/observable";
  76597. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  76598. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76599. /**
  76600. * Options used in the plane detector module
  76601. */
  76602. export interface IWebXRPlaneDetectorOptions {
  76603. /**
  76604. * The node to use to transform the local results to world coordinates
  76605. */
  76606. worldParentNode?: TransformNode;
  76607. /**
  76608. * If set to true a reference of the created planes will be kept until the next session starts
  76609. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  76610. */
  76611. doNotRemovePlanesOnSessionEnded?: boolean;
  76612. }
  76613. /**
  76614. * A babylon interface for a WebXR plane.
  76615. * A Plane is actually a polygon, built from N points in space
  76616. *
  76617. * Supported in chrome 79, not supported in canary 81 ATM
  76618. */
  76619. export interface IWebXRPlane {
  76620. /**
  76621. * a babylon-assigned ID for this polygon
  76622. */
  76623. id: number;
  76624. /**
  76625. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  76626. */
  76627. polygonDefinition: Array<Vector3>;
  76628. /**
  76629. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  76630. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  76631. */
  76632. transformationMatrix: Matrix;
  76633. /**
  76634. * the native xr-plane object
  76635. */
  76636. xrPlane: XRPlane;
  76637. }
  76638. /**
  76639. * The plane detector is used to detect planes in the real world when in AR
  76640. * For more information see https://github.com/immersive-web/real-world-geometry/
  76641. */
  76642. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  76643. private _options;
  76644. private _detectedPlanes;
  76645. private _enabled;
  76646. private _lastFrameDetected;
  76647. /**
  76648. * The module's name
  76649. */
  76650. static readonly Name: string;
  76651. /**
  76652. * The (Babylon) version of this module.
  76653. * This is an integer representing the implementation version.
  76654. * This number does not correspond to the WebXR specs version
  76655. */
  76656. static readonly Version: number;
  76657. /**
  76658. * Observers registered here will be executed when a new plane was added to the session
  76659. */
  76660. onPlaneAddedObservable: Observable<IWebXRPlane>;
  76661. /**
  76662. * Observers registered here will be executed when a plane is no longer detected in the session
  76663. */
  76664. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  76665. /**
  76666. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  76667. * This can execute N times every frame
  76668. */
  76669. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  76670. /**
  76671. * construct a new Plane Detector
  76672. * @param _xrSessionManager an instance of xr Session manager
  76673. * @param _options configuration to use when constructing this feature
  76674. */
  76675. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  76676. /**
  76677. * detach this feature.
  76678. * Will usually be called by the features manager
  76679. *
  76680. * @returns true if successful.
  76681. */
  76682. detach(): boolean;
  76683. /**
  76684. * Dispose this feature and all of the resources attached
  76685. */
  76686. dispose(): void;
  76687. protected _onXRFrame(frame: XRFrame): void;
  76688. private _init;
  76689. private _updatePlaneWithXRPlane;
  76690. /**
  76691. * avoiding using Array.find for global support.
  76692. * @param xrPlane the plane to find in the array
  76693. */
  76694. private findIndexInPlaneArray;
  76695. }
  76696. }
  76697. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  76698. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76700. import { Observable } from "babylonjs/Misc/observable";
  76701. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76702. /**
  76703. * Options interface for the background remover plugin
  76704. */
  76705. export interface IWebXRBackgroundRemoverOptions {
  76706. /**
  76707. * Further background meshes to disable when entering AR
  76708. */
  76709. backgroundMeshes?: AbstractMesh[];
  76710. /**
  76711. * flags to configure the removal of the environment helper.
  76712. * If not set, the entire background will be removed. If set, flags should be set as well.
  76713. */
  76714. environmentHelperRemovalFlags?: {
  76715. /**
  76716. * Should the skybox be removed (default false)
  76717. */
  76718. skyBox?: boolean;
  76719. /**
  76720. * Should the ground be removed (default false)
  76721. */
  76722. ground?: boolean;
  76723. };
  76724. /**
  76725. * don't disable the environment helper
  76726. */
  76727. ignoreEnvironmentHelper?: boolean;
  76728. }
  76729. /**
  76730. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  76731. */
  76732. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  76733. /**
  76734. * read-only options to be used in this module
  76735. */
  76736. readonly options: IWebXRBackgroundRemoverOptions;
  76737. /**
  76738. * The module's name
  76739. */
  76740. static readonly Name: string;
  76741. /**
  76742. * The (Babylon) version of this module.
  76743. * This is an integer representing the implementation version.
  76744. * This number does not correspond to the WebXR specs version
  76745. */
  76746. static readonly Version: number;
  76747. /**
  76748. * registered observers will be triggered when the background state changes
  76749. */
  76750. onBackgroundStateChangedObservable: Observable<boolean>;
  76751. /**
  76752. * constructs a new background remover module
  76753. * @param _xrSessionManager the session manager for this module
  76754. * @param options read-only options to be used in this module
  76755. */
  76756. constructor(_xrSessionManager: WebXRSessionManager,
  76757. /**
  76758. * read-only options to be used in this module
  76759. */
  76760. options?: IWebXRBackgroundRemoverOptions);
  76761. /**
  76762. * attach this feature
  76763. * Will usually be called by the features manager
  76764. *
  76765. * @returns true if successful.
  76766. */
  76767. attach(): boolean;
  76768. /**
  76769. * detach this feature.
  76770. * Will usually be called by the features manager
  76771. *
  76772. * @returns true if successful.
  76773. */
  76774. detach(): boolean;
  76775. /**
  76776. * Dispose this feature and all of the resources attached
  76777. */
  76778. dispose(): void;
  76779. protected _onXRFrame(_xrFrame: XRFrame): void;
  76780. private _setBackgroundState;
  76781. }
  76782. }
  76783. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  76784. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76785. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  76786. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  76787. import { WebXRInput } from "babylonjs/XR/webXRInput";
  76788. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76789. import { Nullable } from "babylonjs/types";
  76790. /**
  76791. * Options for the controller physics feature
  76792. */
  76793. export class IWebXRControllerPhysicsOptions {
  76794. /**
  76795. * Should the headset get its own impostor
  76796. */
  76797. enableHeadsetImpostor?: boolean;
  76798. /**
  76799. * Optional parameters for the headset impostor
  76800. */
  76801. headsetImpostorParams?: {
  76802. /**
  76803. * The type of impostor to create. Default is sphere
  76804. */
  76805. impostorType: number;
  76806. /**
  76807. * the size of the impostor. Defaults to 10cm
  76808. */
  76809. impostorSize?: number | {
  76810. width: number;
  76811. height: number;
  76812. depth: number;
  76813. };
  76814. /**
  76815. * Friction definitions
  76816. */
  76817. friction?: number;
  76818. /**
  76819. * Restitution
  76820. */
  76821. restitution?: number;
  76822. };
  76823. /**
  76824. * The physics properties of the future impostors
  76825. */
  76826. physicsProperties?: {
  76827. /**
  76828. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  76829. * Note that this requires a physics engine that supports mesh impostors!
  76830. */
  76831. useControllerMesh?: boolean;
  76832. /**
  76833. * The type of impostor to create. Default is sphere
  76834. */
  76835. impostorType?: number;
  76836. /**
  76837. * the size of the impostor. Defaults to 10cm
  76838. */
  76839. impostorSize?: number | {
  76840. width: number;
  76841. height: number;
  76842. depth: number;
  76843. };
  76844. /**
  76845. * Friction definitions
  76846. */
  76847. friction?: number;
  76848. /**
  76849. * Restitution
  76850. */
  76851. restitution?: number;
  76852. };
  76853. /**
  76854. * the xr input to use with this pointer selection
  76855. */
  76856. xrInput: WebXRInput;
  76857. }
  76858. /**
  76859. * Add physics impostor to your webxr controllers,
  76860. * including naive calculation of their linear and angular velocity
  76861. */
  76862. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  76863. private readonly _options;
  76864. private _attachController;
  76865. private _controllers;
  76866. private _debugMode;
  76867. private _delta;
  76868. private _headsetImpostor?;
  76869. private _headsetMesh?;
  76870. private _lastTimestamp;
  76871. private _tmpQuaternion;
  76872. private _tmpVector;
  76873. /**
  76874. * The module's name
  76875. */
  76876. static readonly Name: string;
  76877. /**
  76878. * The (Babylon) version of this module.
  76879. * This is an integer representing the implementation version.
  76880. * This number does not correspond to the webxr specs version
  76881. */
  76882. static readonly Version: number;
  76883. /**
  76884. * Construct a new Controller Physics Feature
  76885. * @param _xrSessionManager the corresponding xr session manager
  76886. * @param _options options to create this feature with
  76887. */
  76888. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  76889. /**
  76890. * @hidden
  76891. * enable debugging - will show console outputs and the impostor mesh
  76892. */
  76893. _enablePhysicsDebug(): void;
  76894. /**
  76895. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  76896. * @param xrController the controller to add
  76897. */
  76898. addController(xrController: WebXRInputSource): void;
  76899. /**
  76900. * attach this feature
  76901. * Will usually be called by the features manager
  76902. *
  76903. * @returns true if successful.
  76904. */
  76905. attach(): boolean;
  76906. /**
  76907. * detach this feature.
  76908. * Will usually be called by the features manager
  76909. *
  76910. * @returns true if successful.
  76911. */
  76912. detach(): boolean;
  76913. /**
  76914. * Get the headset impostor, if enabled
  76915. * @returns the impostor
  76916. */
  76917. getHeadsetImpostor(): PhysicsImpostor | undefined;
  76918. /**
  76919. * Get the physics impostor of a specific controller.
  76920. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  76921. * @param controller the controller or the controller id of which to get the impostor
  76922. * @returns the impostor or null
  76923. */
  76924. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  76925. /**
  76926. * Update the physics properties provided in the constructor
  76927. * @param newProperties the new properties object
  76928. */
  76929. setPhysicsProperties(newProperties: {
  76930. impostorType?: number;
  76931. impostorSize?: number | {
  76932. width: number;
  76933. height: number;
  76934. depth: number;
  76935. };
  76936. friction?: number;
  76937. restitution?: number;
  76938. }): void;
  76939. protected _onXRFrame(_xrFrame: any): void;
  76940. private _detachController;
  76941. }
  76942. }
  76943. declare module "babylonjs/XR/features/index" {
  76944. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  76945. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  76946. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  76947. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  76948. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  76949. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  76950. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  76951. export * from "babylonjs/XR/features/WebXRHitTest";
  76952. }
  76953. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  76954. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  76955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76956. import { Scene } from "babylonjs/scene";
  76957. /**
  76958. * The motion controller class for all microsoft mixed reality controllers
  76959. */
  76960. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76961. protected readonly _mapping: {
  76962. defaultButton: {
  76963. valueNodeName: string;
  76964. unpressedNodeName: string;
  76965. pressedNodeName: string;
  76966. };
  76967. defaultAxis: {
  76968. valueNodeName: string;
  76969. minNodeName: string;
  76970. maxNodeName: string;
  76971. };
  76972. buttons: {
  76973. "xr-standard-trigger": {
  76974. rootNodeName: string;
  76975. componentProperty: string;
  76976. states: string[];
  76977. };
  76978. "xr-standard-squeeze": {
  76979. rootNodeName: string;
  76980. componentProperty: string;
  76981. states: string[];
  76982. };
  76983. "xr-standard-touchpad": {
  76984. rootNodeName: string;
  76985. labelAnchorNodeName: string;
  76986. touchPointNodeName: string;
  76987. };
  76988. "xr-standard-thumbstick": {
  76989. rootNodeName: string;
  76990. componentProperty: string;
  76991. states: string[];
  76992. };
  76993. };
  76994. axes: {
  76995. "xr-standard-touchpad": {
  76996. "x-axis": {
  76997. rootNodeName: string;
  76998. };
  76999. "y-axis": {
  77000. rootNodeName: string;
  77001. };
  77002. };
  77003. "xr-standard-thumbstick": {
  77004. "x-axis": {
  77005. rootNodeName: string;
  77006. };
  77007. "y-axis": {
  77008. rootNodeName: string;
  77009. };
  77010. };
  77011. };
  77012. };
  77013. /**
  77014. * The base url used to load the left and right controller models
  77015. */
  77016. static MODEL_BASE_URL: string;
  77017. /**
  77018. * The name of the left controller model file
  77019. */
  77020. static MODEL_LEFT_FILENAME: string;
  77021. /**
  77022. * The name of the right controller model file
  77023. */
  77024. static MODEL_RIGHT_FILENAME: string;
  77025. profileId: string;
  77026. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77027. protected _getFilenameAndPath(): {
  77028. filename: string;
  77029. path: string;
  77030. };
  77031. protected _getModelLoadingConstraints(): boolean;
  77032. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77033. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77034. protected _updateModel(): void;
  77035. }
  77036. }
  77037. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  77038. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77040. import { Scene } from "babylonjs/scene";
  77041. /**
  77042. * The motion controller class for oculus touch (quest, rift).
  77043. * This class supports legacy mapping as well the standard xr mapping
  77044. */
  77045. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  77046. private _forceLegacyControllers;
  77047. private _modelRootNode;
  77048. /**
  77049. * The base url used to load the left and right controller models
  77050. */
  77051. static MODEL_BASE_URL: string;
  77052. /**
  77053. * The name of the left controller model file
  77054. */
  77055. static MODEL_LEFT_FILENAME: string;
  77056. /**
  77057. * The name of the right controller model file
  77058. */
  77059. static MODEL_RIGHT_FILENAME: string;
  77060. /**
  77061. * Base Url for the Quest controller model.
  77062. */
  77063. static QUEST_MODEL_BASE_URL: string;
  77064. profileId: string;
  77065. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  77066. protected _getFilenameAndPath(): {
  77067. filename: string;
  77068. path: string;
  77069. };
  77070. protected _getModelLoadingConstraints(): boolean;
  77071. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77072. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77073. protected _updateModel(): void;
  77074. /**
  77075. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  77076. * between the touch and touch 2.
  77077. */
  77078. private _isQuest;
  77079. }
  77080. }
  77081. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  77082. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77083. import { Scene } from "babylonjs/scene";
  77084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77085. /**
  77086. * The motion controller class for the standard HTC-Vive controllers
  77087. */
  77088. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  77089. private _modelRootNode;
  77090. /**
  77091. * The base url used to load the left and right controller models
  77092. */
  77093. static MODEL_BASE_URL: string;
  77094. /**
  77095. * File name for the controller model.
  77096. */
  77097. static MODEL_FILENAME: string;
  77098. profileId: string;
  77099. /**
  77100. * Create a new Vive motion controller object
  77101. * @param scene the scene to use to create this controller
  77102. * @param gamepadObject the corresponding gamepad object
  77103. * @param handedness the handedness of the controller
  77104. */
  77105. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77106. protected _getFilenameAndPath(): {
  77107. filename: string;
  77108. path: string;
  77109. };
  77110. protected _getModelLoadingConstraints(): boolean;
  77111. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77112. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77113. protected _updateModel(): void;
  77114. }
  77115. }
  77116. declare module "babylonjs/XR/motionController/index" {
  77117. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77118. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  77119. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  77120. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  77121. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  77122. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  77123. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  77124. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  77125. }
  77126. declare module "babylonjs/XR/index" {
  77127. export * from "babylonjs/XR/webXRCamera";
  77128. export * from "babylonjs/XR/webXREnterExitUI";
  77129. export * from "babylonjs/XR/webXRExperienceHelper";
  77130. export * from "babylonjs/XR/webXRInput";
  77131. export * from "babylonjs/XR/webXRInputSource";
  77132. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  77133. export * from "babylonjs/XR/webXRTypes";
  77134. export * from "babylonjs/XR/webXRSessionManager";
  77135. export * from "babylonjs/XR/webXRDefaultExperience";
  77136. export * from "babylonjs/XR/webXRFeaturesManager";
  77137. export * from "babylonjs/XR/features/index";
  77138. export * from "babylonjs/XR/motionController/index";
  77139. }
  77140. declare module "babylonjs/index" {
  77141. export * from "babylonjs/abstractScene";
  77142. export * from "babylonjs/Actions/index";
  77143. export * from "babylonjs/Animations/index";
  77144. export * from "babylonjs/assetContainer";
  77145. export * from "babylonjs/Audio/index";
  77146. export * from "babylonjs/Behaviors/index";
  77147. export * from "babylonjs/Bones/index";
  77148. export * from "babylonjs/Cameras/index";
  77149. export * from "babylonjs/Collisions/index";
  77150. export * from "babylonjs/Culling/index";
  77151. export * from "babylonjs/Debug/index";
  77152. export * from "babylonjs/DeviceInput/index";
  77153. export * from "babylonjs/Engines/index";
  77154. export * from "babylonjs/Events/index";
  77155. export * from "babylonjs/Gamepads/index";
  77156. export * from "babylonjs/Gizmos/index";
  77157. export * from "babylonjs/Helpers/index";
  77158. export * from "babylonjs/Instrumentation/index";
  77159. export * from "babylonjs/Layers/index";
  77160. export * from "babylonjs/LensFlares/index";
  77161. export * from "babylonjs/Lights/index";
  77162. export * from "babylonjs/Loading/index";
  77163. export * from "babylonjs/Materials/index";
  77164. export * from "babylonjs/Maths/index";
  77165. export * from "babylonjs/Meshes/index";
  77166. export * from "babylonjs/Morph/index";
  77167. export * from "babylonjs/Navigation/index";
  77168. export * from "babylonjs/node";
  77169. export * from "babylonjs/Offline/index";
  77170. export * from "babylonjs/Particles/index";
  77171. export * from "babylonjs/Physics/index";
  77172. export * from "babylonjs/PostProcesses/index";
  77173. export * from "babylonjs/Probes/index";
  77174. export * from "babylonjs/Rendering/index";
  77175. export * from "babylonjs/scene";
  77176. export * from "babylonjs/sceneComponent";
  77177. export * from "babylonjs/Sprites/index";
  77178. export * from "babylonjs/States/index";
  77179. export * from "babylonjs/Misc/index";
  77180. export * from "babylonjs/XR/index";
  77181. export * from "babylonjs/types";
  77182. }
  77183. declare module "babylonjs/Animations/pathCursor" {
  77184. import { Vector3 } from "babylonjs/Maths/math.vector";
  77185. import { Path2 } from "babylonjs/Maths/math.path";
  77186. /**
  77187. * A cursor which tracks a point on a path
  77188. */
  77189. export class PathCursor {
  77190. private path;
  77191. /**
  77192. * Stores path cursor callbacks for when an onchange event is triggered
  77193. */
  77194. private _onchange;
  77195. /**
  77196. * The value of the path cursor
  77197. */
  77198. value: number;
  77199. /**
  77200. * The animation array of the path cursor
  77201. */
  77202. animations: Animation[];
  77203. /**
  77204. * Initializes the path cursor
  77205. * @param path The path to track
  77206. */
  77207. constructor(path: Path2);
  77208. /**
  77209. * Gets the cursor point on the path
  77210. * @returns A point on the path cursor at the cursor location
  77211. */
  77212. getPoint(): Vector3;
  77213. /**
  77214. * Moves the cursor ahead by the step amount
  77215. * @param step The amount to move the cursor forward
  77216. * @returns This path cursor
  77217. */
  77218. moveAhead(step?: number): PathCursor;
  77219. /**
  77220. * Moves the cursor behind by the step amount
  77221. * @param step The amount to move the cursor back
  77222. * @returns This path cursor
  77223. */
  77224. moveBack(step?: number): PathCursor;
  77225. /**
  77226. * Moves the cursor by the step amount
  77227. * If the step amount is greater than one, an exception is thrown
  77228. * @param step The amount to move the cursor
  77229. * @returns This path cursor
  77230. */
  77231. move(step: number): PathCursor;
  77232. /**
  77233. * Ensures that the value is limited between zero and one
  77234. * @returns This path cursor
  77235. */
  77236. private ensureLimits;
  77237. /**
  77238. * Runs onchange callbacks on change (used by the animation engine)
  77239. * @returns This path cursor
  77240. */
  77241. private raiseOnChange;
  77242. /**
  77243. * Executes a function on change
  77244. * @param f A path cursor onchange callback
  77245. * @returns This path cursor
  77246. */
  77247. onchange(f: (cursor: PathCursor) => void): PathCursor;
  77248. }
  77249. }
  77250. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  77251. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  77252. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  77253. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  77254. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  77255. }
  77256. declare module "babylonjs/Engines/Processors/Expressions/index" {
  77257. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  77258. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  77259. }
  77260. declare module "babylonjs/Engines/Processors/index" {
  77261. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  77262. export * from "babylonjs/Engines/Processors/Expressions/index";
  77263. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  77264. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  77265. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  77266. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  77267. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  77268. export * from "babylonjs/Engines/Processors/shaderProcessor";
  77269. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  77270. }
  77271. declare module "babylonjs/Legacy/legacy" {
  77272. import * as Babylon from "babylonjs/index";
  77273. export * from "babylonjs/index";
  77274. }
  77275. declare module "babylonjs/Shaders/blur.fragment" {
  77276. /** @hidden */
  77277. export var blurPixelShader: {
  77278. name: string;
  77279. shader: string;
  77280. };
  77281. }
  77282. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  77283. /** @hidden */
  77284. export var pointCloudVertexDeclaration: {
  77285. name: string;
  77286. shader: string;
  77287. };
  77288. }
  77289. declare module "babylonjs" {
  77290. export * from "babylonjs/Legacy/legacy";
  77291. }
  77292. declare module BABYLON {
  77293. /** Alias type for value that can be null */
  77294. export type Nullable<T> = T | null;
  77295. /**
  77296. * Alias type for number that are floats
  77297. * @ignorenaming
  77298. */
  77299. export type float = number;
  77300. /**
  77301. * Alias type for number that are doubles.
  77302. * @ignorenaming
  77303. */
  77304. export type double = number;
  77305. /**
  77306. * Alias type for number that are integer
  77307. * @ignorenaming
  77308. */
  77309. export type int = number;
  77310. /** Alias type for number array or Float32Array */
  77311. export type FloatArray = number[] | Float32Array;
  77312. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  77313. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  77314. /**
  77315. * Alias for types that can be used by a Buffer or VertexBuffer.
  77316. */
  77317. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  77318. /**
  77319. * Alias type for primitive types
  77320. * @ignorenaming
  77321. */
  77322. type Primitive = undefined | null | boolean | string | number | Function;
  77323. /**
  77324. * Type modifier to make all the properties of an object Readonly
  77325. */
  77326. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  77327. /**
  77328. * Type modifier to make all the properties of an object Readonly recursively
  77329. */
  77330. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  77331. /**
  77332. * Type modifier to make object properties readonly.
  77333. */
  77334. export type DeepImmutableObject<T> = {
  77335. readonly [K in keyof T]: DeepImmutable<T[K]>;
  77336. };
  77337. /** @hidden */
  77338. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  77339. }
  77340. }
  77341. declare module BABYLON {
  77342. /**
  77343. * A class serves as a medium between the observable and its observers
  77344. */
  77345. export class EventState {
  77346. /**
  77347. * Create a new EventState
  77348. * @param mask defines the mask associated with this state
  77349. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  77350. * @param target defines the original target of the state
  77351. * @param currentTarget defines the current target of the state
  77352. */
  77353. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  77354. /**
  77355. * Initialize the current event state
  77356. * @param mask defines the mask associated with this state
  77357. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  77358. * @param target defines the original target of the state
  77359. * @param currentTarget defines the current target of the state
  77360. * @returns the current event state
  77361. */
  77362. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  77363. /**
  77364. * An Observer can set this property to true to prevent subsequent observers of being notified
  77365. */
  77366. skipNextObservers: boolean;
  77367. /**
  77368. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77369. */
  77370. mask: number;
  77371. /**
  77372. * The object that originally notified the event
  77373. */
  77374. target?: any;
  77375. /**
  77376. * The current object in the bubbling phase
  77377. */
  77378. currentTarget?: any;
  77379. /**
  77380. * This will be populated with the return value of the last function that was executed.
  77381. * If it is the first function in the callback chain it will be the event data.
  77382. */
  77383. lastReturnValue?: any;
  77384. }
  77385. /**
  77386. * Represent an Observer registered to a given Observable object.
  77387. */
  77388. export class Observer<T> {
  77389. /**
  77390. * Defines the callback to call when the observer is notified
  77391. */
  77392. callback: (eventData: T, eventState: EventState) => void;
  77393. /**
  77394. * Defines the mask of the observer (used to filter notifications)
  77395. */
  77396. mask: number;
  77397. /**
  77398. * Defines the current scope used to restore the JS context
  77399. */
  77400. scope: any;
  77401. /** @hidden */
  77402. _willBeUnregistered: boolean;
  77403. /**
  77404. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  77405. */
  77406. unregisterOnNextCall: boolean;
  77407. /**
  77408. * Creates a new observer
  77409. * @param callback defines the callback to call when the observer is notified
  77410. * @param mask defines the mask of the observer (used to filter notifications)
  77411. * @param scope defines the current scope used to restore the JS context
  77412. */
  77413. constructor(
  77414. /**
  77415. * Defines the callback to call when the observer is notified
  77416. */
  77417. callback: (eventData: T, eventState: EventState) => void,
  77418. /**
  77419. * Defines the mask of the observer (used to filter notifications)
  77420. */
  77421. mask: number,
  77422. /**
  77423. * Defines the current scope used to restore the JS context
  77424. */
  77425. scope?: any);
  77426. }
  77427. /**
  77428. * Represent a list of observers registered to multiple Observables object.
  77429. */
  77430. export class MultiObserver<T> {
  77431. private _observers;
  77432. private _observables;
  77433. /**
  77434. * Release associated resources
  77435. */
  77436. dispose(): void;
  77437. /**
  77438. * Raise a callback when one of the observable will notify
  77439. * @param observables defines a list of observables to watch
  77440. * @param callback defines the callback to call on notification
  77441. * @param mask defines the mask used to filter notifications
  77442. * @param scope defines the current scope used to restore the JS context
  77443. * @returns the new MultiObserver
  77444. */
  77445. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  77446. }
  77447. /**
  77448. * The Observable class is a simple implementation of the Observable pattern.
  77449. *
  77450. * 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.
  77451. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  77452. * 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).
  77453. * 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.
  77454. */
  77455. export class Observable<T> {
  77456. private _observers;
  77457. private _eventState;
  77458. private _onObserverAdded;
  77459. /**
  77460. * Gets the list of observers
  77461. */
  77462. get observers(): Array<Observer<T>>;
  77463. /**
  77464. * Creates a new observable
  77465. * @param onObserverAdded defines a callback to call when a new observer is added
  77466. */
  77467. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  77468. /**
  77469. * Create a new Observer with the specified callback
  77470. * @param callback the callback that will be executed for that Observer
  77471. * @param mask the mask used to filter observers
  77472. * @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.
  77473. * @param scope optional scope for the callback to be called from
  77474. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  77475. * @returns the new observer created for the callback
  77476. */
  77477. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  77478. /**
  77479. * Create a new Observer with the specified callback and unregisters after the next notification
  77480. * @param callback the callback that will be executed for that Observer
  77481. * @returns the new observer created for the callback
  77482. */
  77483. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  77484. /**
  77485. * Remove an Observer from the Observable object
  77486. * @param observer the instance of the Observer to remove
  77487. * @returns false if it doesn't belong to this Observable
  77488. */
  77489. remove(observer: Nullable<Observer<T>>): boolean;
  77490. /**
  77491. * Remove a callback from the Observable object
  77492. * @param callback the callback to remove
  77493. * @param scope optional scope. If used only the callbacks with this scope will be removed
  77494. * @returns false if it doesn't belong to this Observable
  77495. */
  77496. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  77497. private _deferUnregister;
  77498. private _remove;
  77499. /**
  77500. * Moves the observable to the top of the observer list making it get called first when notified
  77501. * @param observer the observer to move
  77502. */
  77503. makeObserverTopPriority(observer: Observer<T>): void;
  77504. /**
  77505. * Moves the observable to the bottom of the observer list making it get called last when notified
  77506. * @param observer the observer to move
  77507. */
  77508. makeObserverBottomPriority(observer: Observer<T>): void;
  77509. /**
  77510. * Notify all Observers by calling their respective callback with the given data
  77511. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  77512. * @param eventData defines the data to send to all observers
  77513. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  77514. * @param target defines the original target of the state
  77515. * @param currentTarget defines the current target of the state
  77516. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  77517. */
  77518. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  77519. /**
  77520. * Calling this will execute each callback, expecting it to be a promise or return a value.
  77521. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  77522. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  77523. * and it is crucial that all callbacks will be executed.
  77524. * The order of the callbacks is kept, callbacks are not executed parallel.
  77525. *
  77526. * @param eventData The data to be sent to each callback
  77527. * @param mask is used to filter observers defaults to -1
  77528. * @param target defines the callback target (see EventState)
  77529. * @param currentTarget defines he current object in the bubbling phase
  77530. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  77531. */
  77532. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  77533. /**
  77534. * Notify a specific observer
  77535. * @param observer defines the observer to notify
  77536. * @param eventData defines the data to be sent to each callback
  77537. * @param mask is used to filter observers defaults to -1
  77538. */
  77539. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  77540. /**
  77541. * Gets a boolean indicating if the observable has at least one observer
  77542. * @returns true is the Observable has at least one Observer registered
  77543. */
  77544. hasObservers(): boolean;
  77545. /**
  77546. * Clear the list of observers
  77547. */
  77548. clear(): void;
  77549. /**
  77550. * Clone the current observable
  77551. * @returns a new observable
  77552. */
  77553. clone(): Observable<T>;
  77554. /**
  77555. * Does this observable handles observer registered with a given mask
  77556. * @param mask defines the mask to be tested
  77557. * @return whether or not one observer registered with the given mask is handeled
  77558. **/
  77559. hasSpecificMask(mask?: number): boolean;
  77560. }
  77561. }
  77562. declare module BABYLON {
  77563. /**
  77564. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  77565. * Babylon.js
  77566. */
  77567. export class DomManagement {
  77568. /**
  77569. * Checks if the window object exists
  77570. * @returns true if the window object exists
  77571. */
  77572. static IsWindowObjectExist(): boolean;
  77573. /**
  77574. * Checks if the navigator object exists
  77575. * @returns true if the navigator object exists
  77576. */
  77577. static IsNavigatorAvailable(): boolean;
  77578. /**
  77579. * Check if the document object exists
  77580. * @returns true if the document object exists
  77581. */
  77582. static IsDocumentAvailable(): boolean;
  77583. /**
  77584. * Extracts text content from a DOM element hierarchy
  77585. * @param element defines the root element
  77586. * @returns a string
  77587. */
  77588. static GetDOMTextContent(element: HTMLElement): string;
  77589. }
  77590. }
  77591. declare module BABYLON {
  77592. /**
  77593. * Logger used througouht the application to allow configuration of
  77594. * the log level required for the messages.
  77595. */
  77596. export class Logger {
  77597. /**
  77598. * No log
  77599. */
  77600. static readonly NoneLogLevel: number;
  77601. /**
  77602. * Only message logs
  77603. */
  77604. static readonly MessageLogLevel: number;
  77605. /**
  77606. * Only warning logs
  77607. */
  77608. static readonly WarningLogLevel: number;
  77609. /**
  77610. * Only error logs
  77611. */
  77612. static readonly ErrorLogLevel: number;
  77613. /**
  77614. * All logs
  77615. */
  77616. static readonly AllLogLevel: number;
  77617. private static _LogCache;
  77618. /**
  77619. * Gets a value indicating the number of loading errors
  77620. * @ignorenaming
  77621. */
  77622. static errorsCount: number;
  77623. /**
  77624. * Callback called when a new log is added
  77625. */
  77626. static OnNewCacheEntry: (entry: string) => void;
  77627. private static _AddLogEntry;
  77628. private static _FormatMessage;
  77629. private static _LogDisabled;
  77630. private static _LogEnabled;
  77631. private static _WarnDisabled;
  77632. private static _WarnEnabled;
  77633. private static _ErrorDisabled;
  77634. private static _ErrorEnabled;
  77635. /**
  77636. * Log a message to the console
  77637. */
  77638. static Log: (message: string) => void;
  77639. /**
  77640. * Write a warning message to the console
  77641. */
  77642. static Warn: (message: string) => void;
  77643. /**
  77644. * Write an error message to the console
  77645. */
  77646. static Error: (message: string) => void;
  77647. /**
  77648. * Gets current log cache (list of logs)
  77649. */
  77650. static get LogCache(): string;
  77651. /**
  77652. * Clears the log cache
  77653. */
  77654. static ClearLogCache(): void;
  77655. /**
  77656. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  77657. */
  77658. static set LogLevels(level: number);
  77659. }
  77660. }
  77661. declare module BABYLON {
  77662. /** @hidden */
  77663. export class _TypeStore {
  77664. /** @hidden */
  77665. static RegisteredTypes: {
  77666. [key: string]: Object;
  77667. };
  77668. /** @hidden */
  77669. static GetClass(fqdn: string): any;
  77670. }
  77671. }
  77672. declare module BABYLON {
  77673. /**
  77674. * Helper to manipulate strings
  77675. */
  77676. export class StringTools {
  77677. /**
  77678. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  77679. * @param str Source string
  77680. * @param suffix Suffix to search for in the source string
  77681. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  77682. */
  77683. static EndsWith(str: string, suffix: string): boolean;
  77684. /**
  77685. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  77686. * @param str Source string
  77687. * @param suffix Suffix to search for in the source string
  77688. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  77689. */
  77690. static StartsWith(str: string, suffix: string): boolean;
  77691. /**
  77692. * Decodes a buffer into a string
  77693. * @param buffer The buffer to decode
  77694. * @returns The decoded string
  77695. */
  77696. static Decode(buffer: Uint8Array | Uint16Array): string;
  77697. /**
  77698. * Encode a buffer to a base64 string
  77699. * @param buffer defines the buffer to encode
  77700. * @returns the encoded string
  77701. */
  77702. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  77703. /**
  77704. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  77705. * @param num the number to convert and pad
  77706. * @param length the expected length of the string
  77707. * @returns the padded string
  77708. */
  77709. static PadNumber(num: number, length: number): string;
  77710. }
  77711. }
  77712. declare module BABYLON {
  77713. /**
  77714. * Class containing a set of static utilities functions for deep copy.
  77715. */
  77716. export class DeepCopier {
  77717. /**
  77718. * Tries to copy an object by duplicating every property
  77719. * @param source defines the source object
  77720. * @param destination defines the target object
  77721. * @param doNotCopyList defines a list of properties to avoid
  77722. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  77723. */
  77724. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  77725. }
  77726. }
  77727. declare module BABYLON {
  77728. /**
  77729. * Class containing a set of static utilities functions for precision date
  77730. */
  77731. export class PrecisionDate {
  77732. /**
  77733. * Gets either window.performance.now() if supported or Date.now() else
  77734. */
  77735. static get Now(): number;
  77736. }
  77737. }
  77738. declare module BABYLON {
  77739. /** @hidden */
  77740. export class _DevTools {
  77741. static WarnImport(name: string): string;
  77742. }
  77743. }
  77744. declare module BABYLON {
  77745. /**
  77746. * Interface used to define the mechanism to get data from the network
  77747. */
  77748. export interface IWebRequest {
  77749. /**
  77750. * Returns client's response url
  77751. */
  77752. responseURL: string;
  77753. /**
  77754. * Returns client's status
  77755. */
  77756. status: number;
  77757. /**
  77758. * Returns client's status as a text
  77759. */
  77760. statusText: string;
  77761. }
  77762. }
  77763. declare module BABYLON {
  77764. /**
  77765. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  77766. */
  77767. export class WebRequest implements IWebRequest {
  77768. private _xhr;
  77769. /**
  77770. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  77771. * i.e. when loading files, where the server/service expects an Authorization header
  77772. */
  77773. static CustomRequestHeaders: {
  77774. [key: string]: string;
  77775. };
  77776. /**
  77777. * Add callback functions in this array to update all the requests before they get sent to the network
  77778. */
  77779. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  77780. private _injectCustomRequestHeaders;
  77781. /**
  77782. * Gets or sets a function to be called when loading progress changes
  77783. */
  77784. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  77785. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  77786. /**
  77787. * Returns client's state
  77788. */
  77789. get readyState(): number;
  77790. /**
  77791. * Returns client's status
  77792. */
  77793. get status(): number;
  77794. /**
  77795. * Returns client's status as a text
  77796. */
  77797. get statusText(): string;
  77798. /**
  77799. * Returns client's response
  77800. */
  77801. get response(): any;
  77802. /**
  77803. * Returns client's response url
  77804. */
  77805. get responseURL(): string;
  77806. /**
  77807. * Returns client's response as text
  77808. */
  77809. get responseText(): string;
  77810. /**
  77811. * Gets or sets the expected response type
  77812. */
  77813. get responseType(): XMLHttpRequestResponseType;
  77814. set responseType(value: XMLHttpRequestResponseType);
  77815. /** @hidden */
  77816. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  77817. /** @hidden */
  77818. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  77819. /**
  77820. * Cancels any network activity
  77821. */
  77822. abort(): void;
  77823. /**
  77824. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  77825. * @param body defines an optional request body
  77826. */
  77827. send(body?: Document | BodyInit | null): void;
  77828. /**
  77829. * Sets the request method, request URL
  77830. * @param method defines the method to use (GET, POST, etc..)
  77831. * @param url defines the url to connect with
  77832. */
  77833. open(method: string, url: string): void;
  77834. /**
  77835. * Sets the value of a request header.
  77836. * @param name The name of the header whose value is to be set
  77837. * @param value The value to set as the body of the header
  77838. */
  77839. setRequestHeader(name: string, value: string): void;
  77840. /**
  77841. * Get the string containing the text of a particular header's value.
  77842. * @param name The name of the header
  77843. * @returns The string containing the text of the given header name
  77844. */
  77845. getResponseHeader(name: string): Nullable<string>;
  77846. }
  77847. }
  77848. declare module BABYLON {
  77849. /**
  77850. * File request interface
  77851. */
  77852. export interface IFileRequest {
  77853. /**
  77854. * Raised when the request is complete (success or error).
  77855. */
  77856. onCompleteObservable: Observable<IFileRequest>;
  77857. /**
  77858. * Aborts the request for a file.
  77859. */
  77860. abort: () => void;
  77861. }
  77862. }
  77863. declare module BABYLON {
  77864. /**
  77865. * Define options used to create a render target texture
  77866. */
  77867. export class RenderTargetCreationOptions {
  77868. /**
  77869. * Specifies is mipmaps must be generated
  77870. */
  77871. generateMipMaps?: boolean;
  77872. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  77873. generateDepthBuffer?: boolean;
  77874. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  77875. generateStencilBuffer?: boolean;
  77876. /** Defines texture type (int by default) */
  77877. type?: number;
  77878. /** Defines sampling mode (trilinear by default) */
  77879. samplingMode?: number;
  77880. /** Defines format (RGBA by default) */
  77881. format?: number;
  77882. }
  77883. }
  77884. declare module BABYLON {
  77885. /** Defines the cross module used constants to avoid circular dependncies */
  77886. export class Constants {
  77887. /** Defines that alpha blending is disabled */
  77888. static readonly ALPHA_DISABLE: number;
  77889. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  77890. static readonly ALPHA_ADD: number;
  77891. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  77892. static readonly ALPHA_COMBINE: number;
  77893. /** Defines that alpha blending is DEST - SRC * DEST */
  77894. static readonly ALPHA_SUBTRACT: number;
  77895. /** Defines that alpha blending is SRC * DEST */
  77896. static readonly ALPHA_MULTIPLY: number;
  77897. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  77898. static readonly ALPHA_MAXIMIZED: number;
  77899. /** Defines that alpha blending is SRC + DEST */
  77900. static readonly ALPHA_ONEONE: number;
  77901. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  77902. static readonly ALPHA_PREMULTIPLIED: number;
  77903. /**
  77904. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  77905. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  77906. */
  77907. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  77908. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  77909. static readonly ALPHA_INTERPOLATE: number;
  77910. /**
  77911. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  77912. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  77913. */
  77914. static readonly ALPHA_SCREENMODE: number;
  77915. /**
  77916. * Defines that alpha blending is SRC + DST
  77917. * Alpha will be set to SRC ALPHA + DST ALPHA
  77918. */
  77919. static readonly ALPHA_ONEONE_ONEONE: number;
  77920. /**
  77921. * Defines that alpha blending is SRC * DST ALPHA + DST
  77922. * Alpha will be set to 0
  77923. */
  77924. static readonly ALPHA_ALPHATOCOLOR: number;
  77925. /**
  77926. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  77927. */
  77928. static readonly ALPHA_REVERSEONEMINUS: number;
  77929. /**
  77930. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  77931. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  77932. */
  77933. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  77934. /**
  77935. * Defines that alpha blending is SRC + DST
  77936. * Alpha will be set to SRC ALPHA
  77937. */
  77938. static readonly ALPHA_ONEONE_ONEZERO: number;
  77939. /**
  77940. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  77941. * Alpha will be set to DST ALPHA
  77942. */
  77943. static readonly ALPHA_EXCLUSION: number;
  77944. /** Defines that alpha blending equation a SUM */
  77945. static readonly ALPHA_EQUATION_ADD: number;
  77946. /** Defines that alpha blending equation a SUBSTRACTION */
  77947. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  77948. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  77949. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  77950. /** Defines that alpha blending equation a MAX operation */
  77951. static readonly ALPHA_EQUATION_MAX: number;
  77952. /** Defines that alpha blending equation a MIN operation */
  77953. static readonly ALPHA_EQUATION_MIN: number;
  77954. /**
  77955. * Defines that alpha blending equation a DARKEN operation:
  77956. * It takes the min of the src and sums the alpha channels.
  77957. */
  77958. static readonly ALPHA_EQUATION_DARKEN: number;
  77959. /** Defines that the ressource is not delayed*/
  77960. static readonly DELAYLOADSTATE_NONE: number;
  77961. /** Defines that the ressource was successfully delay loaded */
  77962. static readonly DELAYLOADSTATE_LOADED: number;
  77963. /** Defines that the ressource is currently delay loading */
  77964. static readonly DELAYLOADSTATE_LOADING: number;
  77965. /** Defines that the ressource is delayed and has not started loading */
  77966. static readonly DELAYLOADSTATE_NOTLOADED: number;
  77967. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  77968. static readonly NEVER: number;
  77969. /** 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 */
  77970. static readonly ALWAYS: number;
  77971. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  77972. static readonly LESS: number;
  77973. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  77974. static readonly EQUAL: number;
  77975. /** 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 */
  77976. static readonly LEQUAL: number;
  77977. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  77978. static readonly GREATER: number;
  77979. /** 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 */
  77980. static readonly GEQUAL: number;
  77981. /** 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 */
  77982. static readonly NOTEQUAL: number;
  77983. /** Passed to stencilOperation to specify that stencil value must be kept */
  77984. static readonly KEEP: number;
  77985. /** Passed to stencilOperation to specify that stencil value must be replaced */
  77986. static readonly REPLACE: number;
  77987. /** Passed to stencilOperation to specify that stencil value must be incremented */
  77988. static readonly INCR: number;
  77989. /** Passed to stencilOperation to specify that stencil value must be decremented */
  77990. static readonly DECR: number;
  77991. /** Passed to stencilOperation to specify that stencil value must be inverted */
  77992. static readonly INVERT: number;
  77993. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  77994. static readonly INCR_WRAP: number;
  77995. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  77996. static readonly DECR_WRAP: number;
  77997. /** Texture is not repeating outside of 0..1 UVs */
  77998. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  77999. /** Texture is repeating outside of 0..1 UVs */
  78000. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  78001. /** Texture is repeating and mirrored */
  78002. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  78003. /** ALPHA */
  78004. static readonly TEXTUREFORMAT_ALPHA: number;
  78005. /** LUMINANCE */
  78006. static readonly TEXTUREFORMAT_LUMINANCE: number;
  78007. /** LUMINANCE_ALPHA */
  78008. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  78009. /** RGB */
  78010. static readonly TEXTUREFORMAT_RGB: number;
  78011. /** RGBA */
  78012. static readonly TEXTUREFORMAT_RGBA: number;
  78013. /** RED */
  78014. static readonly TEXTUREFORMAT_RED: number;
  78015. /** RED (2nd reference) */
  78016. static readonly TEXTUREFORMAT_R: number;
  78017. /** RG */
  78018. static readonly TEXTUREFORMAT_RG: number;
  78019. /** RED_INTEGER */
  78020. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  78021. /** RED_INTEGER (2nd reference) */
  78022. static readonly TEXTUREFORMAT_R_INTEGER: number;
  78023. /** RG_INTEGER */
  78024. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  78025. /** RGB_INTEGER */
  78026. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  78027. /** RGBA_INTEGER */
  78028. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  78029. /** UNSIGNED_BYTE */
  78030. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  78031. /** UNSIGNED_BYTE (2nd reference) */
  78032. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  78033. /** FLOAT */
  78034. static readonly TEXTURETYPE_FLOAT: number;
  78035. /** HALF_FLOAT */
  78036. static readonly TEXTURETYPE_HALF_FLOAT: number;
  78037. /** BYTE */
  78038. static readonly TEXTURETYPE_BYTE: number;
  78039. /** SHORT */
  78040. static readonly TEXTURETYPE_SHORT: number;
  78041. /** UNSIGNED_SHORT */
  78042. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  78043. /** INT */
  78044. static readonly TEXTURETYPE_INT: number;
  78045. /** UNSIGNED_INT */
  78046. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  78047. /** UNSIGNED_SHORT_4_4_4_4 */
  78048. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  78049. /** UNSIGNED_SHORT_5_5_5_1 */
  78050. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  78051. /** UNSIGNED_SHORT_5_6_5 */
  78052. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  78053. /** UNSIGNED_INT_2_10_10_10_REV */
  78054. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  78055. /** UNSIGNED_INT_24_8 */
  78056. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  78057. /** UNSIGNED_INT_10F_11F_11F_REV */
  78058. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  78059. /** UNSIGNED_INT_5_9_9_9_REV */
  78060. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  78061. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  78062. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  78063. /** nearest is mag = nearest and min = nearest and no mip */
  78064. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  78065. /** mag = nearest and min = nearest and mip = none */
  78066. static readonly TEXTURE_NEAREST_NEAREST: number;
  78067. /** Bilinear is mag = linear and min = linear and no mip */
  78068. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  78069. /** mag = linear and min = linear and mip = none */
  78070. static readonly TEXTURE_LINEAR_LINEAR: number;
  78071. /** Trilinear is mag = linear and min = linear and mip = linear */
  78072. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  78073. /** Trilinear is mag = linear and min = linear and mip = linear */
  78074. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  78075. /** mag = nearest and min = nearest and mip = nearest */
  78076. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  78077. /** mag = nearest and min = linear and mip = nearest */
  78078. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  78079. /** mag = nearest and min = linear and mip = linear */
  78080. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  78081. /** mag = nearest and min = linear and mip = none */
  78082. static readonly TEXTURE_NEAREST_LINEAR: number;
  78083. /** nearest is mag = nearest and min = nearest and mip = linear */
  78084. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  78085. /** mag = linear and min = nearest and mip = nearest */
  78086. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  78087. /** mag = linear and min = nearest and mip = linear */
  78088. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  78089. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78090. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  78091. /** mag = linear and min = nearest and mip = none */
  78092. static readonly TEXTURE_LINEAR_NEAREST: number;
  78093. /** Explicit coordinates mode */
  78094. static readonly TEXTURE_EXPLICIT_MODE: number;
  78095. /** Spherical coordinates mode */
  78096. static readonly TEXTURE_SPHERICAL_MODE: number;
  78097. /** Planar coordinates mode */
  78098. static readonly TEXTURE_PLANAR_MODE: number;
  78099. /** Cubic coordinates mode */
  78100. static readonly TEXTURE_CUBIC_MODE: number;
  78101. /** Projection coordinates mode */
  78102. static readonly TEXTURE_PROJECTION_MODE: number;
  78103. /** Skybox coordinates mode */
  78104. static readonly TEXTURE_SKYBOX_MODE: number;
  78105. /** Inverse Cubic coordinates mode */
  78106. static readonly TEXTURE_INVCUBIC_MODE: number;
  78107. /** Equirectangular coordinates mode */
  78108. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  78109. /** Equirectangular Fixed coordinates mode */
  78110. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  78111. /** Equirectangular Fixed Mirrored coordinates mode */
  78112. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  78113. /** Offline (baking) quality for texture filtering */
  78114. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  78115. /** High quality for texture filtering */
  78116. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  78117. /** Medium quality for texture filtering */
  78118. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  78119. /** Low quality for texture filtering */
  78120. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  78121. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  78122. static readonly SCALEMODE_FLOOR: number;
  78123. /** Defines that texture rescaling will look for the nearest power of 2 size */
  78124. static readonly SCALEMODE_NEAREST: number;
  78125. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  78126. static readonly SCALEMODE_CEILING: number;
  78127. /**
  78128. * The dirty texture flag value
  78129. */
  78130. static readonly MATERIAL_TextureDirtyFlag: number;
  78131. /**
  78132. * The dirty light flag value
  78133. */
  78134. static readonly MATERIAL_LightDirtyFlag: number;
  78135. /**
  78136. * The dirty fresnel flag value
  78137. */
  78138. static readonly MATERIAL_FresnelDirtyFlag: number;
  78139. /**
  78140. * The dirty attribute flag value
  78141. */
  78142. static readonly MATERIAL_AttributesDirtyFlag: number;
  78143. /**
  78144. * The dirty misc flag value
  78145. */
  78146. static readonly MATERIAL_MiscDirtyFlag: number;
  78147. /**
  78148. * The all dirty flag value
  78149. */
  78150. static readonly MATERIAL_AllDirtyFlag: number;
  78151. /**
  78152. * Returns the triangle fill mode
  78153. */
  78154. static readonly MATERIAL_TriangleFillMode: number;
  78155. /**
  78156. * Returns the wireframe mode
  78157. */
  78158. static readonly MATERIAL_WireFrameFillMode: number;
  78159. /**
  78160. * Returns the point fill mode
  78161. */
  78162. static readonly MATERIAL_PointFillMode: number;
  78163. /**
  78164. * Returns the point list draw mode
  78165. */
  78166. static readonly MATERIAL_PointListDrawMode: number;
  78167. /**
  78168. * Returns the line list draw mode
  78169. */
  78170. static readonly MATERIAL_LineListDrawMode: number;
  78171. /**
  78172. * Returns the line loop draw mode
  78173. */
  78174. static readonly MATERIAL_LineLoopDrawMode: number;
  78175. /**
  78176. * Returns the line strip draw mode
  78177. */
  78178. static readonly MATERIAL_LineStripDrawMode: number;
  78179. /**
  78180. * Returns the triangle strip draw mode
  78181. */
  78182. static readonly MATERIAL_TriangleStripDrawMode: number;
  78183. /**
  78184. * Returns the triangle fan draw mode
  78185. */
  78186. static readonly MATERIAL_TriangleFanDrawMode: number;
  78187. /**
  78188. * Stores the clock-wise side orientation
  78189. */
  78190. static readonly MATERIAL_ClockWiseSideOrientation: number;
  78191. /**
  78192. * Stores the counter clock-wise side orientation
  78193. */
  78194. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  78195. /**
  78196. * Nothing
  78197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78198. */
  78199. static readonly ACTION_NothingTrigger: number;
  78200. /**
  78201. * On pick
  78202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78203. */
  78204. static readonly ACTION_OnPickTrigger: number;
  78205. /**
  78206. * On left pick
  78207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78208. */
  78209. static readonly ACTION_OnLeftPickTrigger: number;
  78210. /**
  78211. * On right pick
  78212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78213. */
  78214. static readonly ACTION_OnRightPickTrigger: number;
  78215. /**
  78216. * On center pick
  78217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78218. */
  78219. static readonly ACTION_OnCenterPickTrigger: number;
  78220. /**
  78221. * On pick down
  78222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78223. */
  78224. static readonly ACTION_OnPickDownTrigger: number;
  78225. /**
  78226. * On double pick
  78227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78228. */
  78229. static readonly ACTION_OnDoublePickTrigger: number;
  78230. /**
  78231. * On pick up
  78232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78233. */
  78234. static readonly ACTION_OnPickUpTrigger: number;
  78235. /**
  78236. * On pick out.
  78237. * This trigger will only be raised if you also declared a OnPickDown
  78238. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78239. */
  78240. static readonly ACTION_OnPickOutTrigger: number;
  78241. /**
  78242. * On long press
  78243. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78244. */
  78245. static readonly ACTION_OnLongPressTrigger: number;
  78246. /**
  78247. * On pointer over
  78248. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78249. */
  78250. static readonly ACTION_OnPointerOverTrigger: number;
  78251. /**
  78252. * On pointer out
  78253. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78254. */
  78255. static readonly ACTION_OnPointerOutTrigger: number;
  78256. /**
  78257. * On every frame
  78258. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78259. */
  78260. static readonly ACTION_OnEveryFrameTrigger: number;
  78261. /**
  78262. * On intersection enter
  78263. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78264. */
  78265. static readonly ACTION_OnIntersectionEnterTrigger: number;
  78266. /**
  78267. * On intersection exit
  78268. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78269. */
  78270. static readonly ACTION_OnIntersectionExitTrigger: number;
  78271. /**
  78272. * On key down
  78273. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78274. */
  78275. static readonly ACTION_OnKeyDownTrigger: number;
  78276. /**
  78277. * On key up
  78278. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78279. */
  78280. static readonly ACTION_OnKeyUpTrigger: number;
  78281. /**
  78282. * Billboard mode will only apply to Y axis
  78283. */
  78284. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  78285. /**
  78286. * Billboard mode will apply to all axes
  78287. */
  78288. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  78289. /**
  78290. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  78291. */
  78292. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  78293. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  78294. * Test order :
  78295. * Is the bounding sphere outside the frustum ?
  78296. * If not, are the bounding box vertices outside the frustum ?
  78297. * It not, then the cullable object is in the frustum.
  78298. */
  78299. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  78300. /** Culling strategy : Bounding Sphere Only.
  78301. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  78302. * It's also less accurate than the standard because some not visible objects can still be selected.
  78303. * Test : is the bounding sphere outside the frustum ?
  78304. * If not, then the cullable object is in the frustum.
  78305. */
  78306. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  78307. /** Culling strategy : Optimistic Inclusion.
  78308. * This in an inclusion test first, then the standard exclusion test.
  78309. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  78310. * 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.
  78311. * Anyway, it's as accurate as the standard strategy.
  78312. * Test :
  78313. * Is the cullable object bounding sphere center in the frustum ?
  78314. * If not, apply the default culling strategy.
  78315. */
  78316. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  78317. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  78318. * This in an inclusion test first, then the bounding sphere only exclusion test.
  78319. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  78320. * 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.
  78321. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  78322. * Test :
  78323. * Is the cullable object bounding sphere center in the frustum ?
  78324. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  78325. */
  78326. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  78327. /**
  78328. * No logging while loading
  78329. */
  78330. static readonly SCENELOADER_NO_LOGGING: number;
  78331. /**
  78332. * Minimal logging while loading
  78333. */
  78334. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  78335. /**
  78336. * Summary logging while loading
  78337. */
  78338. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  78339. /**
  78340. * Detailled logging while loading
  78341. */
  78342. static readonly SCENELOADER_DETAILED_LOGGING: number;
  78343. }
  78344. }
  78345. declare module BABYLON {
  78346. /**
  78347. * This represents the required contract to create a new type of texture loader.
  78348. */
  78349. export interface IInternalTextureLoader {
  78350. /**
  78351. * Defines wether the loader supports cascade loading the different faces.
  78352. */
  78353. supportCascades: boolean;
  78354. /**
  78355. * This returns if the loader support the current file information.
  78356. * @param extension defines the file extension of the file being loaded
  78357. * @returns true if the loader can load the specified file
  78358. */
  78359. canLoad(extension: string): boolean;
  78360. /**
  78361. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  78362. * @param data contains the texture data
  78363. * @param texture defines the BabylonJS internal texture
  78364. * @param createPolynomials will be true if polynomials have been requested
  78365. * @param onLoad defines the callback to trigger once the texture is ready
  78366. * @param onError defines the callback to trigger in case of error
  78367. */
  78368. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  78369. /**
  78370. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  78371. * @param data contains the texture data
  78372. * @param texture defines the BabylonJS internal texture
  78373. * @param callback defines the method to call once ready to upload
  78374. */
  78375. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  78376. }
  78377. }
  78378. declare module BABYLON {
  78379. /**
  78380. * Class used to store and describe the pipeline context associated with an effect
  78381. */
  78382. export interface IPipelineContext {
  78383. /**
  78384. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  78385. */
  78386. isAsync: boolean;
  78387. /**
  78388. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  78389. */
  78390. isReady: boolean;
  78391. /** @hidden */
  78392. _getVertexShaderCode(): string | null;
  78393. /** @hidden */
  78394. _getFragmentShaderCode(): string | null;
  78395. /** @hidden */
  78396. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  78397. }
  78398. }
  78399. declare module BABYLON {
  78400. /**
  78401. * Class used to store gfx data (like WebGLBuffer)
  78402. */
  78403. export class DataBuffer {
  78404. /**
  78405. * Gets or sets the number of objects referencing this buffer
  78406. */
  78407. references: number;
  78408. /** Gets or sets the size of the underlying buffer */
  78409. capacity: number;
  78410. /**
  78411. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  78412. */
  78413. is32Bits: boolean;
  78414. /**
  78415. * Gets the underlying buffer
  78416. */
  78417. get underlyingResource(): any;
  78418. }
  78419. }
  78420. declare module BABYLON {
  78421. /** @hidden */
  78422. export interface IShaderProcessor {
  78423. attributeProcessor?: (attribute: string) => string;
  78424. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  78425. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  78426. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  78427. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  78428. lineProcessor?: (line: string, isFragment: boolean) => string;
  78429. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  78430. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  78431. }
  78432. }
  78433. declare module BABYLON {
  78434. /** @hidden */
  78435. export interface ProcessingOptions {
  78436. defines: string[];
  78437. indexParameters: any;
  78438. isFragment: boolean;
  78439. shouldUseHighPrecisionShader: boolean;
  78440. supportsUniformBuffers: boolean;
  78441. shadersRepository: string;
  78442. includesShadersStore: {
  78443. [key: string]: string;
  78444. };
  78445. processor?: IShaderProcessor;
  78446. version: string;
  78447. platformName: string;
  78448. lookForClosingBracketForUniformBuffer?: boolean;
  78449. }
  78450. }
  78451. declare module BABYLON {
  78452. /** @hidden */
  78453. export class ShaderCodeNode {
  78454. line: string;
  78455. children: ShaderCodeNode[];
  78456. additionalDefineKey?: string;
  78457. additionalDefineValue?: string;
  78458. isValid(preprocessors: {
  78459. [key: string]: string;
  78460. }): boolean;
  78461. process(preprocessors: {
  78462. [key: string]: string;
  78463. }, options: ProcessingOptions): string;
  78464. }
  78465. }
  78466. declare module BABYLON {
  78467. /** @hidden */
  78468. export class ShaderCodeCursor {
  78469. private _lines;
  78470. lineIndex: number;
  78471. get currentLine(): string;
  78472. get canRead(): boolean;
  78473. set lines(value: string[]);
  78474. }
  78475. }
  78476. declare module BABYLON {
  78477. /** @hidden */
  78478. export class ShaderCodeConditionNode extends ShaderCodeNode {
  78479. process(preprocessors: {
  78480. [key: string]: string;
  78481. }, options: ProcessingOptions): string;
  78482. }
  78483. }
  78484. declare module BABYLON {
  78485. /** @hidden */
  78486. export class ShaderDefineExpression {
  78487. isTrue(preprocessors: {
  78488. [key: string]: string;
  78489. }): boolean;
  78490. private static _OperatorPriority;
  78491. private static _Stack;
  78492. static postfixToInfix(postfix: string[]): string;
  78493. static infixToPostfix(infix: string): string[];
  78494. }
  78495. }
  78496. declare module BABYLON {
  78497. /** @hidden */
  78498. export class ShaderCodeTestNode extends ShaderCodeNode {
  78499. testExpression: ShaderDefineExpression;
  78500. isValid(preprocessors: {
  78501. [key: string]: string;
  78502. }): boolean;
  78503. }
  78504. }
  78505. declare module BABYLON {
  78506. /** @hidden */
  78507. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  78508. define: string;
  78509. not: boolean;
  78510. constructor(define: string, not?: boolean);
  78511. isTrue(preprocessors: {
  78512. [key: string]: string;
  78513. }): boolean;
  78514. }
  78515. }
  78516. declare module BABYLON {
  78517. /** @hidden */
  78518. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  78519. leftOperand: ShaderDefineExpression;
  78520. rightOperand: ShaderDefineExpression;
  78521. isTrue(preprocessors: {
  78522. [key: string]: string;
  78523. }): boolean;
  78524. }
  78525. }
  78526. declare module BABYLON {
  78527. /** @hidden */
  78528. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  78529. leftOperand: ShaderDefineExpression;
  78530. rightOperand: ShaderDefineExpression;
  78531. isTrue(preprocessors: {
  78532. [key: string]: string;
  78533. }): boolean;
  78534. }
  78535. }
  78536. declare module BABYLON {
  78537. /** @hidden */
  78538. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  78539. define: string;
  78540. operand: string;
  78541. testValue: string;
  78542. constructor(define: string, operand: string, testValue: string);
  78543. isTrue(preprocessors: {
  78544. [key: string]: string;
  78545. }): boolean;
  78546. }
  78547. }
  78548. declare module BABYLON {
  78549. /**
  78550. * Class used to enable access to offline support
  78551. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  78552. */
  78553. export interface IOfflineProvider {
  78554. /**
  78555. * Gets a boolean indicating if scene must be saved in the database
  78556. */
  78557. enableSceneOffline: boolean;
  78558. /**
  78559. * Gets a boolean indicating if textures must be saved in the database
  78560. */
  78561. enableTexturesOffline: boolean;
  78562. /**
  78563. * Open the offline support and make it available
  78564. * @param successCallback defines the callback to call on success
  78565. * @param errorCallback defines the callback to call on error
  78566. */
  78567. open(successCallback: () => void, errorCallback: () => void): void;
  78568. /**
  78569. * Loads an image from the offline support
  78570. * @param url defines the url to load from
  78571. * @param image defines the target DOM image
  78572. */
  78573. loadImage(url: string, image: HTMLImageElement): void;
  78574. /**
  78575. * Loads a file from offline support
  78576. * @param url defines the URL to load from
  78577. * @param sceneLoaded defines a callback to call on success
  78578. * @param progressCallBack defines a callback to call when progress changed
  78579. * @param errorCallback defines a callback to call on error
  78580. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  78581. */
  78582. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  78583. }
  78584. }
  78585. declare module BABYLON {
  78586. /**
  78587. * Class used to help managing file picking and drag'n'drop
  78588. * File Storage
  78589. */
  78590. export class FilesInputStore {
  78591. /**
  78592. * List of files ready to be loaded
  78593. */
  78594. static FilesToLoad: {
  78595. [key: string]: File;
  78596. };
  78597. }
  78598. }
  78599. declare module BABYLON {
  78600. /**
  78601. * Class used to define a retry strategy when error happens while loading assets
  78602. */
  78603. export class RetryStrategy {
  78604. /**
  78605. * Function used to defines an exponential back off strategy
  78606. * @param maxRetries defines the maximum number of retries (3 by default)
  78607. * @param baseInterval defines the interval between retries
  78608. * @returns the strategy function to use
  78609. */
  78610. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  78611. }
  78612. }
  78613. declare module BABYLON {
  78614. /**
  78615. * @ignore
  78616. * Application error to support additional information when loading a file
  78617. */
  78618. export abstract class BaseError extends Error {
  78619. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  78620. }
  78621. }
  78622. declare module BABYLON {
  78623. /** @ignore */
  78624. export class LoadFileError extends BaseError {
  78625. request?: WebRequest;
  78626. file?: File;
  78627. /**
  78628. * Creates a new LoadFileError
  78629. * @param message defines the message of the error
  78630. * @param request defines the optional web request
  78631. * @param file defines the optional file
  78632. */
  78633. constructor(message: string, object?: WebRequest | File);
  78634. }
  78635. /** @ignore */
  78636. export class RequestFileError extends BaseError {
  78637. request: WebRequest;
  78638. /**
  78639. * Creates a new LoadFileError
  78640. * @param message defines the message of the error
  78641. * @param request defines the optional web request
  78642. */
  78643. constructor(message: string, request: WebRequest);
  78644. }
  78645. /** @ignore */
  78646. export class ReadFileError extends BaseError {
  78647. file: File;
  78648. /**
  78649. * Creates a new ReadFileError
  78650. * @param message defines the message of the error
  78651. * @param file defines the optional file
  78652. */
  78653. constructor(message: string, file: File);
  78654. }
  78655. /**
  78656. * @hidden
  78657. */
  78658. export class FileTools {
  78659. /**
  78660. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  78661. */
  78662. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  78663. /**
  78664. * Gets or sets the base URL to use to load assets
  78665. */
  78666. static BaseUrl: string;
  78667. /**
  78668. * Default behaviour for cors in the application.
  78669. * It can be a string if the expected behavior is identical in the entire app.
  78670. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  78671. */
  78672. static CorsBehavior: string | ((url: string | string[]) => string);
  78673. /**
  78674. * Gets or sets a function used to pre-process url before using them to load assets
  78675. */
  78676. static PreprocessUrl: (url: string) => string;
  78677. /**
  78678. * Removes unwanted characters from an url
  78679. * @param url defines the url to clean
  78680. * @returns the cleaned url
  78681. */
  78682. private static _CleanUrl;
  78683. /**
  78684. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  78685. * @param url define the url we are trying
  78686. * @param element define the dom element where to configure the cors policy
  78687. */
  78688. static SetCorsBehavior(url: string | string[], element: {
  78689. crossOrigin: string | null;
  78690. }): void;
  78691. /**
  78692. * Loads an image as an HTMLImageElement.
  78693. * @param input url string, ArrayBuffer, or Blob to load
  78694. * @param onLoad callback called when the image successfully loads
  78695. * @param onError callback called when the image fails to load
  78696. * @param offlineProvider offline provider for caching
  78697. * @param mimeType optional mime type
  78698. * @returns the HTMLImageElement of the loaded image
  78699. */
  78700. 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>;
  78701. /**
  78702. * Reads a file from a File object
  78703. * @param file defines the file to load
  78704. * @param onSuccess defines the callback to call when data is loaded
  78705. * @param onProgress defines the callback to call during loading process
  78706. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  78707. * @param onError defines the callback to call when an error occurs
  78708. * @returns a file request object
  78709. */
  78710. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  78711. /**
  78712. * Loads a file from a url
  78713. * @param url url to load
  78714. * @param onSuccess callback called when the file successfully loads
  78715. * @param onProgress callback called while file is loading (if the server supports this mode)
  78716. * @param offlineProvider defines the offline provider for caching
  78717. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  78718. * @param onError callback called when the file fails to load
  78719. * @returns a file request object
  78720. */
  78721. 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;
  78722. /**
  78723. * Loads a file
  78724. * @param url url to load
  78725. * @param onSuccess callback called when the file successfully loads
  78726. * @param onProgress callback called while file is loading (if the server supports this mode)
  78727. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  78728. * @param onError callback called when the file fails to load
  78729. * @param onOpened callback called when the web request is opened
  78730. * @returns a file request object
  78731. */
  78732. 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;
  78733. /**
  78734. * Checks if the loaded document was accessed via `file:`-Protocol.
  78735. * @returns boolean
  78736. */
  78737. static IsFileURL(): boolean;
  78738. }
  78739. }
  78740. declare module BABYLON {
  78741. /** @hidden */
  78742. export class ShaderProcessor {
  78743. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  78744. private static _ProcessPrecision;
  78745. private static _ExtractOperation;
  78746. private static _BuildSubExpression;
  78747. private static _BuildExpression;
  78748. private static _MoveCursorWithinIf;
  78749. private static _MoveCursor;
  78750. private static _EvaluatePreProcessors;
  78751. private static _PreparePreProcessors;
  78752. private static _ProcessShaderConversion;
  78753. private static _ProcessIncludes;
  78754. /**
  78755. * Loads a file from a url
  78756. * @param url url to load
  78757. * @param onSuccess callback called when the file successfully loads
  78758. * @param onProgress callback called while file is loading (if the server supports this mode)
  78759. * @param offlineProvider defines the offline provider for caching
  78760. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  78761. * @param onError callback called when the file fails to load
  78762. * @returns a file request object
  78763. * @hidden
  78764. */
  78765. 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;
  78766. }
  78767. }
  78768. declare module BABYLON {
  78769. /**
  78770. * @hidden
  78771. */
  78772. export interface IColor4Like {
  78773. r: float;
  78774. g: float;
  78775. b: float;
  78776. a: float;
  78777. }
  78778. /**
  78779. * @hidden
  78780. */
  78781. export interface IColor3Like {
  78782. r: float;
  78783. g: float;
  78784. b: float;
  78785. }
  78786. /**
  78787. * @hidden
  78788. */
  78789. export interface IVector4Like {
  78790. x: float;
  78791. y: float;
  78792. z: float;
  78793. w: float;
  78794. }
  78795. /**
  78796. * @hidden
  78797. */
  78798. export interface IVector3Like {
  78799. x: float;
  78800. y: float;
  78801. z: float;
  78802. }
  78803. /**
  78804. * @hidden
  78805. */
  78806. export interface IVector2Like {
  78807. x: float;
  78808. y: float;
  78809. }
  78810. /**
  78811. * @hidden
  78812. */
  78813. export interface IMatrixLike {
  78814. toArray(): DeepImmutable<Float32Array>;
  78815. updateFlag: int;
  78816. }
  78817. /**
  78818. * @hidden
  78819. */
  78820. export interface IViewportLike {
  78821. x: float;
  78822. y: float;
  78823. width: float;
  78824. height: float;
  78825. }
  78826. /**
  78827. * @hidden
  78828. */
  78829. export interface IPlaneLike {
  78830. normal: IVector3Like;
  78831. d: float;
  78832. normalize(): void;
  78833. }
  78834. }
  78835. declare module BABYLON {
  78836. /**
  78837. * Interface used to define common properties for effect fallbacks
  78838. */
  78839. export interface IEffectFallbacks {
  78840. /**
  78841. * Removes the defines that should be removed when falling back.
  78842. * @param currentDefines defines the current define statements for the shader.
  78843. * @param effect defines the current effect we try to compile
  78844. * @returns The resulting defines with defines of the current rank removed.
  78845. */
  78846. reduce(currentDefines: string, effect: Effect): string;
  78847. /**
  78848. * Removes the fallback from the bound mesh.
  78849. */
  78850. unBindMesh(): void;
  78851. /**
  78852. * Checks to see if more fallbacks are still availible.
  78853. */
  78854. hasMoreFallbacks: boolean;
  78855. }
  78856. }
  78857. declare module BABYLON {
  78858. /**
  78859. * Class used to evalaute queries containing `and` and `or` operators
  78860. */
  78861. export class AndOrNotEvaluator {
  78862. /**
  78863. * Evaluate a query
  78864. * @param query defines the query to evaluate
  78865. * @param evaluateCallback defines the callback used to filter result
  78866. * @returns true if the query matches
  78867. */
  78868. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  78869. private static _HandleParenthesisContent;
  78870. private static _SimplifyNegation;
  78871. }
  78872. }
  78873. declare module BABYLON {
  78874. /**
  78875. * Class used to store custom tags
  78876. */
  78877. export class Tags {
  78878. /**
  78879. * Adds support for tags on the given object
  78880. * @param obj defines the object to use
  78881. */
  78882. static EnableFor(obj: any): void;
  78883. /**
  78884. * Removes tags support
  78885. * @param obj defines the object to use
  78886. */
  78887. static DisableFor(obj: any): void;
  78888. /**
  78889. * Gets a boolean indicating if the given object has tags
  78890. * @param obj defines the object to use
  78891. * @returns a boolean
  78892. */
  78893. static HasTags(obj: any): boolean;
  78894. /**
  78895. * Gets the tags available on a given object
  78896. * @param obj defines the object to use
  78897. * @param asString defines if the tags must be returned as a string instead of an array of strings
  78898. * @returns the tags
  78899. */
  78900. static GetTags(obj: any, asString?: boolean): any;
  78901. /**
  78902. * Adds tags to an object
  78903. * @param obj defines the object to use
  78904. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  78905. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  78906. */
  78907. static AddTagsTo(obj: any, tagsString: string): void;
  78908. /**
  78909. * @hidden
  78910. */
  78911. static _AddTagTo(obj: any, tag: string): void;
  78912. /**
  78913. * Removes specific tags from a specific object
  78914. * @param obj defines the object to use
  78915. * @param tagsString defines the tags to remove
  78916. */
  78917. static RemoveTagsFrom(obj: any, tagsString: string): void;
  78918. /**
  78919. * @hidden
  78920. */
  78921. static _RemoveTagFrom(obj: any, tag: string): void;
  78922. /**
  78923. * Defines if tags hosted on an object match a given query
  78924. * @param obj defines the object to use
  78925. * @param tagsQuery defines the tag query
  78926. * @returns a boolean
  78927. */
  78928. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  78929. }
  78930. }
  78931. declare module BABYLON {
  78932. /**
  78933. * Scalar computation library
  78934. */
  78935. export class Scalar {
  78936. /**
  78937. * Two pi constants convenient for computation.
  78938. */
  78939. static TwoPi: number;
  78940. /**
  78941. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78942. * @param a number
  78943. * @param b number
  78944. * @param epsilon (default = 1.401298E-45)
  78945. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78946. */
  78947. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  78948. /**
  78949. * Returns a string : the upper case translation of the number i to hexadecimal.
  78950. * @param i number
  78951. * @returns the upper case translation of the number i to hexadecimal.
  78952. */
  78953. static ToHex(i: number): string;
  78954. /**
  78955. * Returns -1 if value is negative and +1 is value is positive.
  78956. * @param value the value
  78957. * @returns the value itself if it's equal to zero.
  78958. */
  78959. static Sign(value: number): number;
  78960. /**
  78961. * Returns the value itself if it's between min and max.
  78962. * Returns min if the value is lower than min.
  78963. * Returns max if the value is greater than max.
  78964. * @param value the value to clmap
  78965. * @param min the min value to clamp to (default: 0)
  78966. * @param max the max value to clamp to (default: 1)
  78967. * @returns the clamped value
  78968. */
  78969. static Clamp(value: number, min?: number, max?: number): number;
  78970. /**
  78971. * the log2 of value.
  78972. * @param value the value to compute log2 of
  78973. * @returns the log2 of value.
  78974. */
  78975. static Log2(value: number): number;
  78976. /**
  78977. * Loops the value, so that it is never larger than length and never smaller than 0.
  78978. *
  78979. * This is similar to the modulo operator but it works with floating point numbers.
  78980. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  78981. * With t = 5 and length = 2.5, the result would be 0.0.
  78982. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  78983. * @param value the value
  78984. * @param length the length
  78985. * @returns the looped value
  78986. */
  78987. static Repeat(value: number, length: number): number;
  78988. /**
  78989. * Normalize the value between 0.0 and 1.0 using min and max values
  78990. * @param value value to normalize
  78991. * @param min max to normalize between
  78992. * @param max min to normalize between
  78993. * @returns the normalized value
  78994. */
  78995. static Normalize(value: number, min: number, max: number): number;
  78996. /**
  78997. * Denormalize the value from 0.0 and 1.0 using min and max values
  78998. * @param normalized value to denormalize
  78999. * @param min max to denormalize between
  79000. * @param max min to denormalize between
  79001. * @returns the denormalized value
  79002. */
  79003. static Denormalize(normalized: number, min: number, max: number): number;
  79004. /**
  79005. * Calculates the shortest difference between two given angles given in degrees.
  79006. * @param current current angle in degrees
  79007. * @param target target angle in degrees
  79008. * @returns the delta
  79009. */
  79010. static DeltaAngle(current: number, target: number): number;
  79011. /**
  79012. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  79013. * @param tx value
  79014. * @param length length
  79015. * @returns The returned value will move back and forth between 0 and length
  79016. */
  79017. static PingPong(tx: number, length: number): number;
  79018. /**
  79019. * Interpolates between min and max with smoothing at the limits.
  79020. *
  79021. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  79022. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  79023. * @param from from
  79024. * @param to to
  79025. * @param tx value
  79026. * @returns the smooth stepped value
  79027. */
  79028. static SmoothStep(from: number, to: number, tx: number): number;
  79029. /**
  79030. * Moves a value current towards target.
  79031. *
  79032. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  79033. * Negative values of maxDelta pushes the value away from target.
  79034. * @param current current value
  79035. * @param target target value
  79036. * @param maxDelta max distance to move
  79037. * @returns resulting value
  79038. */
  79039. static MoveTowards(current: number, target: number, maxDelta: number): number;
  79040. /**
  79041. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  79042. *
  79043. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  79044. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  79045. * @param current current value
  79046. * @param target target value
  79047. * @param maxDelta max distance to move
  79048. * @returns resulting angle
  79049. */
  79050. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  79051. /**
  79052. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  79053. * @param start start value
  79054. * @param end target value
  79055. * @param amount amount to lerp between
  79056. * @returns the lerped value
  79057. */
  79058. static Lerp(start: number, end: number, amount: number): number;
  79059. /**
  79060. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  79061. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  79062. * @param start start value
  79063. * @param end target value
  79064. * @param amount amount to lerp between
  79065. * @returns the lerped value
  79066. */
  79067. static LerpAngle(start: number, end: number, amount: number): number;
  79068. /**
  79069. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  79070. * @param a start value
  79071. * @param b target value
  79072. * @param value value between a and b
  79073. * @returns the inverseLerp value
  79074. */
  79075. static InverseLerp(a: number, b: number, value: number): number;
  79076. /**
  79077. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  79078. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  79079. * @param value1 spline value
  79080. * @param tangent1 spline value
  79081. * @param value2 spline value
  79082. * @param tangent2 spline value
  79083. * @param amount input value
  79084. * @returns hermite result
  79085. */
  79086. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  79087. /**
  79088. * Returns a random float number between and min and max values
  79089. * @param min min value of random
  79090. * @param max max value of random
  79091. * @returns random value
  79092. */
  79093. static RandomRange(min: number, max: number): number;
  79094. /**
  79095. * This function returns percentage of a number in a given range.
  79096. *
  79097. * RangeToPercent(40,20,60) will return 0.5 (50%)
  79098. * RangeToPercent(34,0,100) will return 0.34 (34%)
  79099. * @param number to convert to percentage
  79100. * @param min min range
  79101. * @param max max range
  79102. * @returns the percentage
  79103. */
  79104. static RangeToPercent(number: number, min: number, max: number): number;
  79105. /**
  79106. * This function returns number that corresponds to the percentage in a given range.
  79107. *
  79108. * PercentToRange(0.34,0,100) will return 34.
  79109. * @param percent to convert to number
  79110. * @param min min range
  79111. * @param max max range
  79112. * @returns the number
  79113. */
  79114. static PercentToRange(percent: number, min: number, max: number): number;
  79115. /**
  79116. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  79117. * @param angle The angle to normalize in radian.
  79118. * @return The converted angle.
  79119. */
  79120. static NormalizeRadians(angle: number): number;
  79121. }
  79122. }
  79123. declare module BABYLON {
  79124. /**
  79125. * Constant used to convert a value to gamma space
  79126. * @ignorenaming
  79127. */
  79128. export const ToGammaSpace: number;
  79129. /**
  79130. * Constant used to convert a value to linear space
  79131. * @ignorenaming
  79132. */
  79133. export const ToLinearSpace = 2.2;
  79134. /**
  79135. * Constant used to define the minimal number value in Babylon.js
  79136. * @ignorenaming
  79137. */
  79138. let Epsilon: number;
  79139. }
  79140. declare module BABYLON {
  79141. /**
  79142. * Class used to represent a viewport on screen
  79143. */
  79144. export class Viewport {
  79145. /** viewport left coordinate */
  79146. x: number;
  79147. /** viewport top coordinate */
  79148. y: number;
  79149. /**viewport width */
  79150. width: number;
  79151. /** viewport height */
  79152. height: number;
  79153. /**
  79154. * Creates a Viewport object located at (x, y) and sized (width, height)
  79155. * @param x defines viewport left coordinate
  79156. * @param y defines viewport top coordinate
  79157. * @param width defines the viewport width
  79158. * @param height defines the viewport height
  79159. */
  79160. constructor(
  79161. /** viewport left coordinate */
  79162. x: number,
  79163. /** viewport top coordinate */
  79164. y: number,
  79165. /**viewport width */
  79166. width: number,
  79167. /** viewport height */
  79168. height: number);
  79169. /**
  79170. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  79171. * @param renderWidth defines the rendering width
  79172. * @param renderHeight defines the rendering height
  79173. * @returns a new Viewport
  79174. */
  79175. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  79176. /**
  79177. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  79178. * @param renderWidth defines the rendering width
  79179. * @param renderHeight defines the rendering height
  79180. * @param ref defines the target viewport
  79181. * @returns the current viewport
  79182. */
  79183. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  79184. /**
  79185. * Returns a new Viewport copied from the current one
  79186. * @returns a new Viewport
  79187. */
  79188. clone(): Viewport;
  79189. }
  79190. }
  79191. declare module BABYLON {
  79192. /**
  79193. * Class containing a set of static utilities functions for arrays.
  79194. */
  79195. export class ArrayTools {
  79196. /**
  79197. * Returns an array of the given size filled with element built from the given constructor and the paramters
  79198. * @param size the number of element to construct and put in the array
  79199. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  79200. * @returns a new array filled with new objects
  79201. */
  79202. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  79203. }
  79204. }
  79205. declare module BABYLON {
  79206. /**
  79207. * Represens a plane by the equation ax + by + cz + d = 0
  79208. */
  79209. export class Plane {
  79210. private static _TmpMatrix;
  79211. /**
  79212. * Normal of the plane (a,b,c)
  79213. */
  79214. normal: Vector3;
  79215. /**
  79216. * d component of the plane
  79217. */
  79218. d: number;
  79219. /**
  79220. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79221. * @param a a component of the plane
  79222. * @param b b component of the plane
  79223. * @param c c component of the plane
  79224. * @param d d component of the plane
  79225. */
  79226. constructor(a: number, b: number, c: number, d: number);
  79227. /**
  79228. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79229. */
  79230. asArray(): number[];
  79231. /**
  79232. * @returns a new plane copied from the current Plane.
  79233. */
  79234. clone(): Plane;
  79235. /**
  79236. * @returns the string "Plane".
  79237. */
  79238. getClassName(): string;
  79239. /**
  79240. * @returns the Plane hash code.
  79241. */
  79242. getHashCode(): number;
  79243. /**
  79244. * Normalize the current Plane in place.
  79245. * @returns the updated Plane.
  79246. */
  79247. normalize(): Plane;
  79248. /**
  79249. * Applies a transformation the plane and returns the result
  79250. * @param transformation the transformation matrix to be applied to the plane
  79251. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79252. */
  79253. transform(transformation: DeepImmutable<Matrix>): Plane;
  79254. /**
  79255. * Compute the dot product between the point and the plane normal
  79256. * @param point point to calculate the dot product with
  79257. * @returns the dot product (float) of the point coordinates and the plane normal.
  79258. */
  79259. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79260. /**
  79261. * Updates the current Plane from the plane defined by the three given points.
  79262. * @param point1 one of the points used to contruct the plane
  79263. * @param point2 one of the points used to contruct the plane
  79264. * @param point3 one of the points used to contruct the plane
  79265. * @returns the updated Plane.
  79266. */
  79267. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79268. /**
  79269. * Checks if the plane is facing a given direction
  79270. * @param direction the direction to check if the plane is facing
  79271. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79272. * @returns True is the vector "direction" is the same side than the plane normal.
  79273. */
  79274. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79275. /**
  79276. * Calculates the distance to a point
  79277. * @param point point to calculate distance to
  79278. * @returns the signed distance (float) from the given point to the Plane.
  79279. */
  79280. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79281. /**
  79282. * Creates a plane from an array
  79283. * @param array the array to create a plane from
  79284. * @returns a new Plane from the given array.
  79285. */
  79286. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79287. /**
  79288. * Creates a plane from three points
  79289. * @param point1 point used to create the plane
  79290. * @param point2 point used to create the plane
  79291. * @param point3 point used to create the plane
  79292. * @returns a new Plane defined by the three given points.
  79293. */
  79294. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79295. /**
  79296. * Creates a plane from an origin point and a normal
  79297. * @param origin origin of the plane to be constructed
  79298. * @param normal normal of the plane to be constructed
  79299. * @returns a new Plane the normal vector to this plane at the given origin point.
  79300. * Note : the vector "normal" is updated because normalized.
  79301. */
  79302. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  79303. /**
  79304. * Calculates the distance from a plane and a point
  79305. * @param origin origin of the plane to be constructed
  79306. * @param normal normal of the plane to be constructed
  79307. * @param point point to calculate distance to
  79308. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79309. */
  79310. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79311. }
  79312. }
  79313. declare module BABYLON {
  79314. /**
  79315. * Class representing a vector containing 2 coordinates
  79316. */
  79317. export class Vector2 {
  79318. /** defines the first coordinate */
  79319. x: number;
  79320. /** defines the second coordinate */
  79321. y: number;
  79322. /**
  79323. * Creates a new Vector2 from the given x and y coordinates
  79324. * @param x defines the first coordinate
  79325. * @param y defines the second coordinate
  79326. */
  79327. constructor(
  79328. /** defines the first coordinate */
  79329. x?: number,
  79330. /** defines the second coordinate */
  79331. y?: number);
  79332. /**
  79333. * Gets a string with the Vector2 coordinates
  79334. * @returns a string with the Vector2 coordinates
  79335. */
  79336. toString(): string;
  79337. /**
  79338. * Gets class name
  79339. * @returns the string "Vector2"
  79340. */
  79341. getClassName(): string;
  79342. /**
  79343. * Gets current vector hash code
  79344. * @returns the Vector2 hash code as a number
  79345. */
  79346. getHashCode(): number;
  79347. /**
  79348. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  79349. * @param array defines the source array
  79350. * @param index defines the offset in source array
  79351. * @returns the current Vector2
  79352. */
  79353. toArray(array: FloatArray, index?: number): Vector2;
  79354. /**
  79355. * Copy the current vector to an array
  79356. * @returns a new array with 2 elements: the Vector2 coordinates.
  79357. */
  79358. asArray(): number[];
  79359. /**
  79360. * Sets the Vector2 coordinates with the given Vector2 coordinates
  79361. * @param source defines the source Vector2
  79362. * @returns the current updated Vector2
  79363. */
  79364. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  79365. /**
  79366. * Sets the Vector2 coordinates with the given floats
  79367. * @param x defines the first coordinate
  79368. * @param y defines the second coordinate
  79369. * @returns the current updated Vector2
  79370. */
  79371. copyFromFloats(x: number, y: number): Vector2;
  79372. /**
  79373. * Sets the Vector2 coordinates with the given floats
  79374. * @param x defines the first coordinate
  79375. * @param y defines the second coordinate
  79376. * @returns the current updated Vector2
  79377. */
  79378. set(x: number, y: number): Vector2;
  79379. /**
  79380. * Add another vector with the current one
  79381. * @param otherVector defines the other vector
  79382. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  79383. */
  79384. add(otherVector: DeepImmutable<Vector2>): Vector2;
  79385. /**
  79386. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  79387. * @param otherVector defines the other vector
  79388. * @param result defines the target vector
  79389. * @returns the unmodified current Vector2
  79390. */
  79391. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79392. /**
  79393. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  79394. * @param otherVector defines the other vector
  79395. * @returns the current updated Vector2
  79396. */
  79397. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79398. /**
  79399. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  79400. * @param otherVector defines the other vector
  79401. * @returns a new Vector2
  79402. */
  79403. addVector3(otherVector: Vector3): Vector2;
  79404. /**
  79405. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  79406. * @param otherVector defines the other vector
  79407. * @returns a new Vector2
  79408. */
  79409. subtract(otherVector: Vector2): Vector2;
  79410. /**
  79411. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  79412. * @param otherVector defines the other vector
  79413. * @param result defines the target vector
  79414. * @returns the unmodified current Vector2
  79415. */
  79416. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79417. /**
  79418. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  79419. * @param otherVector defines the other vector
  79420. * @returns the current updated Vector2
  79421. */
  79422. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79423. /**
  79424. * Multiplies in place the current Vector2 coordinates by the given ones
  79425. * @param otherVector defines the other vector
  79426. * @returns the current updated Vector2
  79427. */
  79428. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79429. /**
  79430. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  79431. * @param otherVector defines the other vector
  79432. * @returns a new Vector2
  79433. */
  79434. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  79435. /**
  79436. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  79437. * @param otherVector defines the other vector
  79438. * @param result defines the target vector
  79439. * @returns the unmodified current Vector2
  79440. */
  79441. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79442. /**
  79443. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  79444. * @param x defines the first coordinate
  79445. * @param y defines the second coordinate
  79446. * @returns a new Vector2
  79447. */
  79448. multiplyByFloats(x: number, y: number): Vector2;
  79449. /**
  79450. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  79451. * @param otherVector defines the other vector
  79452. * @returns a new Vector2
  79453. */
  79454. divide(otherVector: Vector2): Vector2;
  79455. /**
  79456. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  79457. * @param otherVector defines the other vector
  79458. * @param result defines the target vector
  79459. * @returns the unmodified current Vector2
  79460. */
  79461. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79462. /**
  79463. * Divides the current Vector2 coordinates by the given ones
  79464. * @param otherVector defines the other vector
  79465. * @returns the current updated Vector2
  79466. */
  79467. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79468. /**
  79469. * Gets a new Vector2 with current Vector2 negated coordinates
  79470. * @returns a new Vector2
  79471. */
  79472. negate(): Vector2;
  79473. /**
  79474. * Negate this vector in place
  79475. * @returns this
  79476. */
  79477. negateInPlace(): Vector2;
  79478. /**
  79479. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  79480. * @param result defines the Vector3 object where to store the result
  79481. * @returns the current Vector2
  79482. */
  79483. negateToRef(result: Vector2): Vector2;
  79484. /**
  79485. * Multiply the Vector2 coordinates by scale
  79486. * @param scale defines the scaling factor
  79487. * @returns the current updated Vector2
  79488. */
  79489. scaleInPlace(scale: number): Vector2;
  79490. /**
  79491. * Returns a new Vector2 scaled by "scale" from the current Vector2
  79492. * @param scale defines the scaling factor
  79493. * @returns a new Vector2
  79494. */
  79495. scale(scale: number): Vector2;
  79496. /**
  79497. * Scale the current Vector2 values by a factor to a given Vector2
  79498. * @param scale defines the scale factor
  79499. * @param result defines the Vector2 object where to store the result
  79500. * @returns the unmodified current Vector2
  79501. */
  79502. scaleToRef(scale: number, result: Vector2): Vector2;
  79503. /**
  79504. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  79505. * @param scale defines the scale factor
  79506. * @param result defines the Vector2 object where to store the result
  79507. * @returns the unmodified current Vector2
  79508. */
  79509. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  79510. /**
  79511. * Gets a boolean if two vectors are equals
  79512. * @param otherVector defines the other vector
  79513. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  79514. */
  79515. equals(otherVector: DeepImmutable<Vector2>): boolean;
  79516. /**
  79517. * Gets a boolean if two vectors are equals (using an epsilon value)
  79518. * @param otherVector defines the other vector
  79519. * @param epsilon defines the minimal distance to consider equality
  79520. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  79521. */
  79522. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  79523. /**
  79524. * Gets a new Vector2 from current Vector2 floored values
  79525. * @returns a new Vector2
  79526. */
  79527. floor(): Vector2;
  79528. /**
  79529. * Gets a new Vector2 from current Vector2 floored values
  79530. * @returns a new Vector2
  79531. */
  79532. fract(): Vector2;
  79533. /**
  79534. * Gets the length of the vector
  79535. * @returns the vector length (float)
  79536. */
  79537. length(): number;
  79538. /**
  79539. * Gets the vector squared length
  79540. * @returns the vector squared length (float)
  79541. */
  79542. lengthSquared(): number;
  79543. /**
  79544. * Normalize the vector
  79545. * @returns the current updated Vector2
  79546. */
  79547. normalize(): Vector2;
  79548. /**
  79549. * Gets a new Vector2 copied from the Vector2
  79550. * @returns a new Vector2
  79551. */
  79552. clone(): Vector2;
  79553. /**
  79554. * Gets a new Vector2(0, 0)
  79555. * @returns a new Vector2
  79556. */
  79557. static Zero(): Vector2;
  79558. /**
  79559. * Gets a new Vector2(1, 1)
  79560. * @returns a new Vector2
  79561. */
  79562. static One(): Vector2;
  79563. /**
  79564. * Gets a new Vector2 set from the given index element of the given array
  79565. * @param array defines the data source
  79566. * @param offset defines the offset in the data source
  79567. * @returns a new Vector2
  79568. */
  79569. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  79570. /**
  79571. * Sets "result" from the given index element of the given array
  79572. * @param array defines the data source
  79573. * @param offset defines the offset in the data source
  79574. * @param result defines the target vector
  79575. */
  79576. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  79577. /**
  79578. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  79579. * @param value1 defines 1st point of control
  79580. * @param value2 defines 2nd point of control
  79581. * @param value3 defines 3rd point of control
  79582. * @param value4 defines 4th point of control
  79583. * @param amount defines the interpolation factor
  79584. * @returns a new Vector2
  79585. */
  79586. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  79587. /**
  79588. * 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".
  79589. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  79590. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  79591. * @param value defines the value to clamp
  79592. * @param min defines the lower limit
  79593. * @param max defines the upper limit
  79594. * @returns a new Vector2
  79595. */
  79596. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  79597. /**
  79598. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  79599. * @param value1 defines the 1st control point
  79600. * @param tangent1 defines the outgoing tangent
  79601. * @param value2 defines the 2nd control point
  79602. * @param tangent2 defines the incoming tangent
  79603. * @param amount defines the interpolation factor
  79604. * @returns a new Vector2
  79605. */
  79606. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  79607. /**
  79608. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  79609. * @param start defines the start vector
  79610. * @param end defines the end vector
  79611. * @param amount defines the interpolation factor
  79612. * @returns a new Vector2
  79613. */
  79614. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  79615. /**
  79616. * Gets the dot product of the vector "left" and the vector "right"
  79617. * @param left defines first vector
  79618. * @param right defines second vector
  79619. * @returns the dot product (float)
  79620. */
  79621. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  79622. /**
  79623. * Returns a new Vector2 equal to the normalized given vector
  79624. * @param vector defines the vector to normalize
  79625. * @returns a new Vector2
  79626. */
  79627. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  79628. /**
  79629. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  79630. * @param left defines 1st vector
  79631. * @param right defines 2nd vector
  79632. * @returns a new Vector2
  79633. */
  79634. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  79635. /**
  79636. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  79637. * @param left defines 1st vector
  79638. * @param right defines 2nd vector
  79639. * @returns a new Vector2
  79640. */
  79641. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  79642. /**
  79643. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  79644. * @param vector defines the vector to transform
  79645. * @param transformation defines the matrix to apply
  79646. * @returns a new Vector2
  79647. */
  79648. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  79649. /**
  79650. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  79651. * @param vector defines the vector to transform
  79652. * @param transformation defines the matrix to apply
  79653. * @param result defines the target vector
  79654. */
  79655. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  79656. /**
  79657. * Determines if a given vector is included in a triangle
  79658. * @param p defines the vector to test
  79659. * @param p0 defines 1st triangle point
  79660. * @param p1 defines 2nd triangle point
  79661. * @param p2 defines 3rd triangle point
  79662. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  79663. */
  79664. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  79665. /**
  79666. * Gets the distance between the vectors "value1" and "value2"
  79667. * @param value1 defines first vector
  79668. * @param value2 defines second vector
  79669. * @returns the distance between vectors
  79670. */
  79671. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  79672. /**
  79673. * Returns the squared distance between the vectors "value1" and "value2"
  79674. * @param value1 defines first vector
  79675. * @param value2 defines second vector
  79676. * @returns the squared distance between vectors
  79677. */
  79678. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  79679. /**
  79680. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  79681. * @param value1 defines first vector
  79682. * @param value2 defines second vector
  79683. * @returns a new Vector2
  79684. */
  79685. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  79686. /**
  79687. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  79688. * @param p defines the middle point
  79689. * @param segA defines one point of the segment
  79690. * @param segB defines the other point of the segment
  79691. * @returns the shortest distance
  79692. */
  79693. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  79694. }
  79695. /**
  79696. * Class used to store (x,y,z) vector representation
  79697. * A Vector3 is the main object used in 3D geometry
  79698. * It can represent etiher the coordinates of a point the space, either a direction
  79699. * Reminder: js uses a left handed forward facing system
  79700. */
  79701. export class Vector3 {
  79702. /**
  79703. * Defines the first coordinates (on X axis)
  79704. */
  79705. x: number;
  79706. /**
  79707. * Defines the second coordinates (on Y axis)
  79708. */
  79709. y: number;
  79710. /**
  79711. * Defines the third coordinates (on Z axis)
  79712. */
  79713. z: number;
  79714. private static _UpReadOnly;
  79715. private static _ZeroReadOnly;
  79716. /**
  79717. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  79718. * @param x defines the first coordinates (on X axis)
  79719. * @param y defines the second coordinates (on Y axis)
  79720. * @param z defines the third coordinates (on Z axis)
  79721. */
  79722. constructor(
  79723. /**
  79724. * Defines the first coordinates (on X axis)
  79725. */
  79726. x?: number,
  79727. /**
  79728. * Defines the second coordinates (on Y axis)
  79729. */
  79730. y?: number,
  79731. /**
  79732. * Defines the third coordinates (on Z axis)
  79733. */
  79734. z?: number);
  79735. /**
  79736. * Creates a string representation of the Vector3
  79737. * @returns a string with the Vector3 coordinates.
  79738. */
  79739. toString(): string;
  79740. /**
  79741. * Gets the class name
  79742. * @returns the string "Vector3"
  79743. */
  79744. getClassName(): string;
  79745. /**
  79746. * Creates the Vector3 hash code
  79747. * @returns a number which tends to be unique between Vector3 instances
  79748. */
  79749. getHashCode(): number;
  79750. /**
  79751. * Creates an array containing three elements : the coordinates of the Vector3
  79752. * @returns a new array of numbers
  79753. */
  79754. asArray(): number[];
  79755. /**
  79756. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  79757. * @param array defines the destination array
  79758. * @param index defines the offset in the destination array
  79759. * @returns the current Vector3
  79760. */
  79761. toArray(array: FloatArray, index?: number): Vector3;
  79762. /**
  79763. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  79764. * @returns a new Quaternion object, computed from the Vector3 coordinates
  79765. */
  79766. toQuaternion(): Quaternion;
  79767. /**
  79768. * Adds the given vector to the current Vector3
  79769. * @param otherVector defines the second operand
  79770. * @returns the current updated Vector3
  79771. */
  79772. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  79773. /**
  79774. * Adds the given coordinates to the current Vector3
  79775. * @param x defines the x coordinate of the operand
  79776. * @param y defines the y coordinate of the operand
  79777. * @param z defines the z coordinate of the operand
  79778. * @returns the current updated Vector3
  79779. */
  79780. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  79781. /**
  79782. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  79783. * @param otherVector defines the second operand
  79784. * @returns the resulting Vector3
  79785. */
  79786. add(otherVector: DeepImmutable<Vector3>): Vector3;
  79787. /**
  79788. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  79789. * @param otherVector defines the second operand
  79790. * @param result defines the Vector3 object where to store the result
  79791. * @returns the current Vector3
  79792. */
  79793. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  79794. /**
  79795. * Subtract the given vector from the current Vector3
  79796. * @param otherVector defines the second operand
  79797. * @returns the current updated Vector3
  79798. */
  79799. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  79800. /**
  79801. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  79802. * @param otherVector defines the second operand
  79803. * @returns the resulting Vector3
  79804. */
  79805. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  79806. /**
  79807. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  79808. * @param otherVector defines the second operand
  79809. * @param result defines the Vector3 object where to store the result
  79810. * @returns the current Vector3
  79811. */
  79812. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  79813. /**
  79814. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  79815. * @param x defines the x coordinate of the operand
  79816. * @param y defines the y coordinate of the operand
  79817. * @param z defines the z coordinate of the operand
  79818. * @returns the resulting Vector3
  79819. */
  79820. subtractFromFloats(x: number, y: number, z: number): Vector3;
  79821. /**
  79822. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  79823. * @param x defines the x coordinate of the operand
  79824. * @param y defines the y coordinate of the operand
  79825. * @param z defines the z coordinate of the operand
  79826. * @param result defines the Vector3 object where to store the result
  79827. * @returns the current Vector3
  79828. */
  79829. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  79830. /**
  79831. * Gets a new Vector3 set with the current Vector3 negated coordinates
  79832. * @returns a new Vector3
  79833. */
  79834. negate(): Vector3;
  79835. /**
  79836. * Negate this vector in place
  79837. * @returns this
  79838. */
  79839. negateInPlace(): Vector3;
  79840. /**
  79841. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  79842. * @param result defines the Vector3 object where to store the result
  79843. * @returns the current Vector3
  79844. */
  79845. negateToRef(result: Vector3): Vector3;
  79846. /**
  79847. * Multiplies the Vector3 coordinates by the float "scale"
  79848. * @param scale defines the multiplier factor
  79849. * @returns the current updated Vector3
  79850. */
  79851. scaleInPlace(scale: number): Vector3;
  79852. /**
  79853. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  79854. * @param scale defines the multiplier factor
  79855. * @returns a new Vector3
  79856. */
  79857. scale(scale: number): Vector3;
  79858. /**
  79859. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  79860. * @param scale defines the multiplier factor
  79861. * @param result defines the Vector3 object where to store the result
  79862. * @returns the current Vector3
  79863. */
  79864. scaleToRef(scale: number, result: Vector3): Vector3;
  79865. /**
  79866. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  79867. * @param scale defines the scale factor
  79868. * @param result defines the Vector3 object where to store the result
  79869. * @returns the unmodified current Vector3
  79870. */
  79871. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  79872. /**
  79873. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  79874. * @param origin defines the origin of the projection ray
  79875. * @param plane defines the plane to project to
  79876. * @returns the projected vector3
  79877. */
  79878. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  79879. /**
  79880. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  79881. * @param origin defines the origin of the projection ray
  79882. * @param plane defines the plane to project to
  79883. * @param result defines the Vector3 where to store the result
  79884. */
  79885. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  79886. /**
  79887. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  79888. * @param otherVector defines the second operand
  79889. * @returns true if both vectors are equals
  79890. */
  79891. equals(otherVector: DeepImmutable<Vector3>): boolean;
  79892. /**
  79893. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  79894. * @param otherVector defines the second operand
  79895. * @param epsilon defines the minimal distance to define values as equals
  79896. * @returns true if both vectors are distant less than epsilon
  79897. */
  79898. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  79899. /**
  79900. * Returns true if the current Vector3 coordinates equals the given floats
  79901. * @param x defines the x coordinate of the operand
  79902. * @param y defines the y coordinate of the operand
  79903. * @param z defines the z coordinate of the operand
  79904. * @returns true if both vectors are equals
  79905. */
  79906. equalsToFloats(x: number, y: number, z: number): boolean;
  79907. /**
  79908. * Multiplies the current Vector3 coordinates by the given ones
  79909. * @param otherVector defines the second operand
  79910. * @returns the current updated Vector3
  79911. */
  79912. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  79913. /**
  79914. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  79915. * @param otherVector defines the second operand
  79916. * @returns the new Vector3
  79917. */
  79918. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  79919. /**
  79920. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  79921. * @param otherVector defines the second operand
  79922. * @param result defines the Vector3 object where to store the result
  79923. * @returns the current Vector3
  79924. */
  79925. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  79926. /**
  79927. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  79928. * @param x defines the x coordinate of the operand
  79929. * @param y defines the y coordinate of the operand
  79930. * @param z defines the z coordinate of the operand
  79931. * @returns the new Vector3
  79932. */
  79933. multiplyByFloats(x: number, y: number, z: number): Vector3;
  79934. /**
  79935. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  79936. * @param otherVector defines the second operand
  79937. * @returns the new Vector3
  79938. */
  79939. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  79940. /**
  79941. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  79942. * @param otherVector defines the second operand
  79943. * @param result defines the Vector3 object where to store the result
  79944. * @returns the current Vector3
  79945. */
  79946. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  79947. /**
  79948. * Divides the current Vector3 coordinates by the given ones.
  79949. * @param otherVector defines the second operand
  79950. * @returns the current updated Vector3
  79951. */
  79952. divideInPlace(otherVector: Vector3): Vector3;
  79953. /**
  79954. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  79955. * @param other defines the second operand
  79956. * @returns the current updated Vector3
  79957. */
  79958. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  79959. /**
  79960. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  79961. * @param other defines the second operand
  79962. * @returns the current updated Vector3
  79963. */
  79964. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  79965. /**
  79966. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  79967. * @param x defines the x coordinate of the operand
  79968. * @param y defines the y coordinate of the operand
  79969. * @param z defines the z coordinate of the operand
  79970. * @returns the current updated Vector3
  79971. */
  79972. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  79973. /**
  79974. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  79975. * @param x defines the x coordinate of the operand
  79976. * @param y defines the y coordinate of the operand
  79977. * @param z defines the z coordinate of the operand
  79978. * @returns the current updated Vector3
  79979. */
  79980. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  79981. /**
  79982. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  79983. * Check if is non uniform within a certain amount of decimal places to account for this
  79984. * @param epsilon the amount the values can differ
  79985. * @returns if the the vector is non uniform to a certain number of decimal places
  79986. */
  79987. isNonUniformWithinEpsilon(epsilon: number): boolean;
  79988. /**
  79989. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  79990. */
  79991. get isNonUniform(): boolean;
  79992. /**
  79993. * Gets a new Vector3 from current Vector3 floored values
  79994. * @returns a new Vector3
  79995. */
  79996. floor(): Vector3;
  79997. /**
  79998. * Gets a new Vector3 from current Vector3 floored values
  79999. * @returns a new Vector3
  80000. */
  80001. fract(): Vector3;
  80002. /**
  80003. * Gets the length of the Vector3
  80004. * @returns the length of the Vector3
  80005. */
  80006. length(): number;
  80007. /**
  80008. * Gets the squared length of the Vector3
  80009. * @returns squared length of the Vector3
  80010. */
  80011. lengthSquared(): number;
  80012. /**
  80013. * Normalize the current Vector3.
  80014. * Please note that this is an in place operation.
  80015. * @returns the current updated Vector3
  80016. */
  80017. normalize(): Vector3;
  80018. /**
  80019. * Reorders the x y z properties of the vector in place
  80020. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  80021. * @returns the current updated vector
  80022. */
  80023. reorderInPlace(order: string): this;
  80024. /**
  80025. * Rotates the vector around 0,0,0 by a quaternion
  80026. * @param quaternion the rotation quaternion
  80027. * @param result vector to store the result
  80028. * @returns the resulting vector
  80029. */
  80030. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  80031. /**
  80032. * Rotates a vector around a given point
  80033. * @param quaternion the rotation quaternion
  80034. * @param point the point to rotate around
  80035. * @param result vector to store the result
  80036. * @returns the resulting vector
  80037. */
  80038. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  80039. /**
  80040. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  80041. * The cross product is then orthogonal to both current and "other"
  80042. * @param other defines the right operand
  80043. * @returns the cross product
  80044. */
  80045. cross(other: Vector3): Vector3;
  80046. /**
  80047. * Normalize the current Vector3 with the given input length.
  80048. * Please note that this is an in place operation.
  80049. * @param len the length of the vector
  80050. * @returns the current updated Vector3
  80051. */
  80052. normalizeFromLength(len: number): Vector3;
  80053. /**
  80054. * Normalize the current Vector3 to a new vector
  80055. * @returns the new Vector3
  80056. */
  80057. normalizeToNew(): Vector3;
  80058. /**
  80059. * Normalize the current Vector3 to the reference
  80060. * @param reference define the Vector3 to update
  80061. * @returns the updated Vector3
  80062. */
  80063. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  80064. /**
  80065. * Creates a new Vector3 copied from the current Vector3
  80066. * @returns the new Vector3
  80067. */
  80068. clone(): Vector3;
  80069. /**
  80070. * Copies the given vector coordinates to the current Vector3 ones
  80071. * @param source defines the source Vector3
  80072. * @returns the current updated Vector3
  80073. */
  80074. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  80075. /**
  80076. * Copies the given floats to the current Vector3 coordinates
  80077. * @param x defines the x coordinate of the operand
  80078. * @param y defines the y coordinate of the operand
  80079. * @param z defines the z coordinate of the operand
  80080. * @returns the current updated Vector3
  80081. */
  80082. copyFromFloats(x: number, y: number, z: number): Vector3;
  80083. /**
  80084. * Copies the given floats to the current Vector3 coordinates
  80085. * @param x defines the x coordinate of the operand
  80086. * @param y defines the y coordinate of the operand
  80087. * @param z defines the z coordinate of the operand
  80088. * @returns the current updated Vector3
  80089. */
  80090. set(x: number, y: number, z: number): Vector3;
  80091. /**
  80092. * Copies the given float to the current Vector3 coordinates
  80093. * @param v defines the x, y and z coordinates of the operand
  80094. * @returns the current updated Vector3
  80095. */
  80096. setAll(v: number): Vector3;
  80097. /**
  80098. * Get the clip factor between two vectors
  80099. * @param vector0 defines the first operand
  80100. * @param vector1 defines the second operand
  80101. * @param axis defines the axis to use
  80102. * @param size defines the size along the axis
  80103. * @returns the clip factor
  80104. */
  80105. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  80106. /**
  80107. * Get angle between two vectors
  80108. * @param vector0 angle between vector0 and vector1
  80109. * @param vector1 angle between vector0 and vector1
  80110. * @param normal direction of the normal
  80111. * @return the angle between vector0 and vector1
  80112. */
  80113. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  80114. /**
  80115. * Returns a new Vector3 set from the index "offset" of the given array
  80116. * @param array defines the source array
  80117. * @param offset defines the offset in the source array
  80118. * @returns the new Vector3
  80119. */
  80120. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  80121. /**
  80122. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  80123. * @param array defines the source array
  80124. * @param offset defines the offset in the source array
  80125. * @returns the new Vector3
  80126. * @deprecated Please use FromArray instead.
  80127. */
  80128. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  80129. /**
  80130. * Sets the given vector "result" with the element values from the index "offset" of the given array
  80131. * @param array defines the source array
  80132. * @param offset defines the offset in the source array
  80133. * @param result defines the Vector3 where to store the result
  80134. */
  80135. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  80136. /**
  80137. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  80138. * @param array defines the source array
  80139. * @param offset defines the offset in the source array
  80140. * @param result defines the Vector3 where to store the result
  80141. * @deprecated Please use FromArrayToRef instead.
  80142. */
  80143. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  80144. /**
  80145. * Sets the given vector "result" with the given floats.
  80146. * @param x defines the x coordinate of the source
  80147. * @param y defines the y coordinate of the source
  80148. * @param z defines the z coordinate of the source
  80149. * @param result defines the Vector3 where to store the result
  80150. */
  80151. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  80152. /**
  80153. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  80154. * @returns a new empty Vector3
  80155. */
  80156. static Zero(): Vector3;
  80157. /**
  80158. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  80159. * @returns a new unit Vector3
  80160. */
  80161. static One(): Vector3;
  80162. /**
  80163. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  80164. * @returns a new up Vector3
  80165. */
  80166. static Up(): Vector3;
  80167. /**
  80168. * Gets a up Vector3 that must not be updated
  80169. */
  80170. static get UpReadOnly(): DeepImmutable<Vector3>;
  80171. /**
  80172. * Gets a zero Vector3 that must not be updated
  80173. */
  80174. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  80175. /**
  80176. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  80177. * @returns a new down Vector3
  80178. */
  80179. static Down(): Vector3;
  80180. /**
  80181. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  80182. * @param rightHandedSystem is the scene right-handed (negative z)
  80183. * @returns a new forward Vector3
  80184. */
  80185. static Forward(rightHandedSystem?: boolean): Vector3;
  80186. /**
  80187. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  80188. * @param rightHandedSystem is the scene right-handed (negative-z)
  80189. * @returns a new forward Vector3
  80190. */
  80191. static Backward(rightHandedSystem?: boolean): Vector3;
  80192. /**
  80193. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  80194. * @returns a new right Vector3
  80195. */
  80196. static Right(): Vector3;
  80197. /**
  80198. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  80199. * @returns a new left Vector3
  80200. */
  80201. static Left(): Vector3;
  80202. /**
  80203. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  80204. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  80205. * @param vector defines the Vector3 to transform
  80206. * @param transformation defines the transformation matrix
  80207. * @returns the transformed Vector3
  80208. */
  80209. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  80210. /**
  80211. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  80212. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  80213. * @param vector defines the Vector3 to transform
  80214. * @param transformation defines the transformation matrix
  80215. * @param result defines the Vector3 where to store the result
  80216. */
  80217. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80218. /**
  80219. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  80220. * This method computes tranformed coordinates only, not transformed direction vectors
  80221. * @param x define the x coordinate of the source vector
  80222. * @param y define the y coordinate of the source vector
  80223. * @param z define the z coordinate of the source vector
  80224. * @param transformation defines the transformation matrix
  80225. * @param result defines the Vector3 where to store the result
  80226. */
  80227. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80228. /**
  80229. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  80230. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80231. * @param vector defines the Vector3 to transform
  80232. * @param transformation defines the transformation matrix
  80233. * @returns the new Vector3
  80234. */
  80235. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  80236. /**
  80237. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  80238. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80239. * @param vector defines the Vector3 to transform
  80240. * @param transformation defines the transformation matrix
  80241. * @param result defines the Vector3 where to store the result
  80242. */
  80243. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80244. /**
  80245. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  80246. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80247. * @param x define the x coordinate of the source vector
  80248. * @param y define the y coordinate of the source vector
  80249. * @param z define the z coordinate of the source vector
  80250. * @param transformation defines the transformation matrix
  80251. * @param result defines the Vector3 where to store the result
  80252. */
  80253. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80254. /**
  80255. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  80256. * @param value1 defines the first control point
  80257. * @param value2 defines the second control point
  80258. * @param value3 defines the third control point
  80259. * @param value4 defines the fourth control point
  80260. * @param amount defines the amount on the spline to use
  80261. * @returns the new Vector3
  80262. */
  80263. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  80264. /**
  80265. * 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"
  80266. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  80267. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  80268. * @param value defines the current value
  80269. * @param min defines the lower range value
  80270. * @param max defines the upper range value
  80271. * @returns the new Vector3
  80272. */
  80273. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  80274. /**
  80275. * 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"
  80276. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  80277. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  80278. * @param value defines the current value
  80279. * @param min defines the lower range value
  80280. * @param max defines the upper range value
  80281. * @param result defines the Vector3 where to store the result
  80282. */
  80283. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  80284. /**
  80285. * Checks if a given vector is inside a specific range
  80286. * @param v defines the vector to test
  80287. * @param min defines the minimum range
  80288. * @param max defines the maximum range
  80289. */
  80290. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  80291. /**
  80292. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  80293. * @param value1 defines the first control point
  80294. * @param tangent1 defines the first tangent vector
  80295. * @param value2 defines the second control point
  80296. * @param tangent2 defines the second tangent vector
  80297. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  80298. * @returns the new Vector3
  80299. */
  80300. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  80301. /**
  80302. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  80303. * @param start defines the start value
  80304. * @param end defines the end value
  80305. * @param amount max defines amount between both (between 0 and 1)
  80306. * @returns the new Vector3
  80307. */
  80308. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  80309. /**
  80310. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  80311. * @param start defines the start value
  80312. * @param end defines the end value
  80313. * @param amount max defines amount between both (between 0 and 1)
  80314. * @param result defines the Vector3 where to store the result
  80315. */
  80316. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  80317. /**
  80318. * Returns the dot product (float) between the vectors "left" and "right"
  80319. * @param left defines the left operand
  80320. * @param right defines the right operand
  80321. * @returns the dot product
  80322. */
  80323. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  80324. /**
  80325. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  80326. * The cross product is then orthogonal to both "left" and "right"
  80327. * @param left defines the left operand
  80328. * @param right defines the right operand
  80329. * @returns the cross product
  80330. */
  80331. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80332. /**
  80333. * Sets the given vector "result" with the cross product of "left" and "right"
  80334. * The cross product is then orthogonal to both "left" and "right"
  80335. * @param left defines the left operand
  80336. * @param right defines the right operand
  80337. * @param result defines the Vector3 where to store the result
  80338. */
  80339. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  80340. /**
  80341. * Returns a new Vector3 as the normalization of the given vector
  80342. * @param vector defines the Vector3 to normalize
  80343. * @returns the new Vector3
  80344. */
  80345. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  80346. /**
  80347. * Sets the given vector "result" with the normalization of the given first vector
  80348. * @param vector defines the Vector3 to normalize
  80349. * @param result defines the Vector3 where to store the result
  80350. */
  80351. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  80352. /**
  80353. * Project a Vector3 onto screen space
  80354. * @param vector defines the Vector3 to project
  80355. * @param world defines the world matrix to use
  80356. * @param transform defines the transform (view x projection) matrix to use
  80357. * @param viewport defines the screen viewport to use
  80358. * @returns the new Vector3
  80359. */
  80360. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  80361. /** @hidden */
  80362. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  80363. /**
  80364. * Unproject from screen space to object space
  80365. * @param source defines the screen space Vector3 to use
  80366. * @param viewportWidth defines the current width of the viewport
  80367. * @param viewportHeight defines the current height of the viewport
  80368. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80369. * @param transform defines the transform (view x projection) matrix to use
  80370. * @returns the new Vector3
  80371. */
  80372. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  80373. /**
  80374. * Unproject from screen space to object space
  80375. * @param source defines the screen space Vector3 to use
  80376. * @param viewportWidth defines the current width of the viewport
  80377. * @param viewportHeight defines the current height of the viewport
  80378. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80379. * @param view defines the view matrix to use
  80380. * @param projection defines the projection matrix to use
  80381. * @returns the new Vector3
  80382. */
  80383. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  80384. /**
  80385. * Unproject from screen space to object space
  80386. * @param source defines the screen space Vector3 to use
  80387. * @param viewportWidth defines the current width of the viewport
  80388. * @param viewportHeight defines the current height of the viewport
  80389. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80390. * @param view defines the view matrix to use
  80391. * @param projection defines the projection matrix to use
  80392. * @param result defines the Vector3 where to store the result
  80393. */
  80394. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  80395. /**
  80396. * Unproject from screen space to object space
  80397. * @param sourceX defines the screen space x coordinate to use
  80398. * @param sourceY defines the screen space y coordinate to use
  80399. * @param sourceZ defines the screen space z coordinate to use
  80400. * @param viewportWidth defines the current width of the viewport
  80401. * @param viewportHeight defines the current height of the viewport
  80402. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80403. * @param view defines the view matrix to use
  80404. * @param projection defines the projection matrix to use
  80405. * @param result defines the Vector3 where to store the result
  80406. */
  80407. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  80408. /**
  80409. * Gets the minimal coordinate values between two Vector3
  80410. * @param left defines the first operand
  80411. * @param right defines the second operand
  80412. * @returns the new Vector3
  80413. */
  80414. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80415. /**
  80416. * Gets the maximal coordinate values between two Vector3
  80417. * @param left defines the first operand
  80418. * @param right defines the second operand
  80419. * @returns the new Vector3
  80420. */
  80421. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80422. /**
  80423. * Returns the distance between the vectors "value1" and "value2"
  80424. * @param value1 defines the first operand
  80425. * @param value2 defines the second operand
  80426. * @returns the distance
  80427. */
  80428. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  80429. /**
  80430. * Returns the squared distance between the vectors "value1" and "value2"
  80431. * @param value1 defines the first operand
  80432. * @param value2 defines the second operand
  80433. * @returns the squared distance
  80434. */
  80435. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  80436. /**
  80437. * Returns a new Vector3 located at the center between "value1" and "value2"
  80438. * @param value1 defines the first operand
  80439. * @param value2 defines the second operand
  80440. * @returns the new Vector3
  80441. */
  80442. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  80443. /**
  80444. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  80445. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  80446. * to something in order to rotate it from its local system to the given target system
  80447. * Note: axis1, axis2 and axis3 are normalized during this operation
  80448. * @param axis1 defines the first axis
  80449. * @param axis2 defines the second axis
  80450. * @param axis3 defines the third axis
  80451. * @returns a new Vector3
  80452. */
  80453. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  80454. /**
  80455. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  80456. * @param axis1 defines the first axis
  80457. * @param axis2 defines the second axis
  80458. * @param axis3 defines the third axis
  80459. * @param ref defines the Vector3 where to store the result
  80460. */
  80461. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  80462. }
  80463. /**
  80464. * Vector4 class created for EulerAngle class conversion to Quaternion
  80465. */
  80466. export class Vector4 {
  80467. /** x value of the vector */
  80468. x: number;
  80469. /** y value of the vector */
  80470. y: number;
  80471. /** z value of the vector */
  80472. z: number;
  80473. /** w value of the vector */
  80474. w: number;
  80475. /**
  80476. * Creates a Vector4 object from the given floats.
  80477. * @param x x value of the vector
  80478. * @param y y value of the vector
  80479. * @param z z value of the vector
  80480. * @param w w value of the vector
  80481. */
  80482. constructor(
  80483. /** x value of the vector */
  80484. x: number,
  80485. /** y value of the vector */
  80486. y: number,
  80487. /** z value of the vector */
  80488. z: number,
  80489. /** w value of the vector */
  80490. w: number);
  80491. /**
  80492. * Returns the string with the Vector4 coordinates.
  80493. * @returns a string containing all the vector values
  80494. */
  80495. toString(): string;
  80496. /**
  80497. * Returns the string "Vector4".
  80498. * @returns "Vector4"
  80499. */
  80500. getClassName(): string;
  80501. /**
  80502. * Returns the Vector4 hash code.
  80503. * @returns a unique hash code
  80504. */
  80505. getHashCode(): number;
  80506. /**
  80507. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  80508. * @returns the resulting array
  80509. */
  80510. asArray(): number[];
  80511. /**
  80512. * Populates the given array from the given index with the Vector4 coordinates.
  80513. * @param array array to populate
  80514. * @param index index of the array to start at (default: 0)
  80515. * @returns the Vector4.
  80516. */
  80517. toArray(array: FloatArray, index?: number): Vector4;
  80518. /**
  80519. * Adds the given vector to the current Vector4.
  80520. * @param otherVector the vector to add
  80521. * @returns the updated Vector4.
  80522. */
  80523. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80524. /**
  80525. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  80526. * @param otherVector the vector to add
  80527. * @returns the resulting vector
  80528. */
  80529. add(otherVector: DeepImmutable<Vector4>): Vector4;
  80530. /**
  80531. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  80532. * @param otherVector the vector to add
  80533. * @param result the vector to store the result
  80534. * @returns the current Vector4.
  80535. */
  80536. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80537. /**
  80538. * Subtract in place the given vector from the current Vector4.
  80539. * @param otherVector the vector to subtract
  80540. * @returns the updated Vector4.
  80541. */
  80542. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80543. /**
  80544. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  80545. * @param otherVector the vector to add
  80546. * @returns the new vector with the result
  80547. */
  80548. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  80549. /**
  80550. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  80551. * @param otherVector the vector to subtract
  80552. * @param result the vector to store the result
  80553. * @returns the current Vector4.
  80554. */
  80555. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80556. /**
  80557. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80558. */
  80559. /**
  80560. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80561. * @param x value to subtract
  80562. * @param y value to subtract
  80563. * @param z value to subtract
  80564. * @param w value to subtract
  80565. * @returns new vector containing the result
  80566. */
  80567. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  80568. /**
  80569. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80570. * @param x value to subtract
  80571. * @param y value to subtract
  80572. * @param z value to subtract
  80573. * @param w value to subtract
  80574. * @param result the vector to store the result in
  80575. * @returns the current Vector4.
  80576. */
  80577. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  80578. /**
  80579. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  80580. * @returns a new vector with the negated values
  80581. */
  80582. negate(): Vector4;
  80583. /**
  80584. * Negate this vector in place
  80585. * @returns this
  80586. */
  80587. negateInPlace(): Vector4;
  80588. /**
  80589. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  80590. * @param result defines the Vector3 object where to store the result
  80591. * @returns the current Vector4
  80592. */
  80593. negateToRef(result: Vector4): Vector4;
  80594. /**
  80595. * Multiplies the current Vector4 coordinates by scale (float).
  80596. * @param scale the number to scale with
  80597. * @returns the updated Vector4.
  80598. */
  80599. scaleInPlace(scale: number): Vector4;
  80600. /**
  80601. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  80602. * @param scale the number to scale with
  80603. * @returns a new vector with the result
  80604. */
  80605. scale(scale: number): Vector4;
  80606. /**
  80607. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  80608. * @param scale the number to scale with
  80609. * @param result a vector to store the result in
  80610. * @returns the current Vector4.
  80611. */
  80612. scaleToRef(scale: number, result: Vector4): Vector4;
  80613. /**
  80614. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  80615. * @param scale defines the scale factor
  80616. * @param result defines the Vector4 object where to store the result
  80617. * @returns the unmodified current Vector4
  80618. */
  80619. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  80620. /**
  80621. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  80622. * @param otherVector the vector to compare against
  80623. * @returns true if they are equal
  80624. */
  80625. equals(otherVector: DeepImmutable<Vector4>): boolean;
  80626. /**
  80627. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  80628. * @param otherVector vector to compare against
  80629. * @param epsilon (Default: very small number)
  80630. * @returns true if they are equal
  80631. */
  80632. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  80633. /**
  80634. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  80635. * @param x x value to compare against
  80636. * @param y y value to compare against
  80637. * @param z z value to compare against
  80638. * @param w w value to compare against
  80639. * @returns true if equal
  80640. */
  80641. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  80642. /**
  80643. * Multiplies in place the current Vector4 by the given one.
  80644. * @param otherVector vector to multiple with
  80645. * @returns the updated Vector4.
  80646. */
  80647. multiplyInPlace(otherVector: Vector4): Vector4;
  80648. /**
  80649. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  80650. * @param otherVector vector to multiple with
  80651. * @returns resulting new vector
  80652. */
  80653. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  80654. /**
  80655. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  80656. * @param otherVector vector to multiple with
  80657. * @param result vector to store the result
  80658. * @returns the current Vector4.
  80659. */
  80660. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80661. /**
  80662. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  80663. * @param x x value multiply with
  80664. * @param y y value multiply with
  80665. * @param z z value multiply with
  80666. * @param w w value multiply with
  80667. * @returns resulting new vector
  80668. */
  80669. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  80670. /**
  80671. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  80672. * @param otherVector vector to devide with
  80673. * @returns resulting new vector
  80674. */
  80675. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  80676. /**
  80677. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  80678. * @param otherVector vector to devide with
  80679. * @param result vector to store the result
  80680. * @returns the current Vector4.
  80681. */
  80682. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80683. /**
  80684. * Divides the current Vector3 coordinates by the given ones.
  80685. * @param otherVector vector to devide with
  80686. * @returns the updated Vector3.
  80687. */
  80688. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80689. /**
  80690. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  80691. * @param other defines the second operand
  80692. * @returns the current updated Vector4
  80693. */
  80694. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  80695. /**
  80696. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  80697. * @param other defines the second operand
  80698. * @returns the current updated Vector4
  80699. */
  80700. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  80701. /**
  80702. * Gets a new Vector4 from current Vector4 floored values
  80703. * @returns a new Vector4
  80704. */
  80705. floor(): Vector4;
  80706. /**
  80707. * Gets a new Vector4 from current Vector3 floored values
  80708. * @returns a new Vector4
  80709. */
  80710. fract(): Vector4;
  80711. /**
  80712. * Returns the Vector4 length (float).
  80713. * @returns the length
  80714. */
  80715. length(): number;
  80716. /**
  80717. * Returns the Vector4 squared length (float).
  80718. * @returns the length squared
  80719. */
  80720. lengthSquared(): number;
  80721. /**
  80722. * Normalizes in place the Vector4.
  80723. * @returns the updated Vector4.
  80724. */
  80725. normalize(): Vector4;
  80726. /**
  80727. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  80728. * @returns this converted to a new vector3
  80729. */
  80730. toVector3(): Vector3;
  80731. /**
  80732. * Returns a new Vector4 copied from the current one.
  80733. * @returns the new cloned vector
  80734. */
  80735. clone(): Vector4;
  80736. /**
  80737. * Updates the current Vector4 with the given one coordinates.
  80738. * @param source the source vector to copy from
  80739. * @returns the updated Vector4.
  80740. */
  80741. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  80742. /**
  80743. * Updates the current Vector4 coordinates with the given floats.
  80744. * @param x float to copy from
  80745. * @param y float to copy from
  80746. * @param z float to copy from
  80747. * @param w float to copy from
  80748. * @returns the updated Vector4.
  80749. */
  80750. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  80751. /**
  80752. * Updates the current Vector4 coordinates with the given floats.
  80753. * @param x float to set from
  80754. * @param y float to set from
  80755. * @param z float to set from
  80756. * @param w float to set from
  80757. * @returns the updated Vector4.
  80758. */
  80759. set(x: number, y: number, z: number, w: number): Vector4;
  80760. /**
  80761. * Copies the given float to the current Vector3 coordinates
  80762. * @param v defines the x, y, z and w coordinates of the operand
  80763. * @returns the current updated Vector3
  80764. */
  80765. setAll(v: number): Vector4;
  80766. /**
  80767. * Returns a new Vector4 set from the starting index of the given array.
  80768. * @param array the array to pull values from
  80769. * @param offset the offset into the array to start at
  80770. * @returns the new vector
  80771. */
  80772. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  80773. /**
  80774. * Updates the given vector "result" from the starting index of the given array.
  80775. * @param array the array to pull values from
  80776. * @param offset the offset into the array to start at
  80777. * @param result the vector to store the result in
  80778. */
  80779. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  80780. /**
  80781. * Updates the given vector "result" from the starting index of the given Float32Array.
  80782. * @param array the array to pull values from
  80783. * @param offset the offset into the array to start at
  80784. * @param result the vector to store the result in
  80785. */
  80786. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  80787. /**
  80788. * Updates the given vector "result" coordinates from the given floats.
  80789. * @param x float to set from
  80790. * @param y float to set from
  80791. * @param z float to set from
  80792. * @param w float to set from
  80793. * @param result the vector to the floats in
  80794. */
  80795. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  80796. /**
  80797. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  80798. * @returns the new vector
  80799. */
  80800. static Zero(): Vector4;
  80801. /**
  80802. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  80803. * @returns the new vector
  80804. */
  80805. static One(): Vector4;
  80806. /**
  80807. * Returns a new normalized Vector4 from the given one.
  80808. * @param vector the vector to normalize
  80809. * @returns the vector
  80810. */
  80811. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  80812. /**
  80813. * Updates the given vector "result" from the normalization of the given one.
  80814. * @param vector the vector to normalize
  80815. * @param result the vector to store the result in
  80816. */
  80817. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  80818. /**
  80819. * Returns a vector with the minimum values from the left and right vectors
  80820. * @param left left vector to minimize
  80821. * @param right right vector to minimize
  80822. * @returns a new vector with the minimum of the left and right vector values
  80823. */
  80824. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  80825. /**
  80826. * Returns a vector with the maximum values from the left and right vectors
  80827. * @param left left vector to maximize
  80828. * @param right right vector to maximize
  80829. * @returns a new vector with the maximum of the left and right vector values
  80830. */
  80831. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  80832. /**
  80833. * Returns the distance (float) between the vectors "value1" and "value2".
  80834. * @param value1 value to calulate the distance between
  80835. * @param value2 value to calulate the distance between
  80836. * @return the distance between the two vectors
  80837. */
  80838. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  80839. /**
  80840. * Returns the squared distance (float) between the vectors "value1" and "value2".
  80841. * @param value1 value to calulate the distance between
  80842. * @param value2 value to calulate the distance between
  80843. * @return the distance between the two vectors squared
  80844. */
  80845. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  80846. /**
  80847. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  80848. * @param value1 value to calulate the center between
  80849. * @param value2 value to calulate the center between
  80850. * @return the center between the two vectors
  80851. */
  80852. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  80853. /**
  80854. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  80855. * This methods computes transformed normalized direction vectors only.
  80856. * @param vector the vector to transform
  80857. * @param transformation the transformation matrix to apply
  80858. * @returns the new vector
  80859. */
  80860. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  80861. /**
  80862. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  80863. * This methods computes transformed normalized direction vectors only.
  80864. * @param vector the vector to transform
  80865. * @param transformation the transformation matrix to apply
  80866. * @param result the vector to store the result in
  80867. */
  80868. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  80869. /**
  80870. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  80871. * This methods computes transformed normalized direction vectors only.
  80872. * @param x value to transform
  80873. * @param y value to transform
  80874. * @param z value to transform
  80875. * @param w value to transform
  80876. * @param transformation the transformation matrix to apply
  80877. * @param result the vector to store the results in
  80878. */
  80879. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  80880. /**
  80881. * Creates a new Vector4 from a Vector3
  80882. * @param source defines the source data
  80883. * @param w defines the 4th component (default is 0)
  80884. * @returns a new Vector4
  80885. */
  80886. static FromVector3(source: Vector3, w?: number): Vector4;
  80887. }
  80888. /**
  80889. * Class used to store quaternion data
  80890. * @see https://en.wikipedia.org/wiki/Quaternion
  80891. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  80892. */
  80893. export class Quaternion {
  80894. /** defines the first component (0 by default) */
  80895. x: number;
  80896. /** defines the second component (0 by default) */
  80897. y: number;
  80898. /** defines the third component (0 by default) */
  80899. z: number;
  80900. /** defines the fourth component (1.0 by default) */
  80901. w: number;
  80902. /**
  80903. * Creates a new Quaternion from the given floats
  80904. * @param x defines the first component (0 by default)
  80905. * @param y defines the second component (0 by default)
  80906. * @param z defines the third component (0 by default)
  80907. * @param w defines the fourth component (1.0 by default)
  80908. */
  80909. constructor(
  80910. /** defines the first component (0 by default) */
  80911. x?: number,
  80912. /** defines the second component (0 by default) */
  80913. y?: number,
  80914. /** defines the third component (0 by default) */
  80915. z?: number,
  80916. /** defines the fourth component (1.0 by default) */
  80917. w?: number);
  80918. /**
  80919. * Gets a string representation for the current quaternion
  80920. * @returns a string with the Quaternion coordinates
  80921. */
  80922. toString(): string;
  80923. /**
  80924. * Gets the class name of the quaternion
  80925. * @returns the string "Quaternion"
  80926. */
  80927. getClassName(): string;
  80928. /**
  80929. * Gets a hash code for this quaternion
  80930. * @returns the quaternion hash code
  80931. */
  80932. getHashCode(): number;
  80933. /**
  80934. * Copy the quaternion to an array
  80935. * @returns a new array populated with 4 elements from the quaternion coordinates
  80936. */
  80937. asArray(): number[];
  80938. /**
  80939. * Check if two quaternions are equals
  80940. * @param otherQuaternion defines the second operand
  80941. * @return true if the current quaternion and the given one coordinates are strictly equals
  80942. */
  80943. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  80944. /**
  80945. * Gets a boolean if two quaternions are equals (using an epsilon value)
  80946. * @param otherQuaternion defines the other quaternion
  80947. * @param epsilon defines the minimal distance to consider equality
  80948. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  80949. */
  80950. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  80951. /**
  80952. * Clone the current quaternion
  80953. * @returns a new quaternion copied from the current one
  80954. */
  80955. clone(): Quaternion;
  80956. /**
  80957. * Copy a quaternion to the current one
  80958. * @param other defines the other quaternion
  80959. * @returns the updated current quaternion
  80960. */
  80961. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  80962. /**
  80963. * Updates the current quaternion with the given float coordinates
  80964. * @param x defines the x coordinate
  80965. * @param y defines the y coordinate
  80966. * @param z defines the z coordinate
  80967. * @param w defines the w coordinate
  80968. * @returns the updated current quaternion
  80969. */
  80970. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  80971. /**
  80972. * Updates the current quaternion from the given float coordinates
  80973. * @param x defines the x coordinate
  80974. * @param y defines the y coordinate
  80975. * @param z defines the z coordinate
  80976. * @param w defines the w coordinate
  80977. * @returns the updated current quaternion
  80978. */
  80979. set(x: number, y: number, z: number, w: number): Quaternion;
  80980. /**
  80981. * Adds two quaternions
  80982. * @param other defines the second operand
  80983. * @returns a new quaternion as the addition result of the given one and the current quaternion
  80984. */
  80985. add(other: DeepImmutable<Quaternion>): Quaternion;
  80986. /**
  80987. * Add a quaternion to the current one
  80988. * @param other defines the quaternion to add
  80989. * @returns the current quaternion
  80990. */
  80991. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  80992. /**
  80993. * Subtract two quaternions
  80994. * @param other defines the second operand
  80995. * @returns a new quaternion as the subtraction result of the given one from the current one
  80996. */
  80997. subtract(other: Quaternion): Quaternion;
  80998. /**
  80999. * Multiplies the current quaternion by a scale factor
  81000. * @param value defines the scale factor
  81001. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  81002. */
  81003. scale(value: number): Quaternion;
  81004. /**
  81005. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  81006. * @param scale defines the scale factor
  81007. * @param result defines the Quaternion object where to store the result
  81008. * @returns the unmodified current quaternion
  81009. */
  81010. scaleToRef(scale: number, result: Quaternion): Quaternion;
  81011. /**
  81012. * Multiplies in place the current quaternion by a scale factor
  81013. * @param value defines the scale factor
  81014. * @returns the current modified quaternion
  81015. */
  81016. scaleInPlace(value: number): Quaternion;
  81017. /**
  81018. * Scale the current quaternion values by a factor and add the result to a given quaternion
  81019. * @param scale defines the scale factor
  81020. * @param result defines the Quaternion object where to store the result
  81021. * @returns the unmodified current quaternion
  81022. */
  81023. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  81024. /**
  81025. * Multiplies two quaternions
  81026. * @param q1 defines the second operand
  81027. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  81028. */
  81029. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  81030. /**
  81031. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  81032. * @param q1 defines the second operand
  81033. * @param result defines the target quaternion
  81034. * @returns the current quaternion
  81035. */
  81036. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  81037. /**
  81038. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  81039. * @param q1 defines the second operand
  81040. * @returns the currentupdated quaternion
  81041. */
  81042. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  81043. /**
  81044. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  81045. * @param ref defines the target quaternion
  81046. * @returns the current quaternion
  81047. */
  81048. conjugateToRef(ref: Quaternion): Quaternion;
  81049. /**
  81050. * Conjugates in place (1-q) the current quaternion
  81051. * @returns the current updated quaternion
  81052. */
  81053. conjugateInPlace(): Quaternion;
  81054. /**
  81055. * Conjugates in place (1-q) the current quaternion
  81056. * @returns a new quaternion
  81057. */
  81058. conjugate(): Quaternion;
  81059. /**
  81060. * Gets length of current quaternion
  81061. * @returns the quaternion length (float)
  81062. */
  81063. length(): number;
  81064. /**
  81065. * Normalize in place the current quaternion
  81066. * @returns the current updated quaternion
  81067. */
  81068. normalize(): Quaternion;
  81069. /**
  81070. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  81071. * @param order is a reserved parameter and is ignore for now
  81072. * @returns a new Vector3 containing the Euler angles
  81073. */
  81074. toEulerAngles(order?: string): Vector3;
  81075. /**
  81076. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  81077. * @param result defines the vector which will be filled with the Euler angles
  81078. * @param order is a reserved parameter and is ignore for now
  81079. * @returns the current unchanged quaternion
  81080. */
  81081. toEulerAnglesToRef(result: Vector3): Quaternion;
  81082. /**
  81083. * Updates the given rotation matrix with the current quaternion values
  81084. * @param result defines the target matrix
  81085. * @returns the current unchanged quaternion
  81086. */
  81087. toRotationMatrix(result: Matrix): Quaternion;
  81088. /**
  81089. * Updates the current quaternion from the given rotation matrix values
  81090. * @param matrix defines the source matrix
  81091. * @returns the current updated quaternion
  81092. */
  81093. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  81094. /**
  81095. * Creates a new quaternion from a rotation matrix
  81096. * @param matrix defines the source matrix
  81097. * @returns a new quaternion created from the given rotation matrix values
  81098. */
  81099. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  81100. /**
  81101. * Updates the given quaternion with the given rotation matrix values
  81102. * @param matrix defines the source matrix
  81103. * @param result defines the target quaternion
  81104. */
  81105. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  81106. /**
  81107. * Returns the dot product (float) between the quaternions "left" and "right"
  81108. * @param left defines the left operand
  81109. * @param right defines the right operand
  81110. * @returns the dot product
  81111. */
  81112. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  81113. /**
  81114. * Checks if the two quaternions are close to each other
  81115. * @param quat0 defines the first quaternion to check
  81116. * @param quat1 defines the second quaternion to check
  81117. * @returns true if the two quaternions are close to each other
  81118. */
  81119. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  81120. /**
  81121. * Creates an empty quaternion
  81122. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  81123. */
  81124. static Zero(): Quaternion;
  81125. /**
  81126. * Inverse a given quaternion
  81127. * @param q defines the source quaternion
  81128. * @returns a new quaternion as the inverted current quaternion
  81129. */
  81130. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  81131. /**
  81132. * Inverse a given quaternion
  81133. * @param q defines the source quaternion
  81134. * @param result the quaternion the result will be stored in
  81135. * @returns the result quaternion
  81136. */
  81137. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  81138. /**
  81139. * Creates an identity quaternion
  81140. * @returns the identity quaternion
  81141. */
  81142. static Identity(): Quaternion;
  81143. /**
  81144. * Gets a boolean indicating if the given quaternion is identity
  81145. * @param quaternion defines the quaternion to check
  81146. * @returns true if the quaternion is identity
  81147. */
  81148. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  81149. /**
  81150. * Creates a quaternion from a rotation around an axis
  81151. * @param axis defines the axis to use
  81152. * @param angle defines the angle to use
  81153. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  81154. */
  81155. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  81156. /**
  81157. * Creates a rotation around an axis and stores it into the given quaternion
  81158. * @param axis defines the axis to use
  81159. * @param angle defines the angle to use
  81160. * @param result defines the target quaternion
  81161. * @returns the target quaternion
  81162. */
  81163. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  81164. /**
  81165. * Creates a new quaternion from data stored into an array
  81166. * @param array defines the data source
  81167. * @param offset defines the offset in the source array where the data starts
  81168. * @returns a new quaternion
  81169. */
  81170. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  81171. /**
  81172. * Updates the given quaternion "result" from the starting index of the given array.
  81173. * @param array the array to pull values from
  81174. * @param offset the offset into the array to start at
  81175. * @param result the quaternion to store the result in
  81176. */
  81177. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  81178. /**
  81179. * Create a quaternion from Euler rotation angles
  81180. * @param x Pitch
  81181. * @param y Yaw
  81182. * @param z Roll
  81183. * @returns the new Quaternion
  81184. */
  81185. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  81186. /**
  81187. * Updates a quaternion from Euler rotation angles
  81188. * @param x Pitch
  81189. * @param y Yaw
  81190. * @param z Roll
  81191. * @param result the quaternion to store the result
  81192. * @returns the updated quaternion
  81193. */
  81194. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  81195. /**
  81196. * Create a quaternion from Euler rotation vector
  81197. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  81198. * @returns the new Quaternion
  81199. */
  81200. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  81201. /**
  81202. * Updates a quaternion from Euler rotation vector
  81203. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  81204. * @param result the quaternion to store the result
  81205. * @returns the updated quaternion
  81206. */
  81207. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  81208. /**
  81209. * Creates a new quaternion from the given Euler float angles (y, x, z)
  81210. * @param yaw defines the rotation around Y axis
  81211. * @param pitch defines the rotation around X axis
  81212. * @param roll defines the rotation around Z axis
  81213. * @returns the new quaternion
  81214. */
  81215. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  81216. /**
  81217. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  81218. * @param yaw defines the rotation around Y axis
  81219. * @param pitch defines the rotation around X axis
  81220. * @param roll defines the rotation around Z axis
  81221. * @param result defines the target quaternion
  81222. */
  81223. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  81224. /**
  81225. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  81226. * @param alpha defines the rotation around first axis
  81227. * @param beta defines the rotation around second axis
  81228. * @param gamma defines the rotation around third axis
  81229. * @returns the new quaternion
  81230. */
  81231. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  81232. /**
  81233. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  81234. * @param alpha defines the rotation around first axis
  81235. * @param beta defines the rotation around second axis
  81236. * @param gamma defines the rotation around third axis
  81237. * @param result defines the target quaternion
  81238. */
  81239. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  81240. /**
  81241. * 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)
  81242. * @param axis1 defines the first axis
  81243. * @param axis2 defines the second axis
  81244. * @param axis3 defines the third axis
  81245. * @returns the new quaternion
  81246. */
  81247. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  81248. /**
  81249. * 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
  81250. * @param axis1 defines the first axis
  81251. * @param axis2 defines the second axis
  81252. * @param axis3 defines the third axis
  81253. * @param ref defines the target quaternion
  81254. */
  81255. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  81256. /**
  81257. * Interpolates between two quaternions
  81258. * @param left defines first quaternion
  81259. * @param right defines second quaternion
  81260. * @param amount defines the gradient to use
  81261. * @returns the new interpolated quaternion
  81262. */
  81263. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  81264. /**
  81265. * Interpolates between two quaternions and stores it into a target quaternion
  81266. * @param left defines first quaternion
  81267. * @param right defines second quaternion
  81268. * @param amount defines the gradient to use
  81269. * @param result defines the target quaternion
  81270. */
  81271. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  81272. /**
  81273. * Interpolate between two quaternions using Hermite interpolation
  81274. * @param value1 defines first quaternion
  81275. * @param tangent1 defines the incoming tangent
  81276. * @param value2 defines second quaternion
  81277. * @param tangent2 defines the outgoing tangent
  81278. * @param amount defines the target quaternion
  81279. * @returns the new interpolated quaternion
  81280. */
  81281. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  81282. }
  81283. /**
  81284. * Class used to store matrix data (4x4)
  81285. */
  81286. export class Matrix {
  81287. private static _updateFlagSeed;
  81288. private static _identityReadOnly;
  81289. private _isIdentity;
  81290. private _isIdentityDirty;
  81291. private _isIdentity3x2;
  81292. private _isIdentity3x2Dirty;
  81293. /**
  81294. * Gets the update flag of the matrix which is an unique number for the matrix.
  81295. * It will be incremented every time the matrix data change.
  81296. * You can use it to speed the comparison between two versions of the same matrix.
  81297. */
  81298. updateFlag: number;
  81299. private readonly _m;
  81300. /**
  81301. * Gets the internal data of the matrix
  81302. */
  81303. get m(): DeepImmutable<Float32Array>;
  81304. /** @hidden */
  81305. _markAsUpdated(): void;
  81306. /** @hidden */
  81307. private _updateIdentityStatus;
  81308. /**
  81309. * Creates an empty matrix (filled with zeros)
  81310. */
  81311. constructor();
  81312. /**
  81313. * Check if the current matrix is identity
  81314. * @returns true is the matrix is the identity matrix
  81315. */
  81316. isIdentity(): boolean;
  81317. /**
  81318. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  81319. * @returns true is the matrix is the identity matrix
  81320. */
  81321. isIdentityAs3x2(): boolean;
  81322. /**
  81323. * Gets the determinant of the matrix
  81324. * @returns the matrix determinant
  81325. */
  81326. determinant(): number;
  81327. /**
  81328. * Returns the matrix as a Float32Array
  81329. * @returns the matrix underlying array
  81330. */
  81331. toArray(): DeepImmutable<Float32Array>;
  81332. /**
  81333. * Returns the matrix as a Float32Array
  81334. * @returns the matrix underlying array.
  81335. */
  81336. asArray(): DeepImmutable<Float32Array>;
  81337. /**
  81338. * Inverts the current matrix in place
  81339. * @returns the current inverted matrix
  81340. */
  81341. invert(): Matrix;
  81342. /**
  81343. * Sets all the matrix elements to zero
  81344. * @returns the current matrix
  81345. */
  81346. reset(): Matrix;
  81347. /**
  81348. * Adds the current matrix with a second one
  81349. * @param other defines the matrix to add
  81350. * @returns a new matrix as the addition of the current matrix and the given one
  81351. */
  81352. add(other: DeepImmutable<Matrix>): Matrix;
  81353. /**
  81354. * Sets the given matrix "result" to the addition of the current matrix and the given one
  81355. * @param other defines the matrix to add
  81356. * @param result defines the target matrix
  81357. * @returns the current matrix
  81358. */
  81359. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  81360. /**
  81361. * Adds in place the given matrix to the current matrix
  81362. * @param other defines the second operand
  81363. * @returns the current updated matrix
  81364. */
  81365. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  81366. /**
  81367. * Sets the given matrix to the current inverted Matrix
  81368. * @param other defines the target matrix
  81369. * @returns the unmodified current matrix
  81370. */
  81371. invertToRef(other: Matrix): Matrix;
  81372. /**
  81373. * add a value at the specified position in the current Matrix
  81374. * @param index the index of the value within the matrix. between 0 and 15.
  81375. * @param value the value to be added
  81376. * @returns the current updated matrix
  81377. */
  81378. addAtIndex(index: number, value: number): Matrix;
  81379. /**
  81380. * mutiply the specified position in the current Matrix by a value
  81381. * @param index the index of the value within the matrix. between 0 and 15.
  81382. * @param value the value to be added
  81383. * @returns the current updated matrix
  81384. */
  81385. multiplyAtIndex(index: number, value: number): Matrix;
  81386. /**
  81387. * Inserts the translation vector (using 3 floats) in the current matrix
  81388. * @param x defines the 1st component of the translation
  81389. * @param y defines the 2nd component of the translation
  81390. * @param z defines the 3rd component of the translation
  81391. * @returns the current updated matrix
  81392. */
  81393. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  81394. /**
  81395. * Adds the translation vector (using 3 floats) in the current matrix
  81396. * @param x defines the 1st component of the translation
  81397. * @param y defines the 2nd component of the translation
  81398. * @param z defines the 3rd component of the translation
  81399. * @returns the current updated matrix
  81400. */
  81401. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  81402. /**
  81403. * Inserts the translation vector in the current matrix
  81404. * @param vector3 defines the translation to insert
  81405. * @returns the current updated matrix
  81406. */
  81407. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  81408. /**
  81409. * Gets the translation value of the current matrix
  81410. * @returns a new Vector3 as the extracted translation from the matrix
  81411. */
  81412. getTranslation(): Vector3;
  81413. /**
  81414. * Fill a Vector3 with the extracted translation from the matrix
  81415. * @param result defines the Vector3 where to store the translation
  81416. * @returns the current matrix
  81417. */
  81418. getTranslationToRef(result: Vector3): Matrix;
  81419. /**
  81420. * Remove rotation and scaling part from the matrix
  81421. * @returns the updated matrix
  81422. */
  81423. removeRotationAndScaling(): Matrix;
  81424. /**
  81425. * Multiply two matrices
  81426. * @param other defines the second operand
  81427. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  81428. */
  81429. multiply(other: DeepImmutable<Matrix>): Matrix;
  81430. /**
  81431. * Copy the current matrix from the given one
  81432. * @param other defines the source matrix
  81433. * @returns the current updated matrix
  81434. */
  81435. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  81436. /**
  81437. * Populates the given array from the starting index with the current matrix values
  81438. * @param array defines the target array
  81439. * @param offset defines the offset in the target array where to start storing values
  81440. * @returns the current matrix
  81441. */
  81442. copyToArray(array: Float32Array, offset?: number): Matrix;
  81443. /**
  81444. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  81445. * @param other defines the second operand
  81446. * @param result defines the matrix where to store the multiplication
  81447. * @returns the current matrix
  81448. */
  81449. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  81450. /**
  81451. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  81452. * @param other defines the second operand
  81453. * @param result defines the array where to store the multiplication
  81454. * @param offset defines the offset in the target array where to start storing values
  81455. * @returns the current matrix
  81456. */
  81457. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  81458. /**
  81459. * Check equality between this matrix and a second one
  81460. * @param value defines the second matrix to compare
  81461. * @returns true is the current matrix and the given one values are strictly equal
  81462. */
  81463. equals(value: DeepImmutable<Matrix>): boolean;
  81464. /**
  81465. * Clone the current matrix
  81466. * @returns a new matrix from the current matrix
  81467. */
  81468. clone(): Matrix;
  81469. /**
  81470. * Returns the name of the current matrix class
  81471. * @returns the string "Matrix"
  81472. */
  81473. getClassName(): string;
  81474. /**
  81475. * Gets the hash code of the current matrix
  81476. * @returns the hash code
  81477. */
  81478. getHashCode(): number;
  81479. /**
  81480. * Decomposes the current Matrix into a translation, rotation and scaling components
  81481. * @param scale defines the scale vector3 given as a reference to update
  81482. * @param rotation defines the rotation quaternion given as a reference to update
  81483. * @param translation defines the translation vector3 given as a reference to update
  81484. * @returns true if operation was successful
  81485. */
  81486. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  81487. /**
  81488. * Gets specific row of the matrix
  81489. * @param index defines the number of the row to get
  81490. * @returns the index-th row of the current matrix as a new Vector4
  81491. */
  81492. getRow(index: number): Nullable<Vector4>;
  81493. /**
  81494. * Sets the index-th row of the current matrix to the vector4 values
  81495. * @param index defines the number of the row to set
  81496. * @param row defines the target vector4
  81497. * @returns the updated current matrix
  81498. */
  81499. setRow(index: number, row: Vector4): Matrix;
  81500. /**
  81501. * Compute the transpose of the matrix
  81502. * @returns the new transposed matrix
  81503. */
  81504. transpose(): Matrix;
  81505. /**
  81506. * Compute the transpose of the matrix and store it in a given matrix
  81507. * @param result defines the target matrix
  81508. * @returns the current matrix
  81509. */
  81510. transposeToRef(result: Matrix): Matrix;
  81511. /**
  81512. * Sets the index-th row of the current matrix with the given 4 x float values
  81513. * @param index defines the row index
  81514. * @param x defines the x component to set
  81515. * @param y defines the y component to set
  81516. * @param z defines the z component to set
  81517. * @param w defines the w component to set
  81518. * @returns the updated current matrix
  81519. */
  81520. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  81521. /**
  81522. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  81523. * @param scale defines the scale factor
  81524. * @returns a new matrix
  81525. */
  81526. scale(scale: number): Matrix;
  81527. /**
  81528. * Scale the current matrix values by a factor to a given result matrix
  81529. * @param scale defines the scale factor
  81530. * @param result defines the matrix to store the result
  81531. * @returns the current matrix
  81532. */
  81533. scaleToRef(scale: number, result: Matrix): Matrix;
  81534. /**
  81535. * Scale the current matrix values by a factor and add the result to a given matrix
  81536. * @param scale defines the scale factor
  81537. * @param result defines the Matrix to store the result
  81538. * @returns the current matrix
  81539. */
  81540. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  81541. /**
  81542. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  81543. * @param ref matrix to store the result
  81544. */
  81545. toNormalMatrix(ref: Matrix): void;
  81546. /**
  81547. * Gets only rotation part of the current matrix
  81548. * @returns a new matrix sets to the extracted rotation matrix from the current one
  81549. */
  81550. getRotationMatrix(): Matrix;
  81551. /**
  81552. * Extracts the rotation matrix from the current one and sets it as the given "result"
  81553. * @param result defines the target matrix to store data to
  81554. * @returns the current matrix
  81555. */
  81556. getRotationMatrixToRef(result: Matrix): Matrix;
  81557. /**
  81558. * Toggles model matrix from being right handed to left handed in place and vice versa
  81559. */
  81560. toggleModelMatrixHandInPlace(): void;
  81561. /**
  81562. * Toggles projection matrix from being right handed to left handed in place and vice versa
  81563. */
  81564. toggleProjectionMatrixHandInPlace(): void;
  81565. /**
  81566. * Creates a matrix from an array
  81567. * @param array defines the source array
  81568. * @param offset defines an offset in the source array
  81569. * @returns a new Matrix set from the starting index of the given array
  81570. */
  81571. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  81572. /**
  81573. * Copy the content of an array into a given matrix
  81574. * @param array defines the source array
  81575. * @param offset defines an offset in the source array
  81576. * @param result defines the target matrix
  81577. */
  81578. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  81579. /**
  81580. * Stores an array into a matrix after having multiplied each component by a given factor
  81581. * @param array defines the source array
  81582. * @param offset defines the offset in the source array
  81583. * @param scale defines the scaling factor
  81584. * @param result defines the target matrix
  81585. */
  81586. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  81587. /**
  81588. * Gets an identity matrix that must not be updated
  81589. */
  81590. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  81591. /**
  81592. * Stores a list of values (16) inside a given matrix
  81593. * @param initialM11 defines 1st value of 1st row
  81594. * @param initialM12 defines 2nd value of 1st row
  81595. * @param initialM13 defines 3rd value of 1st row
  81596. * @param initialM14 defines 4th value of 1st row
  81597. * @param initialM21 defines 1st value of 2nd row
  81598. * @param initialM22 defines 2nd value of 2nd row
  81599. * @param initialM23 defines 3rd value of 2nd row
  81600. * @param initialM24 defines 4th value of 2nd row
  81601. * @param initialM31 defines 1st value of 3rd row
  81602. * @param initialM32 defines 2nd value of 3rd row
  81603. * @param initialM33 defines 3rd value of 3rd row
  81604. * @param initialM34 defines 4th value of 3rd row
  81605. * @param initialM41 defines 1st value of 4th row
  81606. * @param initialM42 defines 2nd value of 4th row
  81607. * @param initialM43 defines 3rd value of 4th row
  81608. * @param initialM44 defines 4th value of 4th row
  81609. * @param result defines the target matrix
  81610. */
  81611. 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;
  81612. /**
  81613. * Creates new matrix from a list of values (16)
  81614. * @param initialM11 defines 1st value of 1st row
  81615. * @param initialM12 defines 2nd value of 1st row
  81616. * @param initialM13 defines 3rd value of 1st row
  81617. * @param initialM14 defines 4th value of 1st row
  81618. * @param initialM21 defines 1st value of 2nd row
  81619. * @param initialM22 defines 2nd value of 2nd row
  81620. * @param initialM23 defines 3rd value of 2nd row
  81621. * @param initialM24 defines 4th value of 2nd row
  81622. * @param initialM31 defines 1st value of 3rd row
  81623. * @param initialM32 defines 2nd value of 3rd row
  81624. * @param initialM33 defines 3rd value of 3rd row
  81625. * @param initialM34 defines 4th value of 3rd row
  81626. * @param initialM41 defines 1st value of 4th row
  81627. * @param initialM42 defines 2nd value of 4th row
  81628. * @param initialM43 defines 3rd value of 4th row
  81629. * @param initialM44 defines 4th value of 4th row
  81630. * @returns the new matrix
  81631. */
  81632. 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;
  81633. /**
  81634. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  81635. * @param scale defines the scale vector3
  81636. * @param rotation defines the rotation quaternion
  81637. * @param translation defines the translation vector3
  81638. * @returns a new matrix
  81639. */
  81640. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  81641. /**
  81642. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  81643. * @param scale defines the scale vector3
  81644. * @param rotation defines the rotation quaternion
  81645. * @param translation defines the translation vector3
  81646. * @param result defines the target matrix
  81647. */
  81648. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  81649. /**
  81650. * Creates a new identity matrix
  81651. * @returns a new identity matrix
  81652. */
  81653. static Identity(): Matrix;
  81654. /**
  81655. * Creates a new identity matrix and stores the result in a given matrix
  81656. * @param result defines the target matrix
  81657. */
  81658. static IdentityToRef(result: Matrix): void;
  81659. /**
  81660. * Creates a new zero matrix
  81661. * @returns a new zero matrix
  81662. */
  81663. static Zero(): Matrix;
  81664. /**
  81665. * Creates a new rotation matrix for "angle" radians around the X axis
  81666. * @param angle defines the angle (in radians) to use
  81667. * @return the new matrix
  81668. */
  81669. static RotationX(angle: number): Matrix;
  81670. /**
  81671. * Creates a new matrix as the invert of a given matrix
  81672. * @param source defines the source matrix
  81673. * @returns the new matrix
  81674. */
  81675. static Invert(source: DeepImmutable<Matrix>): Matrix;
  81676. /**
  81677. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  81678. * @param angle defines the angle (in radians) to use
  81679. * @param result defines the target matrix
  81680. */
  81681. static RotationXToRef(angle: number, result: Matrix): void;
  81682. /**
  81683. * Creates a new rotation matrix for "angle" radians around the Y axis
  81684. * @param angle defines the angle (in radians) to use
  81685. * @return the new matrix
  81686. */
  81687. static RotationY(angle: number): Matrix;
  81688. /**
  81689. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  81690. * @param angle defines the angle (in radians) to use
  81691. * @param result defines the target matrix
  81692. */
  81693. static RotationYToRef(angle: number, result: Matrix): void;
  81694. /**
  81695. * Creates a new rotation matrix for "angle" radians around the Z axis
  81696. * @param angle defines the angle (in radians) to use
  81697. * @return the new matrix
  81698. */
  81699. static RotationZ(angle: number): Matrix;
  81700. /**
  81701. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  81702. * @param angle defines the angle (in radians) to use
  81703. * @param result defines the target matrix
  81704. */
  81705. static RotationZToRef(angle: number, result: Matrix): void;
  81706. /**
  81707. * Creates a new rotation matrix for "angle" radians around the given axis
  81708. * @param axis defines the axis to use
  81709. * @param angle defines the angle (in radians) to use
  81710. * @return the new matrix
  81711. */
  81712. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  81713. /**
  81714. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  81715. * @param axis defines the axis to use
  81716. * @param angle defines the angle (in radians) to use
  81717. * @param result defines the target matrix
  81718. */
  81719. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  81720. /**
  81721. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  81722. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  81723. * @param from defines the vector to align
  81724. * @param to defines the vector to align to
  81725. * @param result defines the target matrix
  81726. */
  81727. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  81728. /**
  81729. * Creates a rotation matrix
  81730. * @param yaw defines the yaw angle in radians (Y axis)
  81731. * @param pitch defines the pitch angle in radians (X axis)
  81732. * @param roll defines the roll angle in radians (X axis)
  81733. * @returns the new rotation matrix
  81734. */
  81735. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  81736. /**
  81737. * Creates a rotation matrix and stores it in a given matrix
  81738. * @param yaw defines the yaw angle in radians (Y axis)
  81739. * @param pitch defines the pitch angle in radians (X axis)
  81740. * @param roll defines the roll angle in radians (X axis)
  81741. * @param result defines the target matrix
  81742. */
  81743. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  81744. /**
  81745. * Creates a scaling matrix
  81746. * @param x defines the scale factor on X axis
  81747. * @param y defines the scale factor on Y axis
  81748. * @param z defines the scale factor on Z axis
  81749. * @returns the new matrix
  81750. */
  81751. static Scaling(x: number, y: number, z: number): Matrix;
  81752. /**
  81753. * Creates a scaling matrix and stores it in a given matrix
  81754. * @param x defines the scale factor on X axis
  81755. * @param y defines the scale factor on Y axis
  81756. * @param z defines the scale factor on Z axis
  81757. * @param result defines the target matrix
  81758. */
  81759. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  81760. /**
  81761. * Creates a translation matrix
  81762. * @param x defines the translation on X axis
  81763. * @param y defines the translation on Y axis
  81764. * @param z defines the translationon Z axis
  81765. * @returns the new matrix
  81766. */
  81767. static Translation(x: number, y: number, z: number): Matrix;
  81768. /**
  81769. * Creates a translation matrix and stores it in a given matrix
  81770. * @param x defines the translation on X axis
  81771. * @param y defines the translation on Y axis
  81772. * @param z defines the translationon Z axis
  81773. * @param result defines the target matrix
  81774. */
  81775. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  81776. /**
  81777. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  81778. * @param startValue defines the start value
  81779. * @param endValue defines the end value
  81780. * @param gradient defines the gradient factor
  81781. * @returns the new matrix
  81782. */
  81783. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  81784. /**
  81785. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  81786. * @param startValue defines the start value
  81787. * @param endValue defines the end value
  81788. * @param gradient defines the gradient factor
  81789. * @param result defines the Matrix object where to store data
  81790. */
  81791. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  81792. /**
  81793. * Builds a new matrix whose values are computed by:
  81794. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  81795. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  81796. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  81797. * @param startValue defines the first matrix
  81798. * @param endValue defines the second matrix
  81799. * @param gradient defines the gradient between the two matrices
  81800. * @returns the new matrix
  81801. */
  81802. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  81803. /**
  81804. * Update a matrix to values which are computed by:
  81805. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  81806. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  81807. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  81808. * @param startValue defines the first matrix
  81809. * @param endValue defines the second matrix
  81810. * @param gradient defines the gradient between the two matrices
  81811. * @param result defines the target matrix
  81812. */
  81813. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  81814. /**
  81815. * 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"
  81816. * This function works in left handed mode
  81817. * @param eye defines the final position of the entity
  81818. * @param target defines where the entity should look at
  81819. * @param up defines the up vector for the entity
  81820. * @returns the new matrix
  81821. */
  81822. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  81823. /**
  81824. * 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".
  81825. * This function works in left handed mode
  81826. * @param eye defines the final position of the entity
  81827. * @param target defines where the entity should look at
  81828. * @param up defines the up vector for the entity
  81829. * @param result defines the target matrix
  81830. */
  81831. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  81832. /**
  81833. * 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"
  81834. * This function works in right handed mode
  81835. * @param eye defines the final position of the entity
  81836. * @param target defines where the entity should look at
  81837. * @param up defines the up vector for the entity
  81838. * @returns the new matrix
  81839. */
  81840. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  81841. /**
  81842. * 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".
  81843. * This function works in right handed mode
  81844. * @param eye defines the final position of the entity
  81845. * @param target defines where the entity should look at
  81846. * @param up defines the up vector for the entity
  81847. * @param result defines the target matrix
  81848. */
  81849. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  81850. /**
  81851. * Create a left-handed orthographic projection matrix
  81852. * @param width defines the viewport width
  81853. * @param height defines the viewport height
  81854. * @param znear defines the near clip plane
  81855. * @param zfar defines the far clip plane
  81856. * @returns a new matrix as a left-handed orthographic projection matrix
  81857. */
  81858. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  81859. /**
  81860. * Store a left-handed orthographic projection to a given matrix
  81861. * @param width defines the viewport width
  81862. * @param height defines the viewport height
  81863. * @param znear defines the near clip plane
  81864. * @param zfar defines the far clip plane
  81865. * @param result defines the target matrix
  81866. */
  81867. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  81868. /**
  81869. * Create a left-handed orthographic projection matrix
  81870. * @param left defines the viewport left coordinate
  81871. * @param right defines the viewport right coordinate
  81872. * @param bottom defines the viewport bottom coordinate
  81873. * @param top defines the viewport top coordinate
  81874. * @param znear defines the near clip plane
  81875. * @param zfar defines the far clip plane
  81876. * @returns a new matrix as a left-handed orthographic projection matrix
  81877. */
  81878. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  81879. /**
  81880. * Stores a left-handed orthographic projection into a given matrix
  81881. * @param left defines the viewport left coordinate
  81882. * @param right defines the viewport right coordinate
  81883. * @param bottom defines the viewport bottom coordinate
  81884. * @param top defines the viewport top coordinate
  81885. * @param znear defines the near clip plane
  81886. * @param zfar defines the far clip plane
  81887. * @param result defines the target matrix
  81888. */
  81889. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  81890. /**
  81891. * Creates a right-handed orthographic projection matrix
  81892. * @param left defines the viewport left coordinate
  81893. * @param right defines the viewport right coordinate
  81894. * @param bottom defines the viewport bottom coordinate
  81895. * @param top defines the viewport top coordinate
  81896. * @param znear defines the near clip plane
  81897. * @param zfar defines the far clip plane
  81898. * @returns a new matrix as a right-handed orthographic projection matrix
  81899. */
  81900. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  81901. /**
  81902. * Stores a right-handed orthographic projection into a given matrix
  81903. * @param left defines the viewport left coordinate
  81904. * @param right defines the viewport right coordinate
  81905. * @param bottom defines the viewport bottom coordinate
  81906. * @param top defines the viewport top coordinate
  81907. * @param znear defines the near clip plane
  81908. * @param zfar defines the far clip plane
  81909. * @param result defines the target matrix
  81910. */
  81911. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  81912. /**
  81913. * Creates a left-handed perspective projection matrix
  81914. * @param width defines the viewport width
  81915. * @param height defines the viewport height
  81916. * @param znear defines the near clip plane
  81917. * @param zfar defines the far clip plane
  81918. * @returns a new matrix as a left-handed perspective projection matrix
  81919. */
  81920. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  81921. /**
  81922. * Creates a left-handed perspective projection matrix
  81923. * @param fov defines the horizontal field of view
  81924. * @param aspect defines the aspect ratio
  81925. * @param znear defines the near clip plane
  81926. * @param zfar defines the far clip plane
  81927. * @returns a new matrix as a left-handed perspective projection matrix
  81928. */
  81929. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  81930. /**
  81931. * Stores a left-handed perspective projection into a given matrix
  81932. * @param fov defines the horizontal field of view
  81933. * @param aspect defines the aspect ratio
  81934. * @param znear defines the near clip plane
  81935. * @param zfar defines the far clip plane
  81936. * @param result defines the target matrix
  81937. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  81938. */
  81939. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  81940. /**
  81941. * Stores a left-handed perspective projection into a given matrix with depth reversed
  81942. * @param fov defines the horizontal field of view
  81943. * @param aspect defines the aspect ratio
  81944. * @param znear defines the near clip plane
  81945. * @param zfar not used as infinity is used as far clip
  81946. * @param result defines the target matrix
  81947. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  81948. */
  81949. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  81950. /**
  81951. * Creates a right-handed perspective projection matrix
  81952. * @param fov defines the horizontal field of view
  81953. * @param aspect defines the aspect ratio
  81954. * @param znear defines the near clip plane
  81955. * @param zfar defines the far clip plane
  81956. * @returns a new matrix as a right-handed perspective projection matrix
  81957. */
  81958. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  81959. /**
  81960. * Stores a right-handed perspective projection into a given matrix
  81961. * @param fov defines the horizontal field of view
  81962. * @param aspect defines the aspect ratio
  81963. * @param znear defines the near clip plane
  81964. * @param zfar defines the far clip plane
  81965. * @param result defines the target matrix
  81966. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  81967. */
  81968. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  81969. /**
  81970. * Stores a right-handed perspective projection into a given matrix
  81971. * @param fov defines the horizontal field of view
  81972. * @param aspect defines the aspect ratio
  81973. * @param znear defines the near clip plane
  81974. * @param zfar not used as infinity is used as far clip
  81975. * @param result defines the target matrix
  81976. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  81977. */
  81978. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  81979. /**
  81980. * Stores a perspective projection for WebVR info a given matrix
  81981. * @param fov defines the field of view
  81982. * @param znear defines the near clip plane
  81983. * @param zfar defines the far clip plane
  81984. * @param result defines the target matrix
  81985. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  81986. */
  81987. static PerspectiveFovWebVRToRef(fov: {
  81988. upDegrees: number;
  81989. downDegrees: number;
  81990. leftDegrees: number;
  81991. rightDegrees: number;
  81992. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  81993. /**
  81994. * Computes a complete transformation matrix
  81995. * @param viewport defines the viewport to use
  81996. * @param world defines the world matrix
  81997. * @param view defines the view matrix
  81998. * @param projection defines the projection matrix
  81999. * @param zmin defines the near clip plane
  82000. * @param zmax defines the far clip plane
  82001. * @returns the transformation matrix
  82002. */
  82003. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  82004. /**
  82005. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  82006. * @param matrix defines the matrix to use
  82007. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  82008. */
  82009. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  82010. /**
  82011. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  82012. * @param matrix defines the matrix to use
  82013. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  82014. */
  82015. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  82016. /**
  82017. * Compute the transpose of a given matrix
  82018. * @param matrix defines the matrix to transpose
  82019. * @returns the new matrix
  82020. */
  82021. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  82022. /**
  82023. * Compute the transpose of a matrix and store it in a target matrix
  82024. * @param matrix defines the matrix to transpose
  82025. * @param result defines the target matrix
  82026. */
  82027. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  82028. /**
  82029. * Computes a reflection matrix from a plane
  82030. * @param plane defines the reflection plane
  82031. * @returns a new matrix
  82032. */
  82033. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  82034. /**
  82035. * Computes a reflection matrix from a plane
  82036. * @param plane defines the reflection plane
  82037. * @param result defines the target matrix
  82038. */
  82039. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  82040. /**
  82041. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  82042. * @param xaxis defines the value of the 1st axis
  82043. * @param yaxis defines the value of the 2nd axis
  82044. * @param zaxis defines the value of the 3rd axis
  82045. * @param result defines the target matrix
  82046. */
  82047. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  82048. /**
  82049. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  82050. * @param quat defines the quaternion to use
  82051. * @param result defines the target matrix
  82052. */
  82053. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  82054. }
  82055. /**
  82056. * @hidden
  82057. */
  82058. export class TmpVectors {
  82059. static Vector2: Vector2[];
  82060. static Vector3: Vector3[];
  82061. static Vector4: Vector4[];
  82062. static Quaternion: Quaternion[];
  82063. static Matrix: Matrix[];
  82064. }
  82065. }
  82066. declare module BABYLON {
  82067. /**
  82068. * Defines potential orientation for back face culling
  82069. */
  82070. export enum Orientation {
  82071. /**
  82072. * Clockwise
  82073. */
  82074. CW = 0,
  82075. /** Counter clockwise */
  82076. CCW = 1
  82077. }
  82078. /** Class used to represent a Bezier curve */
  82079. export class BezierCurve {
  82080. /**
  82081. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  82082. * @param t defines the time
  82083. * @param x1 defines the left coordinate on X axis
  82084. * @param y1 defines the left coordinate on Y axis
  82085. * @param x2 defines the right coordinate on X axis
  82086. * @param y2 defines the right coordinate on Y axis
  82087. * @returns the interpolated value
  82088. */
  82089. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  82090. }
  82091. /**
  82092. * Defines angle representation
  82093. */
  82094. export class Angle {
  82095. private _radians;
  82096. /**
  82097. * Creates an Angle object of "radians" radians (float).
  82098. * @param radians the angle in radians
  82099. */
  82100. constructor(radians: number);
  82101. /**
  82102. * Get value in degrees
  82103. * @returns the Angle value in degrees (float)
  82104. */
  82105. degrees(): number;
  82106. /**
  82107. * Get value in radians
  82108. * @returns the Angle value in radians (float)
  82109. */
  82110. radians(): number;
  82111. /**
  82112. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  82113. * @param a defines first vector
  82114. * @param b defines second vector
  82115. * @returns a new Angle
  82116. */
  82117. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  82118. /**
  82119. * Gets a new Angle object from the given float in radians
  82120. * @param radians defines the angle value in radians
  82121. * @returns a new Angle
  82122. */
  82123. static FromRadians(radians: number): Angle;
  82124. /**
  82125. * Gets a new Angle object from the given float in degrees
  82126. * @param degrees defines the angle value in degrees
  82127. * @returns a new Angle
  82128. */
  82129. static FromDegrees(degrees: number): Angle;
  82130. }
  82131. /**
  82132. * This represents an arc in a 2d space.
  82133. */
  82134. export class Arc2 {
  82135. /** Defines the start point of the arc */
  82136. startPoint: Vector2;
  82137. /** Defines the mid point of the arc */
  82138. midPoint: Vector2;
  82139. /** Defines the end point of the arc */
  82140. endPoint: Vector2;
  82141. /**
  82142. * Defines the center point of the arc.
  82143. */
  82144. centerPoint: Vector2;
  82145. /**
  82146. * Defines the radius of the arc.
  82147. */
  82148. radius: number;
  82149. /**
  82150. * Defines the angle of the arc (from mid point to end point).
  82151. */
  82152. angle: Angle;
  82153. /**
  82154. * Defines the start angle of the arc (from start point to middle point).
  82155. */
  82156. startAngle: Angle;
  82157. /**
  82158. * Defines the orientation of the arc (clock wise/counter clock wise).
  82159. */
  82160. orientation: Orientation;
  82161. /**
  82162. * Creates an Arc object from the three given points : start, middle and end.
  82163. * @param startPoint Defines the start point of the arc
  82164. * @param midPoint Defines the midlle point of the arc
  82165. * @param endPoint Defines the end point of the arc
  82166. */
  82167. constructor(
  82168. /** Defines the start point of the arc */
  82169. startPoint: Vector2,
  82170. /** Defines the mid point of the arc */
  82171. midPoint: Vector2,
  82172. /** Defines the end point of the arc */
  82173. endPoint: Vector2);
  82174. }
  82175. /**
  82176. * Represents a 2D path made up of multiple 2D points
  82177. */
  82178. export class Path2 {
  82179. private _points;
  82180. private _length;
  82181. /**
  82182. * If the path start and end point are the same
  82183. */
  82184. closed: boolean;
  82185. /**
  82186. * Creates a Path2 object from the starting 2D coordinates x and y.
  82187. * @param x the starting points x value
  82188. * @param y the starting points y value
  82189. */
  82190. constructor(x: number, y: number);
  82191. /**
  82192. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  82193. * @param x the added points x value
  82194. * @param y the added points y value
  82195. * @returns the updated Path2.
  82196. */
  82197. addLineTo(x: number, y: number): Path2;
  82198. /**
  82199. * 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.
  82200. * @param midX middle point x value
  82201. * @param midY middle point y value
  82202. * @param endX end point x value
  82203. * @param endY end point y value
  82204. * @param numberOfSegments (default: 36)
  82205. * @returns the updated Path2.
  82206. */
  82207. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  82208. /**
  82209. * Closes the Path2.
  82210. * @returns the Path2.
  82211. */
  82212. close(): Path2;
  82213. /**
  82214. * Gets the sum of the distance between each sequential point in the path
  82215. * @returns the Path2 total length (float).
  82216. */
  82217. length(): number;
  82218. /**
  82219. * Gets the points which construct the path
  82220. * @returns the Path2 internal array of points.
  82221. */
  82222. getPoints(): Vector2[];
  82223. /**
  82224. * Retreives the point at the distance aways from the starting point
  82225. * @param normalizedLengthPosition the length along the path to retreive the point from
  82226. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  82227. */
  82228. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  82229. /**
  82230. * Creates a new path starting from an x and y position
  82231. * @param x starting x value
  82232. * @param y starting y value
  82233. * @returns a new Path2 starting at the coordinates (x, y).
  82234. */
  82235. static StartingAt(x: number, y: number): Path2;
  82236. }
  82237. /**
  82238. * Represents a 3D path made up of multiple 3D points
  82239. */
  82240. export class Path3D {
  82241. /**
  82242. * an array of Vector3, the curve axis of the Path3D
  82243. */
  82244. path: Vector3[];
  82245. private _curve;
  82246. private _distances;
  82247. private _tangents;
  82248. private _normals;
  82249. private _binormals;
  82250. private _raw;
  82251. private _alignTangentsWithPath;
  82252. private readonly _pointAtData;
  82253. /**
  82254. * new Path3D(path, normal, raw)
  82255. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  82256. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  82257. * @param path an array of Vector3, the curve axis of the Path3D
  82258. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  82259. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  82260. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  82261. */
  82262. constructor(
  82263. /**
  82264. * an array of Vector3, the curve axis of the Path3D
  82265. */
  82266. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  82267. /**
  82268. * Returns the Path3D array of successive Vector3 designing its curve.
  82269. * @returns the Path3D array of successive Vector3 designing its curve.
  82270. */
  82271. getCurve(): Vector3[];
  82272. /**
  82273. * Returns the Path3D array of successive Vector3 designing its curve.
  82274. * @returns the Path3D array of successive Vector3 designing its curve.
  82275. */
  82276. getPoints(): Vector3[];
  82277. /**
  82278. * @returns the computed length (float) of the path.
  82279. */
  82280. length(): number;
  82281. /**
  82282. * Returns an array populated with tangent vectors on each Path3D curve point.
  82283. * @returns an array populated with tangent vectors on each Path3D curve point.
  82284. */
  82285. getTangents(): Vector3[];
  82286. /**
  82287. * Returns an array populated with normal vectors on each Path3D curve point.
  82288. * @returns an array populated with normal vectors on each Path3D curve point.
  82289. */
  82290. getNormals(): Vector3[];
  82291. /**
  82292. * Returns an array populated with binormal vectors on each Path3D curve point.
  82293. * @returns an array populated with binormal vectors on each Path3D curve point.
  82294. */
  82295. getBinormals(): Vector3[];
  82296. /**
  82297. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  82298. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  82299. */
  82300. getDistances(): number[];
  82301. /**
  82302. * Returns an interpolated point along this path
  82303. * @param position the position of the point along this path, from 0.0 to 1.0
  82304. * @returns a new Vector3 as the point
  82305. */
  82306. getPointAt(position: number): Vector3;
  82307. /**
  82308. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  82309. * @param position the position of the point along this path, from 0.0 to 1.0
  82310. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  82311. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  82312. */
  82313. getTangentAt(position: number, interpolated?: boolean): Vector3;
  82314. /**
  82315. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  82316. * @param position the position of the point along this path, from 0.0 to 1.0
  82317. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  82318. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  82319. */
  82320. getNormalAt(position: number, interpolated?: boolean): Vector3;
  82321. /**
  82322. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  82323. * @param position the position of the point along this path, from 0.0 to 1.0
  82324. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  82325. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  82326. */
  82327. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  82328. /**
  82329. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  82330. * @param position the position of the point along this path, from 0.0 to 1.0
  82331. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  82332. */
  82333. getDistanceAt(position: number): number;
  82334. /**
  82335. * Returns the array index of the previous point of an interpolated point along this path
  82336. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  82337. * @returns the array index
  82338. */
  82339. getPreviousPointIndexAt(position: number): number;
  82340. /**
  82341. * 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)
  82342. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  82343. * @returns the sub position
  82344. */
  82345. getSubPositionAt(position: number): number;
  82346. /**
  82347. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  82348. * @param target the vector of which to get the closest position to
  82349. * @returns the position of the closest virtual point on this path to the target vector
  82350. */
  82351. getClosestPositionTo(target: Vector3): number;
  82352. /**
  82353. * Returns a sub path (slice) of this path
  82354. * @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
  82355. * @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
  82356. * @returns a sub path (slice) of this path
  82357. */
  82358. slice(start?: number, end?: number): Path3D;
  82359. /**
  82360. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  82361. * @param path path which all values are copied into the curves points
  82362. * @param firstNormal which should be projected onto the curve
  82363. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  82364. * @returns the same object updated.
  82365. */
  82366. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  82367. private _compute;
  82368. private _getFirstNonNullVector;
  82369. private _getLastNonNullVector;
  82370. private _normalVector;
  82371. /**
  82372. * Updates the point at data for an interpolated point along this curve
  82373. * @param position the position of the point along this curve, from 0.0 to 1.0
  82374. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  82375. * @returns the (updated) point at data
  82376. */
  82377. private _updatePointAtData;
  82378. /**
  82379. * Updates the point at data from the specified parameters
  82380. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  82381. * @param point the interpolated point
  82382. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  82383. */
  82384. private _setPointAtData;
  82385. /**
  82386. * Updates the point at interpolation matrix for the tangents, normals and binormals
  82387. */
  82388. private _updateInterpolationMatrix;
  82389. }
  82390. /**
  82391. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  82392. * A Curve3 is designed from a series of successive Vector3.
  82393. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  82394. */
  82395. export class Curve3 {
  82396. private _points;
  82397. private _length;
  82398. /**
  82399. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  82400. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  82401. * @param v1 (Vector3) the control point
  82402. * @param v2 (Vector3) the end point of the Quadratic Bezier
  82403. * @param nbPoints (integer) the wanted number of points in the curve
  82404. * @returns the created Curve3
  82405. */
  82406. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82407. /**
  82408. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  82409. * @param v0 (Vector3) the origin point of the Cubic Bezier
  82410. * @param v1 (Vector3) the first control point
  82411. * @param v2 (Vector3) the second control point
  82412. * @param v3 (Vector3) the end point of the Cubic Bezier
  82413. * @param nbPoints (integer) the wanted number of points in the curve
  82414. * @returns the created Curve3
  82415. */
  82416. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82417. /**
  82418. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  82419. * @param p1 (Vector3) the origin point of the Hermite Spline
  82420. * @param t1 (Vector3) the tangent vector at the origin point
  82421. * @param p2 (Vector3) the end point of the Hermite Spline
  82422. * @param t2 (Vector3) the tangent vector at the end point
  82423. * @param nbPoints (integer) the wanted number of points in the curve
  82424. * @returns the created Curve3
  82425. */
  82426. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82427. /**
  82428. * Returns a Curve3 object along a CatmullRom Spline curve :
  82429. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  82430. * @param nbPoints (integer) the wanted number of points between each curve control points
  82431. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  82432. * @returns the created Curve3
  82433. */
  82434. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  82435. /**
  82436. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  82437. * A Curve3 is designed from a series of successive Vector3.
  82438. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  82439. * @param points points which make up the curve
  82440. */
  82441. constructor(points: Vector3[]);
  82442. /**
  82443. * @returns the Curve3 stored array of successive Vector3
  82444. */
  82445. getPoints(): Vector3[];
  82446. /**
  82447. * @returns the computed length (float) of the curve.
  82448. */
  82449. length(): number;
  82450. /**
  82451. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  82452. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  82453. * curveA and curveB keep unchanged.
  82454. * @param curve the curve to continue from this curve
  82455. * @returns the newly constructed curve
  82456. */
  82457. continue(curve: DeepImmutable<Curve3>): Curve3;
  82458. private _computeLength;
  82459. }
  82460. }
  82461. declare module BABYLON {
  82462. /**
  82463. * This represents the main contract an easing function should follow.
  82464. * Easing functions are used throughout the animation system.
  82465. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82466. */
  82467. export interface IEasingFunction {
  82468. /**
  82469. * Given an input gradient between 0 and 1, this returns the corrseponding value
  82470. * of the easing function.
  82471. * The link below provides some of the most common examples of easing functions.
  82472. * @see https://easings.net/
  82473. * @param gradient Defines the value between 0 and 1 we want the easing value for
  82474. * @returns the corresponding value on the curve defined by the easing function
  82475. */
  82476. ease(gradient: number): number;
  82477. }
  82478. /**
  82479. * Base class used for every default easing function.
  82480. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82481. */
  82482. export class EasingFunction implements IEasingFunction {
  82483. /**
  82484. * Interpolation follows the mathematical formula associated with the easing function.
  82485. */
  82486. static readonly EASINGMODE_EASEIN: number;
  82487. /**
  82488. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  82489. */
  82490. static readonly EASINGMODE_EASEOUT: number;
  82491. /**
  82492. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  82493. */
  82494. static readonly EASINGMODE_EASEINOUT: number;
  82495. private _easingMode;
  82496. /**
  82497. * Sets the easing mode of the current function.
  82498. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  82499. */
  82500. setEasingMode(easingMode: number): void;
  82501. /**
  82502. * Gets the current easing mode.
  82503. * @returns the easing mode
  82504. */
  82505. getEasingMode(): number;
  82506. /**
  82507. * @hidden
  82508. */
  82509. easeInCore(gradient: number): number;
  82510. /**
  82511. * Given an input gradient between 0 and 1, this returns the corresponding value
  82512. * of the easing function.
  82513. * @param gradient Defines the value between 0 and 1 we want the easing value for
  82514. * @returns the corresponding value on the curve defined by the easing function
  82515. */
  82516. ease(gradient: number): number;
  82517. }
  82518. /**
  82519. * Easing function with a circle shape (see link below).
  82520. * @see https://easings.net/#easeInCirc
  82521. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82522. */
  82523. export class CircleEase extends EasingFunction implements IEasingFunction {
  82524. /** @hidden */
  82525. easeInCore(gradient: number): number;
  82526. }
  82527. /**
  82528. * Easing function with a ease back shape (see link below).
  82529. * @see https://easings.net/#easeInBack
  82530. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82531. */
  82532. export class BackEase extends EasingFunction implements IEasingFunction {
  82533. /** Defines the amplitude of the function */
  82534. amplitude: number;
  82535. /**
  82536. * Instantiates a back ease easing
  82537. * @see https://easings.net/#easeInBack
  82538. * @param amplitude Defines the amplitude of the function
  82539. */
  82540. constructor(
  82541. /** Defines the amplitude of the function */
  82542. amplitude?: number);
  82543. /** @hidden */
  82544. easeInCore(gradient: number): number;
  82545. }
  82546. /**
  82547. * Easing function with a bouncing shape (see link below).
  82548. * @see https://easings.net/#easeInBounce
  82549. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82550. */
  82551. export class BounceEase extends EasingFunction implements IEasingFunction {
  82552. /** Defines the number of bounces */
  82553. bounces: number;
  82554. /** Defines the amplitude of the bounce */
  82555. bounciness: number;
  82556. /**
  82557. * Instantiates a bounce easing
  82558. * @see https://easings.net/#easeInBounce
  82559. * @param bounces Defines the number of bounces
  82560. * @param bounciness Defines the amplitude of the bounce
  82561. */
  82562. constructor(
  82563. /** Defines the number of bounces */
  82564. bounces?: number,
  82565. /** Defines the amplitude of the bounce */
  82566. bounciness?: number);
  82567. /** @hidden */
  82568. easeInCore(gradient: number): number;
  82569. }
  82570. /**
  82571. * Easing function with a power of 3 shape (see link below).
  82572. * @see https://easings.net/#easeInCubic
  82573. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82574. */
  82575. export class CubicEase extends EasingFunction implements IEasingFunction {
  82576. /** @hidden */
  82577. easeInCore(gradient: number): number;
  82578. }
  82579. /**
  82580. * Easing function with an elastic shape (see link below).
  82581. * @see https://easings.net/#easeInElastic
  82582. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82583. */
  82584. export class ElasticEase extends EasingFunction implements IEasingFunction {
  82585. /** Defines the number of oscillations*/
  82586. oscillations: number;
  82587. /** Defines the amplitude of the oscillations*/
  82588. springiness: number;
  82589. /**
  82590. * Instantiates an elastic easing function
  82591. * @see https://easings.net/#easeInElastic
  82592. * @param oscillations Defines the number of oscillations
  82593. * @param springiness Defines the amplitude of the oscillations
  82594. */
  82595. constructor(
  82596. /** Defines the number of oscillations*/
  82597. oscillations?: number,
  82598. /** Defines the amplitude of the oscillations*/
  82599. springiness?: number);
  82600. /** @hidden */
  82601. easeInCore(gradient: number): number;
  82602. }
  82603. /**
  82604. * Easing function with an exponential shape (see link below).
  82605. * @see https://easings.net/#easeInExpo
  82606. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82607. */
  82608. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  82609. /** Defines the exponent of the function */
  82610. exponent: number;
  82611. /**
  82612. * Instantiates an exponential easing function
  82613. * @see https://easings.net/#easeInExpo
  82614. * @param exponent Defines the exponent of the function
  82615. */
  82616. constructor(
  82617. /** Defines the exponent of the function */
  82618. exponent?: number);
  82619. /** @hidden */
  82620. easeInCore(gradient: number): number;
  82621. }
  82622. /**
  82623. * Easing function with a power shape (see link below).
  82624. * @see https://easings.net/#easeInQuad
  82625. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82626. */
  82627. export class PowerEase extends EasingFunction implements IEasingFunction {
  82628. /** Defines the power of the function */
  82629. power: number;
  82630. /**
  82631. * Instantiates an power base easing function
  82632. * @see https://easings.net/#easeInQuad
  82633. * @param power Defines the power of the function
  82634. */
  82635. constructor(
  82636. /** Defines the power of the function */
  82637. power?: number);
  82638. /** @hidden */
  82639. easeInCore(gradient: number): number;
  82640. }
  82641. /**
  82642. * Easing function with a power of 2 shape (see link below).
  82643. * @see https://easings.net/#easeInQuad
  82644. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82645. */
  82646. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  82647. /** @hidden */
  82648. easeInCore(gradient: number): number;
  82649. }
  82650. /**
  82651. * Easing function with a power of 4 shape (see link below).
  82652. * @see https://easings.net/#easeInQuart
  82653. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82654. */
  82655. export class QuarticEase extends EasingFunction implements IEasingFunction {
  82656. /** @hidden */
  82657. easeInCore(gradient: number): number;
  82658. }
  82659. /**
  82660. * Easing function with a power of 5 shape (see link below).
  82661. * @see https://easings.net/#easeInQuint
  82662. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82663. */
  82664. export class QuinticEase extends EasingFunction implements IEasingFunction {
  82665. /** @hidden */
  82666. easeInCore(gradient: number): number;
  82667. }
  82668. /**
  82669. * Easing function with a sin shape (see link below).
  82670. * @see https://easings.net/#easeInSine
  82671. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82672. */
  82673. export class SineEase extends EasingFunction implements IEasingFunction {
  82674. /** @hidden */
  82675. easeInCore(gradient: number): number;
  82676. }
  82677. /**
  82678. * Easing function with a bezier shape (see link below).
  82679. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  82680. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82681. */
  82682. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  82683. /** Defines the x component of the start tangent in the bezier curve */
  82684. x1: number;
  82685. /** Defines the y component of the start tangent in the bezier curve */
  82686. y1: number;
  82687. /** Defines the x component of the end tangent in the bezier curve */
  82688. x2: number;
  82689. /** Defines the y component of the end tangent in the bezier curve */
  82690. y2: number;
  82691. /**
  82692. * Instantiates a bezier function
  82693. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  82694. * @param x1 Defines the x component of the start tangent in the bezier curve
  82695. * @param y1 Defines the y component of the start tangent in the bezier curve
  82696. * @param x2 Defines the x component of the end tangent in the bezier curve
  82697. * @param y2 Defines the y component of the end tangent in the bezier curve
  82698. */
  82699. constructor(
  82700. /** Defines the x component of the start tangent in the bezier curve */
  82701. x1?: number,
  82702. /** Defines the y component of the start tangent in the bezier curve */
  82703. y1?: number,
  82704. /** Defines the x component of the end tangent in the bezier curve */
  82705. x2?: number,
  82706. /** Defines the y component of the end tangent in the bezier curve */
  82707. y2?: number);
  82708. /** @hidden */
  82709. easeInCore(gradient: number): number;
  82710. }
  82711. }
  82712. declare module BABYLON {
  82713. /**
  82714. * Class used to hold a RBG color
  82715. */
  82716. export class Color3 {
  82717. /**
  82718. * Defines the red component (between 0 and 1, default is 0)
  82719. */
  82720. r: number;
  82721. /**
  82722. * Defines the green component (between 0 and 1, default is 0)
  82723. */
  82724. g: number;
  82725. /**
  82726. * Defines the blue component (between 0 and 1, default is 0)
  82727. */
  82728. b: number;
  82729. /**
  82730. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  82731. * @param r defines the red component (between 0 and 1, default is 0)
  82732. * @param g defines the green component (between 0 and 1, default is 0)
  82733. * @param b defines the blue component (between 0 and 1, default is 0)
  82734. */
  82735. constructor(
  82736. /**
  82737. * Defines the red component (between 0 and 1, default is 0)
  82738. */
  82739. r?: number,
  82740. /**
  82741. * Defines the green component (between 0 and 1, default is 0)
  82742. */
  82743. g?: number,
  82744. /**
  82745. * Defines the blue component (between 0 and 1, default is 0)
  82746. */
  82747. b?: number);
  82748. /**
  82749. * Creates a string with the Color3 current values
  82750. * @returns the string representation of the Color3 object
  82751. */
  82752. toString(): string;
  82753. /**
  82754. * Returns the string "Color3"
  82755. * @returns "Color3"
  82756. */
  82757. getClassName(): string;
  82758. /**
  82759. * Compute the Color3 hash code
  82760. * @returns an unique number that can be used to hash Color3 objects
  82761. */
  82762. getHashCode(): number;
  82763. /**
  82764. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  82765. * @param array defines the array where to store the r,g,b components
  82766. * @param index defines an optional index in the target array to define where to start storing values
  82767. * @returns the current Color3 object
  82768. */
  82769. toArray(array: FloatArray, index?: number): Color3;
  82770. /**
  82771. * Returns a new Color4 object from the current Color3 and the given alpha
  82772. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  82773. * @returns a new Color4 object
  82774. */
  82775. toColor4(alpha?: number): Color4;
  82776. /**
  82777. * Returns a new array populated with 3 numeric elements : red, green and blue values
  82778. * @returns the new array
  82779. */
  82780. asArray(): number[];
  82781. /**
  82782. * Returns the luminance value
  82783. * @returns a float value
  82784. */
  82785. toLuminance(): number;
  82786. /**
  82787. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  82788. * @param otherColor defines the second operand
  82789. * @returns the new Color3 object
  82790. */
  82791. multiply(otherColor: DeepImmutable<Color3>): Color3;
  82792. /**
  82793. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  82794. * @param otherColor defines the second operand
  82795. * @param result defines the Color3 object where to store the result
  82796. * @returns the current Color3
  82797. */
  82798. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  82799. /**
  82800. * Determines equality between Color3 objects
  82801. * @param otherColor defines the second operand
  82802. * @returns true if the rgb values are equal to the given ones
  82803. */
  82804. equals(otherColor: DeepImmutable<Color3>): boolean;
  82805. /**
  82806. * Determines equality between the current Color3 object and a set of r,b,g values
  82807. * @param r defines the red component to check
  82808. * @param g defines the green component to check
  82809. * @param b defines the blue component to check
  82810. * @returns true if the rgb values are equal to the given ones
  82811. */
  82812. equalsFloats(r: number, g: number, b: number): boolean;
  82813. /**
  82814. * Multiplies in place each rgb value by scale
  82815. * @param scale defines the scaling factor
  82816. * @returns the updated Color3
  82817. */
  82818. scale(scale: number): Color3;
  82819. /**
  82820. * Multiplies the rgb values by scale and stores the result into "result"
  82821. * @param scale defines the scaling factor
  82822. * @param result defines the Color3 object where to store the result
  82823. * @returns the unmodified current Color3
  82824. */
  82825. scaleToRef(scale: number, result: Color3): Color3;
  82826. /**
  82827. * Scale the current Color3 values by a factor and add the result to a given Color3
  82828. * @param scale defines the scale factor
  82829. * @param result defines color to store the result into
  82830. * @returns the unmodified current Color3
  82831. */
  82832. scaleAndAddToRef(scale: number, result: Color3): Color3;
  82833. /**
  82834. * Clamps the rgb values by the min and max values and stores the result into "result"
  82835. * @param min defines minimum clamping value (default is 0)
  82836. * @param max defines maximum clamping value (default is 1)
  82837. * @param result defines color to store the result into
  82838. * @returns the original Color3
  82839. */
  82840. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  82841. /**
  82842. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  82843. * @param otherColor defines the second operand
  82844. * @returns the new Color3
  82845. */
  82846. add(otherColor: DeepImmutable<Color3>): Color3;
  82847. /**
  82848. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  82849. * @param otherColor defines the second operand
  82850. * @param result defines Color3 object to store the result into
  82851. * @returns the unmodified current Color3
  82852. */
  82853. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  82854. /**
  82855. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  82856. * @param otherColor defines the second operand
  82857. * @returns the new Color3
  82858. */
  82859. subtract(otherColor: DeepImmutable<Color3>): Color3;
  82860. /**
  82861. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  82862. * @param otherColor defines the second operand
  82863. * @param result defines Color3 object to store the result into
  82864. * @returns the unmodified current Color3
  82865. */
  82866. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  82867. /**
  82868. * Copy the current object
  82869. * @returns a new Color3 copied the current one
  82870. */
  82871. clone(): Color3;
  82872. /**
  82873. * Copies the rgb values from the source in the current Color3
  82874. * @param source defines the source Color3 object
  82875. * @returns the updated Color3 object
  82876. */
  82877. copyFrom(source: DeepImmutable<Color3>): Color3;
  82878. /**
  82879. * Updates the Color3 rgb values from the given floats
  82880. * @param r defines the red component to read from
  82881. * @param g defines the green component to read from
  82882. * @param b defines the blue component to read from
  82883. * @returns the current Color3 object
  82884. */
  82885. copyFromFloats(r: number, g: number, b: number): Color3;
  82886. /**
  82887. * Updates the Color3 rgb values from the given floats
  82888. * @param r defines the red component to read from
  82889. * @param g defines the green component to read from
  82890. * @param b defines the blue component to read from
  82891. * @returns the current Color3 object
  82892. */
  82893. set(r: number, g: number, b: number): Color3;
  82894. /**
  82895. * Compute the Color3 hexadecimal code as a string
  82896. * @returns a string containing the hexadecimal representation of the Color3 object
  82897. */
  82898. toHexString(): string;
  82899. /**
  82900. * Computes a new Color3 converted from the current one to linear space
  82901. * @returns a new Color3 object
  82902. */
  82903. toLinearSpace(): Color3;
  82904. /**
  82905. * Converts current color in rgb space to HSV values
  82906. * @returns a new color3 representing the HSV values
  82907. */
  82908. toHSV(): Color3;
  82909. /**
  82910. * Converts current color in rgb space to HSV values
  82911. * @param result defines the Color3 where to store the HSV values
  82912. */
  82913. toHSVToRef(result: Color3): void;
  82914. /**
  82915. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  82916. * @param convertedColor defines the Color3 object where to store the linear space version
  82917. * @returns the unmodified Color3
  82918. */
  82919. toLinearSpaceToRef(convertedColor: Color3): Color3;
  82920. /**
  82921. * Computes a new Color3 converted from the current one to gamma space
  82922. * @returns a new Color3 object
  82923. */
  82924. toGammaSpace(): Color3;
  82925. /**
  82926. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  82927. * @param convertedColor defines the Color3 object where to store the gamma space version
  82928. * @returns the unmodified Color3
  82929. */
  82930. toGammaSpaceToRef(convertedColor: Color3): Color3;
  82931. private static _BlackReadOnly;
  82932. /**
  82933. * Convert Hue, saturation and value to a Color3 (RGB)
  82934. * @param hue defines the hue
  82935. * @param saturation defines the saturation
  82936. * @param value defines the value
  82937. * @param result defines the Color3 where to store the RGB values
  82938. */
  82939. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  82940. /**
  82941. * Creates a new Color3 from the string containing valid hexadecimal values
  82942. * @param hex defines a string containing valid hexadecimal values
  82943. * @returns a new Color3 object
  82944. */
  82945. static FromHexString(hex: string): Color3;
  82946. /**
  82947. * Creates a new Color3 from the starting index of the given array
  82948. * @param array defines the source array
  82949. * @param offset defines an offset in the source array
  82950. * @returns a new Color3 object
  82951. */
  82952. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  82953. /**
  82954. * Creates a new Color3 from integer values (< 256)
  82955. * @param r defines the red component to read from (value between 0 and 255)
  82956. * @param g defines the green component to read from (value between 0 and 255)
  82957. * @param b defines the blue component to read from (value between 0 and 255)
  82958. * @returns a new Color3 object
  82959. */
  82960. static FromInts(r: number, g: number, b: number): Color3;
  82961. /**
  82962. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  82963. * @param start defines the start Color3 value
  82964. * @param end defines the end Color3 value
  82965. * @param amount defines the gradient value between start and end
  82966. * @returns a new Color3 object
  82967. */
  82968. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  82969. /**
  82970. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  82971. * @param left defines the start value
  82972. * @param right defines the end value
  82973. * @param amount defines the gradient factor
  82974. * @param result defines the Color3 object where to store the result
  82975. */
  82976. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  82977. /**
  82978. * Returns a Color3 value containing a red color
  82979. * @returns a new Color3 object
  82980. */
  82981. static Red(): Color3;
  82982. /**
  82983. * Returns a Color3 value containing a green color
  82984. * @returns a new Color3 object
  82985. */
  82986. static Green(): Color3;
  82987. /**
  82988. * Returns a Color3 value containing a blue color
  82989. * @returns a new Color3 object
  82990. */
  82991. static Blue(): Color3;
  82992. /**
  82993. * Returns a Color3 value containing a black color
  82994. * @returns a new Color3 object
  82995. */
  82996. static Black(): Color3;
  82997. /**
  82998. * Gets a Color3 value containing a black color that must not be updated
  82999. */
  83000. static get BlackReadOnly(): DeepImmutable<Color3>;
  83001. /**
  83002. * Returns a Color3 value containing a white color
  83003. * @returns a new Color3 object
  83004. */
  83005. static White(): Color3;
  83006. /**
  83007. * Returns a Color3 value containing a purple color
  83008. * @returns a new Color3 object
  83009. */
  83010. static Purple(): Color3;
  83011. /**
  83012. * Returns a Color3 value containing a magenta color
  83013. * @returns a new Color3 object
  83014. */
  83015. static Magenta(): Color3;
  83016. /**
  83017. * Returns a Color3 value containing a yellow color
  83018. * @returns a new Color3 object
  83019. */
  83020. static Yellow(): Color3;
  83021. /**
  83022. * Returns a Color3 value containing a gray color
  83023. * @returns a new Color3 object
  83024. */
  83025. static Gray(): Color3;
  83026. /**
  83027. * Returns a Color3 value containing a teal color
  83028. * @returns a new Color3 object
  83029. */
  83030. static Teal(): Color3;
  83031. /**
  83032. * Returns a Color3 value containing a random color
  83033. * @returns a new Color3 object
  83034. */
  83035. static Random(): Color3;
  83036. }
  83037. /**
  83038. * Class used to hold a RBGA color
  83039. */
  83040. export class Color4 {
  83041. /**
  83042. * Defines the red component (between 0 and 1, default is 0)
  83043. */
  83044. r: number;
  83045. /**
  83046. * Defines the green component (between 0 and 1, default is 0)
  83047. */
  83048. g: number;
  83049. /**
  83050. * Defines the blue component (between 0 and 1, default is 0)
  83051. */
  83052. b: number;
  83053. /**
  83054. * Defines the alpha component (between 0 and 1, default is 1)
  83055. */
  83056. a: number;
  83057. /**
  83058. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  83059. * @param r defines the red component (between 0 and 1, default is 0)
  83060. * @param g defines the green component (between 0 and 1, default is 0)
  83061. * @param b defines the blue component (between 0 and 1, default is 0)
  83062. * @param a defines the alpha component (between 0 and 1, default is 1)
  83063. */
  83064. constructor(
  83065. /**
  83066. * Defines the red component (between 0 and 1, default is 0)
  83067. */
  83068. r?: number,
  83069. /**
  83070. * Defines the green component (between 0 and 1, default is 0)
  83071. */
  83072. g?: number,
  83073. /**
  83074. * Defines the blue component (between 0 and 1, default is 0)
  83075. */
  83076. b?: number,
  83077. /**
  83078. * Defines the alpha component (between 0 and 1, default is 1)
  83079. */
  83080. a?: number);
  83081. /**
  83082. * Adds in place the given Color4 values to the current Color4 object
  83083. * @param right defines the second operand
  83084. * @returns the current updated Color4 object
  83085. */
  83086. addInPlace(right: DeepImmutable<Color4>): Color4;
  83087. /**
  83088. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  83089. * @returns the new array
  83090. */
  83091. asArray(): number[];
  83092. /**
  83093. * Stores from the starting index in the given array the Color4 successive values
  83094. * @param array defines the array where to store the r,g,b components
  83095. * @param index defines an optional index in the target array to define where to start storing values
  83096. * @returns the current Color4 object
  83097. */
  83098. toArray(array: number[], index?: number): Color4;
  83099. /**
  83100. * Determines equality between Color4 objects
  83101. * @param otherColor defines the second operand
  83102. * @returns true if the rgba values are equal to the given ones
  83103. */
  83104. equals(otherColor: DeepImmutable<Color4>): boolean;
  83105. /**
  83106. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  83107. * @param right defines the second operand
  83108. * @returns a new Color4 object
  83109. */
  83110. add(right: DeepImmutable<Color4>): Color4;
  83111. /**
  83112. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  83113. * @param right defines the second operand
  83114. * @returns a new Color4 object
  83115. */
  83116. subtract(right: DeepImmutable<Color4>): Color4;
  83117. /**
  83118. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  83119. * @param right defines the second operand
  83120. * @param result defines the Color4 object where to store the result
  83121. * @returns the current Color4 object
  83122. */
  83123. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  83124. /**
  83125. * Creates a new Color4 with the current Color4 values multiplied by scale
  83126. * @param scale defines the scaling factor to apply
  83127. * @returns a new Color4 object
  83128. */
  83129. scale(scale: number): Color4;
  83130. /**
  83131. * Multiplies the current Color4 values by scale and stores the result in "result"
  83132. * @param scale defines the scaling factor to apply
  83133. * @param result defines the Color4 object where to store the result
  83134. * @returns the current unmodified Color4
  83135. */
  83136. scaleToRef(scale: number, result: Color4): Color4;
  83137. /**
  83138. * Scale the current Color4 values by a factor and add the result to a given Color4
  83139. * @param scale defines the scale factor
  83140. * @param result defines the Color4 object where to store the result
  83141. * @returns the unmodified current Color4
  83142. */
  83143. scaleAndAddToRef(scale: number, result: Color4): Color4;
  83144. /**
  83145. * Clamps the rgb values by the min and max values and stores the result into "result"
  83146. * @param min defines minimum clamping value (default is 0)
  83147. * @param max defines maximum clamping value (default is 1)
  83148. * @param result defines color to store the result into.
  83149. * @returns the cuurent Color4
  83150. */
  83151. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  83152. /**
  83153. * Multipy an Color4 value by another and return a new Color4 object
  83154. * @param color defines the Color4 value to multiply by
  83155. * @returns a new Color4 object
  83156. */
  83157. multiply(color: Color4): Color4;
  83158. /**
  83159. * Multipy a Color4 value by another and push the result in a reference value
  83160. * @param color defines the Color4 value to multiply by
  83161. * @param result defines the Color4 to fill the result in
  83162. * @returns the result Color4
  83163. */
  83164. multiplyToRef(color: Color4, result: Color4): Color4;
  83165. /**
  83166. * Creates a string with the Color4 current values
  83167. * @returns the string representation of the Color4 object
  83168. */
  83169. toString(): string;
  83170. /**
  83171. * Returns the string "Color4"
  83172. * @returns "Color4"
  83173. */
  83174. getClassName(): string;
  83175. /**
  83176. * Compute the Color4 hash code
  83177. * @returns an unique number that can be used to hash Color4 objects
  83178. */
  83179. getHashCode(): number;
  83180. /**
  83181. * Creates a new Color4 copied from the current one
  83182. * @returns a new Color4 object
  83183. */
  83184. clone(): Color4;
  83185. /**
  83186. * Copies the given Color4 values into the current one
  83187. * @param source defines the source Color4 object
  83188. * @returns the current updated Color4 object
  83189. */
  83190. copyFrom(source: Color4): Color4;
  83191. /**
  83192. * Copies the given float values into the current one
  83193. * @param r defines the red component to read from
  83194. * @param g defines the green component to read from
  83195. * @param b defines the blue component to read from
  83196. * @param a defines the alpha component to read from
  83197. * @returns the current updated Color4 object
  83198. */
  83199. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  83200. /**
  83201. * Copies the given float values into the current one
  83202. * @param r defines the red component to read from
  83203. * @param g defines the green component to read from
  83204. * @param b defines the blue component to read from
  83205. * @param a defines the alpha component to read from
  83206. * @returns the current updated Color4 object
  83207. */
  83208. set(r: number, g: number, b: number, a: number): Color4;
  83209. /**
  83210. * Compute the Color4 hexadecimal code as a string
  83211. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  83212. * @returns a string containing the hexadecimal representation of the Color4 object
  83213. */
  83214. toHexString(returnAsColor3?: boolean): string;
  83215. /**
  83216. * Computes a new Color4 converted from the current one to linear space
  83217. * @returns a new Color4 object
  83218. */
  83219. toLinearSpace(): Color4;
  83220. /**
  83221. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  83222. * @param convertedColor defines the Color4 object where to store the linear space version
  83223. * @returns the unmodified Color4
  83224. */
  83225. toLinearSpaceToRef(convertedColor: Color4): Color4;
  83226. /**
  83227. * Computes a new Color4 converted from the current one to gamma space
  83228. * @returns a new Color4 object
  83229. */
  83230. toGammaSpace(): Color4;
  83231. /**
  83232. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  83233. * @param convertedColor defines the Color4 object where to store the gamma space version
  83234. * @returns the unmodified Color4
  83235. */
  83236. toGammaSpaceToRef(convertedColor: Color4): Color4;
  83237. /**
  83238. * Creates a new Color4 from the string containing valid hexadecimal values
  83239. * @param hex defines a string containing valid hexadecimal values
  83240. * @returns a new Color4 object
  83241. */
  83242. static FromHexString(hex: string): Color4;
  83243. /**
  83244. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  83245. * @param left defines the start value
  83246. * @param right defines the end value
  83247. * @param amount defines the gradient factor
  83248. * @returns a new Color4 object
  83249. */
  83250. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  83251. /**
  83252. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  83253. * @param left defines the start value
  83254. * @param right defines the end value
  83255. * @param amount defines the gradient factor
  83256. * @param result defines the Color4 object where to store data
  83257. */
  83258. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  83259. /**
  83260. * Creates a new Color4 from a Color3 and an alpha value
  83261. * @param color3 defines the source Color3 to read from
  83262. * @param alpha defines the alpha component (1.0 by default)
  83263. * @returns a new Color4 object
  83264. */
  83265. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  83266. /**
  83267. * Creates a new Color4 from the starting index element of the given array
  83268. * @param array defines the source array to read from
  83269. * @param offset defines the offset in the source array
  83270. * @returns a new Color4 object
  83271. */
  83272. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  83273. /**
  83274. * Creates a new Color3 from integer values (< 256)
  83275. * @param r defines the red component to read from (value between 0 and 255)
  83276. * @param g defines the green component to read from (value between 0 and 255)
  83277. * @param b defines the blue component to read from (value between 0 and 255)
  83278. * @param a defines the alpha component to read from (value between 0 and 255)
  83279. * @returns a new Color3 object
  83280. */
  83281. static FromInts(r: number, g: number, b: number, a: number): Color4;
  83282. /**
  83283. * Check the content of a given array and convert it to an array containing RGBA data
  83284. * If the original array was already containing count * 4 values then it is returned directly
  83285. * @param colors defines the array to check
  83286. * @param count defines the number of RGBA data to expect
  83287. * @returns an array containing count * 4 values (RGBA)
  83288. */
  83289. static CheckColors4(colors: number[], count: number): number[];
  83290. }
  83291. /**
  83292. * @hidden
  83293. */
  83294. export class TmpColors {
  83295. static Color3: Color3[];
  83296. static Color4: Color4[];
  83297. }
  83298. }
  83299. declare module BABYLON {
  83300. /**
  83301. * Defines an interface which represents an animation key frame
  83302. */
  83303. export interface IAnimationKey {
  83304. /**
  83305. * Frame of the key frame
  83306. */
  83307. frame: number;
  83308. /**
  83309. * Value at the specifies key frame
  83310. */
  83311. value: any;
  83312. /**
  83313. * The input tangent for the cubic hermite spline
  83314. */
  83315. inTangent?: any;
  83316. /**
  83317. * The output tangent for the cubic hermite spline
  83318. */
  83319. outTangent?: any;
  83320. /**
  83321. * The animation interpolation type
  83322. */
  83323. interpolation?: AnimationKeyInterpolation;
  83324. }
  83325. /**
  83326. * Enum for the animation key frame interpolation type
  83327. */
  83328. export enum AnimationKeyInterpolation {
  83329. /**
  83330. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  83331. */
  83332. STEP = 1
  83333. }
  83334. }
  83335. declare module BABYLON {
  83336. /**
  83337. * Represents the range of an animation
  83338. */
  83339. export class AnimationRange {
  83340. /**The name of the animation range**/
  83341. name: string;
  83342. /**The starting frame of the animation */
  83343. from: number;
  83344. /**The ending frame of the animation*/
  83345. to: number;
  83346. /**
  83347. * Initializes the range of an animation
  83348. * @param name The name of the animation range
  83349. * @param from The starting frame of the animation
  83350. * @param to The ending frame of the animation
  83351. */
  83352. constructor(
  83353. /**The name of the animation range**/
  83354. name: string,
  83355. /**The starting frame of the animation */
  83356. from: number,
  83357. /**The ending frame of the animation*/
  83358. to: number);
  83359. /**
  83360. * Makes a copy of the animation range
  83361. * @returns A copy of the animation range
  83362. */
  83363. clone(): AnimationRange;
  83364. }
  83365. }
  83366. declare module BABYLON {
  83367. /**
  83368. * Composed of a frame, and an action function
  83369. */
  83370. export class AnimationEvent {
  83371. /** The frame for which the event is triggered **/
  83372. frame: number;
  83373. /** The event to perform when triggered **/
  83374. action: (currentFrame: number) => void;
  83375. /** Specifies if the event should be triggered only once**/
  83376. onlyOnce?: boolean | undefined;
  83377. /**
  83378. * Specifies if the animation event is done
  83379. */
  83380. isDone: boolean;
  83381. /**
  83382. * Initializes the animation event
  83383. * @param frame The frame for which the event is triggered
  83384. * @param action The event to perform when triggered
  83385. * @param onlyOnce Specifies if the event should be triggered only once
  83386. */
  83387. constructor(
  83388. /** The frame for which the event is triggered **/
  83389. frame: number,
  83390. /** The event to perform when triggered **/
  83391. action: (currentFrame: number) => void,
  83392. /** Specifies if the event should be triggered only once**/
  83393. onlyOnce?: boolean | undefined);
  83394. /** @hidden */
  83395. _clone(): AnimationEvent;
  83396. }
  83397. }
  83398. declare module BABYLON {
  83399. /**
  83400. * Interface used to define a behavior
  83401. */
  83402. export interface Behavior<T> {
  83403. /** gets or sets behavior's name */
  83404. name: string;
  83405. /**
  83406. * Function called when the behavior needs to be initialized (after attaching it to a target)
  83407. */
  83408. init(): void;
  83409. /**
  83410. * Called when the behavior is attached to a target
  83411. * @param target defines the target where the behavior is attached to
  83412. */
  83413. attach(target: T): void;
  83414. /**
  83415. * Called when the behavior is detached from its target
  83416. */
  83417. detach(): void;
  83418. }
  83419. /**
  83420. * Interface implemented by classes supporting behaviors
  83421. */
  83422. export interface IBehaviorAware<T> {
  83423. /**
  83424. * Attach a behavior
  83425. * @param behavior defines the behavior to attach
  83426. * @returns the current host
  83427. */
  83428. addBehavior(behavior: Behavior<T>): T;
  83429. /**
  83430. * Remove a behavior from the current object
  83431. * @param behavior defines the behavior to detach
  83432. * @returns the current host
  83433. */
  83434. removeBehavior(behavior: Behavior<T>): T;
  83435. /**
  83436. * Gets a behavior using its name to search
  83437. * @param name defines the name to search
  83438. * @returns the behavior or null if not found
  83439. */
  83440. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  83441. }
  83442. }
  83443. declare module BABYLON {
  83444. /**
  83445. * Defines an array and its length.
  83446. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  83447. */
  83448. export interface ISmartArrayLike<T> {
  83449. /**
  83450. * The data of the array.
  83451. */
  83452. data: Array<T>;
  83453. /**
  83454. * The active length of the array.
  83455. */
  83456. length: number;
  83457. }
  83458. /**
  83459. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83460. */
  83461. export class SmartArray<T> implements ISmartArrayLike<T> {
  83462. /**
  83463. * The full set of data from the array.
  83464. */
  83465. data: Array<T>;
  83466. /**
  83467. * The active length of the array.
  83468. */
  83469. length: number;
  83470. protected _id: number;
  83471. /**
  83472. * Instantiates a Smart Array.
  83473. * @param capacity defines the default capacity of the array.
  83474. */
  83475. constructor(capacity: number);
  83476. /**
  83477. * Pushes a value at the end of the active data.
  83478. * @param value defines the object to push in the array.
  83479. */
  83480. push(value: T): void;
  83481. /**
  83482. * Iterates over the active data and apply the lambda to them.
  83483. * @param func defines the action to apply on each value.
  83484. */
  83485. forEach(func: (content: T) => void): void;
  83486. /**
  83487. * Sorts the full sets of data.
  83488. * @param compareFn defines the comparison function to apply.
  83489. */
  83490. sort(compareFn: (a: T, b: T) => number): void;
  83491. /**
  83492. * Resets the active data to an empty array.
  83493. */
  83494. reset(): void;
  83495. /**
  83496. * Releases all the data from the array as well as the array.
  83497. */
  83498. dispose(): void;
  83499. /**
  83500. * Concats the active data with a given array.
  83501. * @param array defines the data to concatenate with.
  83502. */
  83503. concat(array: any): void;
  83504. /**
  83505. * Returns the position of a value in the active data.
  83506. * @param value defines the value to find the index for
  83507. * @returns the index if found in the active data otherwise -1
  83508. */
  83509. indexOf(value: T): number;
  83510. /**
  83511. * Returns whether an element is part of the active data.
  83512. * @param value defines the value to look for
  83513. * @returns true if found in the active data otherwise false
  83514. */
  83515. contains(value: T): boolean;
  83516. private static _GlobalId;
  83517. }
  83518. /**
  83519. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83520. * The data in this array can only be present once
  83521. */
  83522. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  83523. private _duplicateId;
  83524. /**
  83525. * Pushes a value at the end of the active data.
  83526. * THIS DOES NOT PREVENT DUPPLICATE DATA
  83527. * @param value defines the object to push in the array.
  83528. */
  83529. push(value: T): void;
  83530. /**
  83531. * Pushes a value at the end of the active data.
  83532. * If the data is already present, it won t be added again
  83533. * @param value defines the object to push in the array.
  83534. * @returns true if added false if it was already present
  83535. */
  83536. pushNoDuplicate(value: T): boolean;
  83537. /**
  83538. * Resets the active data to an empty array.
  83539. */
  83540. reset(): void;
  83541. /**
  83542. * Concats the active data with a given array.
  83543. * This ensures no dupplicate will be present in the result.
  83544. * @param array defines the data to concatenate with.
  83545. */
  83546. concatWithNoDuplicate(array: any): void;
  83547. }
  83548. }
  83549. declare module BABYLON {
  83550. /**
  83551. * @ignore
  83552. * This is a list of all the different input types that are available in the application.
  83553. * Fo instance: ArcRotateCameraGamepadInput...
  83554. */
  83555. export var CameraInputTypes: {};
  83556. /**
  83557. * This is the contract to implement in order to create a new input class.
  83558. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  83559. */
  83560. export interface ICameraInput<TCamera extends Camera> {
  83561. /**
  83562. * Defines the camera the input is attached to.
  83563. */
  83564. camera: Nullable<TCamera>;
  83565. /**
  83566. * Gets the class name of the current intput.
  83567. * @returns the class name
  83568. */
  83569. getClassName(): string;
  83570. /**
  83571. * Get the friendly name associated with the input class.
  83572. * @returns the input friendly name
  83573. */
  83574. getSimpleName(): string;
  83575. /**
  83576. * Attach the input controls to a specific dom element to get the input from.
  83577. * @param element Defines the element the controls should be listened from
  83578. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83579. */
  83580. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83581. /**
  83582. * Detach the current controls from the specified dom element.
  83583. * @param element Defines the element to stop listening the inputs from
  83584. */
  83585. detachControl(element: Nullable<HTMLElement>): void;
  83586. /**
  83587. * Update the current camera state depending on the inputs that have been used this frame.
  83588. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  83589. */
  83590. checkInputs?: () => void;
  83591. }
  83592. /**
  83593. * Represents a map of input types to input instance or input index to input instance.
  83594. */
  83595. export interface CameraInputsMap<TCamera extends Camera> {
  83596. /**
  83597. * Accessor to the input by input type.
  83598. */
  83599. [name: string]: ICameraInput<TCamera>;
  83600. /**
  83601. * Accessor to the input by input index.
  83602. */
  83603. [idx: number]: ICameraInput<TCamera>;
  83604. }
  83605. /**
  83606. * This represents the input manager used within a camera.
  83607. * It helps dealing with all the different kind of input attached to a camera.
  83608. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83609. */
  83610. export class CameraInputsManager<TCamera extends Camera> {
  83611. /**
  83612. * Defines the list of inputs attahed to the camera.
  83613. */
  83614. attached: CameraInputsMap<TCamera>;
  83615. /**
  83616. * Defines the dom element the camera is collecting inputs from.
  83617. * This is null if the controls have not been attached.
  83618. */
  83619. attachedElement: Nullable<HTMLElement>;
  83620. /**
  83621. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83622. */
  83623. noPreventDefault: boolean;
  83624. /**
  83625. * Defined the camera the input manager belongs to.
  83626. */
  83627. camera: TCamera;
  83628. /**
  83629. * Update the current camera state depending on the inputs that have been used this frame.
  83630. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  83631. */
  83632. checkInputs: () => void;
  83633. /**
  83634. * Instantiate a new Camera Input Manager.
  83635. * @param camera Defines the camera the input manager blongs to
  83636. */
  83637. constructor(camera: TCamera);
  83638. /**
  83639. * Add an input method to a camera
  83640. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83641. * @param input camera input method
  83642. */
  83643. add(input: ICameraInput<TCamera>): void;
  83644. /**
  83645. * Remove a specific input method from a camera
  83646. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  83647. * @param inputToRemove camera input method
  83648. */
  83649. remove(inputToRemove: ICameraInput<TCamera>): void;
  83650. /**
  83651. * Remove a specific input type from a camera
  83652. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  83653. * @param inputType the type of the input to remove
  83654. */
  83655. removeByType(inputType: string): void;
  83656. private _addCheckInputs;
  83657. /**
  83658. * Attach the input controls to the currently attached dom element to listen the events from.
  83659. * @param input Defines the input to attach
  83660. */
  83661. attachInput(input: ICameraInput<TCamera>): void;
  83662. /**
  83663. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  83664. * @param element Defines the dom element to collect the events from
  83665. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83666. */
  83667. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  83668. /**
  83669. * Detach the current manager inputs controls from a specific dom element.
  83670. * @param element Defines the dom element to collect the events from
  83671. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  83672. */
  83673. detachElement(element: HTMLElement, disconnect?: boolean): void;
  83674. /**
  83675. * Rebuild the dynamic inputCheck function from the current list of
  83676. * defined inputs in the manager.
  83677. */
  83678. rebuildInputCheck(): void;
  83679. /**
  83680. * Remove all attached input methods from a camera
  83681. */
  83682. clear(): void;
  83683. /**
  83684. * Serialize the current input manager attached to a camera.
  83685. * This ensures than once parsed,
  83686. * the input associated to the camera will be identical to the current ones
  83687. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  83688. */
  83689. serialize(serializedCamera: any): void;
  83690. /**
  83691. * Parses an input manager serialized JSON to restore the previous list of inputs
  83692. * and states associated to a camera.
  83693. * @param parsedCamera Defines the JSON to parse
  83694. */
  83695. parse(parsedCamera: any): void;
  83696. }
  83697. }
  83698. declare module BABYLON {
  83699. /**
  83700. * Class used to store data that will be store in GPU memory
  83701. */
  83702. export class Buffer {
  83703. private _engine;
  83704. private _buffer;
  83705. /** @hidden */
  83706. _data: Nullable<DataArray>;
  83707. private _updatable;
  83708. private _instanced;
  83709. private _divisor;
  83710. /**
  83711. * Gets the byte stride.
  83712. */
  83713. readonly byteStride: number;
  83714. /**
  83715. * Constructor
  83716. * @param engine the engine
  83717. * @param data the data to use for this buffer
  83718. * @param updatable whether the data is updatable
  83719. * @param stride the stride (optional)
  83720. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  83721. * @param instanced whether the buffer is instanced (optional)
  83722. * @param useBytes set to true if the stride in in bytes (optional)
  83723. * @param divisor sets an optional divisor for instances (1 by default)
  83724. */
  83725. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  83726. /**
  83727. * Create a new VertexBuffer based on the current buffer
  83728. * @param kind defines the vertex buffer kind (position, normal, etc.)
  83729. * @param offset defines offset in the buffer (0 by default)
  83730. * @param size defines the size in floats of attributes (position is 3 for instance)
  83731. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  83732. * @param instanced defines if the vertex buffer contains indexed data
  83733. * @param useBytes defines if the offset and stride are in bytes *
  83734. * @param divisor sets an optional divisor for instances (1 by default)
  83735. * @returns the new vertex buffer
  83736. */
  83737. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  83738. /**
  83739. * Gets a boolean indicating if the Buffer is updatable?
  83740. * @returns true if the buffer is updatable
  83741. */
  83742. isUpdatable(): boolean;
  83743. /**
  83744. * Gets current buffer's data
  83745. * @returns a DataArray or null
  83746. */
  83747. getData(): Nullable<DataArray>;
  83748. /**
  83749. * Gets underlying native buffer
  83750. * @returns underlying native buffer
  83751. */
  83752. getBuffer(): Nullable<DataBuffer>;
  83753. /**
  83754. * Gets the stride in float32 units (i.e. byte stride / 4).
  83755. * May not be an integer if the byte stride is not divisible by 4.
  83756. * @returns the stride in float32 units
  83757. * @deprecated Please use byteStride instead.
  83758. */
  83759. getStrideSize(): number;
  83760. /**
  83761. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  83762. * @param data defines the data to store
  83763. */
  83764. create(data?: Nullable<DataArray>): void;
  83765. /** @hidden */
  83766. _rebuild(): void;
  83767. /**
  83768. * Update current buffer data
  83769. * @param data defines the data to store
  83770. */
  83771. update(data: DataArray): void;
  83772. /**
  83773. * Updates the data directly.
  83774. * @param data the new data
  83775. * @param offset the new offset
  83776. * @param vertexCount the vertex count (optional)
  83777. * @param useBytes set to true if the offset is in bytes
  83778. */
  83779. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  83780. /**
  83781. * Release all resources
  83782. */
  83783. dispose(): void;
  83784. }
  83785. /**
  83786. * Specialized buffer used to store vertex data
  83787. */
  83788. export class VertexBuffer {
  83789. /** @hidden */
  83790. _buffer: Buffer;
  83791. private _kind;
  83792. private _size;
  83793. private _ownsBuffer;
  83794. private _instanced;
  83795. private _instanceDivisor;
  83796. /**
  83797. * The byte type.
  83798. */
  83799. static readonly BYTE: number;
  83800. /**
  83801. * The unsigned byte type.
  83802. */
  83803. static readonly UNSIGNED_BYTE: number;
  83804. /**
  83805. * The short type.
  83806. */
  83807. static readonly SHORT: number;
  83808. /**
  83809. * The unsigned short type.
  83810. */
  83811. static readonly UNSIGNED_SHORT: number;
  83812. /**
  83813. * The integer type.
  83814. */
  83815. static readonly INT: number;
  83816. /**
  83817. * The unsigned integer type.
  83818. */
  83819. static readonly UNSIGNED_INT: number;
  83820. /**
  83821. * The float type.
  83822. */
  83823. static readonly FLOAT: number;
  83824. /**
  83825. * Gets or sets the instance divisor when in instanced mode
  83826. */
  83827. get instanceDivisor(): number;
  83828. set instanceDivisor(value: number);
  83829. /**
  83830. * Gets the byte stride.
  83831. */
  83832. readonly byteStride: number;
  83833. /**
  83834. * Gets the byte offset.
  83835. */
  83836. readonly byteOffset: number;
  83837. /**
  83838. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  83839. */
  83840. readonly normalized: boolean;
  83841. /**
  83842. * Gets the data type of each component in the array.
  83843. */
  83844. readonly type: number;
  83845. /**
  83846. * Constructor
  83847. * @param engine the engine
  83848. * @param data the data to use for this vertex buffer
  83849. * @param kind the vertex buffer kind
  83850. * @param updatable whether the data is updatable
  83851. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  83852. * @param stride the stride (optional)
  83853. * @param instanced whether the buffer is instanced (optional)
  83854. * @param offset the offset of the data (optional)
  83855. * @param size the number of components (optional)
  83856. * @param type the type of the component (optional)
  83857. * @param normalized whether the data contains normalized data (optional)
  83858. * @param useBytes set to true if stride and offset are in bytes (optional)
  83859. * @param divisor defines the instance divisor to use (1 by default)
  83860. */
  83861. 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);
  83862. /** @hidden */
  83863. _rebuild(): void;
  83864. /**
  83865. * Returns the kind of the VertexBuffer (string)
  83866. * @returns a string
  83867. */
  83868. getKind(): string;
  83869. /**
  83870. * Gets a boolean indicating if the VertexBuffer is updatable?
  83871. * @returns true if the buffer is updatable
  83872. */
  83873. isUpdatable(): boolean;
  83874. /**
  83875. * Gets current buffer's data
  83876. * @returns a DataArray or null
  83877. */
  83878. getData(): Nullable<DataArray>;
  83879. /**
  83880. * Gets underlying native buffer
  83881. * @returns underlying native buffer
  83882. */
  83883. getBuffer(): Nullable<DataBuffer>;
  83884. /**
  83885. * Gets the stride in float32 units (i.e. byte stride / 4).
  83886. * May not be an integer if the byte stride is not divisible by 4.
  83887. * @returns the stride in float32 units
  83888. * @deprecated Please use byteStride instead.
  83889. */
  83890. getStrideSize(): number;
  83891. /**
  83892. * Returns the offset as a multiple of the type byte length.
  83893. * @returns the offset in bytes
  83894. * @deprecated Please use byteOffset instead.
  83895. */
  83896. getOffset(): number;
  83897. /**
  83898. * Returns the number of components per vertex attribute (integer)
  83899. * @returns the size in float
  83900. */
  83901. getSize(): number;
  83902. /**
  83903. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  83904. * @returns true if this buffer is instanced
  83905. */
  83906. getIsInstanced(): boolean;
  83907. /**
  83908. * Returns the instancing divisor, zero for non-instanced (integer).
  83909. * @returns a number
  83910. */
  83911. getInstanceDivisor(): number;
  83912. /**
  83913. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  83914. * @param data defines the data to store
  83915. */
  83916. create(data?: DataArray): void;
  83917. /**
  83918. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  83919. * This function will create a new buffer if the current one is not updatable
  83920. * @param data defines the data to store
  83921. */
  83922. update(data: DataArray): void;
  83923. /**
  83924. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  83925. * Returns the directly updated WebGLBuffer.
  83926. * @param data the new data
  83927. * @param offset the new offset
  83928. * @param useBytes set to true if the offset is in bytes
  83929. */
  83930. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  83931. /**
  83932. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  83933. */
  83934. dispose(): void;
  83935. /**
  83936. * Enumerates each value of this vertex buffer as numbers.
  83937. * @param count the number of values to enumerate
  83938. * @param callback the callback function called for each value
  83939. */
  83940. forEach(count: number, callback: (value: number, index: number) => void): void;
  83941. /**
  83942. * Positions
  83943. */
  83944. static readonly PositionKind: string;
  83945. /**
  83946. * Normals
  83947. */
  83948. static readonly NormalKind: string;
  83949. /**
  83950. * Tangents
  83951. */
  83952. static readonly TangentKind: string;
  83953. /**
  83954. * Texture coordinates
  83955. */
  83956. static readonly UVKind: string;
  83957. /**
  83958. * Texture coordinates 2
  83959. */
  83960. static readonly UV2Kind: string;
  83961. /**
  83962. * Texture coordinates 3
  83963. */
  83964. static readonly UV3Kind: string;
  83965. /**
  83966. * Texture coordinates 4
  83967. */
  83968. static readonly UV4Kind: string;
  83969. /**
  83970. * Texture coordinates 5
  83971. */
  83972. static readonly UV5Kind: string;
  83973. /**
  83974. * Texture coordinates 6
  83975. */
  83976. static readonly UV6Kind: string;
  83977. /**
  83978. * Colors
  83979. */
  83980. static readonly ColorKind: string;
  83981. /**
  83982. * Matrix indices (for bones)
  83983. */
  83984. static readonly MatricesIndicesKind: string;
  83985. /**
  83986. * Matrix weights (for bones)
  83987. */
  83988. static readonly MatricesWeightsKind: string;
  83989. /**
  83990. * Additional matrix indices (for bones)
  83991. */
  83992. static readonly MatricesIndicesExtraKind: string;
  83993. /**
  83994. * Additional matrix weights (for bones)
  83995. */
  83996. static readonly MatricesWeightsExtraKind: string;
  83997. /**
  83998. * Deduces the stride given a kind.
  83999. * @param kind The kind string to deduce
  84000. * @returns The deduced stride
  84001. */
  84002. static DeduceStride(kind: string): number;
  84003. /**
  84004. * Gets the byte length of the given type.
  84005. * @param type the type
  84006. * @returns the number of bytes
  84007. */
  84008. static GetTypeByteLength(type: number): number;
  84009. /**
  84010. * Enumerates each value of the given parameters as numbers.
  84011. * @param data the data to enumerate
  84012. * @param byteOffset the byte offset of the data
  84013. * @param byteStride the byte stride of the data
  84014. * @param componentCount the number of components per element
  84015. * @param componentType the type of the component
  84016. * @param count the number of values to enumerate
  84017. * @param normalized whether the data is normalized
  84018. * @param callback the callback function called for each value
  84019. */
  84020. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  84021. private static _GetFloatValue;
  84022. }
  84023. }
  84024. declare module BABYLON {
  84025. /**
  84026. * @hidden
  84027. */
  84028. export class IntersectionInfo {
  84029. bu: Nullable<number>;
  84030. bv: Nullable<number>;
  84031. distance: number;
  84032. faceId: number;
  84033. subMeshId: number;
  84034. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  84035. }
  84036. }
  84037. declare module BABYLON {
  84038. /**
  84039. * Class used to store bounding sphere information
  84040. */
  84041. export class BoundingSphere {
  84042. /**
  84043. * Gets the center of the bounding sphere in local space
  84044. */
  84045. readonly center: Vector3;
  84046. /**
  84047. * Radius of the bounding sphere in local space
  84048. */
  84049. radius: number;
  84050. /**
  84051. * Gets the center of the bounding sphere in world space
  84052. */
  84053. readonly centerWorld: Vector3;
  84054. /**
  84055. * Radius of the bounding sphere in world space
  84056. */
  84057. radiusWorld: number;
  84058. /**
  84059. * Gets the minimum vector in local space
  84060. */
  84061. readonly minimum: Vector3;
  84062. /**
  84063. * Gets the maximum vector in local space
  84064. */
  84065. readonly maximum: Vector3;
  84066. private _worldMatrix;
  84067. private static readonly TmpVector3;
  84068. /**
  84069. * Creates a new bounding sphere
  84070. * @param min defines the minimum vector (in local space)
  84071. * @param max defines the maximum vector (in local space)
  84072. * @param worldMatrix defines the new world matrix
  84073. */
  84074. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84075. /**
  84076. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  84077. * @param min defines the new minimum vector (in local space)
  84078. * @param max defines the new maximum vector (in local space)
  84079. * @param worldMatrix defines the new world matrix
  84080. */
  84081. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84082. /**
  84083. * Scale the current bounding sphere by applying a scale factor
  84084. * @param factor defines the scale factor to apply
  84085. * @returns the current bounding box
  84086. */
  84087. scale(factor: number): BoundingSphere;
  84088. /**
  84089. * Gets the world matrix of the bounding box
  84090. * @returns a matrix
  84091. */
  84092. getWorldMatrix(): DeepImmutable<Matrix>;
  84093. /** @hidden */
  84094. _update(worldMatrix: DeepImmutable<Matrix>): void;
  84095. /**
  84096. * Tests if the bounding sphere is intersecting the frustum planes
  84097. * @param frustumPlanes defines the frustum planes to test
  84098. * @returns true if there is an intersection
  84099. */
  84100. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84101. /**
  84102. * Tests if the bounding sphere center is in between the frustum planes.
  84103. * Used for optimistic fast inclusion.
  84104. * @param frustumPlanes defines the frustum planes to test
  84105. * @returns true if the sphere center is in between the frustum planes
  84106. */
  84107. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84108. /**
  84109. * Tests if a point is inside the bounding sphere
  84110. * @param point defines the point to test
  84111. * @returns true if the point is inside the bounding sphere
  84112. */
  84113. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84114. /**
  84115. * Checks if two sphere intersct
  84116. * @param sphere0 sphere 0
  84117. * @param sphere1 sphere 1
  84118. * @returns true if the speres intersect
  84119. */
  84120. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  84121. }
  84122. }
  84123. declare module BABYLON {
  84124. /**
  84125. * Class used to store bounding box information
  84126. */
  84127. export class BoundingBox implements ICullable {
  84128. /**
  84129. * Gets the 8 vectors representing the bounding box in local space
  84130. */
  84131. readonly vectors: Vector3[];
  84132. /**
  84133. * Gets the center of the bounding box in local space
  84134. */
  84135. readonly center: Vector3;
  84136. /**
  84137. * Gets the center of the bounding box in world space
  84138. */
  84139. readonly centerWorld: Vector3;
  84140. /**
  84141. * Gets the extend size in local space
  84142. */
  84143. readonly extendSize: Vector3;
  84144. /**
  84145. * Gets the extend size in world space
  84146. */
  84147. readonly extendSizeWorld: Vector3;
  84148. /**
  84149. * Gets the OBB (object bounding box) directions
  84150. */
  84151. readonly directions: Vector3[];
  84152. /**
  84153. * Gets the 8 vectors representing the bounding box in world space
  84154. */
  84155. readonly vectorsWorld: Vector3[];
  84156. /**
  84157. * Gets the minimum vector in world space
  84158. */
  84159. readonly minimumWorld: Vector3;
  84160. /**
  84161. * Gets the maximum vector in world space
  84162. */
  84163. readonly maximumWorld: Vector3;
  84164. /**
  84165. * Gets the minimum vector in local space
  84166. */
  84167. readonly minimum: Vector3;
  84168. /**
  84169. * Gets the maximum vector in local space
  84170. */
  84171. readonly maximum: Vector3;
  84172. private _worldMatrix;
  84173. private static readonly TmpVector3;
  84174. /**
  84175. * @hidden
  84176. */
  84177. _tag: number;
  84178. /**
  84179. * Creates a new bounding box
  84180. * @param min defines the minimum vector (in local space)
  84181. * @param max defines the maximum vector (in local space)
  84182. * @param worldMatrix defines the new world matrix
  84183. */
  84184. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84185. /**
  84186. * Recreates the entire bounding box from scratch as if we call the constructor in place
  84187. * @param min defines the new minimum vector (in local space)
  84188. * @param max defines the new maximum vector (in local space)
  84189. * @param worldMatrix defines the new world matrix
  84190. */
  84191. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84192. /**
  84193. * Scale the current bounding box by applying a scale factor
  84194. * @param factor defines the scale factor to apply
  84195. * @returns the current bounding box
  84196. */
  84197. scale(factor: number): BoundingBox;
  84198. /**
  84199. * Gets the world matrix of the bounding box
  84200. * @returns a matrix
  84201. */
  84202. getWorldMatrix(): DeepImmutable<Matrix>;
  84203. /** @hidden */
  84204. _update(world: DeepImmutable<Matrix>): void;
  84205. /**
  84206. * Tests if the bounding box is intersecting the frustum planes
  84207. * @param frustumPlanes defines the frustum planes to test
  84208. * @returns true if there is an intersection
  84209. */
  84210. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84211. /**
  84212. * Tests if the bounding box is entirely inside the frustum planes
  84213. * @param frustumPlanes defines the frustum planes to test
  84214. * @returns true if there is an inclusion
  84215. */
  84216. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84217. /**
  84218. * Tests if a point is inside the bounding box
  84219. * @param point defines the point to test
  84220. * @returns true if the point is inside the bounding box
  84221. */
  84222. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84223. /**
  84224. * Tests if the bounding box intersects with a bounding sphere
  84225. * @param sphere defines the sphere to test
  84226. * @returns true if there is an intersection
  84227. */
  84228. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  84229. /**
  84230. * Tests if the bounding box intersects with a box defined by a min and max vectors
  84231. * @param min defines the min vector to use
  84232. * @param max defines the max vector to use
  84233. * @returns true if there is an intersection
  84234. */
  84235. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  84236. /**
  84237. * Tests if two bounding boxes are intersections
  84238. * @param box0 defines the first box to test
  84239. * @param box1 defines the second box to test
  84240. * @returns true if there is an intersection
  84241. */
  84242. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  84243. /**
  84244. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  84245. * @param minPoint defines the minimum vector of the bounding box
  84246. * @param maxPoint defines the maximum vector of the bounding box
  84247. * @param sphereCenter defines the sphere center
  84248. * @param sphereRadius defines the sphere radius
  84249. * @returns true if there is an intersection
  84250. */
  84251. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  84252. /**
  84253. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  84254. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  84255. * @param frustumPlanes defines the frustum planes to test
  84256. * @return true if there is an inclusion
  84257. */
  84258. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84259. /**
  84260. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  84261. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  84262. * @param frustumPlanes defines the frustum planes to test
  84263. * @return true if there is an intersection
  84264. */
  84265. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84266. }
  84267. }
  84268. declare module BABYLON {
  84269. /** @hidden */
  84270. export class Collider {
  84271. /** Define if a collision was found */
  84272. collisionFound: boolean;
  84273. /**
  84274. * Define last intersection point in local space
  84275. */
  84276. intersectionPoint: Vector3;
  84277. /**
  84278. * Define last collided mesh
  84279. */
  84280. collidedMesh: Nullable<AbstractMesh>;
  84281. private _collisionPoint;
  84282. private _planeIntersectionPoint;
  84283. private _tempVector;
  84284. private _tempVector2;
  84285. private _tempVector3;
  84286. private _tempVector4;
  84287. private _edge;
  84288. private _baseToVertex;
  84289. private _destinationPoint;
  84290. private _slidePlaneNormal;
  84291. private _displacementVector;
  84292. /** @hidden */
  84293. _radius: Vector3;
  84294. /** @hidden */
  84295. _retry: number;
  84296. private _velocity;
  84297. private _basePoint;
  84298. private _epsilon;
  84299. /** @hidden */
  84300. _velocityWorldLength: number;
  84301. /** @hidden */
  84302. _basePointWorld: Vector3;
  84303. private _velocityWorld;
  84304. private _normalizedVelocity;
  84305. /** @hidden */
  84306. _initialVelocity: Vector3;
  84307. /** @hidden */
  84308. _initialPosition: Vector3;
  84309. private _nearestDistance;
  84310. private _collisionMask;
  84311. get collisionMask(): number;
  84312. set collisionMask(mask: number);
  84313. /**
  84314. * Gets the plane normal used to compute the sliding response (in local space)
  84315. */
  84316. get slidePlaneNormal(): Vector3;
  84317. /** @hidden */
  84318. _initialize(source: Vector3, dir: Vector3, e: number): void;
  84319. /** @hidden */
  84320. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  84321. /** @hidden */
  84322. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  84323. /** @hidden */
  84324. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  84325. /** @hidden */
  84326. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  84327. /** @hidden */
  84328. _getResponse(pos: Vector3, vel: Vector3): void;
  84329. }
  84330. }
  84331. declare module BABYLON {
  84332. /**
  84333. * Interface for cullable objects
  84334. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  84335. */
  84336. export interface ICullable {
  84337. /**
  84338. * Checks if the object or part of the object is in the frustum
  84339. * @param frustumPlanes Camera near/planes
  84340. * @returns true if the object is in frustum otherwise false
  84341. */
  84342. isInFrustum(frustumPlanes: Plane[]): boolean;
  84343. /**
  84344. * Checks if a cullable object (mesh...) is in the camera frustum
  84345. * Unlike isInFrustum this cheks the full bounding box
  84346. * @param frustumPlanes Camera near/planes
  84347. * @returns true if the object is in frustum otherwise false
  84348. */
  84349. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84350. }
  84351. /**
  84352. * Info for a bounding data of a mesh
  84353. */
  84354. export class BoundingInfo implements ICullable {
  84355. /**
  84356. * Bounding box for the mesh
  84357. */
  84358. readonly boundingBox: BoundingBox;
  84359. /**
  84360. * Bounding sphere for the mesh
  84361. */
  84362. readonly boundingSphere: BoundingSphere;
  84363. private _isLocked;
  84364. private static readonly TmpVector3;
  84365. /**
  84366. * Constructs bounding info
  84367. * @param minimum min vector of the bounding box/sphere
  84368. * @param maximum max vector of the bounding box/sphere
  84369. * @param worldMatrix defines the new world matrix
  84370. */
  84371. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84372. /**
  84373. * Recreates the entire bounding info from scratch as if we call the constructor in place
  84374. * @param min defines the new minimum vector (in local space)
  84375. * @param max defines the new maximum vector (in local space)
  84376. * @param worldMatrix defines the new world matrix
  84377. */
  84378. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84379. /**
  84380. * min vector of the bounding box/sphere
  84381. */
  84382. get minimum(): Vector3;
  84383. /**
  84384. * max vector of the bounding box/sphere
  84385. */
  84386. get maximum(): Vector3;
  84387. /**
  84388. * If the info is locked and won't be updated to avoid perf overhead
  84389. */
  84390. get isLocked(): boolean;
  84391. set isLocked(value: boolean);
  84392. /**
  84393. * Updates the bounding sphere and box
  84394. * @param world world matrix to be used to update
  84395. */
  84396. update(world: DeepImmutable<Matrix>): void;
  84397. /**
  84398. * Recreate the bounding info to be centered around a specific point given a specific extend.
  84399. * @param center New center of the bounding info
  84400. * @param extend New extend of the bounding info
  84401. * @returns the current bounding info
  84402. */
  84403. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  84404. /**
  84405. * Scale the current bounding info by applying a scale factor
  84406. * @param factor defines the scale factor to apply
  84407. * @returns the current bounding info
  84408. */
  84409. scale(factor: number): BoundingInfo;
  84410. /**
  84411. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  84412. * @param frustumPlanes defines the frustum to test
  84413. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  84414. * @returns true if the bounding info is in the frustum planes
  84415. */
  84416. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  84417. /**
  84418. * Gets the world distance between the min and max points of the bounding box
  84419. */
  84420. get diagonalLength(): number;
  84421. /**
  84422. * Checks if a cullable object (mesh...) is in the camera frustum
  84423. * Unlike isInFrustum this cheks the full bounding box
  84424. * @param frustumPlanes Camera near/planes
  84425. * @returns true if the object is in frustum otherwise false
  84426. */
  84427. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84428. /** @hidden */
  84429. _checkCollision(collider: Collider): boolean;
  84430. /**
  84431. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  84432. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84433. * @param point the point to check intersection with
  84434. * @returns if the point intersects
  84435. */
  84436. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84437. /**
  84438. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  84439. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84440. * @param boundingInfo the bounding info to check intersection with
  84441. * @param precise if the intersection should be done using OBB
  84442. * @returns if the bounding info intersects
  84443. */
  84444. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  84445. }
  84446. }
  84447. declare module BABYLON {
  84448. /**
  84449. * Extracts minimum and maximum values from a list of indexed positions
  84450. * @param positions defines the positions to use
  84451. * @param indices defines the indices to the positions
  84452. * @param indexStart defines the start index
  84453. * @param indexCount defines the end index
  84454. * @param bias defines bias value to add to the result
  84455. * @return minimum and maximum values
  84456. */
  84457. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  84458. minimum: Vector3;
  84459. maximum: Vector3;
  84460. };
  84461. /**
  84462. * Extracts minimum and maximum values from a list of positions
  84463. * @param positions defines the positions to use
  84464. * @param start defines the start index in the positions array
  84465. * @param count defines the number of positions to handle
  84466. * @param bias defines bias value to add to the result
  84467. * @param stride defines the stride size to use (distance between two positions in the positions array)
  84468. * @return minimum and maximum values
  84469. */
  84470. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  84471. minimum: Vector3;
  84472. maximum: Vector3;
  84473. };
  84474. }
  84475. declare module BABYLON {
  84476. /** @hidden */
  84477. export class WebGLDataBuffer extends DataBuffer {
  84478. private _buffer;
  84479. constructor(resource: WebGLBuffer);
  84480. get underlyingResource(): any;
  84481. }
  84482. }
  84483. declare module BABYLON {
  84484. /** @hidden */
  84485. export class WebGLPipelineContext implements IPipelineContext {
  84486. engine: ThinEngine;
  84487. program: Nullable<WebGLProgram>;
  84488. context?: WebGLRenderingContext;
  84489. vertexShader?: WebGLShader;
  84490. fragmentShader?: WebGLShader;
  84491. isParallelCompiled: boolean;
  84492. onCompiled?: () => void;
  84493. transformFeedback?: WebGLTransformFeedback | null;
  84494. vertexCompilationError: Nullable<string>;
  84495. fragmentCompilationError: Nullable<string>;
  84496. programLinkError: Nullable<string>;
  84497. programValidationError: Nullable<string>;
  84498. get isAsync(): boolean;
  84499. get isReady(): boolean;
  84500. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  84501. _getVertexShaderCode(): string | null;
  84502. _getFragmentShaderCode(): string | null;
  84503. }
  84504. }
  84505. declare module BABYLON {
  84506. interface ThinEngine {
  84507. /**
  84508. * Create an uniform buffer
  84509. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84510. * @param elements defines the content of the uniform buffer
  84511. * @returns the webGL uniform buffer
  84512. */
  84513. createUniformBuffer(elements: FloatArray): DataBuffer;
  84514. /**
  84515. * Create a dynamic uniform buffer
  84516. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84517. * @param elements defines the content of the uniform buffer
  84518. * @returns the webGL uniform buffer
  84519. */
  84520. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  84521. /**
  84522. * Update an existing uniform buffer
  84523. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84524. * @param uniformBuffer defines the target uniform buffer
  84525. * @param elements defines the content to update
  84526. * @param offset defines the offset in the uniform buffer where update should start
  84527. * @param count defines the size of the data to update
  84528. */
  84529. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  84530. /**
  84531. * Bind an uniform buffer to the current webGL context
  84532. * @param buffer defines the buffer to bind
  84533. */
  84534. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  84535. /**
  84536. * Bind a buffer to the current webGL context at a given location
  84537. * @param buffer defines the buffer to bind
  84538. * @param location defines the index where to bind the buffer
  84539. */
  84540. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  84541. /**
  84542. * Bind a specific block at a given index in a specific shader program
  84543. * @param pipelineContext defines the pipeline context to use
  84544. * @param blockName defines the block name
  84545. * @param index defines the index where to bind the block
  84546. */
  84547. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  84548. }
  84549. }
  84550. declare module BABYLON {
  84551. /**
  84552. * Uniform buffer objects.
  84553. *
  84554. * Handles blocks of uniform on the GPU.
  84555. *
  84556. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84557. *
  84558. * For more information, please refer to :
  84559. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84560. */
  84561. export class UniformBuffer {
  84562. private _engine;
  84563. private _buffer;
  84564. private _data;
  84565. private _bufferData;
  84566. private _dynamic?;
  84567. private _uniformLocations;
  84568. private _uniformSizes;
  84569. private _uniformLocationPointer;
  84570. private _needSync;
  84571. private _noUBO;
  84572. private _currentEffect;
  84573. /** @hidden */
  84574. _alreadyBound: boolean;
  84575. private static _MAX_UNIFORM_SIZE;
  84576. private static _tempBuffer;
  84577. /**
  84578. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  84579. * This is dynamic to allow compat with webgl 1 and 2.
  84580. * You will need to pass the name of the uniform as well as the value.
  84581. */
  84582. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  84583. /**
  84584. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  84585. * This is dynamic to allow compat with webgl 1 and 2.
  84586. * You will need to pass the name of the uniform as well as the value.
  84587. */
  84588. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  84589. /**
  84590. * Lambda to Update a single float in a uniform buffer.
  84591. * This is dynamic to allow compat with webgl 1 and 2.
  84592. * You will need to pass the name of the uniform as well as the value.
  84593. */
  84594. updateFloat: (name: string, x: number) => void;
  84595. /**
  84596. * Lambda to Update a vec2 of float in a uniform buffer.
  84597. * This is dynamic to allow compat with webgl 1 and 2.
  84598. * You will need to pass the name of the uniform as well as the value.
  84599. */
  84600. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  84601. /**
  84602. * Lambda to Update a vec3 of float in a uniform buffer.
  84603. * This is dynamic to allow compat with webgl 1 and 2.
  84604. * You will need to pass the name of the uniform as well as the value.
  84605. */
  84606. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  84607. /**
  84608. * Lambda to Update a vec4 of float in a uniform buffer.
  84609. * This is dynamic to allow compat with webgl 1 and 2.
  84610. * You will need to pass the name of the uniform as well as the value.
  84611. */
  84612. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  84613. /**
  84614. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  84615. * This is dynamic to allow compat with webgl 1 and 2.
  84616. * You will need to pass the name of the uniform as well as the value.
  84617. */
  84618. updateMatrix: (name: string, mat: Matrix) => void;
  84619. /**
  84620. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  84621. * This is dynamic to allow compat with webgl 1 and 2.
  84622. * You will need to pass the name of the uniform as well as the value.
  84623. */
  84624. updateVector3: (name: string, vector: Vector3) => void;
  84625. /**
  84626. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  84627. * This is dynamic to allow compat with webgl 1 and 2.
  84628. * You will need to pass the name of the uniform as well as the value.
  84629. */
  84630. updateVector4: (name: string, vector: Vector4) => void;
  84631. /**
  84632. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  84633. * This is dynamic to allow compat with webgl 1 and 2.
  84634. * You will need to pass the name of the uniform as well as the value.
  84635. */
  84636. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  84637. /**
  84638. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  84639. * This is dynamic to allow compat with webgl 1 and 2.
  84640. * You will need to pass the name of the uniform as well as the value.
  84641. */
  84642. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  84643. /**
  84644. * Instantiates a new Uniform buffer objects.
  84645. *
  84646. * Handles blocks of uniform on the GPU.
  84647. *
  84648. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84649. *
  84650. * For more information, please refer to :
  84651. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84652. * @param engine Define the engine the buffer is associated with
  84653. * @param data Define the data contained in the buffer
  84654. * @param dynamic Define if the buffer is updatable
  84655. */
  84656. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  84657. /**
  84658. * Indicates if the buffer is using the WebGL2 UBO implementation,
  84659. * or just falling back on setUniformXXX calls.
  84660. */
  84661. get useUbo(): boolean;
  84662. /**
  84663. * Indicates if the WebGL underlying uniform buffer is in sync
  84664. * with the javascript cache data.
  84665. */
  84666. get isSync(): boolean;
  84667. /**
  84668. * Indicates if the WebGL underlying uniform buffer is dynamic.
  84669. * Also, a dynamic UniformBuffer will disable cache verification and always
  84670. * update the underlying WebGL uniform buffer to the GPU.
  84671. * @returns if Dynamic, otherwise false
  84672. */
  84673. isDynamic(): boolean;
  84674. /**
  84675. * The data cache on JS side.
  84676. * @returns the underlying data as a float array
  84677. */
  84678. getData(): Float32Array;
  84679. /**
  84680. * The underlying WebGL Uniform buffer.
  84681. * @returns the webgl buffer
  84682. */
  84683. getBuffer(): Nullable<DataBuffer>;
  84684. /**
  84685. * std140 layout specifies how to align data within an UBO structure.
  84686. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  84687. * for specs.
  84688. */
  84689. private _fillAlignment;
  84690. /**
  84691. * Adds an uniform in the buffer.
  84692. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  84693. * for the layout to be correct !
  84694. * @param name Name of the uniform, as used in the uniform block in the shader.
  84695. * @param size Data size, or data directly.
  84696. */
  84697. addUniform(name: string, size: number | number[]): void;
  84698. /**
  84699. * Adds a Matrix 4x4 to the uniform buffer.
  84700. * @param name Name of the uniform, as used in the uniform block in the shader.
  84701. * @param mat A 4x4 matrix.
  84702. */
  84703. addMatrix(name: string, mat: Matrix): void;
  84704. /**
  84705. * Adds a vec2 to the uniform buffer.
  84706. * @param name Name of the uniform, as used in the uniform block in the shader.
  84707. * @param x Define the x component value of the vec2
  84708. * @param y Define the y component value of the vec2
  84709. */
  84710. addFloat2(name: string, x: number, y: number): void;
  84711. /**
  84712. * Adds a vec3 to the uniform buffer.
  84713. * @param name Name of the uniform, as used in the uniform block in the shader.
  84714. * @param x Define the x component value of the vec3
  84715. * @param y Define the y component value of the vec3
  84716. * @param z Define the z component value of the vec3
  84717. */
  84718. addFloat3(name: string, x: number, y: number, z: number): void;
  84719. /**
  84720. * Adds a vec3 to the uniform buffer.
  84721. * @param name Name of the uniform, as used in the uniform block in the shader.
  84722. * @param color Define the vec3 from a Color
  84723. */
  84724. addColor3(name: string, color: Color3): void;
  84725. /**
  84726. * Adds a vec4 to the uniform buffer.
  84727. * @param name Name of the uniform, as used in the uniform block in the shader.
  84728. * @param color Define the rgb components from a Color
  84729. * @param alpha Define the a component of the vec4
  84730. */
  84731. addColor4(name: string, color: Color3, alpha: number): void;
  84732. /**
  84733. * Adds a vec3 to the uniform buffer.
  84734. * @param name Name of the uniform, as used in the uniform block in the shader.
  84735. * @param vector Define the vec3 components from a Vector
  84736. */
  84737. addVector3(name: string, vector: Vector3): void;
  84738. /**
  84739. * Adds a Matrix 3x3 to the uniform buffer.
  84740. * @param name Name of the uniform, as used in the uniform block in the shader.
  84741. */
  84742. addMatrix3x3(name: string): void;
  84743. /**
  84744. * Adds a Matrix 2x2 to the uniform buffer.
  84745. * @param name Name of the uniform, as used in the uniform block in the shader.
  84746. */
  84747. addMatrix2x2(name: string): void;
  84748. /**
  84749. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  84750. */
  84751. create(): void;
  84752. /** @hidden */
  84753. _rebuild(): void;
  84754. /**
  84755. * Updates the WebGL Uniform Buffer on the GPU.
  84756. * If the `dynamic` flag is set to true, no cache comparison is done.
  84757. * Otherwise, the buffer will be updated only if the cache differs.
  84758. */
  84759. update(): void;
  84760. /**
  84761. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  84762. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84763. * @param data Define the flattened data
  84764. * @param size Define the size of the data.
  84765. */
  84766. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  84767. private _valueCache;
  84768. private _cacheMatrix;
  84769. private _updateMatrix3x3ForUniform;
  84770. private _updateMatrix3x3ForEffect;
  84771. private _updateMatrix2x2ForEffect;
  84772. private _updateMatrix2x2ForUniform;
  84773. private _updateFloatForEffect;
  84774. private _updateFloatForUniform;
  84775. private _updateFloat2ForEffect;
  84776. private _updateFloat2ForUniform;
  84777. private _updateFloat3ForEffect;
  84778. private _updateFloat3ForUniform;
  84779. private _updateFloat4ForEffect;
  84780. private _updateFloat4ForUniform;
  84781. private _updateMatrixForEffect;
  84782. private _updateMatrixForUniform;
  84783. private _updateVector3ForEffect;
  84784. private _updateVector3ForUniform;
  84785. private _updateVector4ForEffect;
  84786. private _updateVector4ForUniform;
  84787. private _updateColor3ForEffect;
  84788. private _updateColor3ForUniform;
  84789. private _updateColor4ForEffect;
  84790. private _updateColor4ForUniform;
  84791. /**
  84792. * Sets a sampler uniform on the effect.
  84793. * @param name Define the name of the sampler.
  84794. * @param texture Define the texture to set in the sampler
  84795. */
  84796. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  84797. /**
  84798. * Directly updates the value of the uniform in the cache AND on the GPU.
  84799. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84800. * @param data Define the flattened data
  84801. */
  84802. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  84803. /**
  84804. * Binds this uniform buffer to an effect.
  84805. * @param effect Define the effect to bind the buffer to
  84806. * @param name Name of the uniform block in the shader.
  84807. */
  84808. bindToEffect(effect: Effect, name: string): void;
  84809. /**
  84810. * Disposes the uniform buffer.
  84811. */
  84812. dispose(): void;
  84813. }
  84814. }
  84815. declare module BABYLON {
  84816. /**
  84817. * Enum that determines the text-wrapping mode to use.
  84818. */
  84819. export enum InspectableType {
  84820. /**
  84821. * Checkbox for booleans
  84822. */
  84823. Checkbox = 0,
  84824. /**
  84825. * Sliders for numbers
  84826. */
  84827. Slider = 1,
  84828. /**
  84829. * Vector3
  84830. */
  84831. Vector3 = 2,
  84832. /**
  84833. * Quaternions
  84834. */
  84835. Quaternion = 3,
  84836. /**
  84837. * Color3
  84838. */
  84839. Color3 = 4,
  84840. /**
  84841. * String
  84842. */
  84843. String = 5
  84844. }
  84845. /**
  84846. * Interface used to define custom inspectable properties.
  84847. * This interface is used by the inspector to display custom property grids
  84848. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84849. */
  84850. export interface IInspectable {
  84851. /**
  84852. * Gets the label to display
  84853. */
  84854. label: string;
  84855. /**
  84856. * Gets the name of the property to edit
  84857. */
  84858. propertyName: string;
  84859. /**
  84860. * Gets the type of the editor to use
  84861. */
  84862. type: InspectableType;
  84863. /**
  84864. * Gets the minimum value of the property when using in "slider" mode
  84865. */
  84866. min?: number;
  84867. /**
  84868. * Gets the maximum value of the property when using in "slider" mode
  84869. */
  84870. max?: number;
  84871. /**
  84872. * Gets the setp to use when using in "slider" mode
  84873. */
  84874. step?: number;
  84875. }
  84876. }
  84877. declare module BABYLON {
  84878. /**
  84879. * Class used to provide helper for timing
  84880. */
  84881. export class TimingTools {
  84882. /**
  84883. * Polyfill for setImmediate
  84884. * @param action defines the action to execute after the current execution block
  84885. */
  84886. static SetImmediate(action: () => void): void;
  84887. }
  84888. }
  84889. declare module BABYLON {
  84890. /**
  84891. * Class used to enable instatition of objects by class name
  84892. */
  84893. export class InstantiationTools {
  84894. /**
  84895. * Use this object to register external classes like custom textures or material
  84896. * to allow the laoders to instantiate them
  84897. */
  84898. static RegisteredExternalClasses: {
  84899. [key: string]: Object;
  84900. };
  84901. /**
  84902. * Tries to instantiate a new object from a given class name
  84903. * @param className defines the class name to instantiate
  84904. * @returns the new object or null if the system was not able to do the instantiation
  84905. */
  84906. static Instantiate(className: string): any;
  84907. }
  84908. }
  84909. declare module BABYLON {
  84910. /**
  84911. * Define options used to create a depth texture
  84912. */
  84913. export class DepthTextureCreationOptions {
  84914. /** Specifies whether or not a stencil should be allocated in the texture */
  84915. generateStencil?: boolean;
  84916. /** Specifies whether or not bilinear filtering is enable on the texture */
  84917. bilinearFiltering?: boolean;
  84918. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  84919. comparisonFunction?: number;
  84920. /** Specifies if the created texture is a cube texture */
  84921. isCube?: boolean;
  84922. }
  84923. }
  84924. declare module BABYLON {
  84925. interface ThinEngine {
  84926. /**
  84927. * Creates a depth stencil cube texture.
  84928. * This is only available in WebGL 2.
  84929. * @param size The size of face edge in the cube texture.
  84930. * @param options The options defining the cube texture.
  84931. * @returns The cube texture
  84932. */
  84933. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  84934. /**
  84935. * Creates a cube texture
  84936. * @param rootUrl defines the url where the files to load is located
  84937. * @param scene defines the current scene
  84938. * @param files defines the list of files to load (1 per face)
  84939. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84940. * @param onLoad defines an optional callback raised when the texture is loaded
  84941. * @param onError defines an optional callback raised if there is an issue to load the texture
  84942. * @param format defines the format of the data
  84943. * @param forcedExtension defines the extension to use to pick the right loader
  84944. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  84945. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84946. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84947. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  84948. * @returns the cube texture as an InternalTexture
  84949. */
  84950. 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;
  84951. /**
  84952. * Creates a cube texture
  84953. * @param rootUrl defines the url where the files to load is located
  84954. * @param scene defines the current scene
  84955. * @param files defines the list of files to load (1 per face)
  84956. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84957. * @param onLoad defines an optional callback raised when the texture is loaded
  84958. * @param onError defines an optional callback raised if there is an issue to load the texture
  84959. * @param format defines the format of the data
  84960. * @param forcedExtension defines the extension to use to pick the right loader
  84961. * @returns the cube texture as an InternalTexture
  84962. */
  84963. 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;
  84964. /**
  84965. * Creates a cube texture
  84966. * @param rootUrl defines the url where the files to load is located
  84967. * @param scene defines the current scene
  84968. * @param files defines the list of files to load (1 per face)
  84969. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84970. * @param onLoad defines an optional callback raised when the texture is loaded
  84971. * @param onError defines an optional callback raised if there is an issue to load the texture
  84972. * @param format defines the format of the data
  84973. * @param forcedExtension defines the extension to use to pick the right loader
  84974. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  84975. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84976. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84977. * @returns the cube texture as an InternalTexture
  84978. */
  84979. 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;
  84980. /** @hidden */
  84981. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  84982. /** @hidden */
  84983. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  84984. /** @hidden */
  84985. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  84986. /** @hidden */
  84987. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  84988. /**
  84989. * @hidden
  84990. */
  84991. _setCubeMapTextureParams(loadMipmap: boolean): void;
  84992. }
  84993. }
  84994. declare module BABYLON {
  84995. /**
  84996. * Class for creating a cube texture
  84997. */
  84998. export class CubeTexture extends BaseTexture {
  84999. private _delayedOnLoad;
  85000. /**
  85001. * Observable triggered once the texture has been loaded.
  85002. */
  85003. onLoadObservable: Observable<CubeTexture>;
  85004. /**
  85005. * The url of the texture
  85006. */
  85007. url: string;
  85008. /**
  85009. * Gets or sets the center of the bounding box associated with the cube texture.
  85010. * It must define where the camera used to render the texture was set
  85011. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  85012. */
  85013. boundingBoxPosition: Vector3;
  85014. private _boundingBoxSize;
  85015. /**
  85016. * Gets or sets the size of the bounding box associated with the cube texture
  85017. * When defined, the cubemap will switch to local mode
  85018. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  85019. * @example https://www.babylonjs-playground.com/#RNASML
  85020. */
  85021. set boundingBoxSize(value: Vector3);
  85022. /**
  85023. * Returns the bounding box size
  85024. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  85025. */
  85026. get boundingBoxSize(): Vector3;
  85027. protected _rotationY: number;
  85028. /**
  85029. * Sets texture matrix rotation angle around Y axis in radians.
  85030. */
  85031. set rotationY(value: number);
  85032. /**
  85033. * Gets texture matrix rotation angle around Y axis radians.
  85034. */
  85035. get rotationY(): number;
  85036. /**
  85037. * Are mip maps generated for this texture or not.
  85038. */
  85039. get noMipmap(): boolean;
  85040. private _noMipmap;
  85041. private _files;
  85042. protected _forcedExtension: Nullable<string>;
  85043. private _extensions;
  85044. private _textureMatrix;
  85045. private _format;
  85046. private _createPolynomials;
  85047. /**
  85048. * Creates a cube texture from an array of image urls
  85049. * @param files defines an array of image urls
  85050. * @param scene defines the hosting scene
  85051. * @param noMipmap specifies if mip maps are not used
  85052. * @returns a cube texture
  85053. */
  85054. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  85055. /**
  85056. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  85057. * @param url defines the url of the prefiltered texture
  85058. * @param scene defines the scene the texture is attached to
  85059. * @param forcedExtension defines the extension of the file if different from the url
  85060. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  85061. * @return the prefiltered texture
  85062. */
  85063. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  85064. /**
  85065. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  85066. * as prefiltered data.
  85067. * @param rootUrl defines the url of the texture or the root name of the six images
  85068. * @param null defines the scene or engine the texture is attached to
  85069. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  85070. * @param noMipmap defines if mipmaps should be created or not
  85071. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  85072. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  85073. * @param onError defines a callback triggered in case of error during load
  85074. * @param format defines the internal format to use for the texture once loaded
  85075. * @param prefiltered defines whether or not the texture is created from prefiltered data
  85076. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  85077. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  85078. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85079. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85080. * @return the cube texture
  85081. */
  85082. 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);
  85083. /**
  85084. * Get the current class name of the texture useful for serialization or dynamic coding.
  85085. * @returns "CubeTexture"
  85086. */
  85087. getClassName(): string;
  85088. /**
  85089. * Update the url (and optional buffer) of this texture if url was null during construction.
  85090. * @param url the url of the texture
  85091. * @param forcedExtension defines the extension to use
  85092. * @param onLoad callback called when the texture is loaded (defaults to null)
  85093. * @param prefiltered Defines whether the updated texture is prefiltered or not
  85094. */
  85095. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  85096. /**
  85097. * Delays loading of the cube texture
  85098. * @param forcedExtension defines the extension to use
  85099. */
  85100. delayLoad(forcedExtension?: string): void;
  85101. /**
  85102. * Returns the reflection texture matrix
  85103. * @returns the reflection texture matrix
  85104. */
  85105. getReflectionTextureMatrix(): Matrix;
  85106. /**
  85107. * Sets the reflection texture matrix
  85108. * @param value Reflection texture matrix
  85109. */
  85110. setReflectionTextureMatrix(value: Matrix): void;
  85111. /**
  85112. * Parses text to create a cube texture
  85113. * @param parsedTexture define the serialized text to read from
  85114. * @param scene defines the hosting scene
  85115. * @param rootUrl defines the root url of the cube texture
  85116. * @returns a cube texture
  85117. */
  85118. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  85119. /**
  85120. * Makes a clone, or deep copy, of the cube texture
  85121. * @returns a new cube texture
  85122. */
  85123. clone(): CubeTexture;
  85124. }
  85125. }
  85126. declare module BABYLON {
  85127. /**
  85128. * Manages the defines for the Material
  85129. */
  85130. export class MaterialDefines {
  85131. /** @hidden */
  85132. protected _keys: string[];
  85133. private _isDirty;
  85134. /** @hidden */
  85135. _renderId: number;
  85136. /** @hidden */
  85137. _areLightsDirty: boolean;
  85138. /** @hidden */
  85139. _areLightsDisposed: boolean;
  85140. /** @hidden */
  85141. _areAttributesDirty: boolean;
  85142. /** @hidden */
  85143. _areTexturesDirty: boolean;
  85144. /** @hidden */
  85145. _areFresnelDirty: boolean;
  85146. /** @hidden */
  85147. _areMiscDirty: boolean;
  85148. /** @hidden */
  85149. _areImageProcessingDirty: boolean;
  85150. /** @hidden */
  85151. _normals: boolean;
  85152. /** @hidden */
  85153. _uvs: boolean;
  85154. /** @hidden */
  85155. _needNormals: boolean;
  85156. /** @hidden */
  85157. _needUVs: boolean;
  85158. [id: string]: any;
  85159. /**
  85160. * Specifies if the material needs to be re-calculated
  85161. */
  85162. get isDirty(): boolean;
  85163. /**
  85164. * Marks the material to indicate that it has been re-calculated
  85165. */
  85166. markAsProcessed(): void;
  85167. /**
  85168. * Marks the material to indicate that it needs to be re-calculated
  85169. */
  85170. markAsUnprocessed(): void;
  85171. /**
  85172. * Marks the material to indicate all of its defines need to be re-calculated
  85173. */
  85174. markAllAsDirty(): void;
  85175. /**
  85176. * Marks the material to indicate that image processing needs to be re-calculated
  85177. */
  85178. markAsImageProcessingDirty(): void;
  85179. /**
  85180. * Marks the material to indicate the lights need to be re-calculated
  85181. * @param disposed Defines whether the light is dirty due to dispose or not
  85182. */
  85183. markAsLightDirty(disposed?: boolean): void;
  85184. /**
  85185. * Marks the attribute state as changed
  85186. */
  85187. markAsAttributesDirty(): void;
  85188. /**
  85189. * Marks the texture state as changed
  85190. */
  85191. markAsTexturesDirty(): void;
  85192. /**
  85193. * Marks the fresnel state as changed
  85194. */
  85195. markAsFresnelDirty(): void;
  85196. /**
  85197. * Marks the misc state as changed
  85198. */
  85199. markAsMiscDirty(): void;
  85200. /**
  85201. * Rebuilds the material defines
  85202. */
  85203. rebuild(): void;
  85204. /**
  85205. * Specifies if two material defines are equal
  85206. * @param other - A material define instance to compare to
  85207. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  85208. */
  85209. isEqual(other: MaterialDefines): boolean;
  85210. /**
  85211. * Clones this instance's defines to another instance
  85212. * @param other - material defines to clone values to
  85213. */
  85214. cloneTo(other: MaterialDefines): void;
  85215. /**
  85216. * Resets the material define values
  85217. */
  85218. reset(): void;
  85219. /**
  85220. * Converts the material define values to a string
  85221. * @returns - String of material define information
  85222. */
  85223. toString(): string;
  85224. }
  85225. }
  85226. declare module BABYLON {
  85227. /**
  85228. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  85229. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  85230. * 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;
  85231. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  85232. */
  85233. export class ColorCurves {
  85234. private _dirty;
  85235. private _tempColor;
  85236. private _globalCurve;
  85237. private _highlightsCurve;
  85238. private _midtonesCurve;
  85239. private _shadowsCurve;
  85240. private _positiveCurve;
  85241. private _negativeCurve;
  85242. private _globalHue;
  85243. private _globalDensity;
  85244. private _globalSaturation;
  85245. private _globalExposure;
  85246. /**
  85247. * Gets the global Hue value.
  85248. * 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).
  85249. */
  85250. get globalHue(): number;
  85251. /**
  85252. * Sets the global Hue value.
  85253. * 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).
  85254. */
  85255. set globalHue(value: number);
  85256. /**
  85257. * Gets the global Density value.
  85258. * 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.
  85259. * Values less than zero provide a filter of opposite hue.
  85260. */
  85261. get globalDensity(): number;
  85262. /**
  85263. * Sets the global Density value.
  85264. * 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.
  85265. * Values less than zero provide a filter of opposite hue.
  85266. */
  85267. set globalDensity(value: number);
  85268. /**
  85269. * Gets the global Saturation value.
  85270. * 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.
  85271. */
  85272. get globalSaturation(): number;
  85273. /**
  85274. * Sets the global Saturation value.
  85275. * 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.
  85276. */
  85277. set globalSaturation(value: number);
  85278. /**
  85279. * Gets the global Exposure value.
  85280. * 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.
  85281. */
  85282. get globalExposure(): number;
  85283. /**
  85284. * Sets the global Exposure value.
  85285. * 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.
  85286. */
  85287. set globalExposure(value: number);
  85288. private _highlightsHue;
  85289. private _highlightsDensity;
  85290. private _highlightsSaturation;
  85291. private _highlightsExposure;
  85292. /**
  85293. * Gets the highlights Hue value.
  85294. * 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).
  85295. */
  85296. get highlightsHue(): number;
  85297. /**
  85298. * Sets the highlights Hue value.
  85299. * 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).
  85300. */
  85301. set highlightsHue(value: number);
  85302. /**
  85303. * Gets the highlights Density value.
  85304. * 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.
  85305. * Values less than zero provide a filter of opposite hue.
  85306. */
  85307. get highlightsDensity(): number;
  85308. /**
  85309. * Sets the highlights Density value.
  85310. * 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.
  85311. * Values less than zero provide a filter of opposite hue.
  85312. */
  85313. set highlightsDensity(value: number);
  85314. /**
  85315. * Gets the highlights Saturation value.
  85316. * 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.
  85317. */
  85318. get highlightsSaturation(): number;
  85319. /**
  85320. * Sets the highlights Saturation value.
  85321. * 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.
  85322. */
  85323. set highlightsSaturation(value: number);
  85324. /**
  85325. * Gets the highlights Exposure value.
  85326. * 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.
  85327. */
  85328. get highlightsExposure(): number;
  85329. /**
  85330. * Sets the highlights Exposure value.
  85331. * 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.
  85332. */
  85333. set highlightsExposure(value: number);
  85334. private _midtonesHue;
  85335. private _midtonesDensity;
  85336. private _midtonesSaturation;
  85337. private _midtonesExposure;
  85338. /**
  85339. * Gets the midtones Hue value.
  85340. * 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).
  85341. */
  85342. get midtonesHue(): number;
  85343. /**
  85344. * Sets the midtones Hue value.
  85345. * 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).
  85346. */
  85347. set midtonesHue(value: number);
  85348. /**
  85349. * Gets the midtones Density value.
  85350. * 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.
  85351. * Values less than zero provide a filter of opposite hue.
  85352. */
  85353. get midtonesDensity(): number;
  85354. /**
  85355. * Sets the midtones Density value.
  85356. * 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.
  85357. * Values less than zero provide a filter of opposite hue.
  85358. */
  85359. set midtonesDensity(value: number);
  85360. /**
  85361. * Gets the midtones Saturation value.
  85362. * 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.
  85363. */
  85364. get midtonesSaturation(): number;
  85365. /**
  85366. * Sets the midtones Saturation value.
  85367. * 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.
  85368. */
  85369. set midtonesSaturation(value: number);
  85370. /**
  85371. * Gets the midtones Exposure value.
  85372. * 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.
  85373. */
  85374. get midtonesExposure(): number;
  85375. /**
  85376. * Sets the midtones Exposure value.
  85377. * 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.
  85378. */
  85379. set midtonesExposure(value: number);
  85380. private _shadowsHue;
  85381. private _shadowsDensity;
  85382. private _shadowsSaturation;
  85383. private _shadowsExposure;
  85384. /**
  85385. * Gets the shadows Hue value.
  85386. * 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).
  85387. */
  85388. get shadowsHue(): number;
  85389. /**
  85390. * Sets the shadows Hue value.
  85391. * 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).
  85392. */
  85393. set shadowsHue(value: number);
  85394. /**
  85395. * Gets the shadows Density value.
  85396. * 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.
  85397. * Values less than zero provide a filter of opposite hue.
  85398. */
  85399. get shadowsDensity(): number;
  85400. /**
  85401. * Sets the shadows Density value.
  85402. * 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.
  85403. * Values less than zero provide a filter of opposite hue.
  85404. */
  85405. set shadowsDensity(value: number);
  85406. /**
  85407. * Gets the shadows Saturation value.
  85408. * 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.
  85409. */
  85410. get shadowsSaturation(): number;
  85411. /**
  85412. * Sets the shadows Saturation value.
  85413. * 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.
  85414. */
  85415. set shadowsSaturation(value: number);
  85416. /**
  85417. * Gets the shadows Exposure value.
  85418. * 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.
  85419. */
  85420. get shadowsExposure(): number;
  85421. /**
  85422. * Sets the shadows Exposure value.
  85423. * 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.
  85424. */
  85425. set shadowsExposure(value: number);
  85426. /**
  85427. * Returns the class name
  85428. * @returns The class name
  85429. */
  85430. getClassName(): string;
  85431. /**
  85432. * Binds the color curves to the shader.
  85433. * @param colorCurves The color curve to bind
  85434. * @param effect The effect to bind to
  85435. * @param positiveUniform The positive uniform shader parameter
  85436. * @param neutralUniform The neutral uniform shader parameter
  85437. * @param negativeUniform The negative uniform shader parameter
  85438. */
  85439. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  85440. /**
  85441. * Prepare the list of uniforms associated with the ColorCurves effects.
  85442. * @param uniformsList The list of uniforms used in the effect
  85443. */
  85444. static PrepareUniforms(uniformsList: string[]): void;
  85445. /**
  85446. * Returns color grading data based on a hue, density, saturation and exposure value.
  85447. * @param filterHue The hue of the color filter.
  85448. * @param filterDensity The density of the color filter.
  85449. * @param saturation The saturation.
  85450. * @param exposure The exposure.
  85451. * @param result The result data container.
  85452. */
  85453. private getColorGradingDataToRef;
  85454. /**
  85455. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  85456. * @param value The input slider value in range [-100,100].
  85457. * @returns Adjusted value.
  85458. */
  85459. private static applyColorGradingSliderNonlinear;
  85460. /**
  85461. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  85462. * @param hue The hue (H) input.
  85463. * @param saturation The saturation (S) input.
  85464. * @param brightness The brightness (B) input.
  85465. * @result An RGBA color represented as Vector4.
  85466. */
  85467. private static fromHSBToRef;
  85468. /**
  85469. * Returns a value clamped between min and max
  85470. * @param value The value to clamp
  85471. * @param min The minimum of value
  85472. * @param max The maximum of value
  85473. * @returns The clamped value.
  85474. */
  85475. private static clamp;
  85476. /**
  85477. * Clones the current color curve instance.
  85478. * @return The cloned curves
  85479. */
  85480. clone(): ColorCurves;
  85481. /**
  85482. * Serializes the current color curve instance to a json representation.
  85483. * @return a JSON representation
  85484. */
  85485. serialize(): any;
  85486. /**
  85487. * Parses the color curve from a json representation.
  85488. * @param source the JSON source to parse
  85489. * @return The parsed curves
  85490. */
  85491. static Parse(source: any): ColorCurves;
  85492. }
  85493. }
  85494. declare module BABYLON {
  85495. /**
  85496. * Interface to follow in your material defines to integrate easily the
  85497. * Image proccessing functions.
  85498. * @hidden
  85499. */
  85500. export interface IImageProcessingConfigurationDefines {
  85501. IMAGEPROCESSING: boolean;
  85502. VIGNETTE: boolean;
  85503. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85504. VIGNETTEBLENDMODEOPAQUE: boolean;
  85505. TONEMAPPING: boolean;
  85506. TONEMAPPING_ACES: boolean;
  85507. CONTRAST: boolean;
  85508. EXPOSURE: boolean;
  85509. COLORCURVES: boolean;
  85510. COLORGRADING: boolean;
  85511. COLORGRADING3D: boolean;
  85512. SAMPLER3DGREENDEPTH: boolean;
  85513. SAMPLER3DBGRMAP: boolean;
  85514. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85515. }
  85516. /**
  85517. * @hidden
  85518. */
  85519. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  85520. IMAGEPROCESSING: boolean;
  85521. VIGNETTE: boolean;
  85522. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85523. VIGNETTEBLENDMODEOPAQUE: boolean;
  85524. TONEMAPPING: boolean;
  85525. TONEMAPPING_ACES: boolean;
  85526. CONTRAST: boolean;
  85527. COLORCURVES: boolean;
  85528. COLORGRADING: boolean;
  85529. COLORGRADING3D: boolean;
  85530. SAMPLER3DGREENDEPTH: boolean;
  85531. SAMPLER3DBGRMAP: boolean;
  85532. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85533. EXPOSURE: boolean;
  85534. constructor();
  85535. }
  85536. /**
  85537. * This groups together the common properties used for image processing either in direct forward pass
  85538. * or through post processing effect depending on the use of the image processing pipeline in your scene
  85539. * or not.
  85540. */
  85541. export class ImageProcessingConfiguration {
  85542. /**
  85543. * Default tone mapping applied in BabylonJS.
  85544. */
  85545. static readonly TONEMAPPING_STANDARD: number;
  85546. /**
  85547. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  85548. * to other engines rendering to increase portability.
  85549. */
  85550. static readonly TONEMAPPING_ACES: number;
  85551. /**
  85552. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  85553. */
  85554. colorCurves: Nullable<ColorCurves>;
  85555. private _colorCurvesEnabled;
  85556. /**
  85557. * Gets wether the color curves effect is enabled.
  85558. */
  85559. get colorCurvesEnabled(): boolean;
  85560. /**
  85561. * Sets wether the color curves effect is enabled.
  85562. */
  85563. set colorCurvesEnabled(value: boolean);
  85564. private _colorGradingTexture;
  85565. /**
  85566. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85567. */
  85568. get colorGradingTexture(): Nullable<BaseTexture>;
  85569. /**
  85570. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85571. */
  85572. set colorGradingTexture(value: Nullable<BaseTexture>);
  85573. private _colorGradingEnabled;
  85574. /**
  85575. * Gets wether the color grading effect is enabled.
  85576. */
  85577. get colorGradingEnabled(): boolean;
  85578. /**
  85579. * Sets wether the color grading effect is enabled.
  85580. */
  85581. set colorGradingEnabled(value: boolean);
  85582. private _colorGradingWithGreenDepth;
  85583. /**
  85584. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  85585. */
  85586. get colorGradingWithGreenDepth(): boolean;
  85587. /**
  85588. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  85589. */
  85590. set colorGradingWithGreenDepth(value: boolean);
  85591. private _colorGradingBGR;
  85592. /**
  85593. * Gets wether the color grading texture contains BGR values.
  85594. */
  85595. get colorGradingBGR(): boolean;
  85596. /**
  85597. * Sets wether the color grading texture contains BGR values.
  85598. */
  85599. set colorGradingBGR(value: boolean);
  85600. /** @hidden */
  85601. _exposure: number;
  85602. /**
  85603. * Gets the Exposure used in the effect.
  85604. */
  85605. get exposure(): number;
  85606. /**
  85607. * Sets the Exposure used in the effect.
  85608. */
  85609. set exposure(value: number);
  85610. private _toneMappingEnabled;
  85611. /**
  85612. * Gets wether the tone mapping effect is enabled.
  85613. */
  85614. get toneMappingEnabled(): boolean;
  85615. /**
  85616. * Sets wether the tone mapping effect is enabled.
  85617. */
  85618. set toneMappingEnabled(value: boolean);
  85619. private _toneMappingType;
  85620. /**
  85621. * Gets the type of tone mapping effect.
  85622. */
  85623. get toneMappingType(): number;
  85624. /**
  85625. * Sets the type of tone mapping effect used in BabylonJS.
  85626. */
  85627. set toneMappingType(value: number);
  85628. protected _contrast: number;
  85629. /**
  85630. * Gets the contrast used in the effect.
  85631. */
  85632. get contrast(): number;
  85633. /**
  85634. * Sets the contrast used in the effect.
  85635. */
  85636. set contrast(value: number);
  85637. /**
  85638. * Vignette stretch size.
  85639. */
  85640. vignetteStretch: number;
  85641. /**
  85642. * Vignette centre X Offset.
  85643. */
  85644. vignetteCentreX: number;
  85645. /**
  85646. * Vignette centre Y Offset.
  85647. */
  85648. vignetteCentreY: number;
  85649. /**
  85650. * Vignette weight or intensity of the vignette effect.
  85651. */
  85652. vignetteWeight: number;
  85653. /**
  85654. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  85655. * if vignetteEnabled is set to true.
  85656. */
  85657. vignetteColor: Color4;
  85658. /**
  85659. * Camera field of view used by the Vignette effect.
  85660. */
  85661. vignetteCameraFov: number;
  85662. private _vignetteBlendMode;
  85663. /**
  85664. * Gets the vignette blend mode allowing different kind of effect.
  85665. */
  85666. get vignetteBlendMode(): number;
  85667. /**
  85668. * Sets the vignette blend mode allowing different kind of effect.
  85669. */
  85670. set vignetteBlendMode(value: number);
  85671. private _vignetteEnabled;
  85672. /**
  85673. * Gets wether the vignette effect is enabled.
  85674. */
  85675. get vignetteEnabled(): boolean;
  85676. /**
  85677. * Sets wether the vignette effect is enabled.
  85678. */
  85679. set vignetteEnabled(value: boolean);
  85680. private _applyByPostProcess;
  85681. /**
  85682. * Gets wether the image processing is applied through a post process or not.
  85683. */
  85684. get applyByPostProcess(): boolean;
  85685. /**
  85686. * Sets wether the image processing is applied through a post process or not.
  85687. */
  85688. set applyByPostProcess(value: boolean);
  85689. private _isEnabled;
  85690. /**
  85691. * Gets wether the image processing is enabled or not.
  85692. */
  85693. get isEnabled(): boolean;
  85694. /**
  85695. * Sets wether the image processing is enabled or not.
  85696. */
  85697. set isEnabled(value: boolean);
  85698. /**
  85699. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  85700. */
  85701. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  85702. /**
  85703. * Method called each time the image processing information changes requires to recompile the effect.
  85704. */
  85705. protected _updateParameters(): void;
  85706. /**
  85707. * Gets the current class name.
  85708. * @return "ImageProcessingConfiguration"
  85709. */
  85710. getClassName(): string;
  85711. /**
  85712. * Prepare the list of uniforms associated with the Image Processing effects.
  85713. * @param uniforms The list of uniforms used in the effect
  85714. * @param defines the list of defines currently in use
  85715. */
  85716. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  85717. /**
  85718. * Prepare the list of samplers associated with the Image Processing effects.
  85719. * @param samplersList The list of uniforms used in the effect
  85720. * @param defines the list of defines currently in use
  85721. */
  85722. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  85723. /**
  85724. * Prepare the list of defines associated to the shader.
  85725. * @param defines the list of defines to complete
  85726. * @param forPostProcess Define if we are currently in post process mode or not
  85727. */
  85728. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  85729. /**
  85730. * Returns true if all the image processing information are ready.
  85731. * @returns True if ready, otherwise, false
  85732. */
  85733. isReady(): boolean;
  85734. /**
  85735. * Binds the image processing to the shader.
  85736. * @param effect The effect to bind to
  85737. * @param overrideAspectRatio Override the aspect ratio of the effect
  85738. */
  85739. bind(effect: Effect, overrideAspectRatio?: number): void;
  85740. /**
  85741. * Clones the current image processing instance.
  85742. * @return The cloned image processing
  85743. */
  85744. clone(): ImageProcessingConfiguration;
  85745. /**
  85746. * Serializes the current image processing instance to a json representation.
  85747. * @return a JSON representation
  85748. */
  85749. serialize(): any;
  85750. /**
  85751. * Parses the image processing from a json representation.
  85752. * @param source the JSON source to parse
  85753. * @return The parsed image processing
  85754. */
  85755. static Parse(source: any): ImageProcessingConfiguration;
  85756. private static _VIGNETTEMODE_MULTIPLY;
  85757. private static _VIGNETTEMODE_OPAQUE;
  85758. /**
  85759. * Used to apply the vignette as a mix with the pixel color.
  85760. */
  85761. static get VIGNETTEMODE_MULTIPLY(): number;
  85762. /**
  85763. * Used to apply the vignette as a replacement of the pixel color.
  85764. */
  85765. static get VIGNETTEMODE_OPAQUE(): number;
  85766. }
  85767. }
  85768. declare module BABYLON {
  85769. /** @hidden */
  85770. export var postprocessVertexShader: {
  85771. name: string;
  85772. shader: string;
  85773. };
  85774. }
  85775. declare module BABYLON {
  85776. interface ThinEngine {
  85777. /**
  85778. * Creates a new render target texture
  85779. * @param size defines the size of the texture
  85780. * @param options defines the options used to create the texture
  85781. * @returns a new render target texture stored in an InternalTexture
  85782. */
  85783. createRenderTargetTexture(size: number | {
  85784. width: number;
  85785. height: number;
  85786. layers?: number;
  85787. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  85788. /**
  85789. * Creates a depth stencil texture.
  85790. * This is only available in WebGL 2 or with the depth texture extension available.
  85791. * @param size The size of face edge in the texture.
  85792. * @param options The options defining the texture.
  85793. * @returns The texture
  85794. */
  85795. createDepthStencilTexture(size: number | {
  85796. width: number;
  85797. height: number;
  85798. layers?: number;
  85799. }, options: DepthTextureCreationOptions): InternalTexture;
  85800. /** @hidden */
  85801. _createDepthStencilTexture(size: number | {
  85802. width: number;
  85803. height: number;
  85804. layers?: number;
  85805. }, options: DepthTextureCreationOptions): InternalTexture;
  85806. }
  85807. }
  85808. declare module BABYLON {
  85809. /**
  85810. * Defines the kind of connection point for node based material
  85811. */
  85812. export enum NodeMaterialBlockConnectionPointTypes {
  85813. /** Float */
  85814. Float = 1,
  85815. /** Int */
  85816. Int = 2,
  85817. /** Vector2 */
  85818. Vector2 = 4,
  85819. /** Vector3 */
  85820. Vector3 = 8,
  85821. /** Vector4 */
  85822. Vector4 = 16,
  85823. /** Color3 */
  85824. Color3 = 32,
  85825. /** Color4 */
  85826. Color4 = 64,
  85827. /** Matrix */
  85828. Matrix = 128,
  85829. /** Custom object */
  85830. Object = 256,
  85831. /** Detect type based on connection */
  85832. AutoDetect = 1024,
  85833. /** Output type that will be defined by input type */
  85834. BasedOnInput = 2048
  85835. }
  85836. }
  85837. declare module BABYLON {
  85838. /**
  85839. * Enum used to define the target of a block
  85840. */
  85841. export enum NodeMaterialBlockTargets {
  85842. /** Vertex shader */
  85843. Vertex = 1,
  85844. /** Fragment shader */
  85845. Fragment = 2,
  85846. /** Neutral */
  85847. Neutral = 4,
  85848. /** Vertex and Fragment */
  85849. VertexAndFragment = 3
  85850. }
  85851. }
  85852. declare module BABYLON {
  85853. /**
  85854. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  85855. */
  85856. export enum NodeMaterialBlockConnectionPointMode {
  85857. /** Value is an uniform */
  85858. Uniform = 0,
  85859. /** Value is a mesh attribute */
  85860. Attribute = 1,
  85861. /** Value is a varying between vertex and fragment shaders */
  85862. Varying = 2,
  85863. /** Mode is undefined */
  85864. Undefined = 3
  85865. }
  85866. }
  85867. declare module BABYLON {
  85868. /**
  85869. * Enum used to define system values e.g. values automatically provided by the system
  85870. */
  85871. export enum NodeMaterialSystemValues {
  85872. /** World */
  85873. World = 1,
  85874. /** View */
  85875. View = 2,
  85876. /** Projection */
  85877. Projection = 3,
  85878. /** ViewProjection */
  85879. ViewProjection = 4,
  85880. /** WorldView */
  85881. WorldView = 5,
  85882. /** WorldViewProjection */
  85883. WorldViewProjection = 6,
  85884. /** CameraPosition */
  85885. CameraPosition = 7,
  85886. /** Fog Color */
  85887. FogColor = 8,
  85888. /** Delta time */
  85889. DeltaTime = 9
  85890. }
  85891. }
  85892. declare module BABYLON {
  85893. /** Defines supported spaces */
  85894. export enum Space {
  85895. /** Local (object) space */
  85896. LOCAL = 0,
  85897. /** World space */
  85898. WORLD = 1,
  85899. /** Bone space */
  85900. BONE = 2
  85901. }
  85902. /** Defines the 3 main axes */
  85903. export class Axis {
  85904. /** X axis */
  85905. static X: Vector3;
  85906. /** Y axis */
  85907. static Y: Vector3;
  85908. /** Z axis */
  85909. static Z: Vector3;
  85910. }
  85911. }
  85912. declare module BABYLON {
  85913. /**
  85914. * Represents a camera frustum
  85915. */
  85916. export class Frustum {
  85917. /**
  85918. * Gets the planes representing the frustum
  85919. * @param transform matrix to be applied to the returned planes
  85920. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  85921. */
  85922. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  85923. /**
  85924. * Gets the near frustum plane transformed by the transform matrix
  85925. * @param transform transformation matrix to be applied to the resulting frustum plane
  85926. * @param frustumPlane the resuling frustum plane
  85927. */
  85928. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85929. /**
  85930. * Gets the far frustum plane transformed by the transform matrix
  85931. * @param transform transformation matrix to be applied to the resulting frustum plane
  85932. * @param frustumPlane the resuling frustum plane
  85933. */
  85934. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85935. /**
  85936. * Gets the left frustum plane transformed by the transform matrix
  85937. * @param transform transformation matrix to be applied to the resulting frustum plane
  85938. * @param frustumPlane the resuling frustum plane
  85939. */
  85940. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85941. /**
  85942. * Gets the right frustum plane transformed by the transform matrix
  85943. * @param transform transformation matrix to be applied to the resulting frustum plane
  85944. * @param frustumPlane the resuling frustum plane
  85945. */
  85946. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85947. /**
  85948. * Gets the top frustum plane transformed by the transform matrix
  85949. * @param transform transformation matrix to be applied to the resulting frustum plane
  85950. * @param frustumPlane the resuling frustum plane
  85951. */
  85952. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85953. /**
  85954. * Gets the bottom frustum plane transformed by the transform matrix
  85955. * @param transform transformation matrix to be applied to the resulting frustum plane
  85956. * @param frustumPlane the resuling frustum plane
  85957. */
  85958. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85959. /**
  85960. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  85961. * @param transform transformation matrix to be applied to the resulting frustum planes
  85962. * @param frustumPlanes the resuling frustum planes
  85963. */
  85964. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  85965. }
  85966. }
  85967. declare module BABYLON {
  85968. /**
  85969. * Interface for the size containing width and height
  85970. */
  85971. export interface ISize {
  85972. /**
  85973. * Width
  85974. */
  85975. width: number;
  85976. /**
  85977. * Heighht
  85978. */
  85979. height: number;
  85980. }
  85981. /**
  85982. * Size containing widht and height
  85983. */
  85984. export class Size implements ISize {
  85985. /**
  85986. * Width
  85987. */
  85988. width: number;
  85989. /**
  85990. * Height
  85991. */
  85992. height: number;
  85993. /**
  85994. * Creates a Size object from the given width and height (floats).
  85995. * @param width width of the new size
  85996. * @param height height of the new size
  85997. */
  85998. constructor(width: number, height: number);
  85999. /**
  86000. * Returns a string with the Size width and height
  86001. * @returns a string with the Size width and height
  86002. */
  86003. toString(): string;
  86004. /**
  86005. * "Size"
  86006. * @returns the string "Size"
  86007. */
  86008. getClassName(): string;
  86009. /**
  86010. * Returns the Size hash code.
  86011. * @returns a hash code for a unique width and height
  86012. */
  86013. getHashCode(): number;
  86014. /**
  86015. * Updates the current size from the given one.
  86016. * @param src the given size
  86017. */
  86018. copyFrom(src: Size): void;
  86019. /**
  86020. * Updates in place the current Size from the given floats.
  86021. * @param width width of the new size
  86022. * @param height height of the new size
  86023. * @returns the updated Size.
  86024. */
  86025. copyFromFloats(width: number, height: number): Size;
  86026. /**
  86027. * Updates in place the current Size from the given floats.
  86028. * @param width width to set
  86029. * @param height height to set
  86030. * @returns the updated Size.
  86031. */
  86032. set(width: number, height: number): Size;
  86033. /**
  86034. * Multiplies the width and height by numbers
  86035. * @param w factor to multiple the width by
  86036. * @param h factor to multiple the height by
  86037. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  86038. */
  86039. multiplyByFloats(w: number, h: number): Size;
  86040. /**
  86041. * Clones the size
  86042. * @returns a new Size copied from the given one.
  86043. */
  86044. clone(): Size;
  86045. /**
  86046. * True if the current Size and the given one width and height are strictly equal.
  86047. * @param other the other size to compare against
  86048. * @returns True if the current Size and the given one width and height are strictly equal.
  86049. */
  86050. equals(other: Size): boolean;
  86051. /**
  86052. * The surface of the Size : width * height (float).
  86053. */
  86054. get surface(): number;
  86055. /**
  86056. * Create a new size of zero
  86057. * @returns a new Size set to (0.0, 0.0)
  86058. */
  86059. static Zero(): Size;
  86060. /**
  86061. * Sums the width and height of two sizes
  86062. * @param otherSize size to add to this size
  86063. * @returns a new Size set as the addition result of the current Size and the given one.
  86064. */
  86065. add(otherSize: Size): Size;
  86066. /**
  86067. * Subtracts the width and height of two
  86068. * @param otherSize size to subtract to this size
  86069. * @returns a new Size set as the subtraction result of the given one from the current Size.
  86070. */
  86071. subtract(otherSize: Size): Size;
  86072. /**
  86073. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  86074. * @param start starting size to lerp between
  86075. * @param end end size to lerp between
  86076. * @param amount amount to lerp between the start and end values
  86077. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  86078. */
  86079. static Lerp(start: Size, end: Size, amount: number): Size;
  86080. }
  86081. }
  86082. declare module BABYLON {
  86083. /**
  86084. * Contains position and normal vectors for a vertex
  86085. */
  86086. export class PositionNormalVertex {
  86087. /** the position of the vertex (defaut: 0,0,0) */
  86088. position: Vector3;
  86089. /** the normal of the vertex (defaut: 0,1,0) */
  86090. normal: Vector3;
  86091. /**
  86092. * Creates a PositionNormalVertex
  86093. * @param position the position of the vertex (defaut: 0,0,0)
  86094. * @param normal the normal of the vertex (defaut: 0,1,0)
  86095. */
  86096. constructor(
  86097. /** the position of the vertex (defaut: 0,0,0) */
  86098. position?: Vector3,
  86099. /** the normal of the vertex (defaut: 0,1,0) */
  86100. normal?: Vector3);
  86101. /**
  86102. * Clones the PositionNormalVertex
  86103. * @returns the cloned PositionNormalVertex
  86104. */
  86105. clone(): PositionNormalVertex;
  86106. }
  86107. /**
  86108. * Contains position, normal and uv vectors for a vertex
  86109. */
  86110. export class PositionNormalTextureVertex {
  86111. /** the position of the vertex (defaut: 0,0,0) */
  86112. position: Vector3;
  86113. /** the normal of the vertex (defaut: 0,1,0) */
  86114. normal: Vector3;
  86115. /** the uv of the vertex (default: 0,0) */
  86116. uv: Vector2;
  86117. /**
  86118. * Creates a PositionNormalTextureVertex
  86119. * @param position the position of the vertex (defaut: 0,0,0)
  86120. * @param normal the normal of the vertex (defaut: 0,1,0)
  86121. * @param uv the uv of the vertex (default: 0,0)
  86122. */
  86123. constructor(
  86124. /** the position of the vertex (defaut: 0,0,0) */
  86125. position?: Vector3,
  86126. /** the normal of the vertex (defaut: 0,1,0) */
  86127. normal?: Vector3,
  86128. /** the uv of the vertex (default: 0,0) */
  86129. uv?: Vector2);
  86130. /**
  86131. * Clones the PositionNormalTextureVertex
  86132. * @returns the cloned PositionNormalTextureVertex
  86133. */
  86134. clone(): PositionNormalTextureVertex;
  86135. }
  86136. }
  86137. declare module BABYLON {
  86138. /**
  86139. * Enum defining the type of animations supported by InputBlock
  86140. */
  86141. export enum AnimatedInputBlockTypes {
  86142. /** No animation */
  86143. None = 0,
  86144. /** Time based animation. Will only work for floats */
  86145. Time = 1
  86146. }
  86147. }
  86148. declare module BABYLON {
  86149. /**
  86150. * Interface describing all the common properties and methods a shadow light needs to implement.
  86151. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  86152. * as well as binding the different shadow properties to the effects.
  86153. */
  86154. export interface IShadowLight extends Light {
  86155. /**
  86156. * The light id in the scene (used in scene.findLighById for instance)
  86157. */
  86158. id: string;
  86159. /**
  86160. * The position the shdow will be casted from.
  86161. */
  86162. position: Vector3;
  86163. /**
  86164. * In 2d mode (needCube being false), the direction used to cast the shadow.
  86165. */
  86166. direction: Vector3;
  86167. /**
  86168. * The transformed position. Position of the light in world space taking parenting in account.
  86169. */
  86170. transformedPosition: Vector3;
  86171. /**
  86172. * The transformed direction. Direction of the light in world space taking parenting in account.
  86173. */
  86174. transformedDirection: Vector3;
  86175. /**
  86176. * The friendly name of the light in the scene.
  86177. */
  86178. name: string;
  86179. /**
  86180. * Defines the shadow projection clipping minimum z value.
  86181. */
  86182. shadowMinZ: number;
  86183. /**
  86184. * Defines the shadow projection clipping maximum z value.
  86185. */
  86186. shadowMaxZ: number;
  86187. /**
  86188. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  86189. * @returns true if the information has been computed, false if it does not need to (no parenting)
  86190. */
  86191. computeTransformedInformation(): boolean;
  86192. /**
  86193. * Gets the scene the light belongs to.
  86194. * @returns The scene
  86195. */
  86196. getScene(): Scene;
  86197. /**
  86198. * Callback defining a custom Projection Matrix Builder.
  86199. * This can be used to override the default projection matrix computation.
  86200. */
  86201. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  86202. /**
  86203. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  86204. * @param matrix The materix to updated with the projection information
  86205. * @param viewMatrix The transform matrix of the light
  86206. * @param renderList The list of mesh to render in the map
  86207. * @returns The current light
  86208. */
  86209. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  86210. /**
  86211. * Gets the current depth scale used in ESM.
  86212. * @returns The scale
  86213. */
  86214. getDepthScale(): number;
  86215. /**
  86216. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  86217. * @returns true if a cube texture needs to be use
  86218. */
  86219. needCube(): boolean;
  86220. /**
  86221. * Detects if the projection matrix requires to be recomputed this frame.
  86222. * @returns true if it requires to be recomputed otherwise, false.
  86223. */
  86224. needProjectionMatrixCompute(): boolean;
  86225. /**
  86226. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  86227. */
  86228. forceProjectionMatrixCompute(): void;
  86229. /**
  86230. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  86231. * @param faceIndex The index of the face we are computed the direction to generate shadow
  86232. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  86233. */
  86234. getShadowDirection(faceIndex?: number): Vector3;
  86235. /**
  86236. * Gets the minZ used for shadow according to both the scene and the light.
  86237. * @param activeCamera The camera we are returning the min for
  86238. * @returns the depth min z
  86239. */
  86240. getDepthMinZ(activeCamera: Camera): number;
  86241. /**
  86242. * Gets the maxZ used for shadow according to both the scene and the light.
  86243. * @param activeCamera The camera we are returning the max for
  86244. * @returns the depth max z
  86245. */
  86246. getDepthMaxZ(activeCamera: Camera): number;
  86247. }
  86248. /**
  86249. * Base implementation IShadowLight
  86250. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  86251. */
  86252. export abstract class ShadowLight extends Light implements IShadowLight {
  86253. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  86254. protected _position: Vector3;
  86255. protected _setPosition(value: Vector3): void;
  86256. /**
  86257. * Sets the position the shadow will be casted from. Also use as the light position for both
  86258. * point and spot lights.
  86259. */
  86260. get position(): Vector3;
  86261. /**
  86262. * Sets the position the shadow will be casted from. Also use as the light position for both
  86263. * point and spot lights.
  86264. */
  86265. set position(value: Vector3);
  86266. protected _direction: Vector3;
  86267. protected _setDirection(value: Vector3): void;
  86268. /**
  86269. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  86270. * Also use as the light direction on spot and directional lights.
  86271. */
  86272. get direction(): Vector3;
  86273. /**
  86274. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  86275. * Also use as the light direction on spot and directional lights.
  86276. */
  86277. set direction(value: Vector3);
  86278. protected _shadowMinZ: number;
  86279. /**
  86280. * Gets the shadow projection clipping minimum z value.
  86281. */
  86282. get shadowMinZ(): number;
  86283. /**
  86284. * Sets the shadow projection clipping minimum z value.
  86285. */
  86286. set shadowMinZ(value: number);
  86287. protected _shadowMaxZ: number;
  86288. /**
  86289. * Sets the shadow projection clipping maximum z value.
  86290. */
  86291. get shadowMaxZ(): number;
  86292. /**
  86293. * Gets the shadow projection clipping maximum z value.
  86294. */
  86295. set shadowMaxZ(value: number);
  86296. /**
  86297. * Callback defining a custom Projection Matrix Builder.
  86298. * This can be used to override the default projection matrix computation.
  86299. */
  86300. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  86301. /**
  86302. * The transformed position. Position of the light in world space taking parenting in account.
  86303. */
  86304. transformedPosition: Vector3;
  86305. /**
  86306. * The transformed direction. Direction of the light in world space taking parenting in account.
  86307. */
  86308. transformedDirection: Vector3;
  86309. private _needProjectionMatrixCompute;
  86310. /**
  86311. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  86312. * @returns true if the information has been computed, false if it does not need to (no parenting)
  86313. */
  86314. computeTransformedInformation(): boolean;
  86315. /**
  86316. * Return the depth scale used for the shadow map.
  86317. * @returns the depth scale.
  86318. */
  86319. getDepthScale(): number;
  86320. /**
  86321. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  86322. * @param faceIndex The index of the face we are computed the direction to generate shadow
  86323. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  86324. */
  86325. getShadowDirection(faceIndex?: number): Vector3;
  86326. /**
  86327. * Returns the ShadowLight absolute position in the World.
  86328. * @returns the position vector in world space
  86329. */
  86330. getAbsolutePosition(): Vector3;
  86331. /**
  86332. * Sets the ShadowLight direction toward the passed target.
  86333. * @param target The point to target in local space
  86334. * @returns the updated ShadowLight direction
  86335. */
  86336. setDirectionToTarget(target: Vector3): Vector3;
  86337. /**
  86338. * Returns the light rotation in euler definition.
  86339. * @returns the x y z rotation in local space.
  86340. */
  86341. getRotation(): Vector3;
  86342. /**
  86343. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  86344. * @returns true if a cube texture needs to be use
  86345. */
  86346. needCube(): boolean;
  86347. /**
  86348. * Detects if the projection matrix requires to be recomputed this frame.
  86349. * @returns true if it requires to be recomputed otherwise, false.
  86350. */
  86351. needProjectionMatrixCompute(): boolean;
  86352. /**
  86353. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  86354. */
  86355. forceProjectionMatrixCompute(): void;
  86356. /** @hidden */
  86357. _initCache(): void;
  86358. /** @hidden */
  86359. _isSynchronized(): boolean;
  86360. /**
  86361. * Computes the world matrix of the node
  86362. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  86363. * @returns the world matrix
  86364. */
  86365. computeWorldMatrix(force?: boolean): Matrix;
  86366. /**
  86367. * Gets the minZ used for shadow according to both the scene and the light.
  86368. * @param activeCamera The camera we are returning the min for
  86369. * @returns the depth min z
  86370. */
  86371. getDepthMinZ(activeCamera: Camera): number;
  86372. /**
  86373. * Gets the maxZ used for shadow according to both the scene and the light.
  86374. * @param activeCamera The camera we are returning the max for
  86375. * @returns the depth max z
  86376. */
  86377. getDepthMaxZ(activeCamera: Camera): number;
  86378. /**
  86379. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  86380. * @param matrix The materix to updated with the projection information
  86381. * @param viewMatrix The transform matrix of the light
  86382. * @param renderList The list of mesh to render in the map
  86383. * @returns The current light
  86384. */
  86385. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  86386. }
  86387. }
  86388. declare module BABYLON {
  86389. /** @hidden */
  86390. export var packingFunctions: {
  86391. name: string;
  86392. shader: string;
  86393. };
  86394. }
  86395. declare module BABYLON {
  86396. /** @hidden */
  86397. export var bayerDitherFunctions: {
  86398. name: string;
  86399. shader: string;
  86400. };
  86401. }
  86402. declare module BABYLON {
  86403. /** @hidden */
  86404. export var shadowMapFragmentDeclaration: {
  86405. name: string;
  86406. shader: string;
  86407. };
  86408. }
  86409. declare module BABYLON {
  86410. /** @hidden */
  86411. export var clipPlaneFragmentDeclaration: {
  86412. name: string;
  86413. shader: string;
  86414. };
  86415. }
  86416. declare module BABYLON {
  86417. /** @hidden */
  86418. export var clipPlaneFragment: {
  86419. name: string;
  86420. shader: string;
  86421. };
  86422. }
  86423. declare module BABYLON {
  86424. /** @hidden */
  86425. export var shadowMapFragment: {
  86426. name: string;
  86427. shader: string;
  86428. };
  86429. }
  86430. declare module BABYLON {
  86431. /** @hidden */
  86432. export var shadowMapPixelShader: {
  86433. name: string;
  86434. shader: string;
  86435. };
  86436. }
  86437. declare module BABYLON {
  86438. /** @hidden */
  86439. export var bonesDeclaration: {
  86440. name: string;
  86441. shader: string;
  86442. };
  86443. }
  86444. declare module BABYLON {
  86445. /** @hidden */
  86446. export var morphTargetsVertexGlobalDeclaration: {
  86447. name: string;
  86448. shader: string;
  86449. };
  86450. }
  86451. declare module BABYLON {
  86452. /** @hidden */
  86453. export var morphTargetsVertexDeclaration: {
  86454. name: string;
  86455. shader: string;
  86456. };
  86457. }
  86458. declare module BABYLON {
  86459. /** @hidden */
  86460. export var instancesDeclaration: {
  86461. name: string;
  86462. shader: string;
  86463. };
  86464. }
  86465. declare module BABYLON {
  86466. /** @hidden */
  86467. export var helperFunctions: {
  86468. name: string;
  86469. shader: string;
  86470. };
  86471. }
  86472. declare module BABYLON {
  86473. /** @hidden */
  86474. export var shadowMapVertexDeclaration: {
  86475. name: string;
  86476. shader: string;
  86477. };
  86478. }
  86479. declare module BABYLON {
  86480. /** @hidden */
  86481. export var clipPlaneVertexDeclaration: {
  86482. name: string;
  86483. shader: string;
  86484. };
  86485. }
  86486. declare module BABYLON {
  86487. /** @hidden */
  86488. export var morphTargetsVertex: {
  86489. name: string;
  86490. shader: string;
  86491. };
  86492. }
  86493. declare module BABYLON {
  86494. /** @hidden */
  86495. export var instancesVertex: {
  86496. name: string;
  86497. shader: string;
  86498. };
  86499. }
  86500. declare module BABYLON {
  86501. /** @hidden */
  86502. export var bonesVertex: {
  86503. name: string;
  86504. shader: string;
  86505. };
  86506. }
  86507. declare module BABYLON {
  86508. /** @hidden */
  86509. export var shadowMapVertexNormalBias: {
  86510. name: string;
  86511. shader: string;
  86512. };
  86513. }
  86514. declare module BABYLON {
  86515. /** @hidden */
  86516. export var shadowMapVertexMetric: {
  86517. name: string;
  86518. shader: string;
  86519. };
  86520. }
  86521. declare module BABYLON {
  86522. /** @hidden */
  86523. export var clipPlaneVertex: {
  86524. name: string;
  86525. shader: string;
  86526. };
  86527. }
  86528. declare module BABYLON {
  86529. /** @hidden */
  86530. export var shadowMapVertexShader: {
  86531. name: string;
  86532. shader: string;
  86533. };
  86534. }
  86535. declare module BABYLON {
  86536. /** @hidden */
  86537. export var depthBoxBlurPixelShader: {
  86538. name: string;
  86539. shader: string;
  86540. };
  86541. }
  86542. declare module BABYLON {
  86543. /** @hidden */
  86544. export var shadowMapFragmentSoftTransparentShadow: {
  86545. name: string;
  86546. shader: string;
  86547. };
  86548. }
  86549. declare module BABYLON {
  86550. /**
  86551. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  86552. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  86553. */
  86554. export class EffectFallbacks implements IEffectFallbacks {
  86555. private _defines;
  86556. private _currentRank;
  86557. private _maxRank;
  86558. private _mesh;
  86559. /**
  86560. * Removes the fallback from the bound mesh.
  86561. */
  86562. unBindMesh(): void;
  86563. /**
  86564. * Adds a fallback on the specified property.
  86565. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86566. * @param define The name of the define in the shader
  86567. */
  86568. addFallback(rank: number, define: string): void;
  86569. /**
  86570. * Sets the mesh to use CPU skinning when needing to fallback.
  86571. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86572. * @param mesh The mesh to use the fallbacks.
  86573. */
  86574. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  86575. /**
  86576. * Checks to see if more fallbacks are still availible.
  86577. */
  86578. get hasMoreFallbacks(): boolean;
  86579. /**
  86580. * Removes the defines that should be removed when falling back.
  86581. * @param currentDefines defines the current define statements for the shader.
  86582. * @param effect defines the current effect we try to compile
  86583. * @returns The resulting defines with defines of the current rank removed.
  86584. */
  86585. reduce(currentDefines: string, effect: Effect): string;
  86586. }
  86587. }
  86588. declare module BABYLON {
  86589. /**
  86590. * Interface used to define Action
  86591. */
  86592. export interface IAction {
  86593. /**
  86594. * Trigger for the action
  86595. */
  86596. trigger: number;
  86597. /** Options of the trigger */
  86598. triggerOptions: any;
  86599. /**
  86600. * Gets the trigger parameters
  86601. * @returns the trigger parameters
  86602. */
  86603. getTriggerParameter(): any;
  86604. /**
  86605. * Internal only - executes current action event
  86606. * @hidden
  86607. */
  86608. _executeCurrent(evt?: ActionEvent): void;
  86609. /**
  86610. * Serialize placeholder for child classes
  86611. * @param parent of child
  86612. * @returns the serialized object
  86613. */
  86614. serialize(parent: any): any;
  86615. /**
  86616. * Internal only
  86617. * @hidden
  86618. */
  86619. _prepare(): void;
  86620. /**
  86621. * Internal only - manager for action
  86622. * @hidden
  86623. */
  86624. _actionManager: AbstractActionManager;
  86625. /**
  86626. * Adds action to chain of actions, may be a DoNothingAction
  86627. * @param action defines the next action to execute
  86628. * @returns The action passed in
  86629. * @see https://www.babylonjs-playground.com/#1T30HR#0
  86630. */
  86631. then(action: IAction): IAction;
  86632. }
  86633. /**
  86634. * The action to be carried out following a trigger
  86635. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  86636. */
  86637. export class Action implements IAction {
  86638. /** the trigger, with or without parameters, for the action */
  86639. triggerOptions: any;
  86640. /**
  86641. * Trigger for the action
  86642. */
  86643. trigger: number;
  86644. /**
  86645. * Internal only - manager for action
  86646. * @hidden
  86647. */
  86648. _actionManager: ActionManager;
  86649. private _nextActiveAction;
  86650. private _child;
  86651. private _condition?;
  86652. private _triggerParameter;
  86653. /**
  86654. * An event triggered prior to action being executed.
  86655. */
  86656. onBeforeExecuteObservable: Observable<Action>;
  86657. /**
  86658. * Creates a new Action
  86659. * @param triggerOptions the trigger, with or without parameters, for the action
  86660. * @param condition an optional determinant of action
  86661. */
  86662. constructor(
  86663. /** the trigger, with or without parameters, for the action */
  86664. triggerOptions: any, condition?: Condition);
  86665. /**
  86666. * Internal only
  86667. * @hidden
  86668. */
  86669. _prepare(): void;
  86670. /**
  86671. * Gets the trigger parameters
  86672. * @returns the trigger parameters
  86673. */
  86674. getTriggerParameter(): any;
  86675. /**
  86676. * Internal only - executes current action event
  86677. * @hidden
  86678. */
  86679. _executeCurrent(evt?: ActionEvent): void;
  86680. /**
  86681. * Execute placeholder for child classes
  86682. * @param evt optional action event
  86683. */
  86684. execute(evt?: ActionEvent): void;
  86685. /**
  86686. * Skips to next active action
  86687. */
  86688. skipToNextActiveAction(): void;
  86689. /**
  86690. * Adds action to chain of actions, may be a DoNothingAction
  86691. * @param action defines the next action to execute
  86692. * @returns The action passed in
  86693. * @see https://www.babylonjs-playground.com/#1T30HR#0
  86694. */
  86695. then(action: Action): Action;
  86696. /**
  86697. * Internal only
  86698. * @hidden
  86699. */
  86700. _getProperty(propertyPath: string): string;
  86701. /**
  86702. * Internal only
  86703. * @hidden
  86704. */
  86705. _getEffectiveTarget(target: any, propertyPath: string): any;
  86706. /**
  86707. * Serialize placeholder for child classes
  86708. * @param parent of child
  86709. * @returns the serialized object
  86710. */
  86711. serialize(parent: any): any;
  86712. /**
  86713. * Internal only called by serialize
  86714. * @hidden
  86715. */
  86716. protected _serialize(serializedAction: any, parent?: any): any;
  86717. /**
  86718. * Internal only
  86719. * @hidden
  86720. */
  86721. static _SerializeValueAsString: (value: any) => string;
  86722. /**
  86723. * Internal only
  86724. * @hidden
  86725. */
  86726. static _GetTargetProperty: (target: Node | Scene) => {
  86727. name: string;
  86728. targetType: string;
  86729. value: string;
  86730. };
  86731. }
  86732. }
  86733. declare module BABYLON {
  86734. /**
  86735. * A Condition applied to an Action
  86736. */
  86737. export class Condition {
  86738. /**
  86739. * Internal only - manager for action
  86740. * @hidden
  86741. */
  86742. _actionManager: ActionManager;
  86743. /**
  86744. * Internal only
  86745. * @hidden
  86746. */
  86747. _evaluationId: number;
  86748. /**
  86749. * Internal only
  86750. * @hidden
  86751. */
  86752. _currentResult: boolean;
  86753. /**
  86754. * Creates a new Condition
  86755. * @param actionManager the manager of the action the condition is applied to
  86756. */
  86757. constructor(actionManager: ActionManager);
  86758. /**
  86759. * Check if the current condition is valid
  86760. * @returns a boolean
  86761. */
  86762. isValid(): boolean;
  86763. /**
  86764. * Internal only
  86765. * @hidden
  86766. */
  86767. _getProperty(propertyPath: string): string;
  86768. /**
  86769. * Internal only
  86770. * @hidden
  86771. */
  86772. _getEffectiveTarget(target: any, propertyPath: string): any;
  86773. /**
  86774. * Serialize placeholder for child classes
  86775. * @returns the serialized object
  86776. */
  86777. serialize(): any;
  86778. /**
  86779. * Internal only
  86780. * @hidden
  86781. */
  86782. protected _serialize(serializedCondition: any): any;
  86783. }
  86784. /**
  86785. * Defines specific conditional operators as extensions of Condition
  86786. */
  86787. export class ValueCondition extends Condition {
  86788. /** path to specify the property of the target the conditional operator uses */
  86789. propertyPath: string;
  86790. /** the value compared by the conditional operator against the current value of the property */
  86791. value: any;
  86792. /** the conditional operator, default ValueCondition.IsEqual */
  86793. operator: number;
  86794. /**
  86795. * Internal only
  86796. * @hidden
  86797. */
  86798. private static _IsEqual;
  86799. /**
  86800. * Internal only
  86801. * @hidden
  86802. */
  86803. private static _IsDifferent;
  86804. /**
  86805. * Internal only
  86806. * @hidden
  86807. */
  86808. private static _IsGreater;
  86809. /**
  86810. * Internal only
  86811. * @hidden
  86812. */
  86813. private static _IsLesser;
  86814. /**
  86815. * returns the number for IsEqual
  86816. */
  86817. static get IsEqual(): number;
  86818. /**
  86819. * Returns the number for IsDifferent
  86820. */
  86821. static get IsDifferent(): number;
  86822. /**
  86823. * Returns the number for IsGreater
  86824. */
  86825. static get IsGreater(): number;
  86826. /**
  86827. * Returns the number for IsLesser
  86828. */
  86829. static get IsLesser(): number;
  86830. /**
  86831. * Internal only The action manager for the condition
  86832. * @hidden
  86833. */
  86834. _actionManager: ActionManager;
  86835. /**
  86836. * Internal only
  86837. * @hidden
  86838. */
  86839. private _target;
  86840. /**
  86841. * Internal only
  86842. * @hidden
  86843. */
  86844. private _effectiveTarget;
  86845. /**
  86846. * Internal only
  86847. * @hidden
  86848. */
  86849. private _property;
  86850. /**
  86851. * Creates a new ValueCondition
  86852. * @param actionManager manager for the action the condition applies to
  86853. * @param target for the action
  86854. * @param propertyPath path to specify the property of the target the conditional operator uses
  86855. * @param value the value compared by the conditional operator against the current value of the property
  86856. * @param operator the conditional operator, default ValueCondition.IsEqual
  86857. */
  86858. constructor(actionManager: ActionManager, target: any,
  86859. /** path to specify the property of the target the conditional operator uses */
  86860. propertyPath: string,
  86861. /** the value compared by the conditional operator against the current value of the property */
  86862. value: any,
  86863. /** the conditional operator, default ValueCondition.IsEqual */
  86864. operator?: number);
  86865. /**
  86866. * Compares the given value with the property value for the specified conditional operator
  86867. * @returns the result of the comparison
  86868. */
  86869. isValid(): boolean;
  86870. /**
  86871. * Serialize the ValueCondition into a JSON compatible object
  86872. * @returns serialization object
  86873. */
  86874. serialize(): any;
  86875. /**
  86876. * Gets the name of the conditional operator for the ValueCondition
  86877. * @param operator the conditional operator
  86878. * @returns the name
  86879. */
  86880. static GetOperatorName(operator: number): string;
  86881. }
  86882. /**
  86883. * Defines a predicate condition as an extension of Condition
  86884. */
  86885. export class PredicateCondition extends Condition {
  86886. /** defines the predicate function used to validate the condition */
  86887. predicate: () => boolean;
  86888. /**
  86889. * Internal only - manager for action
  86890. * @hidden
  86891. */
  86892. _actionManager: ActionManager;
  86893. /**
  86894. * Creates a new PredicateCondition
  86895. * @param actionManager manager for the action the condition applies to
  86896. * @param predicate defines the predicate function used to validate the condition
  86897. */
  86898. constructor(actionManager: ActionManager,
  86899. /** defines the predicate function used to validate the condition */
  86900. predicate: () => boolean);
  86901. /**
  86902. * @returns the validity of the predicate condition
  86903. */
  86904. isValid(): boolean;
  86905. }
  86906. /**
  86907. * Defines a state condition as an extension of Condition
  86908. */
  86909. export class StateCondition extends Condition {
  86910. /** Value to compare with target state */
  86911. value: string;
  86912. /**
  86913. * Internal only - manager for action
  86914. * @hidden
  86915. */
  86916. _actionManager: ActionManager;
  86917. /**
  86918. * Internal only
  86919. * @hidden
  86920. */
  86921. private _target;
  86922. /**
  86923. * Creates a new StateCondition
  86924. * @param actionManager manager for the action the condition applies to
  86925. * @param target of the condition
  86926. * @param value to compare with target state
  86927. */
  86928. constructor(actionManager: ActionManager, target: any,
  86929. /** Value to compare with target state */
  86930. value: string);
  86931. /**
  86932. * Gets a boolean indicating if the current condition is met
  86933. * @returns the validity of the state
  86934. */
  86935. isValid(): boolean;
  86936. /**
  86937. * Serialize the StateCondition into a JSON compatible object
  86938. * @returns serialization object
  86939. */
  86940. serialize(): any;
  86941. }
  86942. }
  86943. declare module BABYLON {
  86944. /**
  86945. * This defines an action responsible to toggle a boolean once triggered.
  86946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86947. */
  86948. export class SwitchBooleanAction extends Action {
  86949. /**
  86950. * The path to the boolean property in the target object
  86951. */
  86952. propertyPath: string;
  86953. private _target;
  86954. private _effectiveTarget;
  86955. private _property;
  86956. /**
  86957. * Instantiate the action
  86958. * @param triggerOptions defines the trigger options
  86959. * @param target defines the object containing the boolean
  86960. * @param propertyPath defines the path to the boolean property in the target object
  86961. * @param condition defines the trigger related conditions
  86962. */
  86963. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  86964. /** @hidden */
  86965. _prepare(): void;
  86966. /**
  86967. * Execute the action toggle the boolean value.
  86968. */
  86969. execute(): void;
  86970. /**
  86971. * Serializes the actions and its related information.
  86972. * @param parent defines the object to serialize in
  86973. * @returns the serialized object
  86974. */
  86975. serialize(parent: any): any;
  86976. }
  86977. /**
  86978. * This defines an action responsible to set a the state field of the target
  86979. * to a desired value once triggered.
  86980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86981. */
  86982. export class SetStateAction extends Action {
  86983. /**
  86984. * The value to store in the state field.
  86985. */
  86986. value: string;
  86987. private _target;
  86988. /**
  86989. * Instantiate the action
  86990. * @param triggerOptions defines the trigger options
  86991. * @param target defines the object containing the state property
  86992. * @param value defines the value to store in the state field
  86993. * @param condition defines the trigger related conditions
  86994. */
  86995. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  86996. /**
  86997. * Execute the action and store the value on the target state property.
  86998. */
  86999. execute(): void;
  87000. /**
  87001. * Serializes the actions and its related information.
  87002. * @param parent defines the object to serialize in
  87003. * @returns the serialized object
  87004. */
  87005. serialize(parent: any): any;
  87006. }
  87007. /**
  87008. * This defines an action responsible to set a property of the target
  87009. * to a desired value once triggered.
  87010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87011. */
  87012. export class SetValueAction extends Action {
  87013. /**
  87014. * The path of the property to set in the target.
  87015. */
  87016. propertyPath: string;
  87017. /**
  87018. * The value to set in the property
  87019. */
  87020. value: any;
  87021. private _target;
  87022. private _effectiveTarget;
  87023. private _property;
  87024. /**
  87025. * Instantiate the action
  87026. * @param triggerOptions defines the trigger options
  87027. * @param target defines the object containing the property
  87028. * @param propertyPath defines the path of the property to set in the target
  87029. * @param value defines the value to set in the property
  87030. * @param condition defines the trigger related conditions
  87031. */
  87032. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  87033. /** @hidden */
  87034. _prepare(): void;
  87035. /**
  87036. * Execute the action and set the targetted property to the desired value.
  87037. */
  87038. execute(): void;
  87039. /**
  87040. * Serializes the actions and its related information.
  87041. * @param parent defines the object to serialize in
  87042. * @returns the serialized object
  87043. */
  87044. serialize(parent: any): any;
  87045. }
  87046. /**
  87047. * This defines an action responsible to increment the target value
  87048. * to a desired value once triggered.
  87049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87050. */
  87051. export class IncrementValueAction extends Action {
  87052. /**
  87053. * The path of the property to increment in the target.
  87054. */
  87055. propertyPath: string;
  87056. /**
  87057. * The value we should increment the property by.
  87058. */
  87059. value: any;
  87060. private _target;
  87061. private _effectiveTarget;
  87062. private _property;
  87063. /**
  87064. * Instantiate the action
  87065. * @param triggerOptions defines the trigger options
  87066. * @param target defines the object containing the property
  87067. * @param propertyPath defines the path of the property to increment in the target
  87068. * @param value defines the value value we should increment the property by
  87069. * @param condition defines the trigger related conditions
  87070. */
  87071. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  87072. /** @hidden */
  87073. _prepare(): void;
  87074. /**
  87075. * Execute the action and increment the target of the value amount.
  87076. */
  87077. execute(): void;
  87078. /**
  87079. * Serializes the actions and its related information.
  87080. * @param parent defines the object to serialize in
  87081. * @returns the serialized object
  87082. */
  87083. serialize(parent: any): any;
  87084. }
  87085. /**
  87086. * This defines an action responsible to start an animation once triggered.
  87087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87088. */
  87089. export class PlayAnimationAction extends Action {
  87090. /**
  87091. * Where the animation should start (animation frame)
  87092. */
  87093. from: number;
  87094. /**
  87095. * Where the animation should stop (animation frame)
  87096. */
  87097. to: number;
  87098. /**
  87099. * Define if the animation should loop or stop after the first play.
  87100. */
  87101. loop?: boolean;
  87102. private _target;
  87103. /**
  87104. * Instantiate the action
  87105. * @param triggerOptions defines the trigger options
  87106. * @param target defines the target animation or animation name
  87107. * @param from defines from where the animation should start (animation frame)
  87108. * @param end defines where the animation should stop (animation frame)
  87109. * @param loop defines if the animation should loop or stop after the first play
  87110. * @param condition defines the trigger related conditions
  87111. */
  87112. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  87113. /** @hidden */
  87114. _prepare(): void;
  87115. /**
  87116. * Execute the action and play the animation.
  87117. */
  87118. execute(): void;
  87119. /**
  87120. * Serializes the actions and its related information.
  87121. * @param parent defines the object to serialize in
  87122. * @returns the serialized object
  87123. */
  87124. serialize(parent: any): any;
  87125. }
  87126. /**
  87127. * This defines an action responsible to stop an animation once triggered.
  87128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87129. */
  87130. export class StopAnimationAction extends Action {
  87131. private _target;
  87132. /**
  87133. * Instantiate the action
  87134. * @param triggerOptions defines the trigger options
  87135. * @param target defines the target animation or animation name
  87136. * @param condition defines the trigger related conditions
  87137. */
  87138. constructor(triggerOptions: any, target: any, condition?: Condition);
  87139. /** @hidden */
  87140. _prepare(): void;
  87141. /**
  87142. * Execute the action and stop the animation.
  87143. */
  87144. execute(): void;
  87145. /**
  87146. * Serializes the actions and its related information.
  87147. * @param parent defines the object to serialize in
  87148. * @returns the serialized object
  87149. */
  87150. serialize(parent: any): any;
  87151. }
  87152. /**
  87153. * This defines an action responsible that does nothing once triggered.
  87154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87155. */
  87156. export class DoNothingAction extends Action {
  87157. /**
  87158. * Instantiate the action
  87159. * @param triggerOptions defines the trigger options
  87160. * @param condition defines the trigger related conditions
  87161. */
  87162. constructor(triggerOptions?: any, condition?: Condition);
  87163. /**
  87164. * Execute the action and do nothing.
  87165. */
  87166. execute(): void;
  87167. /**
  87168. * Serializes the actions and its related information.
  87169. * @param parent defines the object to serialize in
  87170. * @returns the serialized object
  87171. */
  87172. serialize(parent: any): any;
  87173. }
  87174. /**
  87175. * This defines an action responsible to trigger several actions once triggered.
  87176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87177. */
  87178. export class CombineAction extends Action {
  87179. /**
  87180. * The list of aggregated animations to run.
  87181. */
  87182. children: Action[];
  87183. /**
  87184. * Instantiate the action
  87185. * @param triggerOptions defines the trigger options
  87186. * @param children defines the list of aggregated animations to run
  87187. * @param condition defines the trigger related conditions
  87188. */
  87189. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  87190. /** @hidden */
  87191. _prepare(): void;
  87192. /**
  87193. * Execute the action and executes all the aggregated actions.
  87194. */
  87195. execute(evt: ActionEvent): void;
  87196. /**
  87197. * Serializes the actions and its related information.
  87198. * @param parent defines the object to serialize in
  87199. * @returns the serialized object
  87200. */
  87201. serialize(parent: any): any;
  87202. }
  87203. /**
  87204. * This defines an action responsible to run code (external event) once triggered.
  87205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87206. */
  87207. export class ExecuteCodeAction extends Action {
  87208. /**
  87209. * The callback function to run.
  87210. */
  87211. func: (evt: ActionEvent) => void;
  87212. /**
  87213. * Instantiate the action
  87214. * @param triggerOptions defines the trigger options
  87215. * @param func defines the callback function to run
  87216. * @param condition defines the trigger related conditions
  87217. */
  87218. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  87219. /**
  87220. * Execute the action and run the attached code.
  87221. */
  87222. execute(evt: ActionEvent): void;
  87223. }
  87224. /**
  87225. * This defines an action responsible to set the parent property of the target once triggered.
  87226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87227. */
  87228. export class SetParentAction extends Action {
  87229. private _parent;
  87230. private _target;
  87231. /**
  87232. * Instantiate the action
  87233. * @param triggerOptions defines the trigger options
  87234. * @param target defines the target containing the parent property
  87235. * @param parent defines from where the animation should start (animation frame)
  87236. * @param condition defines the trigger related conditions
  87237. */
  87238. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  87239. /** @hidden */
  87240. _prepare(): void;
  87241. /**
  87242. * Execute the action and set the parent property.
  87243. */
  87244. execute(): void;
  87245. /**
  87246. * Serializes the actions and its related information.
  87247. * @param parent defines the object to serialize in
  87248. * @returns the serialized object
  87249. */
  87250. serialize(parent: any): any;
  87251. }
  87252. }
  87253. declare module BABYLON {
  87254. /**
  87255. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  87256. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  87257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87258. */
  87259. export class ActionManager extends AbstractActionManager {
  87260. /**
  87261. * Nothing
  87262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87263. */
  87264. static readonly NothingTrigger: number;
  87265. /**
  87266. * On pick
  87267. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87268. */
  87269. static readonly OnPickTrigger: number;
  87270. /**
  87271. * On left pick
  87272. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87273. */
  87274. static readonly OnLeftPickTrigger: number;
  87275. /**
  87276. * On right pick
  87277. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87278. */
  87279. static readonly OnRightPickTrigger: number;
  87280. /**
  87281. * On center pick
  87282. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87283. */
  87284. static readonly OnCenterPickTrigger: number;
  87285. /**
  87286. * On pick down
  87287. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87288. */
  87289. static readonly OnPickDownTrigger: number;
  87290. /**
  87291. * On double pick
  87292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87293. */
  87294. static readonly OnDoublePickTrigger: number;
  87295. /**
  87296. * On pick up
  87297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87298. */
  87299. static readonly OnPickUpTrigger: number;
  87300. /**
  87301. * On pick out.
  87302. * This trigger will only be raised if you also declared a OnPickDown
  87303. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87304. */
  87305. static readonly OnPickOutTrigger: number;
  87306. /**
  87307. * On long press
  87308. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87309. */
  87310. static readonly OnLongPressTrigger: number;
  87311. /**
  87312. * On pointer over
  87313. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87314. */
  87315. static readonly OnPointerOverTrigger: number;
  87316. /**
  87317. * On pointer out
  87318. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87319. */
  87320. static readonly OnPointerOutTrigger: number;
  87321. /**
  87322. * On every frame
  87323. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87324. */
  87325. static readonly OnEveryFrameTrigger: number;
  87326. /**
  87327. * On intersection enter
  87328. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87329. */
  87330. static readonly OnIntersectionEnterTrigger: number;
  87331. /**
  87332. * On intersection exit
  87333. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87334. */
  87335. static readonly OnIntersectionExitTrigger: number;
  87336. /**
  87337. * On key down
  87338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87339. */
  87340. static readonly OnKeyDownTrigger: number;
  87341. /**
  87342. * On key up
  87343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87344. */
  87345. static readonly OnKeyUpTrigger: number;
  87346. private _scene;
  87347. /**
  87348. * Creates a new action manager
  87349. * @param scene defines the hosting scene
  87350. */
  87351. constructor(scene: Scene);
  87352. /**
  87353. * Releases all associated resources
  87354. */
  87355. dispose(): void;
  87356. /**
  87357. * Gets hosting scene
  87358. * @returns the hosting scene
  87359. */
  87360. getScene(): Scene;
  87361. /**
  87362. * Does this action manager handles actions of any of the given triggers
  87363. * @param triggers defines the triggers to be tested
  87364. * @return a boolean indicating whether one (or more) of the triggers is handled
  87365. */
  87366. hasSpecificTriggers(triggers: number[]): boolean;
  87367. /**
  87368. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  87369. * speed.
  87370. * @param triggerA defines the trigger to be tested
  87371. * @param triggerB defines the trigger to be tested
  87372. * @return a boolean indicating whether one (or more) of the triggers is handled
  87373. */
  87374. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  87375. /**
  87376. * Does this action manager handles actions of a given trigger
  87377. * @param trigger defines the trigger to be tested
  87378. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  87379. * @return whether the trigger is handled
  87380. */
  87381. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  87382. /**
  87383. * Does this action manager has pointer triggers
  87384. */
  87385. get hasPointerTriggers(): boolean;
  87386. /**
  87387. * Does this action manager has pick triggers
  87388. */
  87389. get hasPickTriggers(): boolean;
  87390. /**
  87391. * Registers an action to this action manager
  87392. * @param action defines the action to be registered
  87393. * @return the action amended (prepared) after registration
  87394. */
  87395. registerAction(action: IAction): Nullable<IAction>;
  87396. /**
  87397. * Unregisters an action to this action manager
  87398. * @param action defines the action to be unregistered
  87399. * @return a boolean indicating whether the action has been unregistered
  87400. */
  87401. unregisterAction(action: IAction): Boolean;
  87402. /**
  87403. * Process a specific trigger
  87404. * @param trigger defines the trigger to process
  87405. * @param evt defines the event details to be processed
  87406. */
  87407. processTrigger(trigger: number, evt?: IActionEvent): void;
  87408. /** @hidden */
  87409. _getEffectiveTarget(target: any, propertyPath: string): any;
  87410. /** @hidden */
  87411. _getProperty(propertyPath: string): string;
  87412. /**
  87413. * Serialize this manager to a JSON object
  87414. * @param name defines the property name to store this manager
  87415. * @returns a JSON representation of this manager
  87416. */
  87417. serialize(name: string): any;
  87418. /**
  87419. * Creates a new ActionManager from a JSON data
  87420. * @param parsedActions defines the JSON data to read from
  87421. * @param object defines the hosting mesh
  87422. * @param scene defines the hosting scene
  87423. */
  87424. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  87425. /**
  87426. * Get a trigger name by index
  87427. * @param trigger defines the trigger index
  87428. * @returns a trigger name
  87429. */
  87430. static GetTriggerName(trigger: number): string;
  87431. }
  87432. }
  87433. declare module BABYLON {
  87434. /**
  87435. * Class used to represent a sprite
  87436. * @see http://doc.babylonjs.com/babylon101/sprites
  87437. */
  87438. export class Sprite implements IAnimatable {
  87439. /** defines the name */
  87440. name: string;
  87441. /** Gets or sets the current world position */
  87442. position: Vector3;
  87443. /** Gets or sets the main color */
  87444. color: Color4;
  87445. /** Gets or sets the width */
  87446. width: number;
  87447. /** Gets or sets the height */
  87448. height: number;
  87449. /** Gets or sets rotation angle */
  87450. angle: number;
  87451. /** Gets or sets the cell index in the sprite sheet */
  87452. cellIndex: number;
  87453. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  87454. cellRef: string;
  87455. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  87456. invertU: boolean;
  87457. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  87458. invertV: boolean;
  87459. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  87460. disposeWhenFinishedAnimating: boolean;
  87461. /** Gets the list of attached animations */
  87462. animations: Nullable<Array<Animation>>;
  87463. /** Gets or sets a boolean indicating if the sprite can be picked */
  87464. isPickable: boolean;
  87465. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  87466. useAlphaForPicking: boolean;
  87467. /** @hidden */
  87468. _xOffset: number;
  87469. /** @hidden */
  87470. _yOffset: number;
  87471. /** @hidden */
  87472. _xSize: number;
  87473. /** @hidden */
  87474. _ySize: number;
  87475. /**
  87476. * Gets or sets the associated action manager
  87477. */
  87478. actionManager: Nullable<ActionManager>;
  87479. /**
  87480. * An event triggered when the control has been disposed
  87481. */
  87482. onDisposeObservable: Observable<Sprite>;
  87483. private _animationStarted;
  87484. private _loopAnimation;
  87485. private _fromIndex;
  87486. private _toIndex;
  87487. private _delay;
  87488. private _direction;
  87489. private _manager;
  87490. private _time;
  87491. private _onAnimationEnd;
  87492. /**
  87493. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  87494. */
  87495. isVisible: boolean;
  87496. /**
  87497. * Gets or sets the sprite size
  87498. */
  87499. get size(): number;
  87500. set size(value: number);
  87501. /**
  87502. * Returns a boolean indicating if the animation is started
  87503. */
  87504. get animationStarted(): boolean;
  87505. /**
  87506. * Gets or sets the unique id of the sprite
  87507. */
  87508. uniqueId: number;
  87509. /**
  87510. * Gets the manager of this sprite
  87511. */
  87512. get manager(): ISpriteManager;
  87513. /**
  87514. * Creates a new Sprite
  87515. * @param name defines the name
  87516. * @param manager defines the manager
  87517. */
  87518. constructor(
  87519. /** defines the name */
  87520. name: string, manager: ISpriteManager);
  87521. /**
  87522. * Returns the string "Sprite"
  87523. * @returns "Sprite"
  87524. */
  87525. getClassName(): string;
  87526. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  87527. get fromIndex(): number;
  87528. set fromIndex(value: number);
  87529. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  87530. get toIndex(): number;
  87531. set toIndex(value: number);
  87532. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  87533. get loopAnimation(): boolean;
  87534. set loopAnimation(value: boolean);
  87535. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  87536. get delay(): number;
  87537. set delay(value: number);
  87538. /**
  87539. * Starts an animation
  87540. * @param from defines the initial key
  87541. * @param to defines the end key
  87542. * @param loop defines if the animation must loop
  87543. * @param delay defines the start delay (in ms)
  87544. * @param onAnimationEnd defines a callback to call when animation ends
  87545. */
  87546. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  87547. /** Stops current animation (if any) */
  87548. stopAnimation(): void;
  87549. /** @hidden */
  87550. _animate(deltaTime: number): void;
  87551. /** Release associated resources */
  87552. dispose(): void;
  87553. /**
  87554. * Serializes the sprite to a JSON object
  87555. * @returns the JSON object
  87556. */
  87557. serialize(): any;
  87558. /**
  87559. * Parses a JSON object to create a new sprite
  87560. * @param parsedSprite The JSON object to parse
  87561. * @param manager defines the hosting manager
  87562. * @returns the new sprite
  87563. */
  87564. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  87565. }
  87566. }
  87567. declare module BABYLON {
  87568. /**
  87569. * Information about the result of picking within a scene
  87570. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  87571. */
  87572. export class PickingInfo {
  87573. /** @hidden */
  87574. _pickingUnavailable: boolean;
  87575. /**
  87576. * If the pick collided with an object
  87577. */
  87578. hit: boolean;
  87579. /**
  87580. * Distance away where the pick collided
  87581. */
  87582. distance: number;
  87583. /**
  87584. * The location of pick collision
  87585. */
  87586. pickedPoint: Nullable<Vector3>;
  87587. /**
  87588. * The mesh corresponding the the pick collision
  87589. */
  87590. pickedMesh: Nullable<AbstractMesh>;
  87591. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  87592. bu: number;
  87593. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  87594. bv: number;
  87595. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  87596. faceId: number;
  87597. /** Id of the the submesh that was picked */
  87598. subMeshId: number;
  87599. /** If a sprite was picked, this will be the sprite the pick collided with */
  87600. pickedSprite: Nullable<Sprite>;
  87601. /**
  87602. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  87603. */
  87604. originMesh: Nullable<AbstractMesh>;
  87605. /**
  87606. * The ray that was used to perform the picking.
  87607. */
  87608. ray: Nullable<Ray>;
  87609. /**
  87610. * Gets the normal correspodning to the face the pick collided with
  87611. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  87612. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  87613. * @returns The normal correspodning to the face the pick collided with
  87614. */
  87615. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  87616. /**
  87617. * Gets the texture coordinates of where the pick occured
  87618. * @returns the vector containing the coordnates of the texture
  87619. */
  87620. getTextureCoordinates(): Nullable<Vector2>;
  87621. }
  87622. }
  87623. declare module BABYLON {
  87624. /**
  87625. * Class representing a ray with position and direction
  87626. */
  87627. export class Ray {
  87628. /** origin point */
  87629. origin: Vector3;
  87630. /** direction */
  87631. direction: Vector3;
  87632. /** length of the ray */
  87633. length: number;
  87634. private static readonly TmpVector3;
  87635. private _tmpRay;
  87636. /**
  87637. * Creates a new ray
  87638. * @param origin origin point
  87639. * @param direction direction
  87640. * @param length length of the ray
  87641. */
  87642. constructor(
  87643. /** origin point */
  87644. origin: Vector3,
  87645. /** direction */
  87646. direction: Vector3,
  87647. /** length of the ray */
  87648. length?: number);
  87649. /**
  87650. * Checks if the ray intersects a box
  87651. * This does not account for the ray lenght by design to improve perfs.
  87652. * @param minimum bound of the box
  87653. * @param maximum bound of the box
  87654. * @param intersectionTreshold extra extend to be added to the box in all direction
  87655. * @returns if the box was hit
  87656. */
  87657. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  87658. /**
  87659. * Checks if the ray intersects a box
  87660. * This does not account for the ray lenght by design to improve perfs.
  87661. * @param box the bounding box to check
  87662. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  87663. * @returns if the box was hit
  87664. */
  87665. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  87666. /**
  87667. * If the ray hits a sphere
  87668. * @param sphere the bounding sphere to check
  87669. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  87670. * @returns true if it hits the sphere
  87671. */
  87672. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  87673. /**
  87674. * If the ray hits a triange
  87675. * @param vertex0 triangle vertex
  87676. * @param vertex1 triangle vertex
  87677. * @param vertex2 triangle vertex
  87678. * @returns intersection information if hit
  87679. */
  87680. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  87681. /**
  87682. * Checks if ray intersects a plane
  87683. * @param plane the plane to check
  87684. * @returns the distance away it was hit
  87685. */
  87686. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  87687. /**
  87688. * Calculate the intercept of a ray on a given axis
  87689. * @param axis to check 'x' | 'y' | 'z'
  87690. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  87691. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  87692. */
  87693. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  87694. /**
  87695. * Checks if ray intersects a mesh
  87696. * @param mesh the mesh to check
  87697. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87698. * @returns picking info of the intersecton
  87699. */
  87700. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  87701. /**
  87702. * Checks if ray intersects a mesh
  87703. * @param meshes the meshes to check
  87704. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87705. * @param results array to store result in
  87706. * @returns Array of picking infos
  87707. */
  87708. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  87709. private _comparePickingInfo;
  87710. private static smallnum;
  87711. private static rayl;
  87712. /**
  87713. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  87714. * @param sega the first point of the segment to test the intersection against
  87715. * @param segb the second point of the segment to test the intersection against
  87716. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  87717. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  87718. */
  87719. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  87720. /**
  87721. * Update the ray from viewport position
  87722. * @param x position
  87723. * @param y y position
  87724. * @param viewportWidth viewport width
  87725. * @param viewportHeight viewport height
  87726. * @param world world matrix
  87727. * @param view view matrix
  87728. * @param projection projection matrix
  87729. * @returns this ray updated
  87730. */
  87731. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  87732. /**
  87733. * Creates a ray with origin and direction of 0,0,0
  87734. * @returns the new ray
  87735. */
  87736. static Zero(): Ray;
  87737. /**
  87738. * Creates a new ray from screen space and viewport
  87739. * @param x position
  87740. * @param y y position
  87741. * @param viewportWidth viewport width
  87742. * @param viewportHeight viewport height
  87743. * @param world world matrix
  87744. * @param view view matrix
  87745. * @param projection projection matrix
  87746. * @returns new ray
  87747. */
  87748. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  87749. /**
  87750. * 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
  87751. * transformed to the given world matrix.
  87752. * @param origin The origin point
  87753. * @param end The end point
  87754. * @param world a matrix to transform the ray to. Default is the identity matrix.
  87755. * @returns the new ray
  87756. */
  87757. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  87758. /**
  87759. * Transforms a ray by a matrix
  87760. * @param ray ray to transform
  87761. * @param matrix matrix to apply
  87762. * @returns the resulting new ray
  87763. */
  87764. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  87765. /**
  87766. * Transforms a ray by a matrix
  87767. * @param ray ray to transform
  87768. * @param matrix matrix to apply
  87769. * @param result ray to store result in
  87770. */
  87771. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  87772. /**
  87773. * Unproject a ray from screen space to object space
  87774. * @param sourceX defines the screen space x coordinate to use
  87775. * @param sourceY defines the screen space y coordinate to use
  87776. * @param viewportWidth defines the current width of the viewport
  87777. * @param viewportHeight defines the current height of the viewport
  87778. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  87779. * @param view defines the view matrix to use
  87780. * @param projection defines the projection matrix to use
  87781. */
  87782. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  87783. }
  87784. /**
  87785. * Type used to define predicate used to select faces when a mesh intersection is detected
  87786. */
  87787. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  87788. interface Scene {
  87789. /** @hidden */
  87790. _tempPickingRay: Nullable<Ray>;
  87791. /** @hidden */
  87792. _cachedRayForTransform: Ray;
  87793. /** @hidden */
  87794. _pickWithRayInverseMatrix: Matrix;
  87795. /** @hidden */
  87796. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  87797. /** @hidden */
  87798. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  87799. }
  87800. }
  87801. declare module BABYLON {
  87802. /**
  87803. * Groups all the scene component constants in one place to ease maintenance.
  87804. * @hidden
  87805. */
  87806. export class SceneComponentConstants {
  87807. static readonly NAME_EFFECTLAYER: string;
  87808. static readonly NAME_LAYER: string;
  87809. static readonly NAME_LENSFLARESYSTEM: string;
  87810. static readonly NAME_BOUNDINGBOXRENDERER: string;
  87811. static readonly NAME_PARTICLESYSTEM: string;
  87812. static readonly NAME_GAMEPAD: string;
  87813. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  87814. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  87815. static readonly NAME_DEPTHRENDERER: string;
  87816. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  87817. static readonly NAME_SPRITE: string;
  87818. static readonly NAME_OUTLINERENDERER: string;
  87819. static readonly NAME_PROCEDURALTEXTURE: string;
  87820. static readonly NAME_SHADOWGENERATOR: string;
  87821. static readonly NAME_OCTREE: string;
  87822. static readonly NAME_PHYSICSENGINE: string;
  87823. static readonly NAME_AUDIO: string;
  87824. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  87825. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  87826. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  87827. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  87828. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  87829. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  87830. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  87831. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  87832. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  87833. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  87834. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  87835. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  87836. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  87837. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  87838. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  87839. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  87840. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  87841. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  87842. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  87843. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  87844. static readonly STEP_AFTERRENDER_AUDIO: number;
  87845. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  87846. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  87847. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  87848. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  87849. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  87850. static readonly STEP_POINTERMOVE_SPRITE: number;
  87851. static readonly STEP_POINTERDOWN_SPRITE: number;
  87852. static readonly STEP_POINTERUP_SPRITE: number;
  87853. }
  87854. /**
  87855. * This represents a scene component.
  87856. *
  87857. * This is used to decouple the dependency the scene is having on the different workloads like
  87858. * layers, post processes...
  87859. */
  87860. export interface ISceneComponent {
  87861. /**
  87862. * The name of the component. Each component must have a unique name.
  87863. */
  87864. name: string;
  87865. /**
  87866. * The scene the component belongs to.
  87867. */
  87868. scene: Scene;
  87869. /**
  87870. * Register the component to one instance of a scene.
  87871. */
  87872. register(): void;
  87873. /**
  87874. * Rebuilds the elements related to this component in case of
  87875. * context lost for instance.
  87876. */
  87877. rebuild(): void;
  87878. /**
  87879. * Disposes the component and the associated ressources.
  87880. */
  87881. dispose(): void;
  87882. }
  87883. /**
  87884. * This represents a SERIALIZABLE scene component.
  87885. *
  87886. * This extends Scene Component to add Serialization methods on top.
  87887. */
  87888. export interface ISceneSerializableComponent extends ISceneComponent {
  87889. /**
  87890. * Adds all the elements from the container to the scene
  87891. * @param container the container holding the elements
  87892. */
  87893. addFromContainer(container: AbstractScene): void;
  87894. /**
  87895. * Removes all the elements in the container from the scene
  87896. * @param container contains the elements to remove
  87897. * @param dispose if the removed element should be disposed (default: false)
  87898. */
  87899. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  87900. /**
  87901. * Serializes the component data to the specified json object
  87902. * @param serializationObject The object to serialize to
  87903. */
  87904. serialize(serializationObject: any): void;
  87905. }
  87906. /**
  87907. * Strong typing of a Mesh related stage step action
  87908. */
  87909. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  87910. /**
  87911. * Strong typing of a Evaluate Sub Mesh related stage step action
  87912. */
  87913. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  87914. /**
  87915. * Strong typing of a Active Mesh related stage step action
  87916. */
  87917. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  87918. /**
  87919. * Strong typing of a Camera related stage step action
  87920. */
  87921. export type CameraStageAction = (camera: Camera) => void;
  87922. /**
  87923. * Strong typing of a Camera Frame buffer related stage step action
  87924. */
  87925. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  87926. /**
  87927. * Strong typing of a Render Target related stage step action
  87928. */
  87929. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  87930. /**
  87931. * Strong typing of a RenderingGroup related stage step action
  87932. */
  87933. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  87934. /**
  87935. * Strong typing of a Mesh Render related stage step action
  87936. */
  87937. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  87938. /**
  87939. * Strong typing of a simple stage step action
  87940. */
  87941. export type SimpleStageAction = () => void;
  87942. /**
  87943. * Strong typing of a render target action.
  87944. */
  87945. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  87946. /**
  87947. * Strong typing of a pointer move action.
  87948. */
  87949. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  87950. /**
  87951. * Strong typing of a pointer up/down action.
  87952. */
  87953. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  87954. /**
  87955. * Representation of a stage in the scene (Basically a list of ordered steps)
  87956. * @hidden
  87957. */
  87958. export class Stage<T extends Function> extends Array<{
  87959. index: number;
  87960. component: ISceneComponent;
  87961. action: T;
  87962. }> {
  87963. /**
  87964. * Hide ctor from the rest of the world.
  87965. * @param items The items to add.
  87966. */
  87967. private constructor();
  87968. /**
  87969. * Creates a new Stage.
  87970. * @returns A new instance of a Stage
  87971. */
  87972. static Create<T extends Function>(): Stage<T>;
  87973. /**
  87974. * Registers a step in an ordered way in the targeted stage.
  87975. * @param index Defines the position to register the step in
  87976. * @param component Defines the component attached to the step
  87977. * @param action Defines the action to launch during the step
  87978. */
  87979. registerStep(index: number, component: ISceneComponent, action: T): void;
  87980. /**
  87981. * Clears all the steps from the stage.
  87982. */
  87983. clear(): void;
  87984. }
  87985. }
  87986. declare module BABYLON {
  87987. interface Scene {
  87988. /** @hidden */
  87989. _pointerOverSprite: Nullable<Sprite>;
  87990. /** @hidden */
  87991. _pickedDownSprite: Nullable<Sprite>;
  87992. /** @hidden */
  87993. _tempSpritePickingRay: Nullable<Ray>;
  87994. /**
  87995. * All of the sprite managers added to this scene
  87996. * @see http://doc.babylonjs.com/babylon101/sprites
  87997. */
  87998. spriteManagers: Array<ISpriteManager>;
  87999. /**
  88000. * An event triggered when sprites rendering is about to start
  88001. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  88002. */
  88003. onBeforeSpritesRenderingObservable: Observable<Scene>;
  88004. /**
  88005. * An event triggered when sprites rendering is done
  88006. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  88007. */
  88008. onAfterSpritesRenderingObservable: Observable<Scene>;
  88009. /** @hidden */
  88010. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88011. /** Launch a ray to try to pick a sprite in the scene
  88012. * @param x position on screen
  88013. * @param y position on screen
  88014. * @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
  88015. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88016. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88017. * @returns a PickingInfo
  88018. */
  88019. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88020. /** Use the given ray to pick a sprite in the scene
  88021. * @param ray The ray (in world space) to use to pick meshes
  88022. * @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
  88023. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88024. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  88025. * @returns a PickingInfo
  88026. */
  88027. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88028. /** @hidden */
  88029. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88030. /** Launch a ray to try to pick sprites in the scene
  88031. * @param x position on screen
  88032. * @param y position on screen
  88033. * @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
  88034. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88035. * @returns a PickingInfo array
  88036. */
  88037. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88038. /** Use the given ray to pick sprites in the scene
  88039. * @param ray The ray (in world space) to use to pick meshes
  88040. * @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
  88041. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  88042. * @returns a PickingInfo array
  88043. */
  88044. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88045. /**
  88046. * Force the sprite under the pointer
  88047. * @param sprite defines the sprite to use
  88048. */
  88049. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  88050. /**
  88051. * Gets the sprite under the pointer
  88052. * @returns a Sprite or null if no sprite is under the pointer
  88053. */
  88054. getPointerOverSprite(): Nullable<Sprite>;
  88055. }
  88056. /**
  88057. * Defines the sprite scene component responsible to manage sprites
  88058. * in a given scene.
  88059. */
  88060. export class SpriteSceneComponent implements ISceneComponent {
  88061. /**
  88062. * The component name helpfull to identify the component in the list of scene components.
  88063. */
  88064. readonly name: string;
  88065. /**
  88066. * The scene the component belongs to.
  88067. */
  88068. scene: Scene;
  88069. /** @hidden */
  88070. private _spritePredicate;
  88071. /**
  88072. * Creates a new instance of the component for the given scene
  88073. * @param scene Defines the scene to register the component in
  88074. */
  88075. constructor(scene: Scene);
  88076. /**
  88077. * Registers the component in a given scene
  88078. */
  88079. register(): void;
  88080. /**
  88081. * Rebuilds the elements related to this component in case of
  88082. * context lost for instance.
  88083. */
  88084. rebuild(): void;
  88085. /**
  88086. * Disposes the component and the associated ressources.
  88087. */
  88088. dispose(): void;
  88089. private _pickSpriteButKeepRay;
  88090. private _pointerMove;
  88091. private _pointerDown;
  88092. private _pointerUp;
  88093. }
  88094. }
  88095. declare module BABYLON {
  88096. /** @hidden */
  88097. export var fogFragmentDeclaration: {
  88098. name: string;
  88099. shader: string;
  88100. };
  88101. }
  88102. declare module BABYLON {
  88103. /** @hidden */
  88104. export var fogFragment: {
  88105. name: string;
  88106. shader: string;
  88107. };
  88108. }
  88109. declare module BABYLON {
  88110. /** @hidden */
  88111. export var spritesPixelShader: {
  88112. name: string;
  88113. shader: string;
  88114. };
  88115. }
  88116. declare module BABYLON {
  88117. /** @hidden */
  88118. export var fogVertexDeclaration: {
  88119. name: string;
  88120. shader: string;
  88121. };
  88122. }
  88123. declare module BABYLON {
  88124. /** @hidden */
  88125. export var spritesVertexShader: {
  88126. name: string;
  88127. shader: string;
  88128. };
  88129. }
  88130. declare module BABYLON {
  88131. /**
  88132. * Defines the minimum interface to fullfil in order to be a sprite manager.
  88133. */
  88134. export interface ISpriteManager extends IDisposable {
  88135. /**
  88136. * Gets manager's name
  88137. */
  88138. name: string;
  88139. /**
  88140. * Restricts the camera to viewing objects with the same layerMask.
  88141. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  88142. */
  88143. layerMask: number;
  88144. /**
  88145. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  88146. */
  88147. isPickable: boolean;
  88148. /**
  88149. * Gets the hosting scene
  88150. */
  88151. scene: Scene;
  88152. /**
  88153. * Specifies the rendering group id for this mesh (0 by default)
  88154. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  88155. */
  88156. renderingGroupId: number;
  88157. /**
  88158. * Defines the list of sprites managed by the manager.
  88159. */
  88160. sprites: Array<Sprite>;
  88161. /**
  88162. * Gets or sets the spritesheet texture
  88163. */
  88164. texture: Texture;
  88165. /** Defines the default width of a cell in the spritesheet */
  88166. cellWidth: number;
  88167. /** Defines the default height of a cell in the spritesheet */
  88168. cellHeight: number;
  88169. /**
  88170. * Tests the intersection of a sprite with a specific ray.
  88171. * @param ray The ray we are sending to test the collision
  88172. * @param camera The camera space we are sending rays in
  88173. * @param predicate A predicate allowing excluding sprites from the list of object to test
  88174. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88175. * @returns picking info or null.
  88176. */
  88177. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  88178. /**
  88179. * Intersects the sprites with a ray
  88180. * @param ray defines the ray to intersect with
  88181. * @param camera defines the current active camera
  88182. * @param predicate defines a predicate used to select candidate sprites
  88183. * @returns null if no hit or a PickingInfo array
  88184. */
  88185. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  88186. /**
  88187. * Renders the list of sprites on screen.
  88188. */
  88189. render(): void;
  88190. }
  88191. /**
  88192. * Class used to manage multiple sprites on the same spritesheet
  88193. * @see http://doc.babylonjs.com/babylon101/sprites
  88194. */
  88195. export class SpriteManager implements ISpriteManager {
  88196. /** defines the manager's name */
  88197. name: string;
  88198. /** Define the Url to load snippets */
  88199. static SnippetUrl: string;
  88200. /** Snippet ID if the manager was created from the snippet server */
  88201. snippetId: string;
  88202. /** Gets the list of sprites */
  88203. sprites: Sprite[];
  88204. /** Gets or sets the rendering group id (0 by default) */
  88205. renderingGroupId: number;
  88206. /** Gets or sets camera layer mask */
  88207. layerMask: number;
  88208. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  88209. fogEnabled: boolean;
  88210. /** Gets or sets a boolean indicating if the sprites are pickable */
  88211. isPickable: boolean;
  88212. /** Defines the default width of a cell in the spritesheet */
  88213. cellWidth: number;
  88214. /** Defines the default height of a cell in the spritesheet */
  88215. cellHeight: number;
  88216. /** Associative array from JSON sprite data file */
  88217. private _cellData;
  88218. /** Array of sprite names from JSON sprite data file */
  88219. private _spriteMap;
  88220. /** True when packed cell data from JSON file is ready*/
  88221. private _packedAndReady;
  88222. private _textureContent;
  88223. /**
  88224. * An event triggered when the manager is disposed.
  88225. */
  88226. onDisposeObservable: Observable<SpriteManager>;
  88227. private _onDisposeObserver;
  88228. /**
  88229. * Callback called when the manager is disposed
  88230. */
  88231. set onDispose(callback: () => void);
  88232. private _capacity;
  88233. private _fromPacked;
  88234. private _spriteTexture;
  88235. private _epsilon;
  88236. private _scene;
  88237. private _vertexData;
  88238. private _buffer;
  88239. private _vertexBuffers;
  88240. private _indexBuffer;
  88241. private _effectBase;
  88242. private _effectFog;
  88243. /**
  88244. * Gets or sets the unique id of the sprite
  88245. */
  88246. uniqueId: number;
  88247. /**
  88248. * Gets the array of sprites
  88249. */
  88250. get children(): Sprite[];
  88251. /**
  88252. * Gets the hosting scene
  88253. */
  88254. get scene(): Scene;
  88255. /**
  88256. * Gets the capacity of the manager
  88257. */
  88258. get capacity(): number;
  88259. /**
  88260. * Gets or sets the spritesheet texture
  88261. */
  88262. get texture(): Texture;
  88263. set texture(value: Texture);
  88264. private _blendMode;
  88265. /**
  88266. * Blend mode use to render the particle, it can be any of
  88267. * the static Constants.ALPHA_x properties provided in this class.
  88268. * Default value is Constants.ALPHA_COMBINE
  88269. */
  88270. get blendMode(): number;
  88271. set blendMode(blendMode: number);
  88272. /** Disables writing to the depth buffer when rendering the sprites.
  88273. * It can be handy to disable depth writing when using textures without alpha channel
  88274. * and setting some specific blend modes.
  88275. */
  88276. disableDepthWrite: boolean;
  88277. /**
  88278. * Creates a new sprite manager
  88279. * @param name defines the manager's name
  88280. * @param imgUrl defines the sprite sheet url
  88281. * @param capacity defines the maximum allowed number of sprites
  88282. * @param cellSize defines the size of a sprite cell
  88283. * @param scene defines the hosting scene
  88284. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  88285. * @param samplingMode defines the smapling mode to use with spritesheet
  88286. * @param fromPacked set to false; do not alter
  88287. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  88288. */
  88289. constructor(
  88290. /** defines the manager's name */
  88291. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  88292. /**
  88293. * Returns the string "SpriteManager"
  88294. * @returns "SpriteManager"
  88295. */
  88296. getClassName(): string;
  88297. private _makePacked;
  88298. private _appendSpriteVertex;
  88299. private _checkTextureAlpha;
  88300. /**
  88301. * Intersects the sprites with a ray
  88302. * @param ray defines the ray to intersect with
  88303. * @param camera defines the current active camera
  88304. * @param predicate defines a predicate used to select candidate sprites
  88305. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  88306. * @returns null if no hit or a PickingInfo
  88307. */
  88308. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  88309. /**
  88310. * Intersects the sprites with a ray
  88311. * @param ray defines the ray to intersect with
  88312. * @param camera defines the current active camera
  88313. * @param predicate defines a predicate used to select candidate sprites
  88314. * @returns null if no hit or a PickingInfo array
  88315. */
  88316. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  88317. /**
  88318. * Render all child sprites
  88319. */
  88320. render(): void;
  88321. /**
  88322. * Release associated resources
  88323. */
  88324. dispose(): void;
  88325. /**
  88326. * Serializes the sprite manager to a JSON object
  88327. * @param serializeTexture defines if the texture must be serialized as well
  88328. * @returns the JSON object
  88329. */
  88330. serialize(serializeTexture?: boolean): any;
  88331. /**
  88332. * Parses a JSON object to create a new sprite manager.
  88333. * @param parsedManager The JSON object to parse
  88334. * @param scene The scene to create the sprite managerin
  88335. * @param rootUrl The root url to use to load external dependencies like texture
  88336. * @returns the new sprite manager
  88337. */
  88338. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  88339. /**
  88340. * Creates a sprite manager from a snippet saved in a remote file
  88341. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  88342. * @param url defines the url to load from
  88343. * @param scene defines the hosting scene
  88344. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88345. * @returns a promise that will resolve to the new sprite manager
  88346. */
  88347. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  88348. /**
  88349. * Creates a sprite manager from a snippet saved by the sprite editor
  88350. * @param snippetId defines the snippet to load
  88351. * @param scene defines the hosting scene
  88352. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88353. * @returns a promise that will resolve to the new sprite manager
  88354. */
  88355. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  88356. }
  88357. }
  88358. declare module BABYLON {
  88359. /** Interface used by value gradients (color, factor, ...) */
  88360. export interface IValueGradient {
  88361. /**
  88362. * Gets or sets the gradient value (between 0 and 1)
  88363. */
  88364. gradient: number;
  88365. }
  88366. /** Class used to store color4 gradient */
  88367. export class ColorGradient implements IValueGradient {
  88368. /**
  88369. * Gets or sets the gradient value (between 0 and 1)
  88370. */
  88371. gradient: number;
  88372. /**
  88373. * Gets or sets first associated color
  88374. */
  88375. color1: Color4;
  88376. /**
  88377. * Gets or sets second associated color
  88378. */
  88379. color2?: Color4 | undefined;
  88380. /**
  88381. * Creates a new color4 gradient
  88382. * @param gradient gets or sets the gradient value (between 0 and 1)
  88383. * @param color1 gets or sets first associated color
  88384. * @param color2 gets or sets first second color
  88385. */
  88386. constructor(
  88387. /**
  88388. * Gets or sets the gradient value (between 0 and 1)
  88389. */
  88390. gradient: number,
  88391. /**
  88392. * Gets or sets first associated color
  88393. */
  88394. color1: Color4,
  88395. /**
  88396. * Gets or sets second associated color
  88397. */
  88398. color2?: Color4 | undefined);
  88399. /**
  88400. * Will get a color picked randomly between color1 and color2.
  88401. * If color2 is undefined then color1 will be used
  88402. * @param result defines the target Color4 to store the result in
  88403. */
  88404. getColorToRef(result: Color4): void;
  88405. }
  88406. /** Class used to store color 3 gradient */
  88407. export class Color3Gradient implements IValueGradient {
  88408. /**
  88409. * Gets or sets the gradient value (between 0 and 1)
  88410. */
  88411. gradient: number;
  88412. /**
  88413. * Gets or sets the associated color
  88414. */
  88415. color: Color3;
  88416. /**
  88417. * Creates a new color3 gradient
  88418. * @param gradient gets or sets the gradient value (between 0 and 1)
  88419. * @param color gets or sets associated color
  88420. */
  88421. constructor(
  88422. /**
  88423. * Gets or sets the gradient value (between 0 and 1)
  88424. */
  88425. gradient: number,
  88426. /**
  88427. * Gets or sets the associated color
  88428. */
  88429. color: Color3);
  88430. }
  88431. /** Class used to store factor gradient */
  88432. export class FactorGradient implements IValueGradient {
  88433. /**
  88434. * Gets or sets the gradient value (between 0 and 1)
  88435. */
  88436. gradient: number;
  88437. /**
  88438. * Gets or sets first associated factor
  88439. */
  88440. factor1: number;
  88441. /**
  88442. * Gets or sets second associated factor
  88443. */
  88444. factor2?: number | undefined;
  88445. /**
  88446. * Creates a new factor gradient
  88447. * @param gradient gets or sets the gradient value (between 0 and 1)
  88448. * @param factor1 gets or sets first associated factor
  88449. * @param factor2 gets or sets second associated factor
  88450. */
  88451. constructor(
  88452. /**
  88453. * Gets or sets the gradient value (between 0 and 1)
  88454. */
  88455. gradient: number,
  88456. /**
  88457. * Gets or sets first associated factor
  88458. */
  88459. factor1: number,
  88460. /**
  88461. * Gets or sets second associated factor
  88462. */
  88463. factor2?: number | undefined);
  88464. /**
  88465. * Will get a number picked randomly between factor1 and factor2.
  88466. * If factor2 is undefined then factor1 will be used
  88467. * @returns the picked number
  88468. */
  88469. getFactor(): number;
  88470. }
  88471. /**
  88472. * Helper used to simplify some generic gradient tasks
  88473. */
  88474. export class GradientHelper {
  88475. /**
  88476. * Gets the current gradient from an array of IValueGradient
  88477. * @param ratio defines the current ratio to get
  88478. * @param gradients defines the array of IValueGradient
  88479. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88480. */
  88481. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88482. }
  88483. }
  88484. declare module BABYLON {
  88485. interface ThinEngine {
  88486. /**
  88487. * Creates a dynamic texture
  88488. * @param width defines the width of the texture
  88489. * @param height defines the height of the texture
  88490. * @param generateMipMaps defines if the engine should generate the mip levels
  88491. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88492. * @returns the dynamic texture inside an InternalTexture
  88493. */
  88494. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88495. /**
  88496. * Update the content of a dynamic texture
  88497. * @param texture defines the texture to update
  88498. * @param canvas defines the canvas containing the source
  88499. * @param invertY defines if data must be stored with Y axis inverted
  88500. * @param premulAlpha defines if alpha is stored as premultiplied
  88501. * @param format defines the format of the data
  88502. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88503. */
  88504. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88505. }
  88506. }
  88507. declare module BABYLON {
  88508. /**
  88509. * Helper class used to generate a canvas to manipulate images
  88510. */
  88511. export class CanvasGenerator {
  88512. /**
  88513. * Create a new canvas (or offscreen canvas depending on the context)
  88514. * @param width defines the expected width
  88515. * @param height defines the expected height
  88516. * @return a new canvas or offscreen canvas
  88517. */
  88518. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  88519. }
  88520. }
  88521. declare module BABYLON {
  88522. /**
  88523. * A class extending Texture allowing drawing on a texture
  88524. * @see http://doc.babylonjs.com/how_to/dynamictexture
  88525. */
  88526. export class DynamicTexture extends Texture {
  88527. private _generateMipMaps;
  88528. private _canvas;
  88529. private _context;
  88530. /**
  88531. * Creates a DynamicTexture
  88532. * @param name defines the name of the texture
  88533. * @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
  88534. * @param scene defines the scene where you want the texture
  88535. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  88536. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  88537. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  88538. */
  88539. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  88540. /**
  88541. * Get the current class name of the texture useful for serialization or dynamic coding.
  88542. * @returns "DynamicTexture"
  88543. */
  88544. getClassName(): string;
  88545. /**
  88546. * Gets the current state of canRescale
  88547. */
  88548. get canRescale(): boolean;
  88549. private _recreate;
  88550. /**
  88551. * Scales the texture
  88552. * @param ratio the scale factor to apply to both width and height
  88553. */
  88554. scale(ratio: number): void;
  88555. /**
  88556. * Resizes the texture
  88557. * @param width the new width
  88558. * @param height the new height
  88559. */
  88560. scaleTo(width: number, height: number): void;
  88561. /**
  88562. * Gets the context of the canvas used by the texture
  88563. * @returns the canvas context of the dynamic texture
  88564. */
  88565. getContext(): CanvasRenderingContext2D;
  88566. /**
  88567. * Clears the texture
  88568. */
  88569. clear(): void;
  88570. /**
  88571. * Updates the texture
  88572. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  88573. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  88574. */
  88575. update(invertY?: boolean, premulAlpha?: boolean): void;
  88576. /**
  88577. * Draws text onto the texture
  88578. * @param text defines the text to be drawn
  88579. * @param x defines the placement of the text from the left
  88580. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  88581. * @param font defines the font to be used with font-style, font-size, font-name
  88582. * @param color defines the color used for the text
  88583. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  88584. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  88585. * @param update defines whether texture is immediately update (default is true)
  88586. */
  88587. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  88588. /**
  88589. * Clones the texture
  88590. * @returns the clone of the texture.
  88591. */
  88592. clone(): DynamicTexture;
  88593. /**
  88594. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  88595. * @returns a serialized dynamic texture object
  88596. */
  88597. serialize(): any;
  88598. /** @hidden */
  88599. _rebuild(): void;
  88600. }
  88601. }
  88602. declare module BABYLON {
  88603. interface ThinEngine {
  88604. /**
  88605. * Creates a raw texture
  88606. * @param data defines the data to store in the texture
  88607. * @param width defines the width of the texture
  88608. * @param height defines the height of the texture
  88609. * @param format defines the format of the data
  88610. * @param generateMipMaps defines if the engine should generate the mip levels
  88611. * @param invertY defines if data must be stored with Y axis inverted
  88612. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88613. * @param compression defines the compression used (null by default)
  88614. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88615. * @returns the raw texture inside an InternalTexture
  88616. */
  88617. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  88618. /**
  88619. * Update a raw texture
  88620. * @param texture defines the texture to update
  88621. * @param data defines the data to store in the texture
  88622. * @param format defines the format of the data
  88623. * @param invertY defines if data must be stored with Y axis inverted
  88624. */
  88625. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  88626. /**
  88627. * Update a raw texture
  88628. * @param texture defines the texture to update
  88629. * @param data defines the data to store in the texture
  88630. * @param format defines the format of the data
  88631. * @param invertY defines if data must be stored with Y axis inverted
  88632. * @param compression defines the compression used (null by default)
  88633. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88634. */
  88635. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  88636. /**
  88637. * Creates a new raw cube texture
  88638. * @param data defines the array of data to use to create each face
  88639. * @param size defines the size of the textures
  88640. * @param format defines the format of the data
  88641. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88642. * @param generateMipMaps defines if the engine should generate the mip levels
  88643. * @param invertY defines if data must be stored with Y axis inverted
  88644. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88645. * @param compression defines the compression used (null by default)
  88646. * @returns the cube texture as an InternalTexture
  88647. */
  88648. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  88649. /**
  88650. * Update a raw cube texture
  88651. * @param texture defines the texture to udpdate
  88652. * @param data defines the data to store
  88653. * @param format defines the data format
  88654. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88655. * @param invertY defines if data must be stored with Y axis inverted
  88656. */
  88657. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  88658. /**
  88659. * Update a raw cube texture
  88660. * @param texture defines the texture to udpdate
  88661. * @param data defines the data to store
  88662. * @param format defines the data format
  88663. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88664. * @param invertY defines if data must be stored with Y axis inverted
  88665. * @param compression defines the compression used (null by default)
  88666. */
  88667. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  88668. /**
  88669. * Update a raw cube texture
  88670. * @param texture defines the texture to udpdate
  88671. * @param data defines the data to store
  88672. * @param format defines the data format
  88673. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88674. * @param invertY defines if data must be stored with Y axis inverted
  88675. * @param compression defines the compression used (null by default)
  88676. * @param level defines which level of the texture to update
  88677. */
  88678. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  88679. /**
  88680. * Creates a new raw cube texture from a specified url
  88681. * @param url defines the url where the data is located
  88682. * @param scene defines the current scene
  88683. * @param size defines the size of the textures
  88684. * @param format defines the format of the data
  88685. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88686. * @param noMipmap defines if the engine should avoid generating the mip levels
  88687. * @param callback defines a callback used to extract texture data from loaded data
  88688. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  88689. * @param onLoad defines a callback called when texture is loaded
  88690. * @param onError defines a callback called if there is an error
  88691. * @returns the cube texture as an InternalTexture
  88692. */
  88693. 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;
  88694. /**
  88695. * Creates a new raw cube texture from a specified url
  88696. * @param url defines the url where the data is located
  88697. * @param scene defines the current scene
  88698. * @param size defines the size of the textures
  88699. * @param format defines the format of the data
  88700. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88701. * @param noMipmap defines if the engine should avoid generating the mip levels
  88702. * @param callback defines a callback used to extract texture data from loaded data
  88703. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  88704. * @param onLoad defines a callback called when texture is loaded
  88705. * @param onError defines a callback called if there is an error
  88706. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88707. * @param invertY defines if data must be stored with Y axis inverted
  88708. * @returns the cube texture as an InternalTexture
  88709. */
  88710. 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;
  88711. /**
  88712. * Creates a new raw 3D texture
  88713. * @param data defines the data used to create the texture
  88714. * @param width defines the width of the texture
  88715. * @param height defines the height of the texture
  88716. * @param depth defines the depth of the texture
  88717. * @param format defines the format of the texture
  88718. * @param generateMipMaps defines if the engine must generate mip levels
  88719. * @param invertY defines if data must be stored with Y axis inverted
  88720. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88721. * @param compression defines the compressed used (can be null)
  88722. * @param textureType defines the compressed used (can be null)
  88723. * @returns a new raw 3D texture (stored in an InternalTexture)
  88724. */
  88725. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  88726. /**
  88727. * Update a raw 3D texture
  88728. * @param texture defines the texture to update
  88729. * @param data defines the data to store
  88730. * @param format defines the data format
  88731. * @param invertY defines if data must be stored with Y axis inverted
  88732. */
  88733. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  88734. /**
  88735. * Update a raw 3D texture
  88736. * @param texture defines the texture to update
  88737. * @param data defines the data to store
  88738. * @param format defines the data format
  88739. * @param invertY defines if data must be stored with Y axis inverted
  88740. * @param compression defines the used compression (can be null)
  88741. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  88742. */
  88743. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  88744. /**
  88745. * Creates a new raw 2D array texture
  88746. * @param data defines the data used to create the texture
  88747. * @param width defines the width of the texture
  88748. * @param height defines the height of the texture
  88749. * @param depth defines the number of layers of the texture
  88750. * @param format defines the format of the texture
  88751. * @param generateMipMaps defines if the engine must generate mip levels
  88752. * @param invertY defines if data must be stored with Y axis inverted
  88753. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88754. * @param compression defines the compressed used (can be null)
  88755. * @param textureType defines the compressed used (can be null)
  88756. * @returns a new raw 2D array texture (stored in an InternalTexture)
  88757. */
  88758. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  88759. /**
  88760. * Update a raw 2D array texture
  88761. * @param texture defines the texture to update
  88762. * @param data defines the data to store
  88763. * @param format defines the data format
  88764. * @param invertY defines if data must be stored with Y axis inverted
  88765. */
  88766. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  88767. /**
  88768. * Update a raw 2D array texture
  88769. * @param texture defines the texture to update
  88770. * @param data defines the data to store
  88771. * @param format defines the data format
  88772. * @param invertY defines if data must be stored with Y axis inverted
  88773. * @param compression defines the used compression (can be null)
  88774. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  88775. */
  88776. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  88777. }
  88778. }
  88779. declare module BABYLON {
  88780. /**
  88781. * Raw texture can help creating a texture directly from an array of data.
  88782. * This can be super useful if you either get the data from an uncompressed source or
  88783. * if you wish to create your texture pixel by pixel.
  88784. */
  88785. export class RawTexture extends Texture {
  88786. /**
  88787. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  88788. */
  88789. format: number;
  88790. /**
  88791. * Instantiates a new RawTexture.
  88792. * Raw texture can help creating a texture directly from an array of data.
  88793. * This can be super useful if you either get the data from an uncompressed source or
  88794. * if you wish to create your texture pixel by pixel.
  88795. * @param data define the array of data to use to create the texture
  88796. * @param width define the width of the texture
  88797. * @param height define the height of the texture
  88798. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  88799. * @param scene define the scene the texture belongs to
  88800. * @param generateMipMaps define whether mip maps should be generated or not
  88801. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88802. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88803. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  88804. */
  88805. constructor(data: ArrayBufferView, width: number, height: number,
  88806. /**
  88807. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  88808. */
  88809. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  88810. /**
  88811. * Updates the texture underlying data.
  88812. * @param data Define the new data of the texture
  88813. */
  88814. update(data: ArrayBufferView): void;
  88815. /**
  88816. * Creates a luminance texture from some data.
  88817. * @param data Define the texture data
  88818. * @param width Define the width of the texture
  88819. * @param height Define the height of the texture
  88820. * @param scene Define the scene the texture belongs to
  88821. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88822. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88823. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88824. * @returns the luminance texture
  88825. */
  88826. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  88827. /**
  88828. * Creates a luminance alpha texture from some data.
  88829. * @param data Define the texture data
  88830. * @param width Define the width of the texture
  88831. * @param height Define the height of the texture
  88832. * @param scene Define the scene the texture belongs to
  88833. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88834. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88835. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88836. * @returns the luminance alpha texture
  88837. */
  88838. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  88839. /**
  88840. * Creates an alpha texture from some data.
  88841. * @param data Define the texture data
  88842. * @param width Define the width of the texture
  88843. * @param height Define the height of the texture
  88844. * @param scene Define the scene the texture belongs to
  88845. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88846. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88847. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88848. * @returns the alpha texture
  88849. */
  88850. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  88851. /**
  88852. * Creates a RGB texture from some data.
  88853. * @param data Define the texture data
  88854. * @param width Define the width of the texture
  88855. * @param height Define the height of the texture
  88856. * @param scene Define the scene the texture belongs to
  88857. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88858. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88859. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88860. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  88861. * @returns the RGB alpha texture
  88862. */
  88863. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  88864. /**
  88865. * Creates a RGBA texture from some data.
  88866. * @param data Define the texture data
  88867. * @param width Define the width of the texture
  88868. * @param height Define the height of the texture
  88869. * @param scene Define the scene the texture belongs to
  88870. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88871. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88872. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88873. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  88874. * @returns the RGBA texture
  88875. */
  88876. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  88877. /**
  88878. * Creates a R texture from some data.
  88879. * @param data Define the texture data
  88880. * @param width Define the width of the texture
  88881. * @param height Define the height of the texture
  88882. * @param scene Define the scene the texture belongs to
  88883. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88884. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88885. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88886. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  88887. * @returns the R texture
  88888. */
  88889. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  88890. }
  88891. }
  88892. declare module BABYLON {
  88893. interface AbstractScene {
  88894. /**
  88895. * The list of procedural textures added to the scene
  88896. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  88897. */
  88898. proceduralTextures: Array<ProceduralTexture>;
  88899. }
  88900. /**
  88901. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  88902. * in a given scene.
  88903. */
  88904. export class ProceduralTextureSceneComponent implements ISceneComponent {
  88905. /**
  88906. * The component name helpfull to identify the component in the list of scene components.
  88907. */
  88908. readonly name: string;
  88909. /**
  88910. * The scene the component belongs to.
  88911. */
  88912. scene: Scene;
  88913. /**
  88914. * Creates a new instance of the component for the given scene
  88915. * @param scene Defines the scene to register the component in
  88916. */
  88917. constructor(scene: Scene);
  88918. /**
  88919. * Registers the component in a given scene
  88920. */
  88921. register(): void;
  88922. /**
  88923. * Rebuilds the elements related to this component in case of
  88924. * context lost for instance.
  88925. */
  88926. rebuild(): void;
  88927. /**
  88928. * Disposes the component and the associated ressources.
  88929. */
  88930. dispose(): void;
  88931. private _beforeClear;
  88932. }
  88933. }
  88934. declare module BABYLON {
  88935. interface ThinEngine {
  88936. /**
  88937. * Creates a new render target cube texture
  88938. * @param size defines the size of the texture
  88939. * @param options defines the options used to create the texture
  88940. * @returns a new render target cube texture stored in an InternalTexture
  88941. */
  88942. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  88943. }
  88944. }
  88945. declare module BABYLON {
  88946. /** @hidden */
  88947. export var proceduralVertexShader: {
  88948. name: string;
  88949. shader: string;
  88950. };
  88951. }
  88952. declare module BABYLON {
  88953. /**
  88954. * 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.
  88955. * This is the base class of any Procedural texture and contains most of the shareable code.
  88956. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  88957. */
  88958. export class ProceduralTexture extends Texture {
  88959. isCube: boolean;
  88960. /**
  88961. * Define if the texture is enabled or not (disabled texture will not render)
  88962. */
  88963. isEnabled: boolean;
  88964. /**
  88965. * Define if the texture must be cleared before rendering (default is true)
  88966. */
  88967. autoClear: boolean;
  88968. /**
  88969. * Callback called when the texture is generated
  88970. */
  88971. onGenerated: () => void;
  88972. /**
  88973. * Event raised when the texture is generated
  88974. */
  88975. onGeneratedObservable: Observable<ProceduralTexture>;
  88976. /** @hidden */
  88977. _generateMipMaps: boolean;
  88978. /** @hidden **/
  88979. _effect: Effect;
  88980. /** @hidden */
  88981. _textures: {
  88982. [key: string]: Texture;
  88983. };
  88984. /** @hidden */
  88985. protected _fallbackTexture: Nullable<Texture>;
  88986. private _size;
  88987. private _currentRefreshId;
  88988. private _frameId;
  88989. private _refreshRate;
  88990. private _vertexBuffers;
  88991. private _indexBuffer;
  88992. private _uniforms;
  88993. private _samplers;
  88994. private _fragment;
  88995. private _floats;
  88996. private _ints;
  88997. private _floatsArrays;
  88998. private _colors3;
  88999. private _colors4;
  89000. private _vectors2;
  89001. private _vectors3;
  89002. private _matrices;
  89003. private _fallbackTextureUsed;
  89004. private _fullEngine;
  89005. private _cachedDefines;
  89006. private _contentUpdateId;
  89007. private _contentData;
  89008. /**
  89009. * Instantiates a new procedural texture.
  89010. * 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.
  89011. * This is the base class of any Procedural texture and contains most of the shareable code.
  89012. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89013. * @param name Define the name of the texture
  89014. * @param size Define the size of the texture to create
  89015. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  89016. * @param scene Define the scene the texture belongs to
  89017. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  89018. * @param generateMipMaps Define if the texture should creates mip maps or not
  89019. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  89020. */
  89021. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  89022. /**
  89023. * The effect that is created when initializing the post process.
  89024. * @returns The created effect corresponding the the postprocess.
  89025. */
  89026. getEffect(): Effect;
  89027. /**
  89028. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  89029. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  89030. */
  89031. getContent(): Nullable<ArrayBufferView>;
  89032. private _createIndexBuffer;
  89033. /** @hidden */
  89034. _rebuild(): void;
  89035. /**
  89036. * Resets the texture in order to recreate its associated resources.
  89037. * This can be called in case of context loss
  89038. */
  89039. reset(): void;
  89040. protected _getDefines(): string;
  89041. /**
  89042. * Is the texture ready to be used ? (rendered at least once)
  89043. * @returns true if ready, otherwise, false.
  89044. */
  89045. isReady(): boolean;
  89046. /**
  89047. * Resets the refresh counter of the texture and start bak from scratch.
  89048. * Could be useful to regenerate the texture if it is setup to render only once.
  89049. */
  89050. resetRefreshCounter(): void;
  89051. /**
  89052. * Set the fragment shader to use in order to render the texture.
  89053. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  89054. */
  89055. setFragment(fragment: any): void;
  89056. /**
  89057. * Define the refresh rate of the texture or the rendering frequency.
  89058. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89059. */
  89060. get refreshRate(): number;
  89061. set refreshRate(value: number);
  89062. /** @hidden */
  89063. _shouldRender(): boolean;
  89064. /**
  89065. * Get the size the texture is rendering at.
  89066. * @returns the size (texture is always squared)
  89067. */
  89068. getRenderSize(): number;
  89069. /**
  89070. * Resize the texture to new value.
  89071. * @param size Define the new size the texture should have
  89072. * @param generateMipMaps Define whether the new texture should create mip maps
  89073. */
  89074. resize(size: number, generateMipMaps: boolean): void;
  89075. private _checkUniform;
  89076. /**
  89077. * Set a texture in the shader program used to render.
  89078. * @param name Define the name of the uniform samplers as defined in the shader
  89079. * @param texture Define the texture to bind to this sampler
  89080. * @return the texture itself allowing "fluent" like uniform updates
  89081. */
  89082. setTexture(name: string, texture: Texture): ProceduralTexture;
  89083. /**
  89084. * Set a float in the shader.
  89085. * @param name Define the name of the uniform as defined in the shader
  89086. * @param value Define the value to give to the uniform
  89087. * @return the texture itself allowing "fluent" like uniform updates
  89088. */
  89089. setFloat(name: string, value: number): ProceduralTexture;
  89090. /**
  89091. * Set a int in the shader.
  89092. * @param name Define the name of the uniform as defined in the shader
  89093. * @param value Define the value to give to the uniform
  89094. * @return the texture itself allowing "fluent" like uniform updates
  89095. */
  89096. setInt(name: string, value: number): ProceduralTexture;
  89097. /**
  89098. * Set an array of floats in the shader.
  89099. * @param name Define the name of the uniform as defined in the shader
  89100. * @param value Define the value to give to the uniform
  89101. * @return the texture itself allowing "fluent" like uniform updates
  89102. */
  89103. setFloats(name: string, value: number[]): ProceduralTexture;
  89104. /**
  89105. * Set a vec3 in the shader from a Color3.
  89106. * @param name Define the name of the uniform as defined in the shader
  89107. * @param value Define the value to give to the uniform
  89108. * @return the texture itself allowing "fluent" like uniform updates
  89109. */
  89110. setColor3(name: string, value: Color3): ProceduralTexture;
  89111. /**
  89112. * Set a vec4 in the shader from a Color4.
  89113. * @param name Define the name of the uniform as defined in the shader
  89114. * @param value Define the value to give to the uniform
  89115. * @return the texture itself allowing "fluent" like uniform updates
  89116. */
  89117. setColor4(name: string, value: Color4): ProceduralTexture;
  89118. /**
  89119. * Set a vec2 in the shader from a Vector2.
  89120. * @param name Define the name of the uniform as defined in the shader
  89121. * @param value Define the value to give to the uniform
  89122. * @return the texture itself allowing "fluent" like uniform updates
  89123. */
  89124. setVector2(name: string, value: Vector2): ProceduralTexture;
  89125. /**
  89126. * Set a vec3 in the shader from a Vector3.
  89127. * @param name Define the name of the uniform as defined in the shader
  89128. * @param value Define the value to give to the uniform
  89129. * @return the texture itself allowing "fluent" like uniform updates
  89130. */
  89131. setVector3(name: string, value: Vector3): ProceduralTexture;
  89132. /**
  89133. * Set a mat4 in the shader from a MAtrix.
  89134. * @param name Define the name of the uniform as defined in the shader
  89135. * @param value Define the value to give to the uniform
  89136. * @return the texture itself allowing "fluent" like uniform updates
  89137. */
  89138. setMatrix(name: string, value: Matrix): ProceduralTexture;
  89139. /**
  89140. * Render the texture to its associated render target.
  89141. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  89142. */
  89143. render(useCameraPostProcess?: boolean): void;
  89144. /**
  89145. * Clone the texture.
  89146. * @returns the cloned texture
  89147. */
  89148. clone(): ProceduralTexture;
  89149. /**
  89150. * Dispose the texture and release its asoociated resources.
  89151. */
  89152. dispose(): void;
  89153. }
  89154. }
  89155. declare module BABYLON {
  89156. /**
  89157. * This represents the base class for particle system in Babylon.
  89158. * 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.
  89159. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89160. * @example https://doc.babylonjs.com/babylon101/particles
  89161. */
  89162. export class BaseParticleSystem {
  89163. /**
  89164. * Source color is added to the destination color without alpha affecting the result
  89165. */
  89166. static BLENDMODE_ONEONE: number;
  89167. /**
  89168. * Blend current color and particle color using particle’s alpha
  89169. */
  89170. static BLENDMODE_STANDARD: number;
  89171. /**
  89172. * Add current color and particle color multiplied by particle’s alpha
  89173. */
  89174. static BLENDMODE_ADD: number;
  89175. /**
  89176. * Multiply current color with particle color
  89177. */
  89178. static BLENDMODE_MULTIPLY: number;
  89179. /**
  89180. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  89181. */
  89182. static BLENDMODE_MULTIPLYADD: number;
  89183. /**
  89184. * List of animations used by the particle system.
  89185. */
  89186. animations: Animation[];
  89187. /**
  89188. * Gets or sets the unique id of the particle system
  89189. */
  89190. uniqueId: number;
  89191. /**
  89192. * The id of the Particle system.
  89193. */
  89194. id: string;
  89195. /**
  89196. * The friendly name of the Particle system.
  89197. */
  89198. name: string;
  89199. /**
  89200. * Snippet ID if the particle system was created from the snippet server
  89201. */
  89202. snippetId: string;
  89203. /**
  89204. * The rendering group used by the Particle system to chose when to render.
  89205. */
  89206. renderingGroupId: number;
  89207. /**
  89208. * The emitter represents the Mesh or position we are attaching the particle system to.
  89209. */
  89210. emitter: Nullable<AbstractMesh | Vector3>;
  89211. /**
  89212. * The maximum number of particles to emit per frame
  89213. */
  89214. emitRate: number;
  89215. /**
  89216. * If you want to launch only a few particles at once, that can be done, as well.
  89217. */
  89218. manualEmitCount: number;
  89219. /**
  89220. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89221. */
  89222. updateSpeed: number;
  89223. /**
  89224. * The amount of time the particle system is running (depends of the overall update speed).
  89225. */
  89226. targetStopDuration: number;
  89227. /**
  89228. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89229. */
  89230. disposeOnStop: boolean;
  89231. /**
  89232. * Minimum power of emitting particles.
  89233. */
  89234. minEmitPower: number;
  89235. /**
  89236. * Maximum power of emitting particles.
  89237. */
  89238. maxEmitPower: number;
  89239. /**
  89240. * Minimum life time of emitting particles.
  89241. */
  89242. minLifeTime: number;
  89243. /**
  89244. * Maximum life time of emitting particles.
  89245. */
  89246. maxLifeTime: number;
  89247. /**
  89248. * Minimum Size of emitting particles.
  89249. */
  89250. minSize: number;
  89251. /**
  89252. * Maximum Size of emitting particles.
  89253. */
  89254. maxSize: number;
  89255. /**
  89256. * Minimum scale of emitting particles on X axis.
  89257. */
  89258. minScaleX: number;
  89259. /**
  89260. * Maximum scale of emitting particles on X axis.
  89261. */
  89262. maxScaleX: number;
  89263. /**
  89264. * Minimum scale of emitting particles on Y axis.
  89265. */
  89266. minScaleY: number;
  89267. /**
  89268. * Maximum scale of emitting particles on Y axis.
  89269. */
  89270. maxScaleY: number;
  89271. /**
  89272. * Gets or sets the minimal initial rotation in radians.
  89273. */
  89274. minInitialRotation: number;
  89275. /**
  89276. * Gets or sets the maximal initial rotation in radians.
  89277. */
  89278. maxInitialRotation: number;
  89279. /**
  89280. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89281. */
  89282. minAngularSpeed: number;
  89283. /**
  89284. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89285. */
  89286. maxAngularSpeed: number;
  89287. /**
  89288. * The texture used to render each particle. (this can be a spritesheet)
  89289. */
  89290. particleTexture: Nullable<Texture>;
  89291. /**
  89292. * The layer mask we are rendering the particles through.
  89293. */
  89294. layerMask: number;
  89295. /**
  89296. * This can help using your own shader to render the particle system.
  89297. * The according effect will be created
  89298. */
  89299. customShader: any;
  89300. /**
  89301. * By default particle system starts as soon as they are created. This prevents the
  89302. * automatic start to happen and let you decide when to start emitting particles.
  89303. */
  89304. preventAutoStart: boolean;
  89305. private _noiseTexture;
  89306. /**
  89307. * Gets or sets a texture used to add random noise to particle positions
  89308. */
  89309. get noiseTexture(): Nullable<ProceduralTexture>;
  89310. set noiseTexture(value: Nullable<ProceduralTexture>);
  89311. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89312. noiseStrength: Vector3;
  89313. /**
  89314. * Callback triggered when the particle animation is ending.
  89315. */
  89316. onAnimationEnd: Nullable<() => void>;
  89317. /**
  89318. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  89319. */
  89320. blendMode: number;
  89321. /**
  89322. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  89323. * to override the particles.
  89324. */
  89325. forceDepthWrite: boolean;
  89326. /** 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 */
  89327. preWarmCycles: number;
  89328. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  89329. preWarmStepOffset: number;
  89330. /**
  89331. * 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)
  89332. */
  89333. spriteCellChangeSpeed: number;
  89334. /**
  89335. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89336. */
  89337. startSpriteCellID: number;
  89338. /**
  89339. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89340. */
  89341. endSpriteCellID: number;
  89342. /**
  89343. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89344. */
  89345. spriteCellWidth: number;
  89346. /**
  89347. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89348. */
  89349. spriteCellHeight: number;
  89350. /**
  89351. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89352. */
  89353. spriteRandomStartCell: boolean;
  89354. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89355. translationPivot: Vector2;
  89356. /** @hidden */
  89357. protected _isAnimationSheetEnabled: boolean;
  89358. /**
  89359. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89360. */
  89361. beginAnimationOnStart: boolean;
  89362. /**
  89363. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89364. */
  89365. beginAnimationFrom: number;
  89366. /**
  89367. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89368. */
  89369. beginAnimationTo: number;
  89370. /**
  89371. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89372. */
  89373. beginAnimationLoop: boolean;
  89374. /**
  89375. * Gets or sets a world offset applied to all particles
  89376. */
  89377. worldOffset: Vector3;
  89378. /**
  89379. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  89380. */
  89381. get isAnimationSheetEnabled(): boolean;
  89382. set isAnimationSheetEnabled(value: boolean);
  89383. /**
  89384. * Get hosting scene
  89385. * @returns the scene
  89386. */
  89387. getScene(): Scene;
  89388. /**
  89389. * You can use gravity if you want to give an orientation to your particles.
  89390. */
  89391. gravity: Vector3;
  89392. protected _colorGradients: Nullable<Array<ColorGradient>>;
  89393. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  89394. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  89395. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  89396. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  89397. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  89398. protected _dragGradients: Nullable<Array<FactorGradient>>;
  89399. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  89400. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  89401. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  89402. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  89403. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  89404. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  89405. /**
  89406. * Defines the delay in milliseconds before starting the system (0 by default)
  89407. */
  89408. startDelay: number;
  89409. /**
  89410. * Gets the current list of drag gradients.
  89411. * You must use addDragGradient and removeDragGradient to udpate this list
  89412. * @returns the list of drag gradients
  89413. */
  89414. getDragGradients(): Nullable<Array<FactorGradient>>;
  89415. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89416. limitVelocityDamping: number;
  89417. /**
  89418. * Gets the current list of limit velocity gradients.
  89419. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89420. * @returns the list of limit velocity gradients
  89421. */
  89422. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89423. /**
  89424. * Gets the current list of color gradients.
  89425. * You must use addColorGradient and removeColorGradient to udpate this list
  89426. * @returns the list of color gradients
  89427. */
  89428. getColorGradients(): Nullable<Array<ColorGradient>>;
  89429. /**
  89430. * Gets the current list of size gradients.
  89431. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89432. * @returns the list of size gradients
  89433. */
  89434. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89435. /**
  89436. * Gets the current list of color remap gradients.
  89437. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89438. * @returns the list of color remap gradients
  89439. */
  89440. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89441. /**
  89442. * Gets the current list of alpha remap gradients.
  89443. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89444. * @returns the list of alpha remap gradients
  89445. */
  89446. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89447. /**
  89448. * Gets the current list of life time gradients.
  89449. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89450. * @returns the list of life time gradients
  89451. */
  89452. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89453. /**
  89454. * Gets the current list of angular speed gradients.
  89455. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89456. * @returns the list of angular speed gradients
  89457. */
  89458. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89459. /**
  89460. * Gets the current list of velocity gradients.
  89461. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89462. * @returns the list of velocity gradients
  89463. */
  89464. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89465. /**
  89466. * Gets the current list of start size gradients.
  89467. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89468. * @returns the list of start size gradients
  89469. */
  89470. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89471. /**
  89472. * Gets the current list of emit rate gradients.
  89473. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89474. * @returns the list of emit rate gradients
  89475. */
  89476. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89477. /**
  89478. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89479. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89480. */
  89481. get direction1(): Vector3;
  89482. set direction1(value: Vector3);
  89483. /**
  89484. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89485. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89486. */
  89487. get direction2(): Vector3;
  89488. set direction2(value: Vector3);
  89489. /**
  89490. * 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.
  89491. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89492. */
  89493. get minEmitBox(): Vector3;
  89494. set minEmitBox(value: Vector3);
  89495. /**
  89496. * 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.
  89497. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89498. */
  89499. get maxEmitBox(): Vector3;
  89500. set maxEmitBox(value: Vector3);
  89501. /**
  89502. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89503. */
  89504. color1: Color4;
  89505. /**
  89506. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89507. */
  89508. color2: Color4;
  89509. /**
  89510. * Color the particle will have at the end of its lifetime
  89511. */
  89512. colorDead: Color4;
  89513. /**
  89514. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  89515. */
  89516. textureMask: Color4;
  89517. /**
  89518. * The particle emitter type defines the emitter used by the particle system.
  89519. * It can be for example box, sphere, or cone...
  89520. */
  89521. particleEmitterType: IParticleEmitterType;
  89522. /** @hidden */
  89523. _isSubEmitter: boolean;
  89524. /**
  89525. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89526. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89527. */
  89528. billboardMode: number;
  89529. protected _isBillboardBased: boolean;
  89530. /**
  89531. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89532. */
  89533. get isBillboardBased(): boolean;
  89534. set isBillboardBased(value: boolean);
  89535. /**
  89536. * The scene the particle system belongs to.
  89537. */
  89538. protected _scene: Scene;
  89539. /**
  89540. * Local cache of defines for image processing.
  89541. */
  89542. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  89543. /**
  89544. * Default configuration related to image processing available in the standard Material.
  89545. */
  89546. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  89547. /**
  89548. * Gets the image processing configuration used either in this material.
  89549. */
  89550. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  89551. /**
  89552. * Sets the Default image processing configuration used either in the this material.
  89553. *
  89554. * If sets to null, the scene one is in use.
  89555. */
  89556. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  89557. /**
  89558. * Attaches a new image processing configuration to the Standard Material.
  89559. * @param configuration
  89560. */
  89561. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  89562. /** @hidden */
  89563. protected _reset(): void;
  89564. /** @hidden */
  89565. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  89566. /**
  89567. * Instantiates a particle system.
  89568. * 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.
  89569. * @param name The name of the particle system
  89570. */
  89571. constructor(name: string);
  89572. /**
  89573. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89574. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89575. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89576. * @returns the emitter
  89577. */
  89578. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89579. /**
  89580. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89581. * @param radius The radius of the hemisphere to emit from
  89582. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89583. * @returns the emitter
  89584. */
  89585. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  89586. /**
  89587. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89588. * @param radius The radius of the sphere to emit from
  89589. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89590. * @returns the emitter
  89591. */
  89592. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  89593. /**
  89594. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89595. * @param radius The radius of the sphere to emit from
  89596. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89597. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89598. * @returns the emitter
  89599. */
  89600. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  89601. /**
  89602. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89603. * @param radius The radius of the emission cylinder
  89604. * @param height The height of the emission cylinder
  89605. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89606. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89607. * @returns the emitter
  89608. */
  89609. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  89610. /**
  89611. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89612. * @param radius The radius of the cylinder to emit from
  89613. * @param height The height of the emission cylinder
  89614. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89615. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89616. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89617. * @returns the emitter
  89618. */
  89619. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  89620. /**
  89621. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89622. * @param radius The radius of the cone to emit from
  89623. * @param angle The base angle of the cone
  89624. * @returns the emitter
  89625. */
  89626. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  89627. /**
  89628. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89629. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89630. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89631. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89632. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89633. * @returns the emitter
  89634. */
  89635. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89636. }
  89637. }
  89638. declare module BABYLON {
  89639. /**
  89640. * Type of sub emitter
  89641. */
  89642. export enum SubEmitterType {
  89643. /**
  89644. * Attached to the particle over it's lifetime
  89645. */
  89646. ATTACHED = 0,
  89647. /**
  89648. * Created when the particle dies
  89649. */
  89650. END = 1
  89651. }
  89652. /**
  89653. * Sub emitter class used to emit particles from an existing particle
  89654. */
  89655. export class SubEmitter {
  89656. /**
  89657. * the particle system to be used by the sub emitter
  89658. */
  89659. particleSystem: ParticleSystem;
  89660. /**
  89661. * Type of the submitter (Default: END)
  89662. */
  89663. type: SubEmitterType;
  89664. /**
  89665. * 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)
  89666. * Note: This only is supported when using an emitter of type Mesh
  89667. */
  89668. inheritDirection: boolean;
  89669. /**
  89670. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  89671. */
  89672. inheritedVelocityAmount: number;
  89673. /**
  89674. * Creates a sub emitter
  89675. * @param particleSystem the particle system to be used by the sub emitter
  89676. */
  89677. constructor(
  89678. /**
  89679. * the particle system to be used by the sub emitter
  89680. */
  89681. particleSystem: ParticleSystem);
  89682. /**
  89683. * Clones the sub emitter
  89684. * @returns the cloned sub emitter
  89685. */
  89686. clone(): SubEmitter;
  89687. /**
  89688. * Serialize current object to a JSON object
  89689. * @returns the serialized object
  89690. */
  89691. serialize(): any;
  89692. /** @hidden */
  89693. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  89694. /**
  89695. * Creates a new SubEmitter from a serialized JSON version
  89696. * @param serializationObject defines the JSON object to read from
  89697. * @param scene defines the hosting scene
  89698. * @param rootUrl defines the rootUrl for data loading
  89699. * @returns a new SubEmitter
  89700. */
  89701. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  89702. /** Release associated resources */
  89703. dispose(): void;
  89704. }
  89705. }
  89706. declare module BABYLON {
  89707. /** @hidden */
  89708. export var imageProcessingDeclaration: {
  89709. name: string;
  89710. shader: string;
  89711. };
  89712. }
  89713. declare module BABYLON {
  89714. /** @hidden */
  89715. export var imageProcessingFunctions: {
  89716. name: string;
  89717. shader: string;
  89718. };
  89719. }
  89720. declare module BABYLON {
  89721. /** @hidden */
  89722. export var particlesPixelShader: {
  89723. name: string;
  89724. shader: string;
  89725. };
  89726. }
  89727. declare module BABYLON {
  89728. /** @hidden */
  89729. export var particlesVertexShader: {
  89730. name: string;
  89731. shader: string;
  89732. };
  89733. }
  89734. declare module BABYLON {
  89735. /**
  89736. * This represents a particle system in Babylon.
  89737. * 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.
  89738. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89739. * @example https://doc.babylonjs.com/babylon101/particles
  89740. */
  89741. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  89742. /**
  89743. * Billboard mode will only apply to Y axis
  89744. */
  89745. static readonly BILLBOARDMODE_Y: number;
  89746. /**
  89747. * Billboard mode will apply to all axes
  89748. */
  89749. static readonly BILLBOARDMODE_ALL: number;
  89750. /**
  89751. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  89752. */
  89753. static readonly BILLBOARDMODE_STRETCHED: number;
  89754. /**
  89755. * This function can be defined to provide custom update for active particles.
  89756. * This function will be called instead of regular update (age, position, color, etc.).
  89757. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  89758. */
  89759. updateFunction: (particles: Particle[]) => void;
  89760. private _emitterWorldMatrix;
  89761. /**
  89762. * This function can be defined to specify initial direction for every new particle.
  89763. * It by default use the emitterType defined function
  89764. */
  89765. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  89766. /**
  89767. * This function can be defined to specify initial position for every new particle.
  89768. * It by default use the emitterType defined function
  89769. */
  89770. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  89771. /**
  89772. * @hidden
  89773. */
  89774. _inheritedVelocityOffset: Vector3;
  89775. /**
  89776. * An event triggered when the system is disposed
  89777. */
  89778. onDisposeObservable: Observable<IParticleSystem>;
  89779. private _onDisposeObserver;
  89780. /**
  89781. * Sets a callback that will be triggered when the system is disposed
  89782. */
  89783. set onDispose(callback: () => void);
  89784. private _particles;
  89785. private _epsilon;
  89786. private _capacity;
  89787. private _stockParticles;
  89788. private _newPartsExcess;
  89789. private _vertexData;
  89790. private _vertexBuffer;
  89791. private _vertexBuffers;
  89792. private _spriteBuffer;
  89793. private _indexBuffer;
  89794. private _effect;
  89795. private _customEffect;
  89796. private _cachedDefines;
  89797. private _scaledColorStep;
  89798. private _colorDiff;
  89799. private _scaledDirection;
  89800. private _scaledGravity;
  89801. private _currentRenderId;
  89802. private _alive;
  89803. private _useInstancing;
  89804. private _started;
  89805. private _stopped;
  89806. private _actualFrame;
  89807. private _scaledUpdateSpeed;
  89808. private _vertexBufferSize;
  89809. /** @hidden */
  89810. _currentEmitRateGradient: Nullable<FactorGradient>;
  89811. /** @hidden */
  89812. _currentEmitRate1: number;
  89813. /** @hidden */
  89814. _currentEmitRate2: number;
  89815. /** @hidden */
  89816. _currentStartSizeGradient: Nullable<FactorGradient>;
  89817. /** @hidden */
  89818. _currentStartSize1: number;
  89819. /** @hidden */
  89820. _currentStartSize2: number;
  89821. private readonly _rawTextureWidth;
  89822. private _rampGradientsTexture;
  89823. private _useRampGradients;
  89824. /** Gets or sets a boolean indicating that ramp gradients must be used
  89825. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  89826. */
  89827. get useRampGradients(): boolean;
  89828. set useRampGradients(value: boolean);
  89829. /**
  89830. * 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.
  89831. * 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: [])
  89832. */
  89833. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  89834. private _subEmitters;
  89835. /**
  89836. * @hidden
  89837. * If the particle systems emitter should be disposed when the particle system is disposed
  89838. */
  89839. _disposeEmitterOnDispose: boolean;
  89840. /**
  89841. * The current active Sub-systems, this property is used by the root particle system only.
  89842. */
  89843. activeSubSystems: Array<ParticleSystem>;
  89844. /**
  89845. * Specifies if the particles are updated in emitter local space or world space
  89846. */
  89847. isLocal: boolean;
  89848. private _rootParticleSystem;
  89849. /**
  89850. * Gets the current list of active particles
  89851. */
  89852. get particles(): Particle[];
  89853. /**
  89854. * Gets the number of particles active at the same time.
  89855. * @returns The number of active particles.
  89856. */
  89857. getActiveCount(): number;
  89858. /**
  89859. * Returns the string "ParticleSystem"
  89860. * @returns a string containing the class name
  89861. */
  89862. getClassName(): string;
  89863. /**
  89864. * Gets a boolean indicating that the system is stopping
  89865. * @returns true if the system is currently stopping
  89866. */
  89867. isStopping(): boolean;
  89868. /**
  89869. * Gets the custom effect used to render the particles
  89870. * @param blendMode Blend mode for which the effect should be retrieved
  89871. * @returns The effect
  89872. */
  89873. getCustomEffect(blendMode?: number): Nullable<Effect>;
  89874. /**
  89875. * Sets the custom effect used to render the particles
  89876. * @param effect The effect to set
  89877. * @param blendMode Blend mode for which the effect should be set
  89878. */
  89879. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  89880. /** @hidden */
  89881. private _onBeforeDrawParticlesObservable;
  89882. /**
  89883. * Observable that will be called just before the particles are drawn
  89884. */
  89885. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  89886. /**
  89887. * Gets the name of the particle vertex shader
  89888. */
  89889. get vertexShaderName(): string;
  89890. /**
  89891. * Instantiates a particle system.
  89892. * 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.
  89893. * @param name The name of the particle system
  89894. * @param capacity The max number of particles alive at the same time
  89895. * @param scene The scene the particle system belongs to
  89896. * @param customEffect a custom effect used to change the way particles are rendered by default
  89897. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  89898. * @param epsilon Offset used to render the particles
  89899. */
  89900. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  89901. private _addFactorGradient;
  89902. private _removeFactorGradient;
  89903. /**
  89904. * Adds a new life time gradient
  89905. * @param gradient defines the gradient to use (between 0 and 1)
  89906. * @param factor defines the life time factor to affect to the specified gradient
  89907. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89908. * @returns the current particle system
  89909. */
  89910. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89911. /**
  89912. * Remove a specific life time gradient
  89913. * @param gradient defines the gradient to remove
  89914. * @returns the current particle system
  89915. */
  89916. removeLifeTimeGradient(gradient: number): IParticleSystem;
  89917. /**
  89918. * Adds a new size gradient
  89919. * @param gradient defines the gradient to use (between 0 and 1)
  89920. * @param factor defines the size factor to affect to the specified gradient
  89921. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89922. * @returns the current particle system
  89923. */
  89924. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89925. /**
  89926. * Remove a specific size gradient
  89927. * @param gradient defines the gradient to remove
  89928. * @returns the current particle system
  89929. */
  89930. removeSizeGradient(gradient: number): IParticleSystem;
  89931. /**
  89932. * Adds a new color remap gradient
  89933. * @param gradient defines the gradient to use (between 0 and 1)
  89934. * @param min defines the color remap minimal range
  89935. * @param max defines the color remap maximal range
  89936. * @returns the current particle system
  89937. */
  89938. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89939. /**
  89940. * Remove a specific color remap gradient
  89941. * @param gradient defines the gradient to remove
  89942. * @returns the current particle system
  89943. */
  89944. removeColorRemapGradient(gradient: number): IParticleSystem;
  89945. /**
  89946. * Adds a new alpha remap gradient
  89947. * @param gradient defines the gradient to use (between 0 and 1)
  89948. * @param min defines the alpha remap minimal range
  89949. * @param max defines the alpha remap maximal range
  89950. * @returns the current particle system
  89951. */
  89952. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89953. /**
  89954. * Remove a specific alpha remap gradient
  89955. * @param gradient defines the gradient to remove
  89956. * @returns the current particle system
  89957. */
  89958. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  89959. /**
  89960. * Adds a new angular speed gradient
  89961. * @param gradient defines the gradient to use (between 0 and 1)
  89962. * @param factor defines the angular speed to affect to the specified gradient
  89963. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89964. * @returns the current particle system
  89965. */
  89966. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89967. /**
  89968. * Remove a specific angular speed gradient
  89969. * @param gradient defines the gradient to remove
  89970. * @returns the current particle system
  89971. */
  89972. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  89973. /**
  89974. * Adds a new velocity gradient
  89975. * @param gradient defines the gradient to use (between 0 and 1)
  89976. * @param factor defines the velocity to affect to the specified gradient
  89977. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89978. * @returns the current particle system
  89979. */
  89980. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89981. /**
  89982. * Remove a specific velocity gradient
  89983. * @param gradient defines the gradient to remove
  89984. * @returns the current particle system
  89985. */
  89986. removeVelocityGradient(gradient: number): IParticleSystem;
  89987. /**
  89988. * Adds a new limit velocity gradient
  89989. * @param gradient defines the gradient to use (between 0 and 1)
  89990. * @param factor defines the limit velocity value to affect to the specified gradient
  89991. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89992. * @returns the current particle system
  89993. */
  89994. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89995. /**
  89996. * Remove a specific limit velocity gradient
  89997. * @param gradient defines the gradient to remove
  89998. * @returns the current particle system
  89999. */
  90000. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  90001. /**
  90002. * Adds a new drag gradient
  90003. * @param gradient defines the gradient to use (between 0 and 1)
  90004. * @param factor defines the drag value to affect to the specified gradient
  90005. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90006. * @returns the current particle system
  90007. */
  90008. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90009. /**
  90010. * Remove a specific drag gradient
  90011. * @param gradient defines the gradient to remove
  90012. * @returns the current particle system
  90013. */
  90014. removeDragGradient(gradient: number): IParticleSystem;
  90015. /**
  90016. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  90017. * @param gradient defines the gradient to use (between 0 and 1)
  90018. * @param factor defines the emit rate value to affect to the specified gradient
  90019. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90020. * @returns the current particle system
  90021. */
  90022. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90023. /**
  90024. * Remove a specific emit rate gradient
  90025. * @param gradient defines the gradient to remove
  90026. * @returns the current particle system
  90027. */
  90028. removeEmitRateGradient(gradient: number): IParticleSystem;
  90029. /**
  90030. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  90031. * @param gradient defines the gradient to use (between 0 and 1)
  90032. * @param factor defines the start size value to affect to the specified gradient
  90033. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90034. * @returns the current particle system
  90035. */
  90036. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90037. /**
  90038. * Remove a specific start size gradient
  90039. * @param gradient defines the gradient to remove
  90040. * @returns the current particle system
  90041. */
  90042. removeStartSizeGradient(gradient: number): IParticleSystem;
  90043. private _createRampGradientTexture;
  90044. /**
  90045. * Gets the current list of ramp gradients.
  90046. * You must use addRampGradient and removeRampGradient to udpate this list
  90047. * @returns the list of ramp gradients
  90048. */
  90049. getRampGradients(): Nullable<Array<Color3Gradient>>;
  90050. /** Force the system to rebuild all gradients that need to be resync */
  90051. forceRefreshGradients(): void;
  90052. private _syncRampGradientTexture;
  90053. /**
  90054. * Adds a new ramp gradient used to remap particle colors
  90055. * @param gradient defines the gradient to use (between 0 and 1)
  90056. * @param color defines the color to affect to the specified gradient
  90057. * @returns the current particle system
  90058. */
  90059. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  90060. /**
  90061. * Remove a specific ramp gradient
  90062. * @param gradient defines the gradient to remove
  90063. * @returns the current particle system
  90064. */
  90065. removeRampGradient(gradient: number): ParticleSystem;
  90066. /**
  90067. * Adds a new color gradient
  90068. * @param gradient defines the gradient to use (between 0 and 1)
  90069. * @param color1 defines the color to affect to the specified gradient
  90070. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  90071. * @returns this particle system
  90072. */
  90073. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  90074. /**
  90075. * Remove a specific color gradient
  90076. * @param gradient defines the gradient to remove
  90077. * @returns this particle system
  90078. */
  90079. removeColorGradient(gradient: number): IParticleSystem;
  90080. private _fetchR;
  90081. protected _reset(): void;
  90082. private _resetEffect;
  90083. private _createVertexBuffers;
  90084. private _createIndexBuffer;
  90085. /**
  90086. * Gets the maximum number of particles active at the same time.
  90087. * @returns The max number of active particles.
  90088. */
  90089. getCapacity(): number;
  90090. /**
  90091. * Gets whether there are still active particles in the system.
  90092. * @returns True if it is alive, otherwise false.
  90093. */
  90094. isAlive(): boolean;
  90095. /**
  90096. * Gets if the system has been started. (Note: this will still be true after stop is called)
  90097. * @returns True if it has been started, otherwise false.
  90098. */
  90099. isStarted(): boolean;
  90100. private _prepareSubEmitterInternalArray;
  90101. /**
  90102. * Starts the particle system and begins to emit
  90103. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  90104. */
  90105. start(delay?: number): void;
  90106. /**
  90107. * Stops the particle system.
  90108. * @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.
  90109. */
  90110. stop(stopSubEmitters?: boolean): void;
  90111. /**
  90112. * Remove all active particles
  90113. */
  90114. reset(): void;
  90115. /**
  90116. * @hidden (for internal use only)
  90117. */
  90118. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  90119. /**
  90120. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  90121. * Its lifetime will start back at 0.
  90122. */
  90123. recycleParticle: (particle: Particle) => void;
  90124. private _stopSubEmitters;
  90125. private _createParticle;
  90126. private _removeFromRoot;
  90127. private _emitFromParticle;
  90128. private _update;
  90129. /** @hidden */
  90130. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  90131. /** @hidden */
  90132. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  90133. /**
  90134. * Fill the defines array according to the current settings of the particle system
  90135. * @param defines Array to be updated
  90136. * @param blendMode blend mode to take into account when updating the array
  90137. */
  90138. fillDefines(defines: Array<string>, blendMode: number): void;
  90139. /**
  90140. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  90141. * @param uniforms Uniforms array to fill
  90142. * @param attributes Attributes array to fill
  90143. * @param samplers Samplers array to fill
  90144. */
  90145. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  90146. /** @hidden */
  90147. private _getEffect;
  90148. /**
  90149. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  90150. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  90151. */
  90152. animate(preWarmOnly?: boolean): void;
  90153. private _appendParticleVertices;
  90154. /**
  90155. * Rebuilds the particle system.
  90156. */
  90157. rebuild(): void;
  90158. /**
  90159. * Is this system ready to be used/rendered
  90160. * @return true if the system is ready
  90161. */
  90162. isReady(): boolean;
  90163. private _render;
  90164. /**
  90165. * Renders the particle system in its current state.
  90166. * @returns the current number of particles
  90167. */
  90168. render(): number;
  90169. /**
  90170. * Disposes the particle system and free the associated resources
  90171. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  90172. */
  90173. dispose(disposeTexture?: boolean): void;
  90174. /**
  90175. * Clones the particle system.
  90176. * @param name The name of the cloned object
  90177. * @param newEmitter The new emitter to use
  90178. * @returns the cloned particle system
  90179. */
  90180. clone(name: string, newEmitter: any): ParticleSystem;
  90181. /**
  90182. * Serializes the particle system to a JSON object
  90183. * @param serializeTexture defines if the texture must be serialized as well
  90184. * @returns the JSON object
  90185. */
  90186. serialize(serializeTexture?: boolean): any;
  90187. /** @hidden */
  90188. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  90189. /** @hidden */
  90190. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  90191. /**
  90192. * Parses a JSON object to create a particle system.
  90193. * @param parsedParticleSystem The JSON object to parse
  90194. * @param scene The scene to create the particle system in
  90195. * @param rootUrl The root url to use to load external dependencies like texture
  90196. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  90197. * @returns the Parsed particle system
  90198. */
  90199. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  90200. }
  90201. }
  90202. declare module BABYLON {
  90203. /**
  90204. * A particle represents one of the element emitted by a particle system.
  90205. * This is mainly define by its coordinates, direction, velocity and age.
  90206. */
  90207. export class Particle {
  90208. /**
  90209. * The particle system the particle belongs to.
  90210. */
  90211. particleSystem: ParticleSystem;
  90212. private static _Count;
  90213. /**
  90214. * Unique ID of the particle
  90215. */
  90216. id: number;
  90217. /**
  90218. * The world position of the particle in the scene.
  90219. */
  90220. position: Vector3;
  90221. /**
  90222. * The world direction of the particle in the scene.
  90223. */
  90224. direction: Vector3;
  90225. /**
  90226. * The color of the particle.
  90227. */
  90228. color: Color4;
  90229. /**
  90230. * The color change of the particle per step.
  90231. */
  90232. colorStep: Color4;
  90233. /**
  90234. * Defines how long will the life of the particle be.
  90235. */
  90236. lifeTime: number;
  90237. /**
  90238. * The current age of the particle.
  90239. */
  90240. age: number;
  90241. /**
  90242. * The current size of the particle.
  90243. */
  90244. size: number;
  90245. /**
  90246. * The current scale of the particle.
  90247. */
  90248. scale: Vector2;
  90249. /**
  90250. * The current angle of the particle.
  90251. */
  90252. angle: number;
  90253. /**
  90254. * Defines how fast is the angle changing.
  90255. */
  90256. angularSpeed: number;
  90257. /**
  90258. * Defines the cell index used by the particle to be rendered from a sprite.
  90259. */
  90260. cellIndex: number;
  90261. /**
  90262. * The information required to support color remapping
  90263. */
  90264. remapData: Vector4;
  90265. /** @hidden */
  90266. _randomCellOffset?: number;
  90267. /** @hidden */
  90268. _initialDirection: Nullable<Vector3>;
  90269. /** @hidden */
  90270. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  90271. /** @hidden */
  90272. _initialStartSpriteCellID: number;
  90273. /** @hidden */
  90274. _initialEndSpriteCellID: number;
  90275. /** @hidden */
  90276. _currentColorGradient: Nullable<ColorGradient>;
  90277. /** @hidden */
  90278. _currentColor1: Color4;
  90279. /** @hidden */
  90280. _currentColor2: Color4;
  90281. /** @hidden */
  90282. _currentSizeGradient: Nullable<FactorGradient>;
  90283. /** @hidden */
  90284. _currentSize1: number;
  90285. /** @hidden */
  90286. _currentSize2: number;
  90287. /** @hidden */
  90288. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  90289. /** @hidden */
  90290. _currentAngularSpeed1: number;
  90291. /** @hidden */
  90292. _currentAngularSpeed2: number;
  90293. /** @hidden */
  90294. _currentVelocityGradient: Nullable<FactorGradient>;
  90295. /** @hidden */
  90296. _currentVelocity1: number;
  90297. /** @hidden */
  90298. _currentVelocity2: number;
  90299. /** @hidden */
  90300. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  90301. /** @hidden */
  90302. _currentLimitVelocity1: number;
  90303. /** @hidden */
  90304. _currentLimitVelocity2: number;
  90305. /** @hidden */
  90306. _currentDragGradient: Nullable<FactorGradient>;
  90307. /** @hidden */
  90308. _currentDrag1: number;
  90309. /** @hidden */
  90310. _currentDrag2: number;
  90311. /** @hidden */
  90312. _randomNoiseCoordinates1: Vector3;
  90313. /** @hidden */
  90314. _randomNoiseCoordinates2: Vector3;
  90315. /** @hidden */
  90316. _localPosition?: Vector3;
  90317. /**
  90318. * Creates a new instance Particle
  90319. * @param particleSystem the particle system the particle belongs to
  90320. */
  90321. constructor(
  90322. /**
  90323. * The particle system the particle belongs to.
  90324. */
  90325. particleSystem: ParticleSystem);
  90326. private updateCellInfoFromSystem;
  90327. /**
  90328. * Defines how the sprite cell index is updated for the particle
  90329. */
  90330. updateCellIndex(): void;
  90331. /** @hidden */
  90332. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  90333. /** @hidden */
  90334. _inheritParticleInfoToSubEmitters(): void;
  90335. /** @hidden */
  90336. _reset(): void;
  90337. /**
  90338. * Copy the properties of particle to another one.
  90339. * @param other the particle to copy the information to.
  90340. */
  90341. copyTo(other: Particle): void;
  90342. }
  90343. }
  90344. declare module BABYLON {
  90345. /**
  90346. * Particle emitter represents a volume emitting particles.
  90347. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  90348. */
  90349. export interface IParticleEmitterType {
  90350. /**
  90351. * Called by the particle System when the direction is computed for the created particle.
  90352. * @param worldMatrix is the world matrix of the particle system
  90353. * @param directionToUpdate is the direction vector to update with the result
  90354. * @param particle is the particle we are computed the direction for
  90355. * @param isLocal defines if the direction should be set in local space
  90356. */
  90357. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90358. /**
  90359. * Called by the particle System when the position is computed for the created particle.
  90360. * @param worldMatrix is the world matrix of the particle system
  90361. * @param positionToUpdate is the position vector to update with the result
  90362. * @param particle is the particle we are computed the position for
  90363. * @param isLocal defines if the position should be set in local space
  90364. */
  90365. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90366. /**
  90367. * Clones the current emitter and returns a copy of it
  90368. * @returns the new emitter
  90369. */
  90370. clone(): IParticleEmitterType;
  90371. /**
  90372. * Called by the GPUParticleSystem to setup the update shader
  90373. * @param effect defines the update shader
  90374. */
  90375. applyToShader(effect: Effect): void;
  90376. /**
  90377. * Returns a string to use to update the GPU particles update shader
  90378. * @returns the effect defines string
  90379. */
  90380. getEffectDefines(): string;
  90381. /**
  90382. * Returns a string representing the class name
  90383. * @returns a string containing the class name
  90384. */
  90385. getClassName(): string;
  90386. /**
  90387. * Serializes the particle system to a JSON object.
  90388. * @returns the JSON object
  90389. */
  90390. serialize(): any;
  90391. /**
  90392. * Parse properties from a JSON object
  90393. * @param serializationObject defines the JSON object
  90394. * @param scene defines the hosting scene
  90395. */
  90396. parse(serializationObject: any, scene: Scene): void;
  90397. }
  90398. }
  90399. declare module BABYLON {
  90400. /**
  90401. * Particle emitter emitting particles from the inside of a box.
  90402. * It emits the particles randomly between 2 given directions.
  90403. */
  90404. export class BoxParticleEmitter implements IParticleEmitterType {
  90405. /**
  90406. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90407. */
  90408. direction1: Vector3;
  90409. /**
  90410. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90411. */
  90412. direction2: Vector3;
  90413. /**
  90414. * 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.
  90415. */
  90416. minEmitBox: Vector3;
  90417. /**
  90418. * 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.
  90419. */
  90420. maxEmitBox: Vector3;
  90421. /**
  90422. * Creates a new instance BoxParticleEmitter
  90423. */
  90424. constructor();
  90425. /**
  90426. * Called by the particle System when the direction is computed for the created particle.
  90427. * @param worldMatrix is the world matrix of the particle system
  90428. * @param directionToUpdate is the direction vector to update with the result
  90429. * @param particle is the particle we are computed the direction for
  90430. * @param isLocal defines if the direction should be set in local space
  90431. */
  90432. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90433. /**
  90434. * Called by the particle System when the position is computed for the created particle.
  90435. * @param worldMatrix is the world matrix of the particle system
  90436. * @param positionToUpdate is the position vector to update with the result
  90437. * @param particle is the particle we are computed the position for
  90438. * @param isLocal defines if the position should be set in local space
  90439. */
  90440. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90441. /**
  90442. * Clones the current emitter and returns a copy of it
  90443. * @returns the new emitter
  90444. */
  90445. clone(): BoxParticleEmitter;
  90446. /**
  90447. * Called by the GPUParticleSystem to setup the update shader
  90448. * @param effect defines the update shader
  90449. */
  90450. applyToShader(effect: Effect): void;
  90451. /**
  90452. * Returns a string to use to update the GPU particles update shader
  90453. * @returns a string containng the defines string
  90454. */
  90455. getEffectDefines(): string;
  90456. /**
  90457. * Returns the string "BoxParticleEmitter"
  90458. * @returns a string containing the class name
  90459. */
  90460. getClassName(): string;
  90461. /**
  90462. * Serializes the particle system to a JSON object.
  90463. * @returns the JSON object
  90464. */
  90465. serialize(): any;
  90466. /**
  90467. * Parse properties from a JSON object
  90468. * @param serializationObject defines the JSON object
  90469. */
  90470. parse(serializationObject: any): void;
  90471. }
  90472. }
  90473. declare module BABYLON {
  90474. /**
  90475. * Particle emitter emitting particles from the inside of a cone.
  90476. * It emits the particles alongside the cone volume from the base to the particle.
  90477. * The emission direction might be randomized.
  90478. */
  90479. export class ConeParticleEmitter implements IParticleEmitterType {
  90480. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90481. directionRandomizer: number;
  90482. private _radius;
  90483. private _angle;
  90484. private _height;
  90485. /**
  90486. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  90487. */
  90488. radiusRange: number;
  90489. /**
  90490. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  90491. */
  90492. heightRange: number;
  90493. /**
  90494. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  90495. */
  90496. emitFromSpawnPointOnly: boolean;
  90497. /**
  90498. * Gets or sets the radius of the emission cone
  90499. */
  90500. get radius(): number;
  90501. set radius(value: number);
  90502. /**
  90503. * Gets or sets the angle of the emission cone
  90504. */
  90505. get angle(): number;
  90506. set angle(value: number);
  90507. private _buildHeight;
  90508. /**
  90509. * Creates a new instance ConeParticleEmitter
  90510. * @param radius the radius of the emission cone (1 by default)
  90511. * @param angle the cone base angle (PI by default)
  90512. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  90513. */
  90514. constructor(radius?: number, angle?: number,
  90515. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90516. directionRandomizer?: number);
  90517. /**
  90518. * Called by the particle System when the direction is computed for the created particle.
  90519. * @param worldMatrix is the world matrix of the particle system
  90520. * @param directionToUpdate is the direction vector to update with the result
  90521. * @param particle is the particle we are computed the direction for
  90522. * @param isLocal defines if the direction should be set in local space
  90523. */
  90524. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90525. /**
  90526. * Called by the particle System when the position is computed for the created particle.
  90527. * @param worldMatrix is the world matrix of the particle system
  90528. * @param positionToUpdate is the position vector to update with the result
  90529. * @param particle is the particle we are computed the position for
  90530. * @param isLocal defines if the position should be set in local space
  90531. */
  90532. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90533. /**
  90534. * Clones the current emitter and returns a copy of it
  90535. * @returns the new emitter
  90536. */
  90537. clone(): ConeParticleEmitter;
  90538. /**
  90539. * Called by the GPUParticleSystem to setup the update shader
  90540. * @param effect defines the update shader
  90541. */
  90542. applyToShader(effect: Effect): void;
  90543. /**
  90544. * Returns a string to use to update the GPU particles update shader
  90545. * @returns a string containng the defines string
  90546. */
  90547. getEffectDefines(): string;
  90548. /**
  90549. * Returns the string "ConeParticleEmitter"
  90550. * @returns a string containing the class name
  90551. */
  90552. getClassName(): string;
  90553. /**
  90554. * Serializes the particle system to a JSON object.
  90555. * @returns the JSON object
  90556. */
  90557. serialize(): any;
  90558. /**
  90559. * Parse properties from a JSON object
  90560. * @param serializationObject defines the JSON object
  90561. */
  90562. parse(serializationObject: any): void;
  90563. }
  90564. }
  90565. declare module BABYLON {
  90566. /**
  90567. * Particle emitter emitting particles from the inside of a cylinder.
  90568. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  90569. */
  90570. export class CylinderParticleEmitter implements IParticleEmitterType {
  90571. /**
  90572. * The radius of the emission cylinder.
  90573. */
  90574. radius: number;
  90575. /**
  90576. * The height of the emission cylinder.
  90577. */
  90578. height: number;
  90579. /**
  90580. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90581. */
  90582. radiusRange: number;
  90583. /**
  90584. * How much to randomize the particle direction [0-1].
  90585. */
  90586. directionRandomizer: number;
  90587. /**
  90588. * Creates a new instance CylinderParticleEmitter
  90589. * @param radius the radius of the emission cylinder (1 by default)
  90590. * @param height the height of the emission cylinder (1 by default)
  90591. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90592. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90593. */
  90594. constructor(
  90595. /**
  90596. * The radius of the emission cylinder.
  90597. */
  90598. radius?: number,
  90599. /**
  90600. * The height of the emission cylinder.
  90601. */
  90602. height?: number,
  90603. /**
  90604. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90605. */
  90606. radiusRange?: number,
  90607. /**
  90608. * How much to randomize the particle direction [0-1].
  90609. */
  90610. directionRandomizer?: number);
  90611. /**
  90612. * Called by the particle System when the direction is computed for the created particle.
  90613. * @param worldMatrix is the world matrix of the particle system
  90614. * @param directionToUpdate is the direction vector to update with the result
  90615. * @param particle is the particle we are computed the direction for
  90616. * @param isLocal defines if the direction should be set in local space
  90617. */
  90618. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90619. /**
  90620. * Called by the particle System when the position is computed for the created particle.
  90621. * @param worldMatrix is the world matrix of the particle system
  90622. * @param positionToUpdate is the position vector to update with the result
  90623. * @param particle is the particle we are computed the position for
  90624. * @param isLocal defines if the position should be set in local space
  90625. */
  90626. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90627. /**
  90628. * Clones the current emitter and returns a copy of it
  90629. * @returns the new emitter
  90630. */
  90631. clone(): CylinderParticleEmitter;
  90632. /**
  90633. * Called by the GPUParticleSystem to setup the update shader
  90634. * @param effect defines the update shader
  90635. */
  90636. applyToShader(effect: Effect): void;
  90637. /**
  90638. * Returns a string to use to update the GPU particles update shader
  90639. * @returns a string containng the defines string
  90640. */
  90641. getEffectDefines(): string;
  90642. /**
  90643. * Returns the string "CylinderParticleEmitter"
  90644. * @returns a string containing the class name
  90645. */
  90646. getClassName(): string;
  90647. /**
  90648. * Serializes the particle system to a JSON object.
  90649. * @returns the JSON object
  90650. */
  90651. serialize(): any;
  90652. /**
  90653. * Parse properties from a JSON object
  90654. * @param serializationObject defines the JSON object
  90655. */
  90656. parse(serializationObject: any): void;
  90657. }
  90658. /**
  90659. * Particle emitter emitting particles from the inside of a cylinder.
  90660. * It emits the particles randomly between two vectors.
  90661. */
  90662. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  90663. /**
  90664. * The min limit of the emission direction.
  90665. */
  90666. direction1: Vector3;
  90667. /**
  90668. * The max limit of the emission direction.
  90669. */
  90670. direction2: Vector3;
  90671. /**
  90672. * Creates a new instance CylinderDirectedParticleEmitter
  90673. * @param radius the radius of the emission cylinder (1 by default)
  90674. * @param height the height of the emission cylinder (1 by default)
  90675. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90676. * @param direction1 the min limit of the emission direction (up vector by default)
  90677. * @param direction2 the max limit of the emission direction (up vector by default)
  90678. */
  90679. constructor(radius?: number, height?: number, radiusRange?: number,
  90680. /**
  90681. * The min limit of the emission direction.
  90682. */
  90683. direction1?: Vector3,
  90684. /**
  90685. * The max limit of the emission direction.
  90686. */
  90687. direction2?: Vector3);
  90688. /**
  90689. * Called by the particle System when the direction is computed for the created particle.
  90690. * @param worldMatrix is the world matrix of the particle system
  90691. * @param directionToUpdate is the direction vector to update with the result
  90692. * @param particle is the particle we are computed the direction for
  90693. */
  90694. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90695. /**
  90696. * Clones the current emitter and returns a copy of it
  90697. * @returns the new emitter
  90698. */
  90699. clone(): CylinderDirectedParticleEmitter;
  90700. /**
  90701. * Called by the GPUParticleSystem to setup the update shader
  90702. * @param effect defines the update shader
  90703. */
  90704. applyToShader(effect: Effect): void;
  90705. /**
  90706. * Returns a string to use to update the GPU particles update shader
  90707. * @returns a string containng the defines string
  90708. */
  90709. getEffectDefines(): string;
  90710. /**
  90711. * Returns the string "CylinderDirectedParticleEmitter"
  90712. * @returns a string containing the class name
  90713. */
  90714. getClassName(): string;
  90715. /**
  90716. * Serializes the particle system to a JSON object.
  90717. * @returns the JSON object
  90718. */
  90719. serialize(): any;
  90720. /**
  90721. * Parse properties from a JSON object
  90722. * @param serializationObject defines the JSON object
  90723. */
  90724. parse(serializationObject: any): void;
  90725. }
  90726. }
  90727. declare module BABYLON {
  90728. /**
  90729. * Particle emitter emitting particles from the inside of a hemisphere.
  90730. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  90731. */
  90732. export class HemisphericParticleEmitter implements IParticleEmitterType {
  90733. /**
  90734. * The radius of the emission hemisphere.
  90735. */
  90736. radius: number;
  90737. /**
  90738. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90739. */
  90740. radiusRange: number;
  90741. /**
  90742. * How much to randomize the particle direction [0-1].
  90743. */
  90744. directionRandomizer: number;
  90745. /**
  90746. * Creates a new instance HemisphericParticleEmitter
  90747. * @param radius the radius of the emission hemisphere (1 by default)
  90748. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90749. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90750. */
  90751. constructor(
  90752. /**
  90753. * The radius of the emission hemisphere.
  90754. */
  90755. radius?: number,
  90756. /**
  90757. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90758. */
  90759. radiusRange?: number,
  90760. /**
  90761. * How much to randomize the particle direction [0-1].
  90762. */
  90763. directionRandomizer?: number);
  90764. /**
  90765. * Called by the particle System when the direction is computed for the created particle.
  90766. * @param worldMatrix is the world matrix of the particle system
  90767. * @param directionToUpdate is the direction vector to update with the result
  90768. * @param particle is the particle we are computed the direction for
  90769. * @param isLocal defines if the direction should be set in local space
  90770. */
  90771. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90772. /**
  90773. * Called by the particle System when the position is computed for the created particle.
  90774. * @param worldMatrix is the world matrix of the particle system
  90775. * @param positionToUpdate is the position vector to update with the result
  90776. * @param particle is the particle we are computed the position for
  90777. * @param isLocal defines if the position should be set in local space
  90778. */
  90779. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90780. /**
  90781. * Clones the current emitter and returns a copy of it
  90782. * @returns the new emitter
  90783. */
  90784. clone(): HemisphericParticleEmitter;
  90785. /**
  90786. * Called by the GPUParticleSystem to setup the update shader
  90787. * @param effect defines the update shader
  90788. */
  90789. applyToShader(effect: Effect): void;
  90790. /**
  90791. * Returns a string to use to update the GPU particles update shader
  90792. * @returns a string containng the defines string
  90793. */
  90794. getEffectDefines(): string;
  90795. /**
  90796. * Returns the string "HemisphericParticleEmitter"
  90797. * @returns a string containing the class name
  90798. */
  90799. getClassName(): string;
  90800. /**
  90801. * Serializes the particle system to a JSON object.
  90802. * @returns the JSON object
  90803. */
  90804. serialize(): any;
  90805. /**
  90806. * Parse properties from a JSON object
  90807. * @param serializationObject defines the JSON object
  90808. */
  90809. parse(serializationObject: any): void;
  90810. }
  90811. }
  90812. declare module BABYLON {
  90813. /**
  90814. * Particle emitter emitting particles from a point.
  90815. * It emits the particles randomly between 2 given directions.
  90816. */
  90817. export class PointParticleEmitter implements IParticleEmitterType {
  90818. /**
  90819. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90820. */
  90821. direction1: Vector3;
  90822. /**
  90823. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90824. */
  90825. direction2: Vector3;
  90826. /**
  90827. * Creates a new instance PointParticleEmitter
  90828. */
  90829. constructor();
  90830. /**
  90831. * Called by the particle System when the direction is computed for the created particle.
  90832. * @param worldMatrix is the world matrix of the particle system
  90833. * @param directionToUpdate is the direction vector to update with the result
  90834. * @param particle is the particle we are computed the direction for
  90835. * @param isLocal defines if the direction should be set in local space
  90836. */
  90837. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90838. /**
  90839. * Called by the particle System when the position is computed for the created particle.
  90840. * @param worldMatrix is the world matrix of the particle system
  90841. * @param positionToUpdate is the position vector to update with the result
  90842. * @param particle is the particle we are computed the position for
  90843. * @param isLocal defines if the position should be set in local space
  90844. */
  90845. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90846. /**
  90847. * Clones the current emitter and returns a copy of it
  90848. * @returns the new emitter
  90849. */
  90850. clone(): PointParticleEmitter;
  90851. /**
  90852. * Called by the GPUParticleSystem to setup the update shader
  90853. * @param effect defines the update shader
  90854. */
  90855. applyToShader(effect: Effect): void;
  90856. /**
  90857. * Returns a string to use to update the GPU particles update shader
  90858. * @returns a string containng the defines string
  90859. */
  90860. getEffectDefines(): string;
  90861. /**
  90862. * Returns the string "PointParticleEmitter"
  90863. * @returns a string containing the class name
  90864. */
  90865. getClassName(): string;
  90866. /**
  90867. * Serializes the particle system to a JSON object.
  90868. * @returns the JSON object
  90869. */
  90870. serialize(): any;
  90871. /**
  90872. * Parse properties from a JSON object
  90873. * @param serializationObject defines the JSON object
  90874. */
  90875. parse(serializationObject: any): void;
  90876. }
  90877. }
  90878. declare module BABYLON {
  90879. /**
  90880. * Particle emitter emitting particles from the inside of a sphere.
  90881. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  90882. */
  90883. export class SphereParticleEmitter implements IParticleEmitterType {
  90884. /**
  90885. * The radius of the emission sphere.
  90886. */
  90887. radius: number;
  90888. /**
  90889. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90890. */
  90891. radiusRange: number;
  90892. /**
  90893. * How much to randomize the particle direction [0-1].
  90894. */
  90895. directionRandomizer: number;
  90896. /**
  90897. * Creates a new instance SphereParticleEmitter
  90898. * @param radius the radius of the emission sphere (1 by default)
  90899. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90900. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90901. */
  90902. constructor(
  90903. /**
  90904. * The radius of the emission sphere.
  90905. */
  90906. radius?: number,
  90907. /**
  90908. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90909. */
  90910. radiusRange?: number,
  90911. /**
  90912. * How much to randomize the particle direction [0-1].
  90913. */
  90914. directionRandomizer?: number);
  90915. /**
  90916. * Called by the particle System when the direction is computed for the created particle.
  90917. * @param worldMatrix is the world matrix of the particle system
  90918. * @param directionToUpdate is the direction vector to update with the result
  90919. * @param particle is the particle we are computed the direction for
  90920. * @param isLocal defines if the direction should be set in local space
  90921. */
  90922. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90923. /**
  90924. * Called by the particle System when the position is computed for the created particle.
  90925. * @param worldMatrix is the world matrix of the particle system
  90926. * @param positionToUpdate is the position vector to update with the result
  90927. * @param particle is the particle we are computed the position for
  90928. * @param isLocal defines if the position should be set in local space
  90929. */
  90930. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90931. /**
  90932. * Clones the current emitter and returns a copy of it
  90933. * @returns the new emitter
  90934. */
  90935. clone(): SphereParticleEmitter;
  90936. /**
  90937. * Called by the GPUParticleSystem to setup the update shader
  90938. * @param effect defines the update shader
  90939. */
  90940. applyToShader(effect: Effect): void;
  90941. /**
  90942. * Returns a string to use to update the GPU particles update shader
  90943. * @returns a string containng the defines string
  90944. */
  90945. getEffectDefines(): string;
  90946. /**
  90947. * Returns the string "SphereParticleEmitter"
  90948. * @returns a string containing the class name
  90949. */
  90950. getClassName(): string;
  90951. /**
  90952. * Serializes the particle system to a JSON object.
  90953. * @returns the JSON object
  90954. */
  90955. serialize(): any;
  90956. /**
  90957. * Parse properties from a JSON object
  90958. * @param serializationObject defines the JSON object
  90959. */
  90960. parse(serializationObject: any): void;
  90961. }
  90962. /**
  90963. * Particle emitter emitting particles from the inside of a sphere.
  90964. * It emits the particles randomly between two vectors.
  90965. */
  90966. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  90967. /**
  90968. * The min limit of the emission direction.
  90969. */
  90970. direction1: Vector3;
  90971. /**
  90972. * The max limit of the emission direction.
  90973. */
  90974. direction2: Vector3;
  90975. /**
  90976. * Creates a new instance SphereDirectedParticleEmitter
  90977. * @param radius the radius of the emission sphere (1 by default)
  90978. * @param direction1 the min limit of the emission direction (up vector by default)
  90979. * @param direction2 the max limit of the emission direction (up vector by default)
  90980. */
  90981. constructor(radius?: number,
  90982. /**
  90983. * The min limit of the emission direction.
  90984. */
  90985. direction1?: Vector3,
  90986. /**
  90987. * The max limit of the emission direction.
  90988. */
  90989. direction2?: Vector3);
  90990. /**
  90991. * Called by the particle System when the direction is computed for the created particle.
  90992. * @param worldMatrix is the world matrix of the particle system
  90993. * @param directionToUpdate is the direction vector to update with the result
  90994. * @param particle is the particle we are computed the direction for
  90995. */
  90996. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90997. /**
  90998. * Clones the current emitter and returns a copy of it
  90999. * @returns the new emitter
  91000. */
  91001. clone(): SphereDirectedParticleEmitter;
  91002. /**
  91003. * Called by the GPUParticleSystem to setup the update shader
  91004. * @param effect defines the update shader
  91005. */
  91006. applyToShader(effect: Effect): void;
  91007. /**
  91008. * Returns a string to use to update the GPU particles update shader
  91009. * @returns a string containng the defines string
  91010. */
  91011. getEffectDefines(): string;
  91012. /**
  91013. * Returns the string "SphereDirectedParticleEmitter"
  91014. * @returns a string containing the class name
  91015. */
  91016. getClassName(): string;
  91017. /**
  91018. * Serializes the particle system to a JSON object.
  91019. * @returns the JSON object
  91020. */
  91021. serialize(): any;
  91022. /**
  91023. * Parse properties from a JSON object
  91024. * @param serializationObject defines the JSON object
  91025. */
  91026. parse(serializationObject: any): void;
  91027. }
  91028. }
  91029. declare module BABYLON {
  91030. /**
  91031. * Particle emitter emitting particles from a custom list of positions.
  91032. */
  91033. export class CustomParticleEmitter implements IParticleEmitterType {
  91034. /**
  91035. * Gets or sets the position generator that will create the inital position of each particle.
  91036. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91037. */
  91038. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  91039. /**
  91040. * Gets or sets the destination generator that will create the final destination of each particle.
  91041. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91042. */
  91043. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  91044. /**
  91045. * Creates a new instance CustomParticleEmitter
  91046. */
  91047. constructor();
  91048. /**
  91049. * Called by the particle System when the direction is computed for the created particle.
  91050. * @param worldMatrix is the world matrix of the particle system
  91051. * @param directionToUpdate is the direction vector to update with the result
  91052. * @param particle is the particle we are computed the direction for
  91053. * @param isLocal defines if the direction should be set in local space
  91054. */
  91055. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91056. /**
  91057. * Called by the particle System when the position is computed for the created particle.
  91058. * @param worldMatrix is the world matrix of the particle system
  91059. * @param positionToUpdate is the position vector to update with the result
  91060. * @param particle is the particle we are computed the position for
  91061. * @param isLocal defines if the position should be set in local space
  91062. */
  91063. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91064. /**
  91065. * Clones the current emitter and returns a copy of it
  91066. * @returns the new emitter
  91067. */
  91068. clone(): CustomParticleEmitter;
  91069. /**
  91070. * Called by the GPUParticleSystem to setup the update shader
  91071. * @param effect defines the update shader
  91072. */
  91073. applyToShader(effect: Effect): void;
  91074. /**
  91075. * Returns a string to use to update the GPU particles update shader
  91076. * @returns a string containng the defines string
  91077. */
  91078. getEffectDefines(): string;
  91079. /**
  91080. * Returns the string "PointParticleEmitter"
  91081. * @returns a string containing the class name
  91082. */
  91083. getClassName(): string;
  91084. /**
  91085. * Serializes the particle system to a JSON object.
  91086. * @returns the JSON object
  91087. */
  91088. serialize(): any;
  91089. /**
  91090. * Parse properties from a JSON object
  91091. * @param serializationObject defines the JSON object
  91092. */
  91093. parse(serializationObject: any): void;
  91094. }
  91095. }
  91096. declare module BABYLON {
  91097. /**
  91098. * Particle emitter emitting particles from the inside of a box.
  91099. * It emits the particles randomly between 2 given directions.
  91100. */
  91101. export class MeshParticleEmitter implements IParticleEmitterType {
  91102. private _indices;
  91103. private _positions;
  91104. private _normals;
  91105. private _storedNormal;
  91106. private _mesh;
  91107. /**
  91108. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91109. */
  91110. direction1: Vector3;
  91111. /**
  91112. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91113. */
  91114. direction2: Vector3;
  91115. /**
  91116. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  91117. */
  91118. useMeshNormalsForDirection: boolean;
  91119. /** Defines the mesh to use as source */
  91120. get mesh(): Nullable<AbstractMesh>;
  91121. set mesh(value: Nullable<AbstractMesh>);
  91122. /**
  91123. * Creates a new instance MeshParticleEmitter
  91124. * @param mesh defines the mesh to use as source
  91125. */
  91126. constructor(mesh?: Nullable<AbstractMesh>);
  91127. /**
  91128. * Called by the particle System when the direction is computed for the created particle.
  91129. * @param worldMatrix is the world matrix of the particle system
  91130. * @param directionToUpdate is the direction vector to update with the result
  91131. * @param particle is the particle we are computed the direction for
  91132. * @param isLocal defines if the direction should be set in local space
  91133. */
  91134. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91135. /**
  91136. * Called by the particle System when the position is computed for the created particle.
  91137. * @param worldMatrix is the world matrix of the particle system
  91138. * @param positionToUpdate is the position vector to update with the result
  91139. * @param particle is the particle we are computed the position for
  91140. * @param isLocal defines if the position should be set in local space
  91141. */
  91142. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91143. /**
  91144. * Clones the current emitter and returns a copy of it
  91145. * @returns the new emitter
  91146. */
  91147. clone(): MeshParticleEmitter;
  91148. /**
  91149. * Called by the GPUParticleSystem to setup the update shader
  91150. * @param effect defines the update shader
  91151. */
  91152. applyToShader(effect: Effect): void;
  91153. /**
  91154. * Returns a string to use to update the GPU particles update shader
  91155. * @returns a string containng the defines string
  91156. */
  91157. getEffectDefines(): string;
  91158. /**
  91159. * Returns the string "BoxParticleEmitter"
  91160. * @returns a string containing the class name
  91161. */
  91162. getClassName(): string;
  91163. /**
  91164. * Serializes the particle system to a JSON object.
  91165. * @returns the JSON object
  91166. */
  91167. serialize(): any;
  91168. /**
  91169. * Parse properties from a JSON object
  91170. * @param serializationObject defines the JSON object
  91171. * @param scene defines the hosting scene
  91172. */
  91173. parse(serializationObject: any, scene: Scene): void;
  91174. }
  91175. }
  91176. declare module BABYLON {
  91177. /**
  91178. * Interface representing a particle system in Babylon.js.
  91179. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  91180. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  91181. */
  91182. export interface IParticleSystem {
  91183. /**
  91184. * List of animations used by the particle system.
  91185. */
  91186. animations: Animation[];
  91187. /**
  91188. * The id of the Particle system.
  91189. */
  91190. id: string;
  91191. /**
  91192. * The name of the Particle system.
  91193. */
  91194. name: string;
  91195. /**
  91196. * The emitter represents the Mesh or position we are attaching the particle system to.
  91197. */
  91198. emitter: Nullable<AbstractMesh | Vector3>;
  91199. /**
  91200. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91201. */
  91202. isBillboardBased: boolean;
  91203. /**
  91204. * The rendering group used by the Particle system to chose when to render.
  91205. */
  91206. renderingGroupId: number;
  91207. /**
  91208. * The layer mask we are rendering the particles through.
  91209. */
  91210. layerMask: number;
  91211. /**
  91212. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  91213. */
  91214. updateSpeed: number;
  91215. /**
  91216. * The amount of time the particle system is running (depends of the overall update speed).
  91217. */
  91218. targetStopDuration: number;
  91219. /**
  91220. * The texture used to render each particle. (this can be a spritesheet)
  91221. */
  91222. particleTexture: Nullable<Texture>;
  91223. /**
  91224. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  91225. */
  91226. blendMode: number;
  91227. /**
  91228. * Minimum life time of emitting particles.
  91229. */
  91230. minLifeTime: number;
  91231. /**
  91232. * Maximum life time of emitting particles.
  91233. */
  91234. maxLifeTime: number;
  91235. /**
  91236. * Minimum Size of emitting particles.
  91237. */
  91238. minSize: number;
  91239. /**
  91240. * Maximum Size of emitting particles.
  91241. */
  91242. maxSize: number;
  91243. /**
  91244. * Minimum scale of emitting particles on X axis.
  91245. */
  91246. minScaleX: number;
  91247. /**
  91248. * Maximum scale of emitting particles on X axis.
  91249. */
  91250. maxScaleX: number;
  91251. /**
  91252. * Minimum scale of emitting particles on Y axis.
  91253. */
  91254. minScaleY: number;
  91255. /**
  91256. * Maximum scale of emitting particles on Y axis.
  91257. */
  91258. maxScaleY: number;
  91259. /**
  91260. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91261. */
  91262. color1: Color4;
  91263. /**
  91264. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91265. */
  91266. color2: Color4;
  91267. /**
  91268. * Color the particle will have at the end of its lifetime.
  91269. */
  91270. colorDead: Color4;
  91271. /**
  91272. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  91273. */
  91274. emitRate: number;
  91275. /**
  91276. * You can use gravity if you want to give an orientation to your particles.
  91277. */
  91278. gravity: Vector3;
  91279. /**
  91280. * Minimum power of emitting particles.
  91281. */
  91282. minEmitPower: number;
  91283. /**
  91284. * Maximum power of emitting particles.
  91285. */
  91286. maxEmitPower: number;
  91287. /**
  91288. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91289. */
  91290. minAngularSpeed: number;
  91291. /**
  91292. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91293. */
  91294. maxAngularSpeed: number;
  91295. /**
  91296. * Gets or sets the minimal initial rotation in radians.
  91297. */
  91298. minInitialRotation: number;
  91299. /**
  91300. * Gets or sets the maximal initial rotation in radians.
  91301. */
  91302. maxInitialRotation: number;
  91303. /**
  91304. * The particle emitter type defines the emitter used by the particle system.
  91305. * It can be for example box, sphere, or cone...
  91306. */
  91307. particleEmitterType: Nullable<IParticleEmitterType>;
  91308. /**
  91309. * Defines the delay in milliseconds before starting the system (0 by default)
  91310. */
  91311. startDelay: number;
  91312. /**
  91313. * 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
  91314. */
  91315. preWarmCycles: number;
  91316. /**
  91317. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  91318. */
  91319. preWarmStepOffset: number;
  91320. /**
  91321. * 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)
  91322. */
  91323. spriteCellChangeSpeed: number;
  91324. /**
  91325. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91326. */
  91327. startSpriteCellID: number;
  91328. /**
  91329. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91330. */
  91331. endSpriteCellID: number;
  91332. /**
  91333. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91334. */
  91335. spriteCellWidth: number;
  91336. /**
  91337. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91338. */
  91339. spriteCellHeight: number;
  91340. /**
  91341. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91342. */
  91343. spriteRandomStartCell: boolean;
  91344. /**
  91345. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  91346. */
  91347. isAnimationSheetEnabled: boolean;
  91348. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91349. translationPivot: Vector2;
  91350. /**
  91351. * Gets or sets a texture used to add random noise to particle positions
  91352. */
  91353. noiseTexture: Nullable<BaseTexture>;
  91354. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91355. noiseStrength: Vector3;
  91356. /**
  91357. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91358. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91359. */
  91360. billboardMode: number;
  91361. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91362. limitVelocityDamping: number;
  91363. /**
  91364. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91365. */
  91366. beginAnimationOnStart: boolean;
  91367. /**
  91368. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91369. */
  91370. beginAnimationFrom: number;
  91371. /**
  91372. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91373. */
  91374. beginAnimationTo: number;
  91375. /**
  91376. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91377. */
  91378. beginAnimationLoop: boolean;
  91379. /**
  91380. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91381. */
  91382. disposeOnStop: boolean;
  91383. /**
  91384. * Specifies if the particles are updated in emitter local space or world space
  91385. */
  91386. isLocal: boolean;
  91387. /** Snippet ID if the particle system was created from the snippet server */
  91388. snippetId: string;
  91389. /**
  91390. * Gets the maximum number of particles active at the same time.
  91391. * @returns The max number of active particles.
  91392. */
  91393. getCapacity(): number;
  91394. /**
  91395. * Gets the number of particles active at the same time.
  91396. * @returns The number of active particles.
  91397. */
  91398. getActiveCount(): number;
  91399. /**
  91400. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91401. * @returns True if it has been started, otherwise false.
  91402. */
  91403. isStarted(): boolean;
  91404. /**
  91405. * Animates the particle system for this frame.
  91406. */
  91407. animate(): void;
  91408. /**
  91409. * Renders the particle system in its current state.
  91410. * @returns the current number of particles
  91411. */
  91412. render(): number;
  91413. /**
  91414. * Dispose the particle system and frees its associated resources.
  91415. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91416. */
  91417. dispose(disposeTexture?: boolean): void;
  91418. /**
  91419. * An event triggered when the system is disposed
  91420. */
  91421. onDisposeObservable: Observable<IParticleSystem>;
  91422. /**
  91423. * Clones the particle system.
  91424. * @param name The name of the cloned object
  91425. * @param newEmitter The new emitter to use
  91426. * @returns the cloned particle system
  91427. */
  91428. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  91429. /**
  91430. * Serializes the particle system to a JSON object
  91431. * @param serializeTexture defines if the texture must be serialized as well
  91432. * @returns the JSON object
  91433. */
  91434. serialize(serializeTexture: boolean): any;
  91435. /**
  91436. * Rebuild the particle system
  91437. */
  91438. rebuild(): void;
  91439. /** Force the system to rebuild all gradients that need to be resync */
  91440. forceRefreshGradients(): void;
  91441. /**
  91442. * Starts the particle system and begins to emit
  91443. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  91444. */
  91445. start(delay?: number): void;
  91446. /**
  91447. * Stops the particle system.
  91448. */
  91449. stop(): void;
  91450. /**
  91451. * Remove all active particles
  91452. */
  91453. reset(): void;
  91454. /**
  91455. * Gets a boolean indicating that the system is stopping
  91456. * @returns true if the system is currently stopping
  91457. */
  91458. isStopping(): boolean;
  91459. /**
  91460. * Is this system ready to be used/rendered
  91461. * @return true if the system is ready
  91462. */
  91463. isReady(): boolean;
  91464. /**
  91465. * Returns the string "ParticleSystem"
  91466. * @returns a string containing the class name
  91467. */
  91468. getClassName(): string;
  91469. /**
  91470. * Gets the custom effect used to render the particles
  91471. * @param blendMode Blend mode for which the effect should be retrieved
  91472. * @returns The effect
  91473. */
  91474. getCustomEffect(blendMode: number): Nullable<Effect>;
  91475. /**
  91476. * Sets the custom effect used to render the particles
  91477. * @param effect The effect to set
  91478. * @param blendMode Blend mode for which the effect should be set
  91479. */
  91480. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  91481. /**
  91482. * Fill the defines array according to the current settings of the particle system
  91483. * @param defines Array to be updated
  91484. * @param blendMode blend mode to take into account when updating the array
  91485. */
  91486. fillDefines(defines: Array<string>, blendMode: number): void;
  91487. /**
  91488. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  91489. * @param uniforms Uniforms array to fill
  91490. * @param attributes Attributes array to fill
  91491. * @param samplers Samplers array to fill
  91492. */
  91493. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  91494. /**
  91495. * Observable that will be called just before the particles are drawn
  91496. */
  91497. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  91498. /**
  91499. * Gets the name of the particle vertex shader
  91500. */
  91501. vertexShaderName: string;
  91502. /**
  91503. * Adds a new color gradient
  91504. * @param gradient defines the gradient to use (between 0 and 1)
  91505. * @param color1 defines the color to affect to the specified gradient
  91506. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91507. * @returns the current particle system
  91508. */
  91509. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91510. /**
  91511. * Remove a specific color gradient
  91512. * @param gradient defines the gradient to remove
  91513. * @returns the current particle system
  91514. */
  91515. removeColorGradient(gradient: number): IParticleSystem;
  91516. /**
  91517. * Adds a new size gradient
  91518. * @param gradient defines the gradient to use (between 0 and 1)
  91519. * @param factor defines the size factor to affect to the specified gradient
  91520. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91521. * @returns the current particle system
  91522. */
  91523. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91524. /**
  91525. * Remove a specific size gradient
  91526. * @param gradient defines the gradient to remove
  91527. * @returns the current particle system
  91528. */
  91529. removeSizeGradient(gradient: number): IParticleSystem;
  91530. /**
  91531. * Gets the current list of color gradients.
  91532. * You must use addColorGradient and removeColorGradient to udpate this list
  91533. * @returns the list of color gradients
  91534. */
  91535. getColorGradients(): Nullable<Array<ColorGradient>>;
  91536. /**
  91537. * Gets the current list of size gradients.
  91538. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91539. * @returns the list of size gradients
  91540. */
  91541. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91542. /**
  91543. * Gets the current list of angular speed gradients.
  91544. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91545. * @returns the list of angular speed gradients
  91546. */
  91547. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91548. /**
  91549. * Adds a new angular speed gradient
  91550. * @param gradient defines the gradient to use (between 0 and 1)
  91551. * @param factor defines the angular speed to affect to the specified gradient
  91552. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91553. * @returns the current particle system
  91554. */
  91555. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91556. /**
  91557. * Remove a specific angular speed gradient
  91558. * @param gradient defines the gradient to remove
  91559. * @returns the current particle system
  91560. */
  91561. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91562. /**
  91563. * Gets the current list of velocity gradients.
  91564. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91565. * @returns the list of velocity gradients
  91566. */
  91567. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91568. /**
  91569. * Adds a new velocity gradient
  91570. * @param gradient defines the gradient to use (between 0 and 1)
  91571. * @param factor defines the velocity to affect to the specified gradient
  91572. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91573. * @returns the current particle system
  91574. */
  91575. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91576. /**
  91577. * Remove a specific velocity gradient
  91578. * @param gradient defines the gradient to remove
  91579. * @returns the current particle system
  91580. */
  91581. removeVelocityGradient(gradient: number): IParticleSystem;
  91582. /**
  91583. * Gets the current list of limit velocity gradients.
  91584. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  91585. * @returns the list of limit velocity gradients
  91586. */
  91587. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  91588. /**
  91589. * Adds a new limit velocity gradient
  91590. * @param gradient defines the gradient to use (between 0 and 1)
  91591. * @param factor defines the limit velocity to affect to the specified gradient
  91592. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91593. * @returns the current particle system
  91594. */
  91595. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91596. /**
  91597. * Remove a specific limit velocity gradient
  91598. * @param gradient defines the gradient to remove
  91599. * @returns the current particle system
  91600. */
  91601. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  91602. /**
  91603. * Adds a new drag gradient
  91604. * @param gradient defines the gradient to use (between 0 and 1)
  91605. * @param factor defines the drag to affect to the specified gradient
  91606. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91607. * @returns the current particle system
  91608. */
  91609. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91610. /**
  91611. * Remove a specific drag gradient
  91612. * @param gradient defines the gradient to remove
  91613. * @returns the current particle system
  91614. */
  91615. removeDragGradient(gradient: number): IParticleSystem;
  91616. /**
  91617. * Gets the current list of drag gradients.
  91618. * You must use addDragGradient and removeDragGradient to udpate this list
  91619. * @returns the list of drag gradients
  91620. */
  91621. getDragGradients(): Nullable<Array<FactorGradient>>;
  91622. /**
  91623. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  91624. * @param gradient defines the gradient to use (between 0 and 1)
  91625. * @param factor defines the emit rate to affect to the specified gradient
  91626. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91627. * @returns the current particle system
  91628. */
  91629. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91630. /**
  91631. * Remove a specific emit rate gradient
  91632. * @param gradient defines the gradient to remove
  91633. * @returns the current particle system
  91634. */
  91635. removeEmitRateGradient(gradient: number): IParticleSystem;
  91636. /**
  91637. * Gets the current list of emit rate gradients.
  91638. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91639. * @returns the list of emit rate gradients
  91640. */
  91641. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91642. /**
  91643. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  91644. * @param gradient defines the gradient to use (between 0 and 1)
  91645. * @param factor defines the start size to affect to the specified gradient
  91646. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91647. * @returns the current particle system
  91648. */
  91649. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91650. /**
  91651. * Remove a specific start size gradient
  91652. * @param gradient defines the gradient to remove
  91653. * @returns the current particle system
  91654. */
  91655. removeStartSizeGradient(gradient: number): IParticleSystem;
  91656. /**
  91657. * Gets the current list of start size gradients.
  91658. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  91659. * @returns the list of start size gradients
  91660. */
  91661. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  91662. /**
  91663. * Adds a new life time gradient
  91664. * @param gradient defines the gradient to use (between 0 and 1)
  91665. * @param factor defines the life time factor to affect to the specified gradient
  91666. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91667. * @returns the current particle system
  91668. */
  91669. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91670. /**
  91671. * Remove a specific life time gradient
  91672. * @param gradient defines the gradient to remove
  91673. * @returns the current particle system
  91674. */
  91675. removeLifeTimeGradient(gradient: number): IParticleSystem;
  91676. /**
  91677. * Gets the current list of life time gradients.
  91678. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  91679. * @returns the list of life time gradients
  91680. */
  91681. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  91682. /**
  91683. * Gets the current list of color gradients.
  91684. * You must use addColorGradient and removeColorGradient to udpate this list
  91685. * @returns the list of color gradients
  91686. */
  91687. getColorGradients(): Nullable<Array<ColorGradient>>;
  91688. /**
  91689. * Adds a new ramp gradient used to remap particle colors
  91690. * @param gradient defines the gradient to use (between 0 and 1)
  91691. * @param color defines the color to affect to the specified gradient
  91692. * @returns the current particle system
  91693. */
  91694. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  91695. /**
  91696. * Gets the current list of ramp gradients.
  91697. * You must use addRampGradient and removeRampGradient to udpate this list
  91698. * @returns the list of ramp gradients
  91699. */
  91700. getRampGradients(): Nullable<Array<Color3Gradient>>;
  91701. /** Gets or sets a boolean indicating that ramp gradients must be used
  91702. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  91703. */
  91704. useRampGradients: boolean;
  91705. /**
  91706. * Adds a new color remap gradient
  91707. * @param gradient defines the gradient to use (between 0 and 1)
  91708. * @param min defines the color remap minimal range
  91709. * @param max defines the color remap maximal range
  91710. * @returns the current particle system
  91711. */
  91712. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91713. /**
  91714. * Gets the current list of color remap gradients.
  91715. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  91716. * @returns the list of color remap gradients
  91717. */
  91718. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  91719. /**
  91720. * Adds a new alpha remap gradient
  91721. * @param gradient defines the gradient to use (between 0 and 1)
  91722. * @param min defines the alpha remap minimal range
  91723. * @param max defines the alpha remap maximal range
  91724. * @returns the current particle system
  91725. */
  91726. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91727. /**
  91728. * Gets the current list of alpha remap gradients.
  91729. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  91730. * @returns the list of alpha remap gradients
  91731. */
  91732. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  91733. /**
  91734. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  91735. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91736. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91737. * @returns the emitter
  91738. */
  91739. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  91740. /**
  91741. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  91742. * @param radius The radius of the hemisphere to emit from
  91743. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91744. * @returns the emitter
  91745. */
  91746. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  91747. /**
  91748. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  91749. * @param radius The radius of the sphere to emit from
  91750. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91751. * @returns the emitter
  91752. */
  91753. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  91754. /**
  91755. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  91756. * @param radius The radius of the sphere to emit from
  91757. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  91758. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  91759. * @returns the emitter
  91760. */
  91761. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  91762. /**
  91763. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  91764. * @param radius The radius of the emission cylinder
  91765. * @param height The height of the emission cylinder
  91766. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  91767. * @param directionRandomizer How much to randomize the particle direction [0-1]
  91768. * @returns the emitter
  91769. */
  91770. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  91771. /**
  91772. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  91773. * @param radius The radius of the cylinder to emit from
  91774. * @param height The height of the emission cylinder
  91775. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91776. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  91777. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  91778. * @returns the emitter
  91779. */
  91780. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  91781. /**
  91782. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  91783. * @param radius The radius of the cone to emit from
  91784. * @param angle The base angle of the cone
  91785. * @returns the emitter
  91786. */
  91787. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  91788. /**
  91789. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  91790. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91791. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91792. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91793. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91794. * @returns the emitter
  91795. */
  91796. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  91797. /**
  91798. * Get hosting scene
  91799. * @returns the scene
  91800. */
  91801. getScene(): Scene;
  91802. }
  91803. }
  91804. declare module BABYLON {
  91805. /**
  91806. * 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.
  91807. * @see https://doc.babylonjs.com/how_to/transformnode
  91808. */
  91809. export class TransformNode extends Node {
  91810. /**
  91811. * Object will not rotate to face the camera
  91812. */
  91813. static BILLBOARDMODE_NONE: number;
  91814. /**
  91815. * Object will rotate to face the camera but only on the x axis
  91816. */
  91817. static BILLBOARDMODE_X: number;
  91818. /**
  91819. * Object will rotate to face the camera but only on the y axis
  91820. */
  91821. static BILLBOARDMODE_Y: number;
  91822. /**
  91823. * Object will rotate to face the camera but only on the z axis
  91824. */
  91825. static BILLBOARDMODE_Z: number;
  91826. /**
  91827. * Object will rotate to face the camera
  91828. */
  91829. static BILLBOARDMODE_ALL: number;
  91830. /**
  91831. * Object will rotate to face the camera's position instead of orientation
  91832. */
  91833. static BILLBOARDMODE_USE_POSITION: number;
  91834. private _forward;
  91835. private _forwardInverted;
  91836. private _up;
  91837. private _right;
  91838. private _rightInverted;
  91839. private _position;
  91840. private _rotation;
  91841. private _rotationQuaternion;
  91842. protected _scaling: Vector3;
  91843. protected _isDirty: boolean;
  91844. private _transformToBoneReferal;
  91845. private _isAbsoluteSynced;
  91846. private _billboardMode;
  91847. /**
  91848. * Gets or sets the billboard mode. Default is 0.
  91849. *
  91850. * | Value | Type | Description |
  91851. * | --- | --- | --- |
  91852. * | 0 | BILLBOARDMODE_NONE | |
  91853. * | 1 | BILLBOARDMODE_X | |
  91854. * | 2 | BILLBOARDMODE_Y | |
  91855. * | 4 | BILLBOARDMODE_Z | |
  91856. * | 7 | BILLBOARDMODE_ALL | |
  91857. *
  91858. */
  91859. get billboardMode(): number;
  91860. set billboardMode(value: number);
  91861. private _preserveParentRotationForBillboard;
  91862. /**
  91863. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  91864. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  91865. */
  91866. get preserveParentRotationForBillboard(): boolean;
  91867. set preserveParentRotationForBillboard(value: boolean);
  91868. /**
  91869. * 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
  91870. */
  91871. scalingDeterminant: number;
  91872. private _infiniteDistance;
  91873. /**
  91874. * Gets or sets the distance of the object to max, often used by skybox
  91875. */
  91876. get infiniteDistance(): boolean;
  91877. set infiniteDistance(value: boolean);
  91878. /**
  91879. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  91880. * By default the system will update normals to compensate
  91881. */
  91882. ignoreNonUniformScaling: boolean;
  91883. /**
  91884. * 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
  91885. */
  91886. reIntegrateRotationIntoRotationQuaternion: boolean;
  91887. /** @hidden */
  91888. _poseMatrix: Nullable<Matrix>;
  91889. /** @hidden */
  91890. _localMatrix: Matrix;
  91891. private _usePivotMatrix;
  91892. private _absolutePosition;
  91893. private _absoluteScaling;
  91894. private _absoluteRotationQuaternion;
  91895. private _pivotMatrix;
  91896. private _pivotMatrixInverse;
  91897. protected _postMultiplyPivotMatrix: boolean;
  91898. protected _isWorldMatrixFrozen: boolean;
  91899. /** @hidden */
  91900. _indexInSceneTransformNodesArray: number;
  91901. /**
  91902. * An event triggered after the world matrix is updated
  91903. */
  91904. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  91905. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  91906. /**
  91907. * Gets a string identifying the name of the class
  91908. * @returns "TransformNode" string
  91909. */
  91910. getClassName(): string;
  91911. /**
  91912. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  91913. */
  91914. get position(): Vector3;
  91915. set position(newPosition: Vector3);
  91916. /**
  91917. * 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)).
  91918. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  91919. */
  91920. get rotation(): Vector3;
  91921. set rotation(newRotation: Vector3);
  91922. /**
  91923. * 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)).
  91924. */
  91925. get scaling(): Vector3;
  91926. set scaling(newScaling: Vector3);
  91927. /**
  91928. * 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).
  91929. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  91930. */
  91931. get rotationQuaternion(): Nullable<Quaternion>;
  91932. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  91933. /**
  91934. * The forward direction of that transform in world space.
  91935. */
  91936. get forward(): Vector3;
  91937. /**
  91938. * The up direction of that transform in world space.
  91939. */
  91940. get up(): Vector3;
  91941. /**
  91942. * The right direction of that transform in world space.
  91943. */
  91944. get right(): Vector3;
  91945. /**
  91946. * Copies the parameter passed Matrix into the mesh Pose matrix.
  91947. * @param matrix the matrix to copy the pose from
  91948. * @returns this TransformNode.
  91949. */
  91950. updatePoseMatrix(matrix: Matrix): TransformNode;
  91951. /**
  91952. * Returns the mesh Pose matrix.
  91953. * @returns the pose matrix
  91954. */
  91955. getPoseMatrix(): Matrix;
  91956. /** @hidden */
  91957. _isSynchronized(): boolean;
  91958. /** @hidden */
  91959. _initCache(): void;
  91960. /**
  91961. * Flag the transform node as dirty (Forcing it to update everything)
  91962. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  91963. * @returns this transform node
  91964. */
  91965. markAsDirty(property: string): TransformNode;
  91966. /**
  91967. * Returns the current mesh absolute position.
  91968. * Returns a Vector3.
  91969. */
  91970. get absolutePosition(): Vector3;
  91971. /**
  91972. * Returns the current mesh absolute scaling.
  91973. * Returns a Vector3.
  91974. */
  91975. get absoluteScaling(): Vector3;
  91976. /**
  91977. * Returns the current mesh absolute rotation.
  91978. * Returns a Quaternion.
  91979. */
  91980. get absoluteRotationQuaternion(): Quaternion;
  91981. /**
  91982. * Sets a new matrix to apply before all other transformation
  91983. * @param matrix defines the transform matrix
  91984. * @returns the current TransformNode
  91985. */
  91986. setPreTransformMatrix(matrix: Matrix): TransformNode;
  91987. /**
  91988. * Sets a new pivot matrix to the current node
  91989. * @param matrix defines the new pivot matrix to use
  91990. * @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
  91991. * @returns the current TransformNode
  91992. */
  91993. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  91994. /**
  91995. * Returns the mesh pivot matrix.
  91996. * Default : Identity.
  91997. * @returns the matrix
  91998. */
  91999. getPivotMatrix(): Matrix;
  92000. /**
  92001. * Instantiate (when possible) or clone that node with its hierarchy
  92002. * @param newParent defines the new parent to use for the instance (or clone)
  92003. * @param options defines options to configure how copy is done
  92004. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  92005. * @returns an instance (or a clone) of the current node with its hiearchy
  92006. */
  92007. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92008. doNotInstantiate: boolean;
  92009. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92010. /**
  92011. * Prevents the World matrix to be computed any longer
  92012. * @param newWorldMatrix defines an optional matrix to use as world matrix
  92013. * @returns the TransformNode.
  92014. */
  92015. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  92016. /**
  92017. * Allows back the World matrix computation.
  92018. * @returns the TransformNode.
  92019. */
  92020. unfreezeWorldMatrix(): this;
  92021. /**
  92022. * True if the World matrix has been frozen.
  92023. */
  92024. get isWorldMatrixFrozen(): boolean;
  92025. /**
  92026. * Retuns the mesh absolute position in the World.
  92027. * @returns a Vector3.
  92028. */
  92029. getAbsolutePosition(): Vector3;
  92030. /**
  92031. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  92032. * @param absolutePosition the absolute position to set
  92033. * @returns the TransformNode.
  92034. */
  92035. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  92036. /**
  92037. * Sets the mesh position in its local space.
  92038. * @param vector3 the position to set in localspace
  92039. * @returns the TransformNode.
  92040. */
  92041. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  92042. /**
  92043. * Returns the mesh position in the local space from the current World matrix values.
  92044. * @returns a new Vector3.
  92045. */
  92046. getPositionExpressedInLocalSpace(): Vector3;
  92047. /**
  92048. * Translates the mesh along the passed Vector3 in its local space.
  92049. * @param vector3 the distance to translate in localspace
  92050. * @returns the TransformNode.
  92051. */
  92052. locallyTranslate(vector3: Vector3): TransformNode;
  92053. private static _lookAtVectorCache;
  92054. /**
  92055. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  92056. * @param targetPoint the position (must be in same space as current mesh) to look at
  92057. * @param yawCor optional yaw (y-axis) correction in radians
  92058. * @param pitchCor optional pitch (x-axis) correction in radians
  92059. * @param rollCor optional roll (z-axis) correction in radians
  92060. * @param space the choosen space of the target
  92061. * @returns the TransformNode.
  92062. */
  92063. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  92064. /**
  92065. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92066. * This Vector3 is expressed in the World space.
  92067. * @param localAxis axis to rotate
  92068. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92069. */
  92070. getDirection(localAxis: Vector3): Vector3;
  92071. /**
  92072. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  92073. * localAxis is expressed in the mesh local space.
  92074. * result is computed in the Wordl space from the mesh World matrix.
  92075. * @param localAxis axis to rotate
  92076. * @param result the resulting transformnode
  92077. * @returns this TransformNode.
  92078. */
  92079. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  92080. /**
  92081. * Sets this transform node rotation to the given local axis.
  92082. * @param localAxis the axis in local space
  92083. * @param yawCor optional yaw (y-axis) correction in radians
  92084. * @param pitchCor optional pitch (x-axis) correction in radians
  92085. * @param rollCor optional roll (z-axis) correction in radians
  92086. * @returns this TransformNode
  92087. */
  92088. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  92089. /**
  92090. * Sets a new pivot point to the current node
  92091. * @param point defines the new pivot point to use
  92092. * @param space defines if the point is in world or local space (local by default)
  92093. * @returns the current TransformNode
  92094. */
  92095. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  92096. /**
  92097. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  92098. * @returns the pivot point
  92099. */
  92100. getPivotPoint(): Vector3;
  92101. /**
  92102. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  92103. * @param result the vector3 to store the result
  92104. * @returns this TransformNode.
  92105. */
  92106. getPivotPointToRef(result: Vector3): TransformNode;
  92107. /**
  92108. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  92109. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  92110. */
  92111. getAbsolutePivotPoint(): Vector3;
  92112. /**
  92113. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  92114. * @param result vector3 to store the result
  92115. * @returns this TransformNode.
  92116. */
  92117. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  92118. /**
  92119. * Defines the passed node as the parent of the current node.
  92120. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  92121. * @see https://doc.babylonjs.com/how_to/parenting
  92122. * @param node the node ot set as the parent
  92123. * @returns this TransformNode.
  92124. */
  92125. setParent(node: Nullable<Node>): TransformNode;
  92126. private _nonUniformScaling;
  92127. /**
  92128. * True if the scaling property of this object is non uniform eg. (1,2,1)
  92129. */
  92130. get nonUniformScaling(): boolean;
  92131. /** @hidden */
  92132. _updateNonUniformScalingState(value: boolean): boolean;
  92133. /**
  92134. * Attach the current TransformNode to another TransformNode associated with a bone
  92135. * @param bone Bone affecting the TransformNode
  92136. * @param affectedTransformNode TransformNode associated with the bone
  92137. * @returns this object
  92138. */
  92139. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  92140. /**
  92141. * Detach the transform node if its associated with a bone
  92142. * @returns this object
  92143. */
  92144. detachFromBone(): TransformNode;
  92145. private static _rotationAxisCache;
  92146. /**
  92147. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  92148. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92149. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92150. * The passed axis is also normalized.
  92151. * @param axis the axis to rotate around
  92152. * @param amount the amount to rotate in radians
  92153. * @param space Space to rotate in (Default: local)
  92154. * @returns the TransformNode.
  92155. */
  92156. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  92157. /**
  92158. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  92159. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92160. * The passed axis is also normalized. .
  92161. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  92162. * @param point the point to rotate around
  92163. * @param axis the axis to rotate around
  92164. * @param amount the amount to rotate in radians
  92165. * @returns the TransformNode
  92166. */
  92167. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  92168. /**
  92169. * Translates the mesh along the axis vector for the passed distance in the given space.
  92170. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92171. * @param axis the axis to translate in
  92172. * @param distance the distance to translate
  92173. * @param space Space to rotate in (Default: local)
  92174. * @returns the TransformNode.
  92175. */
  92176. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  92177. /**
  92178. * Adds a rotation step to the mesh current rotation.
  92179. * x, y, z are Euler angles expressed in radians.
  92180. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  92181. * This means this rotation is made in the mesh local space only.
  92182. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  92183. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  92184. * ```javascript
  92185. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  92186. * ```
  92187. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  92188. * 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.
  92189. * @param x Rotation to add
  92190. * @param y Rotation to add
  92191. * @param z Rotation to add
  92192. * @returns the TransformNode.
  92193. */
  92194. addRotation(x: number, y: number, z: number): TransformNode;
  92195. /**
  92196. * @hidden
  92197. */
  92198. protected _getEffectiveParent(): Nullable<Node>;
  92199. /**
  92200. * Computes the world matrix of the node
  92201. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92202. * @returns the world matrix
  92203. */
  92204. computeWorldMatrix(force?: boolean): Matrix;
  92205. /**
  92206. * Resets this nodeTransform's local matrix to Matrix.Identity().
  92207. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  92208. */
  92209. resetLocalMatrix(independentOfChildren?: boolean): void;
  92210. protected _afterComputeWorldMatrix(): void;
  92211. /**
  92212. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  92213. * @param func callback function to add
  92214. *
  92215. * @returns the TransformNode.
  92216. */
  92217. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  92218. /**
  92219. * Removes a registered callback function.
  92220. * @param func callback function to remove
  92221. * @returns the TransformNode.
  92222. */
  92223. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  92224. /**
  92225. * Gets the position of the current mesh in camera space
  92226. * @param camera defines the camera to use
  92227. * @returns a position
  92228. */
  92229. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  92230. /**
  92231. * Returns the distance from the mesh to the active camera
  92232. * @param camera defines the camera to use
  92233. * @returns the distance
  92234. */
  92235. getDistanceToCamera(camera?: Nullable<Camera>): number;
  92236. /**
  92237. * Clone the current transform node
  92238. * @param name Name of the new clone
  92239. * @param newParent New parent for the clone
  92240. * @param doNotCloneChildren Do not clone children hierarchy
  92241. * @returns the new transform node
  92242. */
  92243. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  92244. /**
  92245. * Serializes the objects information.
  92246. * @param currentSerializationObject defines the object to serialize in
  92247. * @returns the serialized object
  92248. */
  92249. serialize(currentSerializationObject?: any): any;
  92250. /**
  92251. * Returns a new TransformNode object parsed from the source provided.
  92252. * @param parsedTransformNode is the source.
  92253. * @param scene the scne the object belongs to
  92254. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  92255. * @returns a new TransformNode object parsed from the source provided.
  92256. */
  92257. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  92258. /**
  92259. * Get all child-transformNodes of this node
  92260. * @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
  92261. * @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
  92262. * @returns an array of TransformNode
  92263. */
  92264. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  92265. /**
  92266. * Releases resources associated with this transform node.
  92267. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92268. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92269. */
  92270. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92271. /**
  92272. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  92273. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  92274. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  92275. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  92276. * @returns the current mesh
  92277. */
  92278. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  92279. private _syncAbsoluteScalingAndRotation;
  92280. }
  92281. }
  92282. declare module BABYLON {
  92283. /**
  92284. * Class used to override all child animations of a given target
  92285. */
  92286. export class AnimationPropertiesOverride {
  92287. /**
  92288. * Gets or sets a value indicating if animation blending must be used
  92289. */
  92290. enableBlending: boolean;
  92291. /**
  92292. * Gets or sets the blending speed to use when enableBlending is true
  92293. */
  92294. blendingSpeed: number;
  92295. /**
  92296. * Gets or sets the default loop mode to use
  92297. */
  92298. loopMode: number;
  92299. }
  92300. }
  92301. declare module BABYLON {
  92302. /**
  92303. * Class used to store bone information
  92304. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92305. */
  92306. export class Bone extends Node {
  92307. /**
  92308. * defines the bone name
  92309. */
  92310. name: string;
  92311. private static _tmpVecs;
  92312. private static _tmpQuat;
  92313. private static _tmpMats;
  92314. /**
  92315. * Gets the list of child bones
  92316. */
  92317. children: Bone[];
  92318. /** Gets the animations associated with this bone */
  92319. animations: Animation[];
  92320. /**
  92321. * Gets or sets bone length
  92322. */
  92323. length: number;
  92324. /**
  92325. * @hidden Internal only
  92326. * Set this value to map this bone to a different index in the transform matrices
  92327. * Set this value to -1 to exclude the bone from the transform matrices
  92328. */
  92329. _index: Nullable<number>;
  92330. private _skeleton;
  92331. private _localMatrix;
  92332. private _restPose;
  92333. private _baseMatrix;
  92334. private _absoluteTransform;
  92335. private _invertedAbsoluteTransform;
  92336. private _parent;
  92337. private _scalingDeterminant;
  92338. private _worldTransform;
  92339. private _localScaling;
  92340. private _localRotation;
  92341. private _localPosition;
  92342. private _needToDecompose;
  92343. private _needToCompose;
  92344. /** @hidden */
  92345. _linkedTransformNode: Nullable<TransformNode>;
  92346. /** @hidden */
  92347. _waitingTransformNodeId: Nullable<string>;
  92348. /** @hidden */
  92349. get _matrix(): Matrix;
  92350. /** @hidden */
  92351. set _matrix(value: Matrix);
  92352. /**
  92353. * Create a new bone
  92354. * @param name defines the bone name
  92355. * @param skeleton defines the parent skeleton
  92356. * @param parentBone defines the parent (can be null if the bone is the root)
  92357. * @param localMatrix defines the local matrix
  92358. * @param restPose defines the rest pose matrix
  92359. * @param baseMatrix defines the base matrix
  92360. * @param index defines index of the bone in the hiearchy
  92361. */
  92362. constructor(
  92363. /**
  92364. * defines the bone name
  92365. */
  92366. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  92367. /**
  92368. * Gets the current object class name.
  92369. * @return the class name
  92370. */
  92371. getClassName(): string;
  92372. /**
  92373. * Gets the parent skeleton
  92374. * @returns a skeleton
  92375. */
  92376. getSkeleton(): Skeleton;
  92377. /**
  92378. * Gets parent bone
  92379. * @returns a bone or null if the bone is the root of the bone hierarchy
  92380. */
  92381. getParent(): Nullable<Bone>;
  92382. /**
  92383. * Returns an array containing the root bones
  92384. * @returns an array containing the root bones
  92385. */
  92386. getChildren(): Array<Bone>;
  92387. /**
  92388. * Gets the node index in matrix array generated for rendering
  92389. * @returns the node index
  92390. */
  92391. getIndex(): number;
  92392. /**
  92393. * Sets the parent bone
  92394. * @param parent defines the parent (can be null if the bone is the root)
  92395. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  92396. */
  92397. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  92398. /**
  92399. * Gets the local matrix
  92400. * @returns a matrix
  92401. */
  92402. getLocalMatrix(): Matrix;
  92403. /**
  92404. * Gets the base matrix (initial matrix which remains unchanged)
  92405. * @returns a matrix
  92406. */
  92407. getBaseMatrix(): Matrix;
  92408. /**
  92409. * Gets the rest pose matrix
  92410. * @returns a matrix
  92411. */
  92412. getRestPose(): Matrix;
  92413. /**
  92414. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  92415. */
  92416. getWorldMatrix(): Matrix;
  92417. /**
  92418. * Sets the local matrix to rest pose matrix
  92419. */
  92420. returnToRest(): void;
  92421. /**
  92422. * Gets the inverse of the absolute transform matrix.
  92423. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  92424. * @returns a matrix
  92425. */
  92426. getInvertedAbsoluteTransform(): Matrix;
  92427. /**
  92428. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  92429. * @returns a matrix
  92430. */
  92431. getAbsoluteTransform(): Matrix;
  92432. /**
  92433. * Links with the given transform node.
  92434. * The local matrix of this bone is copied from the transform node every frame.
  92435. * @param transformNode defines the transform node to link to
  92436. */
  92437. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  92438. /**
  92439. * Gets the node used to drive the bone's transformation
  92440. * @returns a transform node or null
  92441. */
  92442. getTransformNode(): Nullable<TransformNode>;
  92443. /** Gets or sets current position (in local space) */
  92444. get position(): Vector3;
  92445. set position(newPosition: Vector3);
  92446. /** Gets or sets current rotation (in local space) */
  92447. get rotation(): Vector3;
  92448. set rotation(newRotation: Vector3);
  92449. /** Gets or sets current rotation quaternion (in local space) */
  92450. get rotationQuaternion(): Quaternion;
  92451. set rotationQuaternion(newRotation: Quaternion);
  92452. /** Gets or sets current scaling (in local space) */
  92453. get scaling(): Vector3;
  92454. set scaling(newScaling: Vector3);
  92455. /**
  92456. * Gets the animation properties override
  92457. */
  92458. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  92459. private _decompose;
  92460. private _compose;
  92461. /**
  92462. * Update the base and local matrices
  92463. * @param matrix defines the new base or local matrix
  92464. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  92465. * @param updateLocalMatrix defines if the local matrix should be updated
  92466. */
  92467. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  92468. /** @hidden */
  92469. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  92470. /**
  92471. * Flag the bone as dirty (Forcing it to update everything)
  92472. */
  92473. markAsDirty(): void;
  92474. /** @hidden */
  92475. _markAsDirtyAndCompose(): void;
  92476. private _markAsDirtyAndDecompose;
  92477. /**
  92478. * Translate the bone in local or world space
  92479. * @param vec The amount to translate the bone
  92480. * @param space The space that the translation is in
  92481. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92482. */
  92483. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92484. /**
  92485. * Set the postion of the bone in local or world space
  92486. * @param position The position to set the bone
  92487. * @param space The space that the position is in
  92488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92489. */
  92490. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92491. /**
  92492. * Set the absolute position of the bone (world space)
  92493. * @param position The position to set the bone
  92494. * @param mesh The mesh that this bone is attached to
  92495. */
  92496. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  92497. /**
  92498. * Scale the bone on the x, y and z axes (in local space)
  92499. * @param x The amount to scale the bone on the x axis
  92500. * @param y The amount to scale the bone on the y axis
  92501. * @param z The amount to scale the bone on the z axis
  92502. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  92503. */
  92504. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  92505. /**
  92506. * Set the bone scaling in local space
  92507. * @param scale defines the scaling vector
  92508. */
  92509. setScale(scale: Vector3): void;
  92510. /**
  92511. * Gets the current scaling in local space
  92512. * @returns the current scaling vector
  92513. */
  92514. getScale(): Vector3;
  92515. /**
  92516. * Gets the current scaling in local space and stores it in a target vector
  92517. * @param result defines the target vector
  92518. */
  92519. getScaleToRef(result: Vector3): void;
  92520. /**
  92521. * Set the yaw, pitch, and roll of the bone in local or world space
  92522. * @param yaw The rotation of the bone on the y axis
  92523. * @param pitch The rotation of the bone on the x axis
  92524. * @param roll The rotation of the bone on the z axis
  92525. * @param space The space that the axes of rotation are in
  92526. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92527. */
  92528. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  92529. /**
  92530. * Add a rotation to the bone on an axis in local or world space
  92531. * @param axis The axis to rotate the bone on
  92532. * @param amount The amount to rotate the bone
  92533. * @param space The space that the axis is in
  92534. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92535. */
  92536. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  92537. /**
  92538. * Set the rotation of the bone to a particular axis angle in local or world space
  92539. * @param axis The axis to rotate the bone on
  92540. * @param angle The angle that the bone should be rotated to
  92541. * @param space The space that the axis is in
  92542. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92543. */
  92544. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  92545. /**
  92546. * Set the euler rotation of the bone in local of world space
  92547. * @param rotation The euler rotation that the bone should be set to
  92548. * @param space The space that the rotation is in
  92549. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92550. */
  92551. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92552. /**
  92553. * Set the quaternion rotation of the bone in local of world space
  92554. * @param quat The quaternion rotation that the bone should be set to
  92555. * @param space The space that the rotation is in
  92556. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92557. */
  92558. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  92559. /**
  92560. * Set the rotation matrix of the bone in local of world space
  92561. * @param rotMat The rotation matrix that the bone should be set to
  92562. * @param space The space that the rotation is in
  92563. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92564. */
  92565. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  92566. private _rotateWithMatrix;
  92567. private _getNegativeRotationToRef;
  92568. /**
  92569. * Get the position of the bone in local or world space
  92570. * @param space The space that the returned position is in
  92571. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92572. * @returns The position of the bone
  92573. */
  92574. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  92575. /**
  92576. * Copy the position of the bone to a vector3 in local or world space
  92577. * @param space The space that the returned position is in
  92578. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92579. * @param result The vector3 to copy the position to
  92580. */
  92581. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  92582. /**
  92583. * Get the absolute position of the bone (world space)
  92584. * @param mesh The mesh that this bone is attached to
  92585. * @returns The absolute position of the bone
  92586. */
  92587. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  92588. /**
  92589. * Copy the absolute position of the bone (world space) to the result param
  92590. * @param mesh The mesh that this bone is attached to
  92591. * @param result The vector3 to copy the absolute position to
  92592. */
  92593. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  92594. /**
  92595. * Compute the absolute transforms of this bone and its children
  92596. */
  92597. computeAbsoluteTransforms(): void;
  92598. /**
  92599. * Get the world direction from an axis that is in the local space of the bone
  92600. * @param localAxis The local direction that is used to compute the world direction
  92601. * @param mesh The mesh that this bone is attached to
  92602. * @returns The world direction
  92603. */
  92604. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  92605. /**
  92606. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  92607. * @param localAxis The local direction that is used to compute the world direction
  92608. * @param mesh The mesh that this bone is attached to
  92609. * @param result The vector3 that the world direction will be copied to
  92610. */
  92611. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92612. /**
  92613. * Get the euler rotation of the bone in local or world space
  92614. * @param space The space that the rotation should be in
  92615. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92616. * @returns The euler rotation
  92617. */
  92618. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  92619. /**
  92620. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  92621. * @param space The space that the rotation should be in
  92622. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92623. * @param result The vector3 that the rotation should be copied to
  92624. */
  92625. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92626. /**
  92627. * Get the quaternion rotation of the bone in either local or world space
  92628. * @param space The space that the rotation should be in
  92629. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92630. * @returns The quaternion rotation
  92631. */
  92632. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  92633. /**
  92634. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  92635. * @param space The space that the rotation should be in
  92636. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92637. * @param result The quaternion that the rotation should be copied to
  92638. */
  92639. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  92640. /**
  92641. * Get the rotation matrix of the bone in local or world space
  92642. * @param space The space that the rotation should be in
  92643. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92644. * @returns The rotation matrix
  92645. */
  92646. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  92647. /**
  92648. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  92649. * @param space The space that the rotation should be in
  92650. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92651. * @param result The quaternion that the rotation should be copied to
  92652. */
  92653. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  92654. /**
  92655. * Get the world position of a point that is in the local space of the bone
  92656. * @param position The local position
  92657. * @param mesh The mesh that this bone is attached to
  92658. * @returns The world position
  92659. */
  92660. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  92661. /**
  92662. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  92663. * @param position The local position
  92664. * @param mesh The mesh that this bone is attached to
  92665. * @param result The vector3 that the world position should be copied to
  92666. */
  92667. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92668. /**
  92669. * Get the local position of a point that is in world space
  92670. * @param position The world position
  92671. * @param mesh The mesh that this bone is attached to
  92672. * @returns The local position
  92673. */
  92674. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  92675. /**
  92676. * Get the local position of a point that is in world space and copy it to the result param
  92677. * @param position The world position
  92678. * @param mesh The mesh that this bone is attached to
  92679. * @param result The vector3 that the local position should be copied to
  92680. */
  92681. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92682. }
  92683. }
  92684. declare module BABYLON {
  92685. /**
  92686. * Defines a runtime animation
  92687. */
  92688. export class RuntimeAnimation {
  92689. private _events;
  92690. /**
  92691. * The current frame of the runtime animation
  92692. */
  92693. private _currentFrame;
  92694. /**
  92695. * The animation used by the runtime animation
  92696. */
  92697. private _animation;
  92698. /**
  92699. * The target of the runtime animation
  92700. */
  92701. private _target;
  92702. /**
  92703. * The initiating animatable
  92704. */
  92705. private _host;
  92706. /**
  92707. * The original value of the runtime animation
  92708. */
  92709. private _originalValue;
  92710. /**
  92711. * The original blend value of the runtime animation
  92712. */
  92713. private _originalBlendValue;
  92714. /**
  92715. * The offsets cache of the runtime animation
  92716. */
  92717. private _offsetsCache;
  92718. /**
  92719. * The high limits cache of the runtime animation
  92720. */
  92721. private _highLimitsCache;
  92722. /**
  92723. * Specifies if the runtime animation has been stopped
  92724. */
  92725. private _stopped;
  92726. /**
  92727. * The blending factor of the runtime animation
  92728. */
  92729. private _blendingFactor;
  92730. /**
  92731. * The BabylonJS scene
  92732. */
  92733. private _scene;
  92734. /**
  92735. * The current value of the runtime animation
  92736. */
  92737. private _currentValue;
  92738. /** @hidden */
  92739. _animationState: _IAnimationState;
  92740. /**
  92741. * The active target of the runtime animation
  92742. */
  92743. private _activeTargets;
  92744. private _currentActiveTarget;
  92745. private _directTarget;
  92746. /**
  92747. * The target path of the runtime animation
  92748. */
  92749. private _targetPath;
  92750. /**
  92751. * The weight of the runtime animation
  92752. */
  92753. private _weight;
  92754. /**
  92755. * The ratio offset of the runtime animation
  92756. */
  92757. private _ratioOffset;
  92758. /**
  92759. * The previous delay of the runtime animation
  92760. */
  92761. private _previousDelay;
  92762. /**
  92763. * The previous ratio of the runtime animation
  92764. */
  92765. private _previousRatio;
  92766. private _enableBlending;
  92767. private _keys;
  92768. private _minFrame;
  92769. private _maxFrame;
  92770. private _minValue;
  92771. private _maxValue;
  92772. private _targetIsArray;
  92773. /**
  92774. * Gets the current frame of the runtime animation
  92775. */
  92776. get currentFrame(): number;
  92777. /**
  92778. * Gets the weight of the runtime animation
  92779. */
  92780. get weight(): number;
  92781. /**
  92782. * Gets the current value of the runtime animation
  92783. */
  92784. get currentValue(): any;
  92785. /**
  92786. * Gets the target path of the runtime animation
  92787. */
  92788. get targetPath(): string;
  92789. /**
  92790. * Gets the actual target of the runtime animation
  92791. */
  92792. get target(): any;
  92793. /**
  92794. * Gets the additive state of the runtime animation
  92795. */
  92796. get isAdditive(): boolean;
  92797. /** @hidden */
  92798. _onLoop: () => void;
  92799. /**
  92800. * Create a new RuntimeAnimation object
  92801. * @param target defines the target of the animation
  92802. * @param animation defines the source animation object
  92803. * @param scene defines the hosting scene
  92804. * @param host defines the initiating Animatable
  92805. */
  92806. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  92807. private _preparePath;
  92808. /**
  92809. * Gets the animation from the runtime animation
  92810. */
  92811. get animation(): Animation;
  92812. /**
  92813. * Resets the runtime animation to the beginning
  92814. * @param restoreOriginal defines whether to restore the target property to the original value
  92815. */
  92816. reset(restoreOriginal?: boolean): void;
  92817. /**
  92818. * Specifies if the runtime animation is stopped
  92819. * @returns Boolean specifying if the runtime animation is stopped
  92820. */
  92821. isStopped(): boolean;
  92822. /**
  92823. * Disposes of the runtime animation
  92824. */
  92825. dispose(): void;
  92826. /**
  92827. * Apply the interpolated value to the target
  92828. * @param currentValue defines the value computed by the animation
  92829. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  92830. */
  92831. setValue(currentValue: any, weight: number): void;
  92832. private _getOriginalValues;
  92833. private _setValue;
  92834. /**
  92835. * Gets the loop pmode of the runtime animation
  92836. * @returns Loop Mode
  92837. */
  92838. private _getCorrectLoopMode;
  92839. /**
  92840. * Move the current animation to a given frame
  92841. * @param frame defines the frame to move to
  92842. */
  92843. goToFrame(frame: number): void;
  92844. /**
  92845. * @hidden Internal use only
  92846. */
  92847. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  92848. /**
  92849. * Execute the current animation
  92850. * @param delay defines the delay to add to the current frame
  92851. * @param from defines the lower bound of the animation range
  92852. * @param to defines the upper bound of the animation range
  92853. * @param loop defines if the current animation must loop
  92854. * @param speedRatio defines the current speed ratio
  92855. * @param weight defines the weight of the animation (default is -1 so no weight)
  92856. * @param onLoop optional callback called when animation loops
  92857. * @returns a boolean indicating if the animation is running
  92858. */
  92859. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  92860. }
  92861. }
  92862. declare module BABYLON {
  92863. /**
  92864. * Class used to store an actual running animation
  92865. */
  92866. export class Animatable {
  92867. /** defines the target object */
  92868. target: any;
  92869. /** defines the starting frame number (default is 0) */
  92870. fromFrame: number;
  92871. /** defines the ending frame number (default is 100) */
  92872. toFrame: number;
  92873. /** defines if the animation must loop (default is false) */
  92874. loopAnimation: boolean;
  92875. /** defines a callback to call when animation ends if it is not looping */
  92876. onAnimationEnd?: (() => void) | null | undefined;
  92877. /** defines a callback to call when animation loops */
  92878. onAnimationLoop?: (() => void) | null | undefined;
  92879. /** defines whether the animation should be evaluated additively */
  92880. isAdditive: boolean;
  92881. private _localDelayOffset;
  92882. private _pausedDelay;
  92883. private _runtimeAnimations;
  92884. private _paused;
  92885. private _scene;
  92886. private _speedRatio;
  92887. private _weight;
  92888. private _syncRoot;
  92889. /**
  92890. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  92891. * This will only apply for non looping animation (default is true)
  92892. */
  92893. disposeOnEnd: boolean;
  92894. /**
  92895. * Gets a boolean indicating if the animation has started
  92896. */
  92897. animationStarted: boolean;
  92898. /**
  92899. * Observer raised when the animation ends
  92900. */
  92901. onAnimationEndObservable: Observable<Animatable>;
  92902. /**
  92903. * Observer raised when the animation loops
  92904. */
  92905. onAnimationLoopObservable: Observable<Animatable>;
  92906. /**
  92907. * Gets the root Animatable used to synchronize and normalize animations
  92908. */
  92909. get syncRoot(): Nullable<Animatable>;
  92910. /**
  92911. * Gets the current frame of the first RuntimeAnimation
  92912. * Used to synchronize Animatables
  92913. */
  92914. get masterFrame(): number;
  92915. /**
  92916. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  92917. */
  92918. get weight(): number;
  92919. set weight(value: number);
  92920. /**
  92921. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  92922. */
  92923. get speedRatio(): number;
  92924. set speedRatio(value: number);
  92925. /**
  92926. * Creates a new Animatable
  92927. * @param scene defines the hosting scene
  92928. * @param target defines the target object
  92929. * @param fromFrame defines the starting frame number (default is 0)
  92930. * @param toFrame defines the ending frame number (default is 100)
  92931. * @param loopAnimation defines if the animation must loop (default is false)
  92932. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  92933. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  92934. * @param animations defines a group of animation to add to the new Animatable
  92935. * @param onAnimationLoop defines a callback to call when animation loops
  92936. * @param isAdditive defines whether the animation should be evaluated additively
  92937. */
  92938. constructor(scene: Scene,
  92939. /** defines the target object */
  92940. target: any,
  92941. /** defines the starting frame number (default is 0) */
  92942. fromFrame?: number,
  92943. /** defines the ending frame number (default is 100) */
  92944. toFrame?: number,
  92945. /** defines if the animation must loop (default is false) */
  92946. loopAnimation?: boolean, speedRatio?: number,
  92947. /** defines a callback to call when animation ends if it is not looping */
  92948. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  92949. /** defines a callback to call when animation loops */
  92950. onAnimationLoop?: (() => void) | null | undefined,
  92951. /** defines whether the animation should be evaluated additively */
  92952. isAdditive?: boolean);
  92953. /**
  92954. * Synchronize and normalize current Animatable with a source Animatable
  92955. * This is useful when using animation weights and when animations are not of the same length
  92956. * @param root defines the root Animatable to synchronize with
  92957. * @returns the current Animatable
  92958. */
  92959. syncWith(root: Animatable): Animatable;
  92960. /**
  92961. * Gets the list of runtime animations
  92962. * @returns an array of RuntimeAnimation
  92963. */
  92964. getAnimations(): RuntimeAnimation[];
  92965. /**
  92966. * Adds more animations to the current animatable
  92967. * @param target defines the target of the animations
  92968. * @param animations defines the new animations to add
  92969. */
  92970. appendAnimations(target: any, animations: Animation[]): void;
  92971. /**
  92972. * Gets the source animation for a specific property
  92973. * @param property defines the propertyu to look for
  92974. * @returns null or the source animation for the given property
  92975. */
  92976. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  92977. /**
  92978. * Gets the runtime animation for a specific property
  92979. * @param property defines the propertyu to look for
  92980. * @returns null or the runtime animation for the given property
  92981. */
  92982. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  92983. /**
  92984. * Resets the animatable to its original state
  92985. */
  92986. reset(): void;
  92987. /**
  92988. * Allows the animatable to blend with current running animations
  92989. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  92990. * @param blendingSpeed defines the blending speed to use
  92991. */
  92992. enableBlending(blendingSpeed: number): void;
  92993. /**
  92994. * Disable animation blending
  92995. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  92996. */
  92997. disableBlending(): void;
  92998. /**
  92999. * Jump directly to a given frame
  93000. * @param frame defines the frame to jump to
  93001. */
  93002. goToFrame(frame: number): void;
  93003. /**
  93004. * Pause the animation
  93005. */
  93006. pause(): void;
  93007. /**
  93008. * Restart the animation
  93009. */
  93010. restart(): void;
  93011. private _raiseOnAnimationEnd;
  93012. /**
  93013. * Stop and delete the current animation
  93014. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  93015. * @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)
  93016. */
  93017. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  93018. /**
  93019. * Wait asynchronously for the animation to end
  93020. * @returns a promise which will be fullfilled when the animation ends
  93021. */
  93022. waitAsync(): Promise<Animatable>;
  93023. /** @hidden */
  93024. _animate(delay: number): boolean;
  93025. }
  93026. interface Scene {
  93027. /** @hidden */
  93028. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  93029. /** @hidden */
  93030. _processLateAnimationBindingsForMatrices(holder: {
  93031. totalWeight: number;
  93032. totalAdditiveWeight: number;
  93033. animations: RuntimeAnimation[];
  93034. additiveAnimations: RuntimeAnimation[];
  93035. originalValue: Matrix;
  93036. }): any;
  93037. /** @hidden */
  93038. _processLateAnimationBindingsForQuaternions(holder: {
  93039. totalWeight: number;
  93040. totalAdditiveWeight: number;
  93041. animations: RuntimeAnimation[];
  93042. additiveAnimations: RuntimeAnimation[];
  93043. originalValue: Quaternion;
  93044. }, refQuaternion: Quaternion): Quaternion;
  93045. /** @hidden */
  93046. _processLateAnimationBindings(): void;
  93047. /**
  93048. * Will start the animation sequence of a given target
  93049. * @param target defines the target
  93050. * @param from defines from which frame should animation start
  93051. * @param to defines until which frame should animation run.
  93052. * @param weight defines the weight to apply to the animation (1.0 by default)
  93053. * @param loop defines if the animation loops
  93054. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93055. * @param onAnimationEnd defines the function to be executed when the animation ends
  93056. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93057. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  93058. * @param onAnimationLoop defines the callback to call when an animation loops
  93059. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93060. * @returns the animatable object created for this animation
  93061. */
  93062. 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;
  93063. /**
  93064. * Will start the animation sequence of a given target
  93065. * @param target defines the target
  93066. * @param from defines from which frame should animation start
  93067. * @param to defines until which frame should animation run.
  93068. * @param loop defines if the animation loops
  93069. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93070. * @param onAnimationEnd defines the function to be executed when the animation ends
  93071. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93072. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  93073. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  93074. * @param onAnimationLoop defines the callback to call when an animation loops
  93075. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93076. * @returns the animatable object created for this animation
  93077. */
  93078. 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;
  93079. /**
  93080. * Will start the animation sequence of a given target and its hierarchy
  93081. * @param target defines the target
  93082. * @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.
  93083. * @param from defines from which frame should animation start
  93084. * @param to defines until which frame should animation run.
  93085. * @param loop defines if the animation loops
  93086. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93087. * @param onAnimationEnd defines the function to be executed when the animation ends
  93088. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93089. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  93090. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  93091. * @param onAnimationLoop defines the callback to call when an animation loops
  93092. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93093. * @returns the list of created animatables
  93094. */
  93095. 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[];
  93096. /**
  93097. * Begin a new animation on a given node
  93098. * @param target defines the target where the animation will take place
  93099. * @param animations defines the list of animations to start
  93100. * @param from defines the initial value
  93101. * @param to defines the final value
  93102. * @param loop defines if you want animation to loop (off by default)
  93103. * @param speedRatio defines the speed ratio to apply to all animations
  93104. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93105. * @param onAnimationLoop defines the callback to call when an animation loops
  93106. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93107. * @returns the list of created animatables
  93108. */
  93109. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  93110. /**
  93111. * Begin a new animation on a given node and its hierarchy
  93112. * @param target defines the root node where the animation will take place
  93113. * @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.
  93114. * @param animations defines the list of animations to start
  93115. * @param from defines the initial value
  93116. * @param to defines the final value
  93117. * @param loop defines if you want animation to loop (off by default)
  93118. * @param speedRatio defines the speed ratio to apply to all animations
  93119. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93120. * @param onAnimationLoop defines the callback to call when an animation loops
  93121. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93122. * @returns the list of animatables created for all nodes
  93123. */
  93124. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  93125. /**
  93126. * Gets the animatable associated with a specific target
  93127. * @param target defines the target of the animatable
  93128. * @returns the required animatable if found
  93129. */
  93130. getAnimatableByTarget(target: any): Nullable<Animatable>;
  93131. /**
  93132. * Gets all animatables associated with a given target
  93133. * @param target defines the target to look animatables for
  93134. * @returns an array of Animatables
  93135. */
  93136. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  93137. /**
  93138. * Stops and removes all animations that have been applied to the scene
  93139. */
  93140. stopAllAnimations(): void;
  93141. /**
  93142. * Gets the current delta time used by animation engine
  93143. */
  93144. deltaTime: number;
  93145. }
  93146. interface Bone {
  93147. /**
  93148. * Copy an animation range from another bone
  93149. * @param source defines the source bone
  93150. * @param rangeName defines the range name to copy
  93151. * @param frameOffset defines the frame offset
  93152. * @param rescaleAsRequired defines if rescaling must be applied if required
  93153. * @param skelDimensionsRatio defines the scaling ratio
  93154. * @returns true if operation was successful
  93155. */
  93156. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  93157. }
  93158. }
  93159. declare module BABYLON {
  93160. /**
  93161. * Class used to handle skinning animations
  93162. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93163. */
  93164. export class Skeleton implements IAnimatable {
  93165. /** defines the skeleton name */
  93166. name: string;
  93167. /** defines the skeleton Id */
  93168. id: string;
  93169. /**
  93170. * Defines the list of child bones
  93171. */
  93172. bones: Bone[];
  93173. /**
  93174. * Defines an estimate of the dimension of the skeleton at rest
  93175. */
  93176. dimensionsAtRest: Vector3;
  93177. /**
  93178. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  93179. */
  93180. needInitialSkinMatrix: boolean;
  93181. /**
  93182. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  93183. */
  93184. overrideMesh: Nullable<AbstractMesh>;
  93185. /**
  93186. * Gets the list of animations attached to this skeleton
  93187. */
  93188. animations: Array<Animation>;
  93189. private _scene;
  93190. private _isDirty;
  93191. private _transformMatrices;
  93192. private _transformMatrixTexture;
  93193. private _meshesWithPoseMatrix;
  93194. private _animatables;
  93195. private _identity;
  93196. private _synchronizedWithMesh;
  93197. private _ranges;
  93198. private _lastAbsoluteTransformsUpdateId;
  93199. private _canUseTextureForBones;
  93200. private _uniqueId;
  93201. /** @hidden */
  93202. _numBonesWithLinkedTransformNode: number;
  93203. /** @hidden */
  93204. _hasWaitingData: Nullable<boolean>;
  93205. /**
  93206. * Specifies if the skeleton should be serialized
  93207. */
  93208. doNotSerialize: boolean;
  93209. private _useTextureToStoreBoneMatrices;
  93210. /**
  93211. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  93212. * Please note that this option is not available if the hardware does not support it
  93213. */
  93214. get useTextureToStoreBoneMatrices(): boolean;
  93215. set useTextureToStoreBoneMatrices(value: boolean);
  93216. private _animationPropertiesOverride;
  93217. /**
  93218. * Gets or sets the animation properties override
  93219. */
  93220. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93221. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  93222. /**
  93223. * List of inspectable custom properties (used by the Inspector)
  93224. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93225. */
  93226. inspectableCustomProperties: IInspectable[];
  93227. /**
  93228. * An observable triggered before computing the skeleton's matrices
  93229. */
  93230. onBeforeComputeObservable: Observable<Skeleton>;
  93231. /**
  93232. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  93233. */
  93234. get isUsingTextureForMatrices(): boolean;
  93235. /**
  93236. * Gets the unique ID of this skeleton
  93237. */
  93238. get uniqueId(): number;
  93239. /**
  93240. * Creates a new skeleton
  93241. * @param name defines the skeleton name
  93242. * @param id defines the skeleton Id
  93243. * @param scene defines the hosting scene
  93244. */
  93245. constructor(
  93246. /** defines the skeleton name */
  93247. name: string,
  93248. /** defines the skeleton Id */
  93249. id: string, scene: Scene);
  93250. /**
  93251. * Gets the current object class name.
  93252. * @return the class name
  93253. */
  93254. getClassName(): string;
  93255. /**
  93256. * Returns an array containing the root bones
  93257. * @returns an array containing the root bones
  93258. */
  93259. getChildren(): Array<Bone>;
  93260. /**
  93261. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  93262. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  93263. * @returns a Float32Array containing matrices data
  93264. */
  93265. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  93266. /**
  93267. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  93268. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  93269. * @returns a raw texture containing the data
  93270. */
  93271. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  93272. /**
  93273. * Gets the current hosting scene
  93274. * @returns a scene object
  93275. */
  93276. getScene(): Scene;
  93277. /**
  93278. * Gets a string representing the current skeleton data
  93279. * @param fullDetails defines a boolean indicating if we want a verbose version
  93280. * @returns a string representing the current skeleton data
  93281. */
  93282. toString(fullDetails?: boolean): string;
  93283. /**
  93284. * Get bone's index searching by name
  93285. * @param name defines bone's name to search for
  93286. * @return the indice of the bone. Returns -1 if not found
  93287. */
  93288. getBoneIndexByName(name: string): number;
  93289. /**
  93290. * Creater a new animation range
  93291. * @param name defines the name of the range
  93292. * @param from defines the start key
  93293. * @param to defines the end key
  93294. */
  93295. createAnimationRange(name: string, from: number, to: number): void;
  93296. /**
  93297. * Delete a specific animation range
  93298. * @param name defines the name of the range
  93299. * @param deleteFrames defines if frames must be removed as well
  93300. */
  93301. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93302. /**
  93303. * Gets a specific animation range
  93304. * @param name defines the name of the range to look for
  93305. * @returns the requested animation range or null if not found
  93306. */
  93307. getAnimationRange(name: string): Nullable<AnimationRange>;
  93308. /**
  93309. * Gets the list of all animation ranges defined on this skeleton
  93310. * @returns an array
  93311. */
  93312. getAnimationRanges(): Nullable<AnimationRange>[];
  93313. /**
  93314. * Copy animation range from a source skeleton.
  93315. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  93316. * @param source defines the source skeleton
  93317. * @param name defines the name of the range to copy
  93318. * @param rescaleAsRequired defines if rescaling must be applied if required
  93319. * @returns true if operation was successful
  93320. */
  93321. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  93322. /**
  93323. * Forces the skeleton to go to rest pose
  93324. */
  93325. returnToRest(): void;
  93326. private _getHighestAnimationFrame;
  93327. /**
  93328. * Begin a specific animation range
  93329. * @param name defines the name of the range to start
  93330. * @param loop defines if looping must be turned on (false by default)
  93331. * @param speedRatio defines the speed ratio to apply (1 by default)
  93332. * @param onAnimationEnd defines a callback which will be called when animation will end
  93333. * @returns a new animatable
  93334. */
  93335. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93336. /**
  93337. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  93338. * @param skeleton defines the Skeleton containing the animation range to convert
  93339. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  93340. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  93341. * @returns the original skeleton
  93342. */
  93343. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  93344. /** @hidden */
  93345. _markAsDirty(): void;
  93346. /** @hidden */
  93347. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  93348. /** @hidden */
  93349. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  93350. private _computeTransformMatrices;
  93351. /**
  93352. * Build all resources required to render a skeleton
  93353. */
  93354. prepare(): void;
  93355. /**
  93356. * Gets the list of animatables currently running for this skeleton
  93357. * @returns an array of animatables
  93358. */
  93359. getAnimatables(): IAnimatable[];
  93360. /**
  93361. * Clone the current skeleton
  93362. * @param name defines the name of the new skeleton
  93363. * @param id defines the id of the new skeleton
  93364. * @returns the new skeleton
  93365. */
  93366. clone(name: string, id?: string): Skeleton;
  93367. /**
  93368. * Enable animation blending for this skeleton
  93369. * @param blendingSpeed defines the blending speed to apply
  93370. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  93371. */
  93372. enableBlending(blendingSpeed?: number): void;
  93373. /**
  93374. * Releases all resources associated with the current skeleton
  93375. */
  93376. dispose(): void;
  93377. /**
  93378. * Serialize the skeleton in a JSON object
  93379. * @returns a JSON object
  93380. */
  93381. serialize(): any;
  93382. /**
  93383. * Creates a new skeleton from serialized data
  93384. * @param parsedSkeleton defines the serialized data
  93385. * @param scene defines the hosting scene
  93386. * @returns a new skeleton
  93387. */
  93388. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  93389. /**
  93390. * Compute all node absolute transforms
  93391. * @param forceUpdate defines if computation must be done even if cache is up to date
  93392. */
  93393. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  93394. /**
  93395. * Gets the root pose matrix
  93396. * @returns a matrix
  93397. */
  93398. getPoseMatrix(): Nullable<Matrix>;
  93399. /**
  93400. * Sorts bones per internal index
  93401. */
  93402. sortBones(): void;
  93403. private _sortBones;
  93404. }
  93405. }
  93406. declare module BABYLON {
  93407. /**
  93408. * Creates an instance based on a source mesh.
  93409. */
  93410. export class InstancedMesh extends AbstractMesh {
  93411. private _sourceMesh;
  93412. private _currentLOD;
  93413. /** @hidden */
  93414. _indexInSourceMeshInstanceArray: number;
  93415. constructor(name: string, source: Mesh);
  93416. /**
  93417. * Returns the string "InstancedMesh".
  93418. */
  93419. getClassName(): string;
  93420. /** Gets the list of lights affecting that mesh */
  93421. get lightSources(): Light[];
  93422. _resyncLightSources(): void;
  93423. _resyncLightSource(light: Light): void;
  93424. _removeLightSource(light: Light, dispose: boolean): void;
  93425. /**
  93426. * If the source mesh receives shadows
  93427. */
  93428. get receiveShadows(): boolean;
  93429. /**
  93430. * The material of the source mesh
  93431. */
  93432. get material(): Nullable<Material>;
  93433. /**
  93434. * Visibility of the source mesh
  93435. */
  93436. get visibility(): number;
  93437. /**
  93438. * Skeleton of the source mesh
  93439. */
  93440. get skeleton(): Nullable<Skeleton>;
  93441. /**
  93442. * Rendering ground id of the source mesh
  93443. */
  93444. get renderingGroupId(): number;
  93445. set renderingGroupId(value: number);
  93446. /**
  93447. * Returns the total number of vertices (integer).
  93448. */
  93449. getTotalVertices(): number;
  93450. /**
  93451. * Returns a positive integer : the total number of indices in this mesh geometry.
  93452. * @returns the numner of indices or zero if the mesh has no geometry.
  93453. */
  93454. getTotalIndices(): number;
  93455. /**
  93456. * The source mesh of the instance
  93457. */
  93458. get sourceMesh(): Mesh;
  93459. /**
  93460. * Creates a new InstancedMesh object from the mesh model.
  93461. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93462. * @param name defines the name of the new instance
  93463. * @returns a new InstancedMesh
  93464. */
  93465. createInstance(name: string): InstancedMesh;
  93466. /**
  93467. * Is this node ready to be used/rendered
  93468. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93469. * @return {boolean} is it ready
  93470. */
  93471. isReady(completeCheck?: boolean): boolean;
  93472. /**
  93473. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  93474. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  93475. * @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.
  93476. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  93477. */
  93478. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  93479. /**
  93480. * Sets the vertex data of the mesh geometry for the requested `kind`.
  93481. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  93482. * The `data` are either a numeric array either a Float32Array.
  93483. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  93484. * 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).
  93485. * Note that a new underlying VertexBuffer object is created each call.
  93486. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  93487. *
  93488. * Possible `kind` values :
  93489. * - VertexBuffer.PositionKind
  93490. * - VertexBuffer.UVKind
  93491. * - VertexBuffer.UV2Kind
  93492. * - VertexBuffer.UV3Kind
  93493. * - VertexBuffer.UV4Kind
  93494. * - VertexBuffer.UV5Kind
  93495. * - VertexBuffer.UV6Kind
  93496. * - VertexBuffer.ColorKind
  93497. * - VertexBuffer.MatricesIndicesKind
  93498. * - VertexBuffer.MatricesIndicesExtraKind
  93499. * - VertexBuffer.MatricesWeightsKind
  93500. * - VertexBuffer.MatricesWeightsExtraKind
  93501. *
  93502. * Returns the Mesh.
  93503. */
  93504. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93505. /**
  93506. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  93507. * If the mesh has no geometry, it is simply returned as it is.
  93508. * The `data` are either a numeric array either a Float32Array.
  93509. * No new underlying VertexBuffer object is created.
  93510. * 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.
  93511. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  93512. *
  93513. * Possible `kind` values :
  93514. * - VertexBuffer.PositionKind
  93515. * - VertexBuffer.UVKind
  93516. * - VertexBuffer.UV2Kind
  93517. * - VertexBuffer.UV3Kind
  93518. * - VertexBuffer.UV4Kind
  93519. * - VertexBuffer.UV5Kind
  93520. * - VertexBuffer.UV6Kind
  93521. * - VertexBuffer.ColorKind
  93522. * - VertexBuffer.MatricesIndicesKind
  93523. * - VertexBuffer.MatricesIndicesExtraKind
  93524. * - VertexBuffer.MatricesWeightsKind
  93525. * - VertexBuffer.MatricesWeightsExtraKind
  93526. *
  93527. * Returns the Mesh.
  93528. */
  93529. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  93530. /**
  93531. * Sets the mesh indices.
  93532. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  93533. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  93534. * This method creates a new index buffer each call.
  93535. * Returns the Mesh.
  93536. */
  93537. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  93538. /**
  93539. * Boolean : True if the mesh owns the requested kind of data.
  93540. */
  93541. isVerticesDataPresent(kind: string): boolean;
  93542. /**
  93543. * Returns an array of indices (IndicesArray).
  93544. */
  93545. getIndices(): Nullable<IndicesArray>;
  93546. get _positions(): Nullable<Vector3[]>;
  93547. /**
  93548. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93549. * This means the mesh underlying bounding box and sphere are recomputed.
  93550. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93551. * @returns the current mesh
  93552. */
  93553. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  93554. /** @hidden */
  93555. _preActivate(): InstancedMesh;
  93556. /** @hidden */
  93557. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93558. /** @hidden */
  93559. _postActivate(): void;
  93560. getWorldMatrix(): Matrix;
  93561. get isAnInstance(): boolean;
  93562. /**
  93563. * Returns the current associated LOD AbstractMesh.
  93564. */
  93565. getLOD(camera: Camera): AbstractMesh;
  93566. /** @hidden */
  93567. _preActivateForIntermediateRendering(renderId: number): Mesh;
  93568. /** @hidden */
  93569. _syncSubMeshes(): InstancedMesh;
  93570. /** @hidden */
  93571. _generatePointsArray(): boolean;
  93572. /**
  93573. * Creates a new InstancedMesh from the current mesh.
  93574. * - name (string) : the cloned mesh name
  93575. * - newParent (optional Node) : the optional Node to parent the clone to.
  93576. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  93577. *
  93578. * Returns the clone.
  93579. */
  93580. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  93581. /**
  93582. * Disposes the InstancedMesh.
  93583. * Returns nothing.
  93584. */
  93585. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93586. }
  93587. interface Mesh {
  93588. /**
  93589. * Register a custom buffer that will be instanced
  93590. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  93591. * @param kind defines the buffer kind
  93592. * @param stride defines the stride in floats
  93593. */
  93594. registerInstancedBuffer(kind: string, stride: number): void;
  93595. /** @hidden */
  93596. _userInstancedBuffersStorage: {
  93597. data: {
  93598. [key: string]: Float32Array;
  93599. };
  93600. sizes: {
  93601. [key: string]: number;
  93602. };
  93603. vertexBuffers: {
  93604. [key: string]: Nullable<VertexBuffer>;
  93605. };
  93606. strides: {
  93607. [key: string]: number;
  93608. };
  93609. };
  93610. }
  93611. interface AbstractMesh {
  93612. /**
  93613. * Object used to store instanced buffers defined by user
  93614. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  93615. */
  93616. instancedBuffers: {
  93617. [key: string]: any;
  93618. };
  93619. }
  93620. }
  93621. declare module BABYLON {
  93622. /**
  93623. * Defines the options associated with the creation of a shader material.
  93624. */
  93625. export interface IShaderMaterialOptions {
  93626. /**
  93627. * Does the material work in alpha blend mode
  93628. */
  93629. needAlphaBlending: boolean;
  93630. /**
  93631. * Does the material work in alpha test mode
  93632. */
  93633. needAlphaTesting: boolean;
  93634. /**
  93635. * The list of attribute names used in the shader
  93636. */
  93637. attributes: string[];
  93638. /**
  93639. * The list of unifrom names used in the shader
  93640. */
  93641. uniforms: string[];
  93642. /**
  93643. * The list of UBO names used in the shader
  93644. */
  93645. uniformBuffers: string[];
  93646. /**
  93647. * The list of sampler names used in the shader
  93648. */
  93649. samplers: string[];
  93650. /**
  93651. * The list of defines used in the shader
  93652. */
  93653. defines: string[];
  93654. }
  93655. /**
  93656. * 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.
  93657. *
  93658. * This returned material effects how the mesh will look based on the code in the shaders.
  93659. *
  93660. * @see http://doc.babylonjs.com/how_to/shader_material
  93661. */
  93662. export class ShaderMaterial extends Material {
  93663. private _shaderPath;
  93664. private _options;
  93665. private _textures;
  93666. private _textureArrays;
  93667. private _floats;
  93668. private _ints;
  93669. private _floatsArrays;
  93670. private _colors3;
  93671. private _colors3Arrays;
  93672. private _colors4;
  93673. private _colors4Arrays;
  93674. private _vectors2;
  93675. private _vectors3;
  93676. private _vectors4;
  93677. private _matrices;
  93678. private _matrixArrays;
  93679. private _matrices3x3;
  93680. private _matrices2x2;
  93681. private _vectors2Arrays;
  93682. private _vectors3Arrays;
  93683. private _vectors4Arrays;
  93684. private _cachedWorldViewMatrix;
  93685. private _cachedWorldViewProjectionMatrix;
  93686. private _renderId;
  93687. private _multiview;
  93688. private _cachedDefines;
  93689. /**
  93690. * Instantiate a new shader material.
  93691. * 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.
  93692. * This returned material effects how the mesh will look based on the code in the shaders.
  93693. * @see http://doc.babylonjs.com/how_to/shader_material
  93694. * @param name Define the name of the material in the scene
  93695. * @param scene Define the scene the material belongs to
  93696. * @param shaderPath Defines the route to the shader code in one of three ways:
  93697. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  93698. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  93699. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  93700. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  93701. * @param options Define the options used to create the shader
  93702. */
  93703. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  93704. /**
  93705. * Gets the shader path used to define the shader code
  93706. * It can be modified to trigger a new compilation
  93707. */
  93708. get shaderPath(): any;
  93709. /**
  93710. * Sets the shader path used to define the shader code
  93711. * It can be modified to trigger a new compilation
  93712. */
  93713. set shaderPath(shaderPath: any);
  93714. /**
  93715. * Gets the options used to compile the shader.
  93716. * They can be modified to trigger a new compilation
  93717. */
  93718. get options(): IShaderMaterialOptions;
  93719. /**
  93720. * Gets the current class name of the material e.g. "ShaderMaterial"
  93721. * Mainly use in serialization.
  93722. * @returns the class name
  93723. */
  93724. getClassName(): string;
  93725. /**
  93726. * Specifies if the material will require alpha blending
  93727. * @returns a boolean specifying if alpha blending is needed
  93728. */
  93729. needAlphaBlending(): boolean;
  93730. /**
  93731. * Specifies if this material should be rendered in alpha test mode
  93732. * @returns a boolean specifying if an alpha test is needed.
  93733. */
  93734. needAlphaTesting(): boolean;
  93735. private _checkUniform;
  93736. /**
  93737. * Set a texture in the shader.
  93738. * @param name Define the name of the uniform samplers as defined in the shader
  93739. * @param texture Define the texture to bind to this sampler
  93740. * @return the material itself allowing "fluent" like uniform updates
  93741. */
  93742. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  93743. /**
  93744. * Set a texture array in the shader.
  93745. * @param name Define the name of the uniform sampler array as defined in the shader
  93746. * @param textures Define the list of textures to bind to this sampler
  93747. * @return the material itself allowing "fluent" like uniform updates
  93748. */
  93749. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  93750. /**
  93751. * Set a float in the shader.
  93752. * @param name Define the name of the uniform as defined in the shader
  93753. * @param value Define the value to give to the uniform
  93754. * @return the material itself allowing "fluent" like uniform updates
  93755. */
  93756. setFloat(name: string, value: number): ShaderMaterial;
  93757. /**
  93758. * Set a int in the shader.
  93759. * @param name Define the name of the uniform as defined in the shader
  93760. * @param value Define the value to give to the uniform
  93761. * @return the material itself allowing "fluent" like uniform updates
  93762. */
  93763. setInt(name: string, value: number): ShaderMaterial;
  93764. /**
  93765. * Set an array of floats in the shader.
  93766. * @param name Define the name of the uniform as defined in the shader
  93767. * @param value Define the value to give to the uniform
  93768. * @return the material itself allowing "fluent" like uniform updates
  93769. */
  93770. setFloats(name: string, value: number[]): ShaderMaterial;
  93771. /**
  93772. * Set a vec3 in the shader from a Color3.
  93773. * @param name Define the name of the uniform as defined in the shader
  93774. * @param value Define the value to give to the uniform
  93775. * @return the material itself allowing "fluent" like uniform updates
  93776. */
  93777. setColor3(name: string, value: Color3): ShaderMaterial;
  93778. /**
  93779. * Set a vec3 array in the shader from a Color3 array.
  93780. * @param name Define the name of the uniform as defined in the shader
  93781. * @param value Define the value to give to the uniform
  93782. * @return the material itself allowing "fluent" like uniform updates
  93783. */
  93784. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  93785. /**
  93786. * Set a vec4 in the shader from a Color4.
  93787. * @param name Define the name of the uniform as defined in the shader
  93788. * @param value Define the value to give to the uniform
  93789. * @return the material itself allowing "fluent" like uniform updates
  93790. */
  93791. setColor4(name: string, value: Color4): ShaderMaterial;
  93792. /**
  93793. * Set a vec4 array in the shader from a Color4 array.
  93794. * @param name Define the name of the uniform as defined in the shader
  93795. * @param value Define the value to give to the uniform
  93796. * @return the material itself allowing "fluent" like uniform updates
  93797. */
  93798. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  93799. /**
  93800. * Set a vec2 in the shader from a Vector2.
  93801. * @param name Define the name of the uniform as defined in the shader
  93802. * @param value Define the value to give to the uniform
  93803. * @return the material itself allowing "fluent" like uniform updates
  93804. */
  93805. setVector2(name: string, value: Vector2): ShaderMaterial;
  93806. /**
  93807. * Set a vec3 in the shader from a Vector3.
  93808. * @param name Define the name of the uniform as defined in the shader
  93809. * @param value Define the value to give to the uniform
  93810. * @return the material itself allowing "fluent" like uniform updates
  93811. */
  93812. setVector3(name: string, value: Vector3): ShaderMaterial;
  93813. /**
  93814. * Set a vec4 in the shader from a Vector4.
  93815. * @param name Define the name of the uniform as defined in the shader
  93816. * @param value Define the value to give to the uniform
  93817. * @return the material itself allowing "fluent" like uniform updates
  93818. */
  93819. setVector4(name: string, value: Vector4): ShaderMaterial;
  93820. /**
  93821. * Set a mat4 in the shader from a Matrix.
  93822. * @param name Define the name of the uniform as defined in the shader
  93823. * @param value Define the value to give to the uniform
  93824. * @return the material itself allowing "fluent" like uniform updates
  93825. */
  93826. setMatrix(name: string, value: Matrix): ShaderMaterial;
  93827. /**
  93828. * Set a float32Array in the shader from a matrix array.
  93829. * @param name Define the name of the uniform as defined in the shader
  93830. * @param value Define the value to give to the uniform
  93831. * @return the material itself allowing "fluent" like uniform updates
  93832. */
  93833. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  93834. /**
  93835. * Set a mat3 in the shader from a Float32Array.
  93836. * @param name Define the name of the uniform as defined in the shader
  93837. * @param value Define the value to give to the uniform
  93838. * @return the material itself allowing "fluent" like uniform updates
  93839. */
  93840. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  93841. /**
  93842. * Set a mat2 in the shader from a Float32Array.
  93843. * @param name Define the name of the uniform as defined in the shader
  93844. * @param value Define the value to give to the uniform
  93845. * @return the material itself allowing "fluent" like uniform updates
  93846. */
  93847. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  93848. /**
  93849. * Set a vec2 array in the shader from a number array.
  93850. * @param name Define the name of the uniform as defined in the shader
  93851. * @param value Define the value to give to the uniform
  93852. * @return the material itself allowing "fluent" like uniform updates
  93853. */
  93854. setArray2(name: string, value: number[]): ShaderMaterial;
  93855. /**
  93856. * Set a vec3 array in the shader from a number array.
  93857. * @param name Define the name of the uniform as defined in the shader
  93858. * @param value Define the value to give to the uniform
  93859. * @return the material itself allowing "fluent" like uniform updates
  93860. */
  93861. setArray3(name: string, value: number[]): ShaderMaterial;
  93862. /**
  93863. * Set a vec4 array in the shader from a number array.
  93864. * @param name Define the name of the uniform as defined in the shader
  93865. * @param value Define the value to give to the uniform
  93866. * @return the material itself allowing "fluent" like uniform updates
  93867. */
  93868. setArray4(name: string, value: number[]): ShaderMaterial;
  93869. private _checkCache;
  93870. /**
  93871. * Specifies that the submesh is ready to be used
  93872. * @param mesh defines the mesh to check
  93873. * @param subMesh defines which submesh to check
  93874. * @param useInstances specifies that instances should be used
  93875. * @returns a boolean indicating that the submesh is ready or not
  93876. */
  93877. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  93878. /**
  93879. * Checks if the material is ready to render the requested mesh
  93880. * @param mesh Define the mesh to render
  93881. * @param useInstances Define whether or not the material is used with instances
  93882. * @returns true if ready, otherwise false
  93883. */
  93884. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  93885. /**
  93886. * Binds the world matrix to the material
  93887. * @param world defines the world transformation matrix
  93888. * @param effectOverride - If provided, use this effect instead of internal effect
  93889. */
  93890. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  93891. /**
  93892. * Binds the submesh to this material by preparing the effect and shader to draw
  93893. * @param world defines the world transformation matrix
  93894. * @param mesh defines the mesh containing the submesh
  93895. * @param subMesh defines the submesh to bind the material to
  93896. */
  93897. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  93898. /**
  93899. * Binds the material to the mesh
  93900. * @param world defines the world transformation matrix
  93901. * @param mesh defines the mesh to bind the material to
  93902. * @param effectOverride - If provided, use this effect instead of internal effect
  93903. */
  93904. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  93905. protected _afterBind(mesh?: Mesh): void;
  93906. /**
  93907. * Gets the active textures from the material
  93908. * @returns an array of textures
  93909. */
  93910. getActiveTextures(): BaseTexture[];
  93911. /**
  93912. * Specifies if the material uses a texture
  93913. * @param texture defines the texture to check against the material
  93914. * @returns a boolean specifying if the material uses the texture
  93915. */
  93916. hasTexture(texture: BaseTexture): boolean;
  93917. /**
  93918. * Makes a duplicate of the material, and gives it a new name
  93919. * @param name defines the new name for the duplicated material
  93920. * @returns the cloned material
  93921. */
  93922. clone(name: string): ShaderMaterial;
  93923. /**
  93924. * Disposes the material
  93925. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  93926. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  93927. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  93928. */
  93929. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  93930. /**
  93931. * Serializes this material in a JSON representation
  93932. * @returns the serialized material object
  93933. */
  93934. serialize(): any;
  93935. /**
  93936. * Creates a shader material from parsed shader material data
  93937. * @param source defines the JSON represnetation of the material
  93938. * @param scene defines the hosting scene
  93939. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  93940. * @returns a new material
  93941. */
  93942. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  93943. }
  93944. }
  93945. declare module BABYLON {
  93946. /** @hidden */
  93947. export var colorPixelShader: {
  93948. name: string;
  93949. shader: string;
  93950. };
  93951. }
  93952. declare module BABYLON {
  93953. /** @hidden */
  93954. export var colorVertexShader: {
  93955. name: string;
  93956. shader: string;
  93957. };
  93958. }
  93959. declare module BABYLON {
  93960. /**
  93961. * Line mesh
  93962. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  93963. */
  93964. export class LinesMesh extends Mesh {
  93965. /**
  93966. * If vertex color should be applied to the mesh
  93967. */
  93968. readonly useVertexColor?: boolean | undefined;
  93969. /**
  93970. * If vertex alpha should be applied to the mesh
  93971. */
  93972. readonly useVertexAlpha?: boolean | undefined;
  93973. /**
  93974. * Color of the line (Default: White)
  93975. */
  93976. color: Color3;
  93977. /**
  93978. * Alpha of the line (Default: 1)
  93979. */
  93980. alpha: number;
  93981. /**
  93982. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  93983. * This margin is expressed in world space coordinates, so its value may vary.
  93984. * Default value is 0.1
  93985. */
  93986. intersectionThreshold: number;
  93987. private _colorShader;
  93988. private color4;
  93989. /**
  93990. * Creates a new LinesMesh
  93991. * @param name defines the name
  93992. * @param scene defines the hosting scene
  93993. * @param parent defines the parent mesh if any
  93994. * @param source defines the optional source LinesMesh used to clone data from
  93995. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  93996. * When false, achieved by calling a clone(), also passing False.
  93997. * This will make creation of children, recursive.
  93998. * @param useVertexColor defines if this LinesMesh supports vertex color
  93999. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  94000. */
  94001. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  94002. /**
  94003. * If vertex color should be applied to the mesh
  94004. */
  94005. useVertexColor?: boolean | undefined,
  94006. /**
  94007. * If vertex alpha should be applied to the mesh
  94008. */
  94009. useVertexAlpha?: boolean | undefined);
  94010. private _addClipPlaneDefine;
  94011. private _removeClipPlaneDefine;
  94012. isReady(): boolean;
  94013. /**
  94014. * Returns the string "LineMesh"
  94015. */
  94016. getClassName(): string;
  94017. /**
  94018. * @hidden
  94019. */
  94020. get material(): Material;
  94021. /**
  94022. * @hidden
  94023. */
  94024. set material(value: Material);
  94025. /**
  94026. * @hidden
  94027. */
  94028. get checkCollisions(): boolean;
  94029. /** @hidden */
  94030. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  94031. /** @hidden */
  94032. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  94033. /**
  94034. * Disposes of the line mesh
  94035. * @param doNotRecurse If children should be disposed
  94036. */
  94037. dispose(doNotRecurse?: boolean): void;
  94038. /**
  94039. * Returns a new LineMesh object cloned from the current one.
  94040. */
  94041. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  94042. /**
  94043. * Creates a new InstancedLinesMesh object from the mesh model.
  94044. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  94045. * @param name defines the name of the new instance
  94046. * @returns a new InstancedLinesMesh
  94047. */
  94048. createInstance(name: string): InstancedLinesMesh;
  94049. }
  94050. /**
  94051. * Creates an instance based on a source LinesMesh
  94052. */
  94053. export class InstancedLinesMesh extends InstancedMesh {
  94054. /**
  94055. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  94056. * This margin is expressed in world space coordinates, so its value may vary.
  94057. * Initilized with the intersectionThreshold value of the source LinesMesh
  94058. */
  94059. intersectionThreshold: number;
  94060. constructor(name: string, source: LinesMesh);
  94061. /**
  94062. * Returns the string "InstancedLinesMesh".
  94063. */
  94064. getClassName(): string;
  94065. }
  94066. }
  94067. declare module BABYLON {
  94068. /** @hidden */
  94069. export var linePixelShader: {
  94070. name: string;
  94071. shader: string;
  94072. };
  94073. }
  94074. declare module BABYLON {
  94075. /** @hidden */
  94076. export var lineVertexShader: {
  94077. name: string;
  94078. shader: string;
  94079. };
  94080. }
  94081. declare module BABYLON {
  94082. interface AbstractMesh {
  94083. /**
  94084. * Gets the edgesRenderer associated with the mesh
  94085. */
  94086. edgesRenderer: Nullable<EdgesRenderer>;
  94087. }
  94088. interface LinesMesh {
  94089. /**
  94090. * Enables the edge rendering mode on the mesh.
  94091. * This mode makes the mesh edges visible
  94092. * @param epsilon defines the maximal distance between two angles to detect a face
  94093. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94094. * @returns the currentAbstractMesh
  94095. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94096. */
  94097. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  94098. }
  94099. interface InstancedLinesMesh {
  94100. /**
  94101. * Enables the edge rendering mode on the mesh.
  94102. * This mode makes the mesh edges visible
  94103. * @param epsilon defines the maximal distance between two angles to detect a face
  94104. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94105. * @returns the current InstancedLinesMesh
  94106. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94107. */
  94108. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  94109. }
  94110. /**
  94111. * Defines the minimum contract an Edges renderer should follow.
  94112. */
  94113. export interface IEdgesRenderer extends IDisposable {
  94114. /**
  94115. * Gets or sets a boolean indicating if the edgesRenderer is active
  94116. */
  94117. isEnabled: boolean;
  94118. /**
  94119. * Renders the edges of the attached mesh,
  94120. */
  94121. render(): void;
  94122. /**
  94123. * Checks wether or not the edges renderer is ready to render.
  94124. * @return true if ready, otherwise false.
  94125. */
  94126. isReady(): boolean;
  94127. }
  94128. /**
  94129. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  94130. */
  94131. export class EdgesRenderer implements IEdgesRenderer {
  94132. /**
  94133. * Define the size of the edges with an orthographic camera
  94134. */
  94135. edgesWidthScalerForOrthographic: number;
  94136. /**
  94137. * Define the size of the edges with a perspective camera
  94138. */
  94139. edgesWidthScalerForPerspective: number;
  94140. protected _source: AbstractMesh;
  94141. protected _linesPositions: number[];
  94142. protected _linesNormals: number[];
  94143. protected _linesIndices: number[];
  94144. protected _epsilon: number;
  94145. protected _indicesCount: number;
  94146. protected _lineShader: ShaderMaterial;
  94147. protected _ib: DataBuffer;
  94148. protected _buffers: {
  94149. [key: string]: Nullable<VertexBuffer>;
  94150. };
  94151. protected _checkVerticesInsteadOfIndices: boolean;
  94152. private _meshRebuildObserver;
  94153. private _meshDisposeObserver;
  94154. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  94155. isEnabled: boolean;
  94156. /**
  94157. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  94158. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  94159. * @param source Mesh used to create edges
  94160. * @param epsilon sum of angles in adjacency to check for edge
  94161. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  94162. * @param generateEdgesLines - should generate Lines or only prepare resources.
  94163. */
  94164. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  94165. protected _prepareRessources(): void;
  94166. /** @hidden */
  94167. _rebuild(): void;
  94168. /**
  94169. * Releases the required resources for the edges renderer
  94170. */
  94171. dispose(): void;
  94172. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  94173. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  94174. /**
  94175. * Checks if the pair of p0 and p1 is en edge
  94176. * @param faceIndex
  94177. * @param edge
  94178. * @param faceNormals
  94179. * @param p0
  94180. * @param p1
  94181. * @private
  94182. */
  94183. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  94184. /**
  94185. * push line into the position, normal and index buffer
  94186. * @protected
  94187. */
  94188. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  94189. /**
  94190. * Generates lines edges from adjacencjes
  94191. * @private
  94192. */
  94193. _generateEdgesLines(): void;
  94194. /**
  94195. * Checks wether or not the edges renderer is ready to render.
  94196. * @return true if ready, otherwise false.
  94197. */
  94198. isReady(): boolean;
  94199. /**
  94200. * Renders the edges of the attached mesh,
  94201. */
  94202. render(): void;
  94203. }
  94204. /**
  94205. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  94206. */
  94207. export class LineEdgesRenderer extends EdgesRenderer {
  94208. /**
  94209. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  94210. * @param source LineMesh used to generate edges
  94211. * @param epsilon not important (specified angle for edge detection)
  94212. * @param checkVerticesInsteadOfIndices not important for LineMesh
  94213. */
  94214. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  94215. /**
  94216. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  94217. */
  94218. _generateEdgesLines(): void;
  94219. }
  94220. }
  94221. declare module BABYLON {
  94222. /**
  94223. * This represents the object necessary to create a rendering group.
  94224. * This is exclusively used and created by the rendering manager.
  94225. * To modify the behavior, you use the available helpers in your scene or meshes.
  94226. * @hidden
  94227. */
  94228. export class RenderingGroup {
  94229. index: number;
  94230. private static _zeroVector;
  94231. private _scene;
  94232. private _opaqueSubMeshes;
  94233. private _transparentSubMeshes;
  94234. private _alphaTestSubMeshes;
  94235. private _depthOnlySubMeshes;
  94236. private _particleSystems;
  94237. private _spriteManagers;
  94238. private _opaqueSortCompareFn;
  94239. private _alphaTestSortCompareFn;
  94240. private _transparentSortCompareFn;
  94241. private _renderOpaque;
  94242. private _renderAlphaTest;
  94243. private _renderTransparent;
  94244. /** @hidden */
  94245. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  94246. onBeforeTransparentRendering: () => void;
  94247. /**
  94248. * Set the opaque sort comparison function.
  94249. * If null the sub meshes will be render in the order they were created
  94250. */
  94251. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94252. /**
  94253. * Set the alpha test sort comparison function.
  94254. * If null the sub meshes will be render in the order they were created
  94255. */
  94256. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94257. /**
  94258. * Set the transparent sort comparison function.
  94259. * If null the sub meshes will be render in the order they were created
  94260. */
  94261. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94262. /**
  94263. * Creates a new rendering group.
  94264. * @param index The rendering group index
  94265. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  94266. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  94267. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  94268. */
  94269. 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>);
  94270. /**
  94271. * Render all the sub meshes contained in the group.
  94272. * @param customRenderFunction Used to override the default render behaviour of the group.
  94273. * @returns true if rendered some submeshes.
  94274. */
  94275. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  94276. /**
  94277. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  94278. * @param subMeshes The submeshes to render
  94279. */
  94280. private renderOpaqueSorted;
  94281. /**
  94282. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  94283. * @param subMeshes The submeshes to render
  94284. */
  94285. private renderAlphaTestSorted;
  94286. /**
  94287. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  94288. * @param subMeshes The submeshes to render
  94289. */
  94290. private renderTransparentSorted;
  94291. /**
  94292. * Renders the submeshes in a specified order.
  94293. * @param subMeshes The submeshes to sort before render
  94294. * @param sortCompareFn The comparison function use to sort
  94295. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  94296. * @param transparent Specifies to activate blending if true
  94297. */
  94298. private static renderSorted;
  94299. /**
  94300. * Renders the submeshes in the order they were dispatched (no sort applied).
  94301. * @param subMeshes The submeshes to render
  94302. */
  94303. private static renderUnsorted;
  94304. /**
  94305. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94306. * are rendered back to front if in the same alpha index.
  94307. *
  94308. * @param a The first submesh
  94309. * @param b The second submesh
  94310. * @returns The result of the comparison
  94311. */
  94312. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  94313. /**
  94314. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94315. * are rendered back to front.
  94316. *
  94317. * @param a The first submesh
  94318. * @param b The second submesh
  94319. * @returns The result of the comparison
  94320. */
  94321. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  94322. /**
  94323. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94324. * are rendered front to back (prevent overdraw).
  94325. *
  94326. * @param a The first submesh
  94327. * @param b The second submesh
  94328. * @returns The result of the comparison
  94329. */
  94330. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  94331. /**
  94332. * Resets the different lists of submeshes to prepare a new frame.
  94333. */
  94334. prepare(): void;
  94335. dispose(): void;
  94336. /**
  94337. * Inserts the submesh in its correct queue depending on its material.
  94338. * @param subMesh The submesh to dispatch
  94339. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  94340. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  94341. */
  94342. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  94343. dispatchSprites(spriteManager: ISpriteManager): void;
  94344. dispatchParticles(particleSystem: IParticleSystem): void;
  94345. private _renderParticles;
  94346. private _renderSprites;
  94347. }
  94348. }
  94349. declare module BABYLON {
  94350. /**
  94351. * Interface describing the different options available in the rendering manager
  94352. * regarding Auto Clear between groups.
  94353. */
  94354. export interface IRenderingManagerAutoClearSetup {
  94355. /**
  94356. * Defines whether or not autoclear is enable.
  94357. */
  94358. autoClear: boolean;
  94359. /**
  94360. * Defines whether or not to autoclear the depth buffer.
  94361. */
  94362. depth: boolean;
  94363. /**
  94364. * Defines whether or not to autoclear the stencil buffer.
  94365. */
  94366. stencil: boolean;
  94367. }
  94368. /**
  94369. * This class is used by the onRenderingGroupObservable
  94370. */
  94371. export class RenderingGroupInfo {
  94372. /**
  94373. * The Scene that being rendered
  94374. */
  94375. scene: Scene;
  94376. /**
  94377. * The camera currently used for the rendering pass
  94378. */
  94379. camera: Nullable<Camera>;
  94380. /**
  94381. * The ID of the renderingGroup being processed
  94382. */
  94383. renderingGroupId: number;
  94384. }
  94385. /**
  94386. * This is the manager responsible of all the rendering for meshes sprites and particles.
  94387. * It is enable to manage the different groups as well as the different necessary sort functions.
  94388. * This should not be used directly aside of the few static configurations
  94389. */
  94390. export class RenderingManager {
  94391. /**
  94392. * The max id used for rendering groups (not included)
  94393. */
  94394. static MAX_RENDERINGGROUPS: number;
  94395. /**
  94396. * The min id used for rendering groups (included)
  94397. */
  94398. static MIN_RENDERINGGROUPS: number;
  94399. /**
  94400. * Used to globally prevent autoclearing scenes.
  94401. */
  94402. static AUTOCLEAR: boolean;
  94403. /**
  94404. * @hidden
  94405. */
  94406. _useSceneAutoClearSetup: boolean;
  94407. private _scene;
  94408. private _renderingGroups;
  94409. private _depthStencilBufferAlreadyCleaned;
  94410. private _autoClearDepthStencil;
  94411. private _customOpaqueSortCompareFn;
  94412. private _customAlphaTestSortCompareFn;
  94413. private _customTransparentSortCompareFn;
  94414. private _renderingGroupInfo;
  94415. /**
  94416. * Instantiates a new rendering group for a particular scene
  94417. * @param scene Defines the scene the groups belongs to
  94418. */
  94419. constructor(scene: Scene);
  94420. private _clearDepthStencilBuffer;
  94421. /**
  94422. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  94423. * @hidden
  94424. */
  94425. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  94426. /**
  94427. * Resets the different information of the group to prepare a new frame
  94428. * @hidden
  94429. */
  94430. reset(): void;
  94431. /**
  94432. * Dispose and release the group and its associated resources.
  94433. * @hidden
  94434. */
  94435. dispose(): void;
  94436. /**
  94437. * Clear the info related to rendering groups preventing retention points during dispose.
  94438. */
  94439. freeRenderingGroups(): void;
  94440. private _prepareRenderingGroup;
  94441. /**
  94442. * Add a sprite manager to the rendering manager in order to render it this frame.
  94443. * @param spriteManager Define the sprite manager to render
  94444. */
  94445. dispatchSprites(spriteManager: ISpriteManager): void;
  94446. /**
  94447. * Add a particle system to the rendering manager in order to render it this frame.
  94448. * @param particleSystem Define the particle system to render
  94449. */
  94450. dispatchParticles(particleSystem: IParticleSystem): void;
  94451. /**
  94452. * Add a submesh to the manager in order to render it this frame
  94453. * @param subMesh The submesh to dispatch
  94454. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  94455. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  94456. */
  94457. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  94458. /**
  94459. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  94460. * This allowed control for front to back rendering or reversly depending of the special needs.
  94461. *
  94462. * @param renderingGroupId The rendering group id corresponding to its index
  94463. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  94464. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  94465. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  94466. */
  94467. 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;
  94468. /**
  94469. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  94470. *
  94471. * @param renderingGroupId The rendering group id corresponding to its index
  94472. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  94473. * @param depth Automatically clears depth between groups if true and autoClear is true.
  94474. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  94475. */
  94476. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  94477. /**
  94478. * Gets the current auto clear configuration for one rendering group of the rendering
  94479. * manager.
  94480. * @param index the rendering group index to get the information for
  94481. * @returns The auto clear setup for the requested rendering group
  94482. */
  94483. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  94484. }
  94485. }
  94486. declare module BABYLON {
  94487. /**
  94488. * Defines the options associated with the creation of a custom shader for a shadow generator.
  94489. */
  94490. export interface ICustomShaderOptions {
  94491. /**
  94492. * Gets or sets the custom shader name to use
  94493. */
  94494. shaderName: string;
  94495. /**
  94496. * The list of attribute names used in the shader
  94497. */
  94498. attributes?: string[];
  94499. /**
  94500. * The list of unifrom names used in the shader
  94501. */
  94502. uniforms?: string[];
  94503. /**
  94504. * The list of sampler names used in the shader
  94505. */
  94506. samplers?: string[];
  94507. /**
  94508. * The list of defines used in the shader
  94509. */
  94510. defines?: string[];
  94511. }
  94512. /**
  94513. * Interface to implement to create a shadow generator compatible with BJS.
  94514. */
  94515. export interface IShadowGenerator {
  94516. /**
  94517. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  94518. * @returns The render target texture if present otherwise, null
  94519. */
  94520. getShadowMap(): Nullable<RenderTargetTexture>;
  94521. /**
  94522. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  94523. * @param subMesh The submesh we want to render in the shadow map
  94524. * @param useInstances Defines wether will draw in the map using instances
  94525. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  94526. * @returns true if ready otherwise, false
  94527. */
  94528. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  94529. /**
  94530. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  94531. * @param defines Defines of the material we want to update
  94532. * @param lightIndex Index of the light in the enabled light list of the material
  94533. */
  94534. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  94535. /**
  94536. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  94537. * defined in the generator but impacting the effect).
  94538. * It implies the unifroms available on the materials are the standard BJS ones.
  94539. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  94540. * @param effect The effect we are binfing the information for
  94541. */
  94542. bindShadowLight(lightIndex: string, effect: Effect): void;
  94543. /**
  94544. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  94545. * (eq to shadow prjection matrix * light transform matrix)
  94546. * @returns The transform matrix used to create the shadow map
  94547. */
  94548. getTransformMatrix(): Matrix;
  94549. /**
  94550. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  94551. * Cube and 2D textures for instance.
  94552. */
  94553. recreateShadowMap(): void;
  94554. /**
  94555. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94556. * @param onCompiled Callback triggered at the and of the effects compilation
  94557. * @param options Sets of optional options forcing the compilation with different modes
  94558. */
  94559. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  94560. useInstances: boolean;
  94561. }>): void;
  94562. /**
  94563. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94564. * @param options Sets of optional options forcing the compilation with different modes
  94565. * @returns A promise that resolves when the compilation completes
  94566. */
  94567. forceCompilationAsync(options?: Partial<{
  94568. useInstances: boolean;
  94569. }>): Promise<void>;
  94570. /**
  94571. * Serializes the shadow generator setup to a json object.
  94572. * @returns The serialized JSON object
  94573. */
  94574. serialize(): any;
  94575. /**
  94576. * Disposes the Shadow map and related Textures and effects.
  94577. */
  94578. dispose(): void;
  94579. }
  94580. /**
  94581. * Default implementation IShadowGenerator.
  94582. * This is the main object responsible of generating shadows in the framework.
  94583. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  94584. */
  94585. export class ShadowGenerator implements IShadowGenerator {
  94586. /**
  94587. * Name of the shadow generator class
  94588. */
  94589. static CLASSNAME: string;
  94590. /**
  94591. * Shadow generator mode None: no filtering applied.
  94592. */
  94593. static readonly FILTER_NONE: number;
  94594. /**
  94595. * Shadow generator mode ESM: Exponential Shadow Mapping.
  94596. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94597. */
  94598. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  94599. /**
  94600. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  94601. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  94602. */
  94603. static readonly FILTER_POISSONSAMPLING: number;
  94604. /**
  94605. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  94606. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94607. */
  94608. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  94609. /**
  94610. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  94611. * edge artifacts on steep falloff.
  94612. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94613. */
  94614. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  94615. /**
  94616. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  94617. * edge artifacts on steep falloff.
  94618. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94619. */
  94620. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  94621. /**
  94622. * Shadow generator mode PCF: Percentage Closer Filtering
  94623. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  94624. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  94625. */
  94626. static readonly FILTER_PCF: number;
  94627. /**
  94628. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  94629. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  94630. * Contact Hardening
  94631. */
  94632. static readonly FILTER_PCSS: number;
  94633. /**
  94634. * Reserved for PCF and PCSS
  94635. * Highest Quality.
  94636. *
  94637. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  94638. *
  94639. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  94640. */
  94641. static readonly QUALITY_HIGH: number;
  94642. /**
  94643. * Reserved for PCF and PCSS
  94644. * Good tradeoff for quality/perf cross devices
  94645. *
  94646. * Execute PCF on a 3*3 kernel.
  94647. *
  94648. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  94649. */
  94650. static readonly QUALITY_MEDIUM: number;
  94651. /**
  94652. * Reserved for PCF and PCSS
  94653. * The lowest quality but the fastest.
  94654. *
  94655. * Execute PCF on a 1*1 kernel.
  94656. *
  94657. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  94658. */
  94659. static readonly QUALITY_LOW: number;
  94660. /** Gets or sets the custom shader name to use */
  94661. customShaderOptions: ICustomShaderOptions;
  94662. /**
  94663. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  94664. */
  94665. onBeforeShadowMapRenderObservable: Observable<Effect>;
  94666. /**
  94667. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  94668. */
  94669. onAfterShadowMapRenderObservable: Observable<Effect>;
  94670. /**
  94671. * Observable triggered before a mesh is rendered in the shadow map.
  94672. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  94673. */
  94674. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  94675. /**
  94676. * Observable triggered after a mesh is rendered in the shadow map.
  94677. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  94678. */
  94679. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  94680. protected _bias: number;
  94681. /**
  94682. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  94683. */
  94684. get bias(): number;
  94685. /**
  94686. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  94687. */
  94688. set bias(bias: number);
  94689. protected _normalBias: number;
  94690. /**
  94691. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  94692. */
  94693. get normalBias(): number;
  94694. /**
  94695. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  94696. */
  94697. set normalBias(normalBias: number);
  94698. protected _blurBoxOffset: number;
  94699. /**
  94700. * Gets the blur box offset: offset applied during the blur pass.
  94701. * Only useful if useKernelBlur = false
  94702. */
  94703. get blurBoxOffset(): number;
  94704. /**
  94705. * Sets the blur box offset: offset applied during the blur pass.
  94706. * Only useful if useKernelBlur = false
  94707. */
  94708. set blurBoxOffset(value: number);
  94709. protected _blurScale: number;
  94710. /**
  94711. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  94712. * 2 means half of the size.
  94713. */
  94714. get blurScale(): number;
  94715. /**
  94716. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  94717. * 2 means half of the size.
  94718. */
  94719. set blurScale(value: number);
  94720. protected _blurKernel: number;
  94721. /**
  94722. * Gets the blur kernel: kernel size of the blur pass.
  94723. * Only useful if useKernelBlur = true
  94724. */
  94725. get blurKernel(): number;
  94726. /**
  94727. * Sets the blur kernel: kernel size of the blur pass.
  94728. * Only useful if useKernelBlur = true
  94729. */
  94730. set blurKernel(value: number);
  94731. protected _useKernelBlur: boolean;
  94732. /**
  94733. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  94734. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  94735. */
  94736. get useKernelBlur(): boolean;
  94737. /**
  94738. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  94739. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  94740. */
  94741. set useKernelBlur(value: boolean);
  94742. protected _depthScale: number;
  94743. /**
  94744. * Gets the depth scale used in ESM mode.
  94745. */
  94746. get depthScale(): number;
  94747. /**
  94748. * Sets the depth scale used in ESM mode.
  94749. * This can override the scale stored on the light.
  94750. */
  94751. set depthScale(value: number);
  94752. protected _validateFilter(filter: number): number;
  94753. protected _filter: number;
  94754. /**
  94755. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  94756. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  94757. */
  94758. get filter(): number;
  94759. /**
  94760. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  94761. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  94762. */
  94763. set filter(value: number);
  94764. /**
  94765. * Gets if the current filter is set to Poisson Sampling.
  94766. */
  94767. get usePoissonSampling(): boolean;
  94768. /**
  94769. * Sets the current filter to Poisson Sampling.
  94770. */
  94771. set usePoissonSampling(value: boolean);
  94772. /**
  94773. * Gets if the current filter is set to ESM.
  94774. */
  94775. get useExponentialShadowMap(): boolean;
  94776. /**
  94777. * Sets the current filter is to ESM.
  94778. */
  94779. set useExponentialShadowMap(value: boolean);
  94780. /**
  94781. * Gets if the current filter is set to filtered ESM.
  94782. */
  94783. get useBlurExponentialShadowMap(): boolean;
  94784. /**
  94785. * Gets if the current filter is set to filtered ESM.
  94786. */
  94787. set useBlurExponentialShadowMap(value: boolean);
  94788. /**
  94789. * Gets if the current filter is set to "close ESM" (using the inverse of the
  94790. * exponential to prevent steep falloff artifacts).
  94791. */
  94792. get useCloseExponentialShadowMap(): boolean;
  94793. /**
  94794. * Sets the current filter to "close ESM" (using the inverse of the
  94795. * exponential to prevent steep falloff artifacts).
  94796. */
  94797. set useCloseExponentialShadowMap(value: boolean);
  94798. /**
  94799. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  94800. * exponential to prevent steep falloff artifacts).
  94801. */
  94802. get useBlurCloseExponentialShadowMap(): boolean;
  94803. /**
  94804. * Sets the current filter to filtered "close ESM" (using the inverse of the
  94805. * exponential to prevent steep falloff artifacts).
  94806. */
  94807. set useBlurCloseExponentialShadowMap(value: boolean);
  94808. /**
  94809. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  94810. */
  94811. get usePercentageCloserFiltering(): boolean;
  94812. /**
  94813. * Sets the current filter to "PCF" (percentage closer filtering).
  94814. */
  94815. set usePercentageCloserFiltering(value: boolean);
  94816. protected _filteringQuality: number;
  94817. /**
  94818. * Gets the PCF or PCSS Quality.
  94819. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  94820. */
  94821. get filteringQuality(): number;
  94822. /**
  94823. * Sets the PCF or PCSS Quality.
  94824. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  94825. */
  94826. set filteringQuality(filteringQuality: number);
  94827. /**
  94828. * Gets if the current filter is set to "PCSS" (contact hardening).
  94829. */
  94830. get useContactHardeningShadow(): boolean;
  94831. /**
  94832. * Sets the current filter to "PCSS" (contact hardening).
  94833. */
  94834. set useContactHardeningShadow(value: boolean);
  94835. protected _contactHardeningLightSizeUVRatio: number;
  94836. /**
  94837. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  94838. * Using a ratio helps keeping shape stability independently of the map size.
  94839. *
  94840. * It does not account for the light projection as it was having too much
  94841. * instability during the light setup or during light position changes.
  94842. *
  94843. * Only valid if useContactHardeningShadow is true.
  94844. */
  94845. get contactHardeningLightSizeUVRatio(): number;
  94846. /**
  94847. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  94848. * Using a ratio helps keeping shape stability independently of the map size.
  94849. *
  94850. * It does not account for the light projection as it was having too much
  94851. * instability during the light setup or during light position changes.
  94852. *
  94853. * Only valid if useContactHardeningShadow is true.
  94854. */
  94855. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  94856. protected _darkness: number;
  94857. /** Gets or sets the actual darkness of a shadow */
  94858. get darkness(): number;
  94859. set darkness(value: number);
  94860. /**
  94861. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  94862. * 0 means strongest and 1 would means no shadow.
  94863. * @returns the darkness.
  94864. */
  94865. getDarkness(): number;
  94866. /**
  94867. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  94868. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  94869. * @returns the shadow generator allowing fluent coding.
  94870. */
  94871. setDarkness(darkness: number): ShadowGenerator;
  94872. protected _transparencyShadow: boolean;
  94873. /** Gets or sets the ability to have transparent shadow */
  94874. get transparencyShadow(): boolean;
  94875. set transparencyShadow(value: boolean);
  94876. /**
  94877. * Sets the ability to have transparent shadow (boolean).
  94878. * @param transparent True if transparent else False
  94879. * @returns the shadow generator allowing fluent coding
  94880. */
  94881. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  94882. /**
  94883. * Enables or disables shadows with varying strength based on the transparency
  94884. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  94885. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  94886. * mesh.visibility * alphaTexture.a
  94887. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  94888. */
  94889. enableSoftTransparentShadow: boolean;
  94890. protected _shadowMap: Nullable<RenderTargetTexture>;
  94891. protected _shadowMap2: Nullable<RenderTargetTexture>;
  94892. /**
  94893. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  94894. * @returns The render target texture if present otherwise, null
  94895. */
  94896. getShadowMap(): Nullable<RenderTargetTexture>;
  94897. /**
  94898. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  94899. * @returns The render target texture if the shadow map is present otherwise, null
  94900. */
  94901. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  94902. /**
  94903. * Gets the class name of that object
  94904. * @returns "ShadowGenerator"
  94905. */
  94906. getClassName(): string;
  94907. /**
  94908. * Helper function to add a mesh and its descendants to the list of shadow casters.
  94909. * @param mesh Mesh to add
  94910. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  94911. * @returns the Shadow Generator itself
  94912. */
  94913. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  94914. /**
  94915. * Helper function to remove a mesh and its descendants from the list of shadow casters
  94916. * @param mesh Mesh to remove
  94917. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  94918. * @returns the Shadow Generator itself
  94919. */
  94920. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  94921. /**
  94922. * Controls the extent to which the shadows fade out at the edge of the frustum
  94923. */
  94924. frustumEdgeFalloff: number;
  94925. protected _light: IShadowLight;
  94926. /**
  94927. * Returns the associated light object.
  94928. * @returns the light generating the shadow
  94929. */
  94930. getLight(): IShadowLight;
  94931. /**
  94932. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  94933. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  94934. * It might on the other hand introduce peter panning.
  94935. */
  94936. forceBackFacesOnly: boolean;
  94937. protected _scene: Scene;
  94938. protected _lightDirection: Vector3;
  94939. protected _effect: Effect;
  94940. protected _viewMatrix: Matrix;
  94941. protected _projectionMatrix: Matrix;
  94942. protected _transformMatrix: Matrix;
  94943. protected _cachedPosition: Vector3;
  94944. protected _cachedDirection: Vector3;
  94945. protected _cachedDefines: string;
  94946. protected _currentRenderID: number;
  94947. protected _boxBlurPostprocess: Nullable<PostProcess>;
  94948. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  94949. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  94950. protected _blurPostProcesses: PostProcess[];
  94951. protected _mapSize: number;
  94952. protected _currentFaceIndex: number;
  94953. protected _currentFaceIndexCache: number;
  94954. protected _textureType: number;
  94955. protected _defaultTextureMatrix: Matrix;
  94956. protected _storedUniqueId: Nullable<number>;
  94957. /** @hidden */
  94958. static _SceneComponentInitialization: (scene: Scene) => void;
  94959. /**
  94960. * Creates a ShadowGenerator object.
  94961. * A ShadowGenerator is the required tool to use the shadows.
  94962. * Each light casting shadows needs to use its own ShadowGenerator.
  94963. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  94964. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  94965. * @param light The light object generating the shadows.
  94966. * @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.
  94967. */
  94968. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  94969. protected _initializeGenerator(): void;
  94970. protected _createTargetRenderTexture(): void;
  94971. protected _initializeShadowMap(): void;
  94972. protected _initializeBlurRTTAndPostProcesses(): void;
  94973. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  94974. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  94975. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  94976. protected _applyFilterValues(): void;
  94977. /**
  94978. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94979. * @param onCompiled Callback triggered at the and of the effects compilation
  94980. * @param options Sets of optional options forcing the compilation with different modes
  94981. */
  94982. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  94983. useInstances: boolean;
  94984. }>): void;
  94985. /**
  94986. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94987. * @param options Sets of optional options forcing the compilation with different modes
  94988. * @returns A promise that resolves when the compilation completes
  94989. */
  94990. forceCompilationAsync(options?: Partial<{
  94991. useInstances: boolean;
  94992. }>): Promise<void>;
  94993. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  94994. private _prepareShadowDefines;
  94995. /**
  94996. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  94997. * @param subMesh The submesh we want to render in the shadow map
  94998. * @param useInstances Defines wether will draw in the map using instances
  94999. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  95000. * @returns true if ready otherwise, false
  95001. */
  95002. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  95003. /**
  95004. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  95005. * @param defines Defines of the material we want to update
  95006. * @param lightIndex Index of the light in the enabled light list of the material
  95007. */
  95008. prepareDefines(defines: any, lightIndex: number): void;
  95009. /**
  95010. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  95011. * defined in the generator but impacting the effect).
  95012. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  95013. * @param effect The effect we are binfing the information for
  95014. */
  95015. bindShadowLight(lightIndex: string, effect: Effect): void;
  95016. /**
  95017. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  95018. * (eq to shadow prjection matrix * light transform matrix)
  95019. * @returns The transform matrix used to create the shadow map
  95020. */
  95021. getTransformMatrix(): Matrix;
  95022. /**
  95023. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  95024. * Cube and 2D textures for instance.
  95025. */
  95026. recreateShadowMap(): void;
  95027. protected _disposeBlurPostProcesses(): void;
  95028. protected _disposeRTTandPostProcesses(): void;
  95029. /**
  95030. * Disposes the ShadowGenerator.
  95031. * Returns nothing.
  95032. */
  95033. dispose(): void;
  95034. /**
  95035. * Serializes the shadow generator setup to a json object.
  95036. * @returns The serialized JSON object
  95037. */
  95038. serialize(): any;
  95039. /**
  95040. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  95041. * @param parsedShadowGenerator The JSON object to parse
  95042. * @param scene The scene to create the shadow map for
  95043. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  95044. * @returns The parsed shadow generator
  95045. */
  95046. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  95047. }
  95048. }
  95049. declare module BABYLON {
  95050. /**
  95051. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  95052. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  95053. * 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.
  95054. */
  95055. export abstract class Light extends Node {
  95056. /**
  95057. * Falloff Default: light is falling off following the material specification:
  95058. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  95059. */
  95060. static readonly FALLOFF_DEFAULT: number;
  95061. /**
  95062. * Falloff Physical: light is falling off following the inverse squared distance law.
  95063. */
  95064. static readonly FALLOFF_PHYSICAL: number;
  95065. /**
  95066. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  95067. * to enhance interoperability with other engines.
  95068. */
  95069. static readonly FALLOFF_GLTF: number;
  95070. /**
  95071. * Falloff Standard: light is falling off like in the standard material
  95072. * to enhance interoperability with other materials.
  95073. */
  95074. static readonly FALLOFF_STANDARD: number;
  95075. /**
  95076. * If every light affecting the material is in this lightmapMode,
  95077. * material.lightmapTexture adds or multiplies
  95078. * (depends on material.useLightmapAsShadowmap)
  95079. * after every other light calculations.
  95080. */
  95081. static readonly LIGHTMAP_DEFAULT: number;
  95082. /**
  95083. * material.lightmapTexture as only diffuse lighting from this light
  95084. * adds only specular lighting from this light
  95085. * adds dynamic shadows
  95086. */
  95087. static readonly LIGHTMAP_SPECULAR: number;
  95088. /**
  95089. * material.lightmapTexture as only lighting
  95090. * no light calculation from this light
  95091. * only adds dynamic shadows from this light
  95092. */
  95093. static readonly LIGHTMAP_SHADOWSONLY: number;
  95094. /**
  95095. * Each light type uses the default quantity according to its type:
  95096. * point/spot lights use luminous intensity
  95097. * directional lights use illuminance
  95098. */
  95099. static readonly INTENSITYMODE_AUTOMATIC: number;
  95100. /**
  95101. * lumen (lm)
  95102. */
  95103. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  95104. /**
  95105. * candela (lm/sr)
  95106. */
  95107. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  95108. /**
  95109. * lux (lm/m^2)
  95110. */
  95111. static readonly INTENSITYMODE_ILLUMINANCE: number;
  95112. /**
  95113. * nit (cd/m^2)
  95114. */
  95115. static readonly INTENSITYMODE_LUMINANCE: number;
  95116. /**
  95117. * Light type const id of the point light.
  95118. */
  95119. static readonly LIGHTTYPEID_POINTLIGHT: number;
  95120. /**
  95121. * Light type const id of the directional light.
  95122. */
  95123. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  95124. /**
  95125. * Light type const id of the spot light.
  95126. */
  95127. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  95128. /**
  95129. * Light type const id of the hemispheric light.
  95130. */
  95131. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  95132. /**
  95133. * Diffuse gives the basic color to an object.
  95134. */
  95135. diffuse: Color3;
  95136. /**
  95137. * Specular produces a highlight color on an object.
  95138. * Note: This is note affecting PBR materials.
  95139. */
  95140. specular: Color3;
  95141. /**
  95142. * Defines the falloff type for this light. This lets overrriding how punctual light are
  95143. * falling off base on range or angle.
  95144. * This can be set to any values in Light.FALLOFF_x.
  95145. *
  95146. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  95147. * other types of materials.
  95148. */
  95149. falloffType: number;
  95150. /**
  95151. * Strength of the light.
  95152. * Note: By default it is define in the framework own unit.
  95153. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  95154. */
  95155. intensity: number;
  95156. private _range;
  95157. protected _inverseSquaredRange: number;
  95158. /**
  95159. * Defines how far from the source the light is impacting in scene units.
  95160. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  95161. */
  95162. get range(): number;
  95163. /**
  95164. * Defines how far from the source the light is impacting in scene units.
  95165. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  95166. */
  95167. set range(value: number);
  95168. /**
  95169. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  95170. * of light.
  95171. */
  95172. private _photometricScale;
  95173. private _intensityMode;
  95174. /**
  95175. * Gets the photometric scale used to interpret the intensity.
  95176. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  95177. */
  95178. get intensityMode(): number;
  95179. /**
  95180. * Sets the photometric scale used to interpret the intensity.
  95181. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  95182. */
  95183. set intensityMode(value: number);
  95184. private _radius;
  95185. /**
  95186. * Gets the light radius used by PBR Materials to simulate soft area lights.
  95187. */
  95188. get radius(): number;
  95189. /**
  95190. * sets the light radius used by PBR Materials to simulate soft area lights.
  95191. */
  95192. set radius(value: number);
  95193. private _renderPriority;
  95194. /**
  95195. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  95196. * exceeding the number allowed of the materials.
  95197. */
  95198. renderPriority: number;
  95199. private _shadowEnabled;
  95200. /**
  95201. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  95202. * the current shadow generator.
  95203. */
  95204. get shadowEnabled(): boolean;
  95205. /**
  95206. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  95207. * the current shadow generator.
  95208. */
  95209. set shadowEnabled(value: boolean);
  95210. private _includedOnlyMeshes;
  95211. /**
  95212. * Gets the only meshes impacted by this light.
  95213. */
  95214. get includedOnlyMeshes(): AbstractMesh[];
  95215. /**
  95216. * Sets the only meshes impacted by this light.
  95217. */
  95218. set includedOnlyMeshes(value: AbstractMesh[]);
  95219. private _excludedMeshes;
  95220. /**
  95221. * Gets the meshes not impacted by this light.
  95222. */
  95223. get excludedMeshes(): AbstractMesh[];
  95224. /**
  95225. * Sets the meshes not impacted by this light.
  95226. */
  95227. set excludedMeshes(value: AbstractMesh[]);
  95228. private _excludeWithLayerMask;
  95229. /**
  95230. * Gets the layer id use to find what meshes are not impacted by the light.
  95231. * Inactive if 0
  95232. */
  95233. get excludeWithLayerMask(): number;
  95234. /**
  95235. * Sets the layer id use to find what meshes are not impacted by the light.
  95236. * Inactive if 0
  95237. */
  95238. set excludeWithLayerMask(value: number);
  95239. private _includeOnlyWithLayerMask;
  95240. /**
  95241. * Gets the layer id use to find what meshes are impacted by the light.
  95242. * Inactive if 0
  95243. */
  95244. get includeOnlyWithLayerMask(): number;
  95245. /**
  95246. * Sets the layer id use to find what meshes are impacted by the light.
  95247. * Inactive if 0
  95248. */
  95249. set includeOnlyWithLayerMask(value: number);
  95250. private _lightmapMode;
  95251. /**
  95252. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  95253. */
  95254. get lightmapMode(): number;
  95255. /**
  95256. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  95257. */
  95258. set lightmapMode(value: number);
  95259. /**
  95260. * Shadow generator associted to the light.
  95261. * @hidden Internal use only.
  95262. */
  95263. _shadowGenerator: Nullable<IShadowGenerator>;
  95264. /**
  95265. * @hidden Internal use only.
  95266. */
  95267. _excludedMeshesIds: string[];
  95268. /**
  95269. * @hidden Internal use only.
  95270. */
  95271. _includedOnlyMeshesIds: string[];
  95272. /**
  95273. * The current light unifom buffer.
  95274. * @hidden Internal use only.
  95275. */
  95276. _uniformBuffer: UniformBuffer;
  95277. /** @hidden */
  95278. _renderId: number;
  95279. /**
  95280. * Creates a Light object in the scene.
  95281. * Documentation : https://doc.babylonjs.com/babylon101/lights
  95282. * @param name The firendly name of the light
  95283. * @param scene The scene the light belongs too
  95284. */
  95285. constructor(name: string, scene: Scene);
  95286. protected abstract _buildUniformLayout(): void;
  95287. /**
  95288. * Sets the passed Effect "effect" with the Light information.
  95289. * @param effect The effect to update
  95290. * @param lightIndex The index of the light in the effect to update
  95291. * @returns The light
  95292. */
  95293. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  95294. /**
  95295. * Sets the passed Effect "effect" with the Light textures.
  95296. * @param effect The effect to update
  95297. * @param lightIndex The index of the light in the effect to update
  95298. * @returns The light
  95299. */
  95300. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  95301. /**
  95302. * Binds the lights information from the scene to the effect for the given mesh.
  95303. * @param lightIndex Light index
  95304. * @param scene The scene where the light belongs to
  95305. * @param effect The effect we are binding the data to
  95306. * @param useSpecular Defines if specular is supported
  95307. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  95308. */
  95309. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  95310. /**
  95311. * Sets the passed Effect "effect" with the Light information.
  95312. * @param effect The effect to update
  95313. * @param lightDataUniformName The uniform used to store light data (position or direction)
  95314. * @returns The light
  95315. */
  95316. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  95317. /**
  95318. * Returns the string "Light".
  95319. * @returns the class name
  95320. */
  95321. getClassName(): string;
  95322. /** @hidden */
  95323. readonly _isLight: boolean;
  95324. /**
  95325. * Converts the light information to a readable string for debug purpose.
  95326. * @param fullDetails Supports for multiple levels of logging within scene loading
  95327. * @returns the human readable light info
  95328. */
  95329. toString(fullDetails?: boolean): string;
  95330. /** @hidden */
  95331. protected _syncParentEnabledState(): void;
  95332. /**
  95333. * Set the enabled state of this node.
  95334. * @param value - the new enabled state
  95335. */
  95336. setEnabled(value: boolean): void;
  95337. /**
  95338. * Returns the Light associated shadow generator if any.
  95339. * @return the associated shadow generator.
  95340. */
  95341. getShadowGenerator(): Nullable<IShadowGenerator>;
  95342. /**
  95343. * Returns a Vector3, the absolute light position in the World.
  95344. * @returns the world space position of the light
  95345. */
  95346. getAbsolutePosition(): Vector3;
  95347. /**
  95348. * Specifies if the light will affect the passed mesh.
  95349. * @param mesh The mesh to test against the light
  95350. * @return true the mesh is affected otherwise, false.
  95351. */
  95352. canAffectMesh(mesh: AbstractMesh): boolean;
  95353. /**
  95354. * Sort function to order lights for rendering.
  95355. * @param a First Light object to compare to second.
  95356. * @param b Second Light object to compare first.
  95357. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  95358. */
  95359. static CompareLightsPriority(a: Light, b: Light): number;
  95360. /**
  95361. * Releases resources associated with this node.
  95362. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95363. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95364. */
  95365. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95366. /**
  95367. * Returns the light type ID (integer).
  95368. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  95369. */
  95370. getTypeID(): number;
  95371. /**
  95372. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  95373. * @returns the scaled intensity in intensity mode unit
  95374. */
  95375. getScaledIntensity(): number;
  95376. /**
  95377. * Returns a new Light object, named "name", from the current one.
  95378. * @param name The name of the cloned light
  95379. * @param newParent The parent of this light, if it has one
  95380. * @returns the new created light
  95381. */
  95382. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  95383. /**
  95384. * Serializes the current light into a Serialization object.
  95385. * @returns the serialized object.
  95386. */
  95387. serialize(): any;
  95388. /**
  95389. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  95390. * This new light is named "name" and added to the passed scene.
  95391. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  95392. * @param name The friendly name of the light
  95393. * @param scene The scene the new light will belong to
  95394. * @returns the constructor function
  95395. */
  95396. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  95397. /**
  95398. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  95399. * @param parsedLight The JSON representation of the light
  95400. * @param scene The scene to create the parsed light in
  95401. * @returns the created light after parsing
  95402. */
  95403. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  95404. private _hookArrayForExcluded;
  95405. private _hookArrayForIncludedOnly;
  95406. private _resyncMeshes;
  95407. /**
  95408. * Forces the meshes to update their light related information in their rendering used effects
  95409. * @hidden Internal Use Only
  95410. */
  95411. _markMeshesAsLightDirty(): void;
  95412. /**
  95413. * Recomputes the cached photometric scale if needed.
  95414. */
  95415. private _computePhotometricScale;
  95416. /**
  95417. * Returns the Photometric Scale according to the light type and intensity mode.
  95418. */
  95419. private _getPhotometricScale;
  95420. /**
  95421. * Reorder the light in the scene according to their defined priority.
  95422. * @hidden Internal Use Only
  95423. */
  95424. _reorderLightsInScene(): void;
  95425. /**
  95426. * Prepares the list of defines specific to the light type.
  95427. * @param defines the list of defines
  95428. * @param lightIndex defines the index of the light for the effect
  95429. */
  95430. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  95431. }
  95432. }
  95433. declare module BABYLON {
  95434. /**
  95435. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  95436. * This is the base of the follow, arc rotate cameras and Free camera
  95437. * @see http://doc.babylonjs.com/features/cameras
  95438. */
  95439. export class TargetCamera extends Camera {
  95440. private static _RigCamTransformMatrix;
  95441. private static _TargetTransformMatrix;
  95442. private static _TargetFocalPoint;
  95443. /**
  95444. * Define the current direction the camera is moving to
  95445. */
  95446. cameraDirection: Vector3;
  95447. /**
  95448. * Define the current rotation the camera is rotating to
  95449. */
  95450. cameraRotation: Vector2;
  95451. /**
  95452. * When set, the up vector of the camera will be updated by the rotation of the camera
  95453. */
  95454. updateUpVectorFromRotation: boolean;
  95455. private _tmpQuaternion;
  95456. /**
  95457. * Define the current rotation of the camera
  95458. */
  95459. rotation: Vector3;
  95460. /**
  95461. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  95462. */
  95463. rotationQuaternion: Quaternion;
  95464. /**
  95465. * Define the current speed of the camera
  95466. */
  95467. speed: number;
  95468. /**
  95469. * Add constraint to the camera to prevent it to move freely in all directions and
  95470. * around all axis.
  95471. */
  95472. noRotationConstraint: boolean;
  95473. /**
  95474. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  95475. * panning
  95476. */
  95477. invertRotation: boolean;
  95478. /**
  95479. * Speed multiplier for inverse camera panning
  95480. */
  95481. inverseRotationSpeed: number;
  95482. /**
  95483. * Define the current target of the camera as an object or a position.
  95484. */
  95485. lockedTarget: any;
  95486. /** @hidden */
  95487. _currentTarget: Vector3;
  95488. /** @hidden */
  95489. _initialFocalDistance: number;
  95490. /** @hidden */
  95491. _viewMatrix: Matrix;
  95492. /** @hidden */
  95493. _camMatrix: Matrix;
  95494. /** @hidden */
  95495. _cameraTransformMatrix: Matrix;
  95496. /** @hidden */
  95497. _cameraRotationMatrix: Matrix;
  95498. /** @hidden */
  95499. _referencePoint: Vector3;
  95500. /** @hidden */
  95501. _transformedReferencePoint: Vector3;
  95502. protected _globalCurrentTarget: Vector3;
  95503. protected _globalCurrentUpVector: Vector3;
  95504. /** @hidden */
  95505. _reset: () => void;
  95506. private _defaultUp;
  95507. /**
  95508. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  95509. * This is the base of the follow, arc rotate cameras and Free camera
  95510. * @see http://doc.babylonjs.com/features/cameras
  95511. * @param name Defines the name of the camera in the scene
  95512. * @param position Defines the start position of the camera in the scene
  95513. * @param scene Defines the scene the camera belongs to
  95514. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  95515. */
  95516. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95517. /**
  95518. * Gets the position in front of the camera at a given distance.
  95519. * @param distance The distance from the camera we want the position to be
  95520. * @returns the position
  95521. */
  95522. getFrontPosition(distance: number): Vector3;
  95523. /** @hidden */
  95524. _getLockedTargetPosition(): Nullable<Vector3>;
  95525. private _storedPosition;
  95526. private _storedRotation;
  95527. private _storedRotationQuaternion;
  95528. /**
  95529. * Store current camera state of the camera (fov, position, rotation, etc..)
  95530. * @returns the camera
  95531. */
  95532. storeState(): Camera;
  95533. /**
  95534. * Restored camera state. You must call storeState() first
  95535. * @returns whether it was successful or not
  95536. * @hidden
  95537. */
  95538. _restoreStateValues(): boolean;
  95539. /** @hidden */
  95540. _initCache(): void;
  95541. /** @hidden */
  95542. _updateCache(ignoreParentClass?: boolean): void;
  95543. /** @hidden */
  95544. _isSynchronizedViewMatrix(): boolean;
  95545. /** @hidden */
  95546. _computeLocalCameraSpeed(): number;
  95547. /**
  95548. * Defines the target the camera should look at.
  95549. * @param target Defines the new target as a Vector or a mesh
  95550. */
  95551. setTarget(target: Vector3): void;
  95552. /**
  95553. * Return the current target position of the camera. This value is expressed in local space.
  95554. * @returns the target position
  95555. */
  95556. getTarget(): Vector3;
  95557. /** @hidden */
  95558. _decideIfNeedsToMove(): boolean;
  95559. /** @hidden */
  95560. _updatePosition(): void;
  95561. /** @hidden */
  95562. _checkInputs(): void;
  95563. protected _updateCameraRotationMatrix(): void;
  95564. /**
  95565. * 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)
  95566. * @returns the current camera
  95567. */
  95568. private _rotateUpVectorWithCameraRotationMatrix;
  95569. private _cachedRotationZ;
  95570. private _cachedQuaternionRotationZ;
  95571. /** @hidden */
  95572. _getViewMatrix(): Matrix;
  95573. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  95574. /**
  95575. * @hidden
  95576. */
  95577. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  95578. /**
  95579. * @hidden
  95580. */
  95581. _updateRigCameras(): void;
  95582. private _getRigCamPositionAndTarget;
  95583. /**
  95584. * Gets the current object class name.
  95585. * @return the class name
  95586. */
  95587. getClassName(): string;
  95588. }
  95589. }
  95590. declare module BABYLON {
  95591. /**
  95592. * Gather the list of keyboard event types as constants.
  95593. */
  95594. export class KeyboardEventTypes {
  95595. /**
  95596. * The keydown event is fired when a key becomes active (pressed).
  95597. */
  95598. static readonly KEYDOWN: number;
  95599. /**
  95600. * The keyup event is fired when a key has been released.
  95601. */
  95602. static readonly KEYUP: number;
  95603. }
  95604. /**
  95605. * This class is used to store keyboard related info for the onKeyboardObservable event.
  95606. */
  95607. export class KeyboardInfo {
  95608. /**
  95609. * Defines the type of event (KeyboardEventTypes)
  95610. */
  95611. type: number;
  95612. /**
  95613. * Defines the related dom event
  95614. */
  95615. event: KeyboardEvent;
  95616. /**
  95617. * Instantiates a new keyboard info.
  95618. * This class is used to store keyboard related info for the onKeyboardObservable event.
  95619. * @param type Defines the type of event (KeyboardEventTypes)
  95620. * @param event Defines the related dom event
  95621. */
  95622. constructor(
  95623. /**
  95624. * Defines the type of event (KeyboardEventTypes)
  95625. */
  95626. type: number,
  95627. /**
  95628. * Defines the related dom event
  95629. */
  95630. event: KeyboardEvent);
  95631. }
  95632. /**
  95633. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  95634. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  95635. */
  95636. export class KeyboardInfoPre extends KeyboardInfo {
  95637. /**
  95638. * Defines the type of event (KeyboardEventTypes)
  95639. */
  95640. type: number;
  95641. /**
  95642. * Defines the related dom event
  95643. */
  95644. event: KeyboardEvent;
  95645. /**
  95646. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  95647. */
  95648. skipOnPointerObservable: boolean;
  95649. /**
  95650. * Instantiates a new keyboard pre info.
  95651. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  95652. * @param type Defines the type of event (KeyboardEventTypes)
  95653. * @param event Defines the related dom event
  95654. */
  95655. constructor(
  95656. /**
  95657. * Defines the type of event (KeyboardEventTypes)
  95658. */
  95659. type: number,
  95660. /**
  95661. * Defines the related dom event
  95662. */
  95663. event: KeyboardEvent);
  95664. }
  95665. }
  95666. declare module BABYLON {
  95667. /**
  95668. * Manage the keyboard inputs to control the movement of a free camera.
  95669. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95670. */
  95671. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  95672. /**
  95673. * Defines the camera the input is attached to.
  95674. */
  95675. camera: FreeCamera;
  95676. /**
  95677. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  95678. */
  95679. keysUp: number[];
  95680. /**
  95681. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  95682. */
  95683. keysUpward: number[];
  95684. /**
  95685. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  95686. */
  95687. keysDown: number[];
  95688. /**
  95689. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  95690. */
  95691. keysDownward: number[];
  95692. /**
  95693. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  95694. */
  95695. keysLeft: number[];
  95696. /**
  95697. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  95698. */
  95699. keysRight: number[];
  95700. private _keys;
  95701. private _onCanvasBlurObserver;
  95702. private _onKeyboardObserver;
  95703. private _engine;
  95704. private _scene;
  95705. /**
  95706. * Attach the input controls to a specific dom element to get the input from.
  95707. * @param element Defines the element the controls should be listened from
  95708. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95709. */
  95710. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95711. /**
  95712. * Detach the current controls from the specified dom element.
  95713. * @param element Defines the element to stop listening the inputs from
  95714. */
  95715. detachControl(element: Nullable<HTMLElement>): void;
  95716. /**
  95717. * Update the current camera state depending on the inputs that have been used this frame.
  95718. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95719. */
  95720. checkInputs(): void;
  95721. /**
  95722. * Gets the class name of the current intput.
  95723. * @returns the class name
  95724. */
  95725. getClassName(): string;
  95726. /** @hidden */
  95727. _onLostFocus(): void;
  95728. /**
  95729. * Get the friendly name associated with the input class.
  95730. * @returns the input friendly name
  95731. */
  95732. getSimpleName(): string;
  95733. }
  95734. }
  95735. declare module BABYLON {
  95736. /**
  95737. * Gather the list of pointer event types as constants.
  95738. */
  95739. export class PointerEventTypes {
  95740. /**
  95741. * 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.
  95742. */
  95743. static readonly POINTERDOWN: number;
  95744. /**
  95745. * The pointerup event is fired when a pointer is no longer active.
  95746. */
  95747. static readonly POINTERUP: number;
  95748. /**
  95749. * The pointermove event is fired when a pointer changes coordinates.
  95750. */
  95751. static readonly POINTERMOVE: number;
  95752. /**
  95753. * The pointerwheel event is fired when a mouse wheel has been rotated.
  95754. */
  95755. static readonly POINTERWHEEL: number;
  95756. /**
  95757. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  95758. */
  95759. static readonly POINTERPICK: number;
  95760. /**
  95761. * The pointertap event is fired when a the object has been touched and released without drag.
  95762. */
  95763. static readonly POINTERTAP: number;
  95764. /**
  95765. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  95766. */
  95767. static readonly POINTERDOUBLETAP: number;
  95768. }
  95769. /**
  95770. * Base class of pointer info types.
  95771. */
  95772. export class PointerInfoBase {
  95773. /**
  95774. * Defines the type of event (PointerEventTypes)
  95775. */
  95776. type: number;
  95777. /**
  95778. * Defines the related dom event
  95779. */
  95780. event: PointerEvent | MouseWheelEvent;
  95781. /**
  95782. * Instantiates the base class of pointers info.
  95783. * @param type Defines the type of event (PointerEventTypes)
  95784. * @param event Defines the related dom event
  95785. */
  95786. constructor(
  95787. /**
  95788. * Defines the type of event (PointerEventTypes)
  95789. */
  95790. type: number,
  95791. /**
  95792. * Defines the related dom event
  95793. */
  95794. event: PointerEvent | MouseWheelEvent);
  95795. }
  95796. /**
  95797. * This class is used to store pointer related info for the onPrePointerObservable event.
  95798. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  95799. */
  95800. export class PointerInfoPre extends PointerInfoBase {
  95801. /**
  95802. * Ray from a pointer if availible (eg. 6dof controller)
  95803. */
  95804. ray: Nullable<Ray>;
  95805. /**
  95806. * Defines the local position of the pointer on the canvas.
  95807. */
  95808. localPosition: Vector2;
  95809. /**
  95810. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  95811. */
  95812. skipOnPointerObservable: boolean;
  95813. /**
  95814. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  95815. * @param type Defines the type of event (PointerEventTypes)
  95816. * @param event Defines the related dom event
  95817. * @param localX Defines the local x coordinates of the pointer when the event occured
  95818. * @param localY Defines the local y coordinates of the pointer when the event occured
  95819. */
  95820. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  95821. }
  95822. /**
  95823. * This type contains all the data related to a pointer event in Babylon.js.
  95824. * 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.
  95825. */
  95826. export class PointerInfo extends PointerInfoBase {
  95827. /**
  95828. * Defines the picking info associated to the info (if any)\
  95829. */
  95830. pickInfo: Nullable<PickingInfo>;
  95831. /**
  95832. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  95833. * @param type Defines the type of event (PointerEventTypes)
  95834. * @param event Defines the related dom event
  95835. * @param pickInfo Defines the picking info associated to the info (if any)\
  95836. */
  95837. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  95838. /**
  95839. * Defines the picking info associated to the info (if any)\
  95840. */
  95841. pickInfo: Nullable<PickingInfo>);
  95842. }
  95843. /**
  95844. * Data relating to a touch event on the screen.
  95845. */
  95846. export interface PointerTouch {
  95847. /**
  95848. * X coordinate of touch.
  95849. */
  95850. x: number;
  95851. /**
  95852. * Y coordinate of touch.
  95853. */
  95854. y: number;
  95855. /**
  95856. * Id of touch. Unique for each finger.
  95857. */
  95858. pointerId: number;
  95859. /**
  95860. * Event type passed from DOM.
  95861. */
  95862. type: any;
  95863. }
  95864. }
  95865. declare module BABYLON {
  95866. /**
  95867. * Manage the mouse inputs to control the movement of a free camera.
  95868. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95869. */
  95870. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  95871. /**
  95872. * Define if touch is enabled in the mouse input
  95873. */
  95874. touchEnabled: boolean;
  95875. /**
  95876. * Defines the camera the input is attached to.
  95877. */
  95878. camera: FreeCamera;
  95879. /**
  95880. * Defines the buttons associated with the input to handle camera move.
  95881. */
  95882. buttons: number[];
  95883. /**
  95884. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  95885. */
  95886. angularSensibility: number;
  95887. private _pointerInput;
  95888. private _onMouseMove;
  95889. private _observer;
  95890. private previousPosition;
  95891. /**
  95892. * Observable for when a pointer move event occurs containing the move offset
  95893. */
  95894. onPointerMovedObservable: Observable<{
  95895. offsetX: number;
  95896. offsetY: number;
  95897. }>;
  95898. /**
  95899. * @hidden
  95900. * If the camera should be rotated automatically based on pointer movement
  95901. */
  95902. _allowCameraRotation: boolean;
  95903. /**
  95904. * Manage the mouse inputs to control the movement of a free camera.
  95905. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95906. * @param touchEnabled Defines if touch is enabled or not
  95907. */
  95908. constructor(
  95909. /**
  95910. * Define if touch is enabled in the mouse input
  95911. */
  95912. touchEnabled?: boolean);
  95913. /**
  95914. * Attach the input controls to a specific dom element to get the input from.
  95915. * @param element Defines the element the controls should be listened from
  95916. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95917. */
  95918. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95919. /**
  95920. * Called on JS contextmenu event.
  95921. * Override this method to provide functionality.
  95922. */
  95923. protected onContextMenu(evt: PointerEvent): void;
  95924. /**
  95925. * Detach the current controls from the specified dom element.
  95926. * @param element Defines the element to stop listening the inputs from
  95927. */
  95928. detachControl(element: Nullable<HTMLElement>): void;
  95929. /**
  95930. * Gets the class name of the current intput.
  95931. * @returns the class name
  95932. */
  95933. getClassName(): string;
  95934. /**
  95935. * Get the friendly name associated with the input class.
  95936. * @returns the input friendly name
  95937. */
  95938. getSimpleName(): string;
  95939. }
  95940. }
  95941. declare module BABYLON {
  95942. /**
  95943. * Manage the touch inputs to control the movement of a free camera.
  95944. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95945. */
  95946. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  95947. /**
  95948. * Defines the camera the input is attached to.
  95949. */
  95950. camera: FreeCamera;
  95951. /**
  95952. * Defines the touch sensibility for rotation.
  95953. * The higher the faster.
  95954. */
  95955. touchAngularSensibility: number;
  95956. /**
  95957. * Defines the touch sensibility for move.
  95958. * The higher the faster.
  95959. */
  95960. touchMoveSensibility: number;
  95961. private _offsetX;
  95962. private _offsetY;
  95963. private _pointerPressed;
  95964. private _pointerInput;
  95965. private _observer;
  95966. private _onLostFocus;
  95967. /**
  95968. * Attach the input controls to a specific dom element to get the input from.
  95969. * @param element Defines the element the controls should be listened from
  95970. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95971. */
  95972. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95973. /**
  95974. * Detach the current controls from the specified dom element.
  95975. * @param element Defines the element to stop listening the inputs from
  95976. */
  95977. detachControl(element: Nullable<HTMLElement>): void;
  95978. /**
  95979. * Update the current camera state depending on the inputs that have been used this frame.
  95980. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95981. */
  95982. checkInputs(): void;
  95983. /**
  95984. * Gets the class name of the current intput.
  95985. * @returns the class name
  95986. */
  95987. getClassName(): string;
  95988. /**
  95989. * Get the friendly name associated with the input class.
  95990. * @returns the input friendly name
  95991. */
  95992. getSimpleName(): string;
  95993. }
  95994. }
  95995. declare module BABYLON {
  95996. /**
  95997. * Default Inputs manager for the FreeCamera.
  95998. * It groups all the default supported inputs for ease of use.
  95999. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96000. */
  96001. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  96002. /**
  96003. * @hidden
  96004. */
  96005. _mouseInput: Nullable<FreeCameraMouseInput>;
  96006. /**
  96007. * Instantiates a new FreeCameraInputsManager.
  96008. * @param camera Defines the camera the inputs belong to
  96009. */
  96010. constructor(camera: FreeCamera);
  96011. /**
  96012. * Add keyboard input support to the input manager.
  96013. * @returns the current input manager
  96014. */
  96015. addKeyboard(): FreeCameraInputsManager;
  96016. /**
  96017. * Add mouse input support to the input manager.
  96018. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  96019. * @returns the current input manager
  96020. */
  96021. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  96022. /**
  96023. * Removes the mouse input support from the manager
  96024. * @returns the current input manager
  96025. */
  96026. removeMouse(): FreeCameraInputsManager;
  96027. /**
  96028. * Add touch input support to the input manager.
  96029. * @returns the current input manager
  96030. */
  96031. addTouch(): FreeCameraInputsManager;
  96032. /**
  96033. * Remove all attached input methods from a camera
  96034. */
  96035. clear(): void;
  96036. }
  96037. }
  96038. declare module BABYLON {
  96039. /**
  96040. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96041. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  96042. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96043. */
  96044. export class FreeCamera extends TargetCamera {
  96045. /**
  96046. * Define the collision ellipsoid of the camera.
  96047. * This is helpful to simulate a camera body like the player body around the camera
  96048. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  96049. */
  96050. ellipsoid: Vector3;
  96051. /**
  96052. * Define an offset for the position of the ellipsoid around the camera.
  96053. * This can be helpful to determine the center of the body near the gravity center of the body
  96054. * instead of its head.
  96055. */
  96056. ellipsoidOffset: Vector3;
  96057. /**
  96058. * Enable or disable collisions of the camera with the rest of the scene objects.
  96059. */
  96060. checkCollisions: boolean;
  96061. /**
  96062. * Enable or disable gravity on the camera.
  96063. */
  96064. applyGravity: boolean;
  96065. /**
  96066. * Define the input manager associated to the camera.
  96067. */
  96068. inputs: FreeCameraInputsManager;
  96069. /**
  96070. * Gets the input sensibility for a mouse input. (default is 2000.0)
  96071. * Higher values reduce sensitivity.
  96072. */
  96073. get angularSensibility(): number;
  96074. /**
  96075. * Sets the input sensibility for a mouse input. (default is 2000.0)
  96076. * Higher values reduce sensitivity.
  96077. */
  96078. set angularSensibility(value: number);
  96079. /**
  96080. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  96081. */
  96082. get keysUp(): number[];
  96083. set keysUp(value: number[]);
  96084. /**
  96085. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  96086. */
  96087. get keysUpward(): number[];
  96088. set keysUpward(value: number[]);
  96089. /**
  96090. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  96091. */
  96092. get keysDown(): number[];
  96093. set keysDown(value: number[]);
  96094. /**
  96095. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  96096. */
  96097. get keysDownward(): number[];
  96098. set keysDownward(value: number[]);
  96099. /**
  96100. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  96101. */
  96102. get keysLeft(): number[];
  96103. set keysLeft(value: number[]);
  96104. /**
  96105. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  96106. */
  96107. get keysRight(): number[];
  96108. set keysRight(value: number[]);
  96109. /**
  96110. * Event raised when the camera collide with a mesh in the scene.
  96111. */
  96112. onCollide: (collidedMesh: AbstractMesh) => void;
  96113. private _collider;
  96114. private _needMoveForGravity;
  96115. private _oldPosition;
  96116. private _diffPosition;
  96117. private _newPosition;
  96118. /** @hidden */
  96119. _localDirection: Vector3;
  96120. /** @hidden */
  96121. _transformedDirection: Vector3;
  96122. /**
  96123. * Instantiates a Free Camera.
  96124. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96125. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  96126. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96127. * @param name Define the name of the camera in the scene
  96128. * @param position Define the start position of the camera in the scene
  96129. * @param scene Define the scene the camera belongs to
  96130. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  96131. */
  96132. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96133. /**
  96134. * Attached controls to the current camera.
  96135. * @param element Defines the element the controls should be listened from
  96136. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96137. */
  96138. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96139. /**
  96140. * Detach the current controls from the camera.
  96141. * The camera will stop reacting to inputs.
  96142. * @param element Defines the element to stop listening the inputs from
  96143. */
  96144. detachControl(element: HTMLElement): void;
  96145. private _collisionMask;
  96146. /**
  96147. * Define a collision mask to limit the list of object the camera can collide with
  96148. */
  96149. get collisionMask(): number;
  96150. set collisionMask(mask: number);
  96151. /** @hidden */
  96152. _collideWithWorld(displacement: Vector3): void;
  96153. private _onCollisionPositionChange;
  96154. /** @hidden */
  96155. _checkInputs(): void;
  96156. /** @hidden */
  96157. _decideIfNeedsToMove(): boolean;
  96158. /** @hidden */
  96159. _updatePosition(): void;
  96160. /**
  96161. * Destroy the camera and release the current resources hold by it.
  96162. */
  96163. dispose(): void;
  96164. /**
  96165. * Gets the current object class name.
  96166. * @return the class name
  96167. */
  96168. getClassName(): string;
  96169. }
  96170. }
  96171. declare module BABYLON {
  96172. /**
  96173. * Represents a gamepad control stick position
  96174. */
  96175. export class StickValues {
  96176. /**
  96177. * The x component of the control stick
  96178. */
  96179. x: number;
  96180. /**
  96181. * The y component of the control stick
  96182. */
  96183. y: number;
  96184. /**
  96185. * Initializes the gamepad x and y control stick values
  96186. * @param x The x component of the gamepad control stick value
  96187. * @param y The y component of the gamepad control stick value
  96188. */
  96189. constructor(
  96190. /**
  96191. * The x component of the control stick
  96192. */
  96193. x: number,
  96194. /**
  96195. * The y component of the control stick
  96196. */
  96197. y: number);
  96198. }
  96199. /**
  96200. * An interface which manages callbacks for gamepad button changes
  96201. */
  96202. export interface GamepadButtonChanges {
  96203. /**
  96204. * Called when a gamepad has been changed
  96205. */
  96206. changed: boolean;
  96207. /**
  96208. * Called when a gamepad press event has been triggered
  96209. */
  96210. pressChanged: boolean;
  96211. /**
  96212. * Called when a touch event has been triggered
  96213. */
  96214. touchChanged: boolean;
  96215. /**
  96216. * Called when a value has changed
  96217. */
  96218. valueChanged: boolean;
  96219. }
  96220. /**
  96221. * Represents a gamepad
  96222. */
  96223. export class Gamepad {
  96224. /**
  96225. * The id of the gamepad
  96226. */
  96227. id: string;
  96228. /**
  96229. * The index of the gamepad
  96230. */
  96231. index: number;
  96232. /**
  96233. * The browser gamepad
  96234. */
  96235. browserGamepad: any;
  96236. /**
  96237. * Specifies what type of gamepad this represents
  96238. */
  96239. type: number;
  96240. private _leftStick;
  96241. private _rightStick;
  96242. /** @hidden */
  96243. _isConnected: boolean;
  96244. private _leftStickAxisX;
  96245. private _leftStickAxisY;
  96246. private _rightStickAxisX;
  96247. private _rightStickAxisY;
  96248. /**
  96249. * Triggered when the left control stick has been changed
  96250. */
  96251. private _onleftstickchanged;
  96252. /**
  96253. * Triggered when the right control stick has been changed
  96254. */
  96255. private _onrightstickchanged;
  96256. /**
  96257. * Represents a gamepad controller
  96258. */
  96259. static GAMEPAD: number;
  96260. /**
  96261. * Represents a generic controller
  96262. */
  96263. static GENERIC: number;
  96264. /**
  96265. * Represents an XBox controller
  96266. */
  96267. static XBOX: number;
  96268. /**
  96269. * Represents a pose-enabled controller
  96270. */
  96271. static POSE_ENABLED: number;
  96272. /**
  96273. * Represents an Dual Shock controller
  96274. */
  96275. static DUALSHOCK: number;
  96276. /**
  96277. * Specifies whether the left control stick should be Y-inverted
  96278. */
  96279. protected _invertLeftStickY: boolean;
  96280. /**
  96281. * Specifies if the gamepad has been connected
  96282. */
  96283. get isConnected(): boolean;
  96284. /**
  96285. * Initializes the gamepad
  96286. * @param id The id of the gamepad
  96287. * @param index The index of the gamepad
  96288. * @param browserGamepad The browser gamepad
  96289. * @param leftStickX The x component of the left joystick
  96290. * @param leftStickY The y component of the left joystick
  96291. * @param rightStickX The x component of the right joystick
  96292. * @param rightStickY The y component of the right joystick
  96293. */
  96294. constructor(
  96295. /**
  96296. * The id of the gamepad
  96297. */
  96298. id: string,
  96299. /**
  96300. * The index of the gamepad
  96301. */
  96302. index: number,
  96303. /**
  96304. * The browser gamepad
  96305. */
  96306. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  96307. /**
  96308. * Callback triggered when the left joystick has changed
  96309. * @param callback
  96310. */
  96311. onleftstickchanged(callback: (values: StickValues) => void): void;
  96312. /**
  96313. * Callback triggered when the right joystick has changed
  96314. * @param callback
  96315. */
  96316. onrightstickchanged(callback: (values: StickValues) => void): void;
  96317. /**
  96318. * Gets the left joystick
  96319. */
  96320. get leftStick(): StickValues;
  96321. /**
  96322. * Sets the left joystick values
  96323. */
  96324. set leftStick(newValues: StickValues);
  96325. /**
  96326. * Gets the right joystick
  96327. */
  96328. get rightStick(): StickValues;
  96329. /**
  96330. * Sets the right joystick value
  96331. */
  96332. set rightStick(newValues: StickValues);
  96333. /**
  96334. * Updates the gamepad joystick positions
  96335. */
  96336. update(): void;
  96337. /**
  96338. * Disposes the gamepad
  96339. */
  96340. dispose(): void;
  96341. }
  96342. /**
  96343. * Represents a generic gamepad
  96344. */
  96345. export class GenericPad extends Gamepad {
  96346. private _buttons;
  96347. private _onbuttondown;
  96348. private _onbuttonup;
  96349. /**
  96350. * Observable triggered when a button has been pressed
  96351. */
  96352. onButtonDownObservable: Observable<number>;
  96353. /**
  96354. * Observable triggered when a button has been released
  96355. */
  96356. onButtonUpObservable: Observable<number>;
  96357. /**
  96358. * Callback triggered when a button has been pressed
  96359. * @param callback Called when a button has been pressed
  96360. */
  96361. onbuttondown(callback: (buttonPressed: number) => void): void;
  96362. /**
  96363. * Callback triggered when a button has been released
  96364. * @param callback Called when a button has been released
  96365. */
  96366. onbuttonup(callback: (buttonReleased: number) => void): void;
  96367. /**
  96368. * Initializes the generic gamepad
  96369. * @param id The id of the generic gamepad
  96370. * @param index The index of the generic gamepad
  96371. * @param browserGamepad The browser gamepad
  96372. */
  96373. constructor(id: string, index: number, browserGamepad: any);
  96374. private _setButtonValue;
  96375. /**
  96376. * Updates the generic gamepad
  96377. */
  96378. update(): void;
  96379. /**
  96380. * Disposes the generic gamepad
  96381. */
  96382. dispose(): void;
  96383. }
  96384. }
  96385. declare module BABYLON {
  96386. /**
  96387. * Defines the types of pose enabled controllers that are supported
  96388. */
  96389. export enum PoseEnabledControllerType {
  96390. /**
  96391. * HTC Vive
  96392. */
  96393. VIVE = 0,
  96394. /**
  96395. * Oculus Rift
  96396. */
  96397. OCULUS = 1,
  96398. /**
  96399. * Windows mixed reality
  96400. */
  96401. WINDOWS = 2,
  96402. /**
  96403. * Samsung gear VR
  96404. */
  96405. GEAR_VR = 3,
  96406. /**
  96407. * Google Daydream
  96408. */
  96409. DAYDREAM = 4,
  96410. /**
  96411. * Generic
  96412. */
  96413. GENERIC = 5
  96414. }
  96415. /**
  96416. * Defines the MutableGamepadButton interface for the state of a gamepad button
  96417. */
  96418. export interface MutableGamepadButton {
  96419. /**
  96420. * Value of the button/trigger
  96421. */
  96422. value: number;
  96423. /**
  96424. * If the button/trigger is currently touched
  96425. */
  96426. touched: boolean;
  96427. /**
  96428. * If the button/trigger is currently pressed
  96429. */
  96430. pressed: boolean;
  96431. }
  96432. /**
  96433. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  96434. * @hidden
  96435. */
  96436. export interface ExtendedGamepadButton extends GamepadButton {
  96437. /**
  96438. * If the button/trigger is currently pressed
  96439. */
  96440. readonly pressed: boolean;
  96441. /**
  96442. * If the button/trigger is currently touched
  96443. */
  96444. readonly touched: boolean;
  96445. /**
  96446. * Value of the button/trigger
  96447. */
  96448. readonly value: number;
  96449. }
  96450. /** @hidden */
  96451. export interface _GamePadFactory {
  96452. /**
  96453. * Returns whether or not the current gamepad can be created for this type of controller.
  96454. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  96455. * @returns true if it can be created, otherwise false
  96456. */
  96457. canCreate(gamepadInfo: any): boolean;
  96458. /**
  96459. * Creates a new instance of the Gamepad.
  96460. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  96461. * @returns the new gamepad instance
  96462. */
  96463. create(gamepadInfo: any): Gamepad;
  96464. }
  96465. /**
  96466. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  96467. */
  96468. export class PoseEnabledControllerHelper {
  96469. /** @hidden */
  96470. static _ControllerFactories: _GamePadFactory[];
  96471. /** @hidden */
  96472. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  96473. /**
  96474. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  96475. * @param vrGamepad the gamepad to initialized
  96476. * @returns a vr controller of the type the gamepad identified as
  96477. */
  96478. static InitiateController(vrGamepad: any): Gamepad;
  96479. }
  96480. /**
  96481. * Defines the PoseEnabledController object that contains state of a vr capable controller
  96482. */
  96483. export class PoseEnabledController extends Gamepad implements PoseControlled {
  96484. /**
  96485. * If the controller is used in a webXR session
  96486. */
  96487. isXR: boolean;
  96488. private _deviceRoomPosition;
  96489. private _deviceRoomRotationQuaternion;
  96490. /**
  96491. * The device position in babylon space
  96492. */
  96493. devicePosition: Vector3;
  96494. /**
  96495. * The device rotation in babylon space
  96496. */
  96497. deviceRotationQuaternion: Quaternion;
  96498. /**
  96499. * The scale factor of the device in babylon space
  96500. */
  96501. deviceScaleFactor: number;
  96502. /**
  96503. * (Likely devicePosition should be used instead) The device position in its room space
  96504. */
  96505. position: Vector3;
  96506. /**
  96507. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  96508. */
  96509. rotationQuaternion: Quaternion;
  96510. /**
  96511. * The type of controller (Eg. Windows mixed reality)
  96512. */
  96513. controllerType: PoseEnabledControllerType;
  96514. protected _calculatedPosition: Vector3;
  96515. private _calculatedRotation;
  96516. /**
  96517. * The raw pose from the device
  96518. */
  96519. rawPose: DevicePose;
  96520. private _trackPosition;
  96521. private _maxRotationDistFromHeadset;
  96522. private _draggedRoomRotation;
  96523. /**
  96524. * @hidden
  96525. */
  96526. _disableTrackPosition(fixedPosition: Vector3): void;
  96527. /**
  96528. * Internal, the mesh attached to the controller
  96529. * @hidden
  96530. */
  96531. _mesh: Nullable<AbstractMesh>;
  96532. private _poseControlledCamera;
  96533. private _leftHandSystemQuaternion;
  96534. /**
  96535. * Internal, matrix used to convert room space to babylon space
  96536. * @hidden
  96537. */
  96538. _deviceToWorld: Matrix;
  96539. /**
  96540. * Node to be used when casting a ray from the controller
  96541. * @hidden
  96542. */
  96543. _pointingPoseNode: Nullable<TransformNode>;
  96544. /**
  96545. * Name of the child mesh that can be used to cast a ray from the controller
  96546. */
  96547. static readonly POINTING_POSE: string;
  96548. /**
  96549. * Creates a new PoseEnabledController from a gamepad
  96550. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  96551. */
  96552. constructor(browserGamepad: any);
  96553. private _workingMatrix;
  96554. /**
  96555. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  96556. */
  96557. update(): void;
  96558. /**
  96559. * Updates only the pose device and mesh without doing any button event checking
  96560. */
  96561. protected _updatePoseAndMesh(): void;
  96562. /**
  96563. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  96564. * @param poseData raw pose fromthe device
  96565. */
  96566. updateFromDevice(poseData: DevicePose): void;
  96567. /**
  96568. * @hidden
  96569. */
  96570. _meshAttachedObservable: Observable<AbstractMesh>;
  96571. /**
  96572. * Attaches a mesh to the controller
  96573. * @param mesh the mesh to be attached
  96574. */
  96575. attachToMesh(mesh: AbstractMesh): void;
  96576. /**
  96577. * Attaches the controllers mesh to a camera
  96578. * @param camera the camera the mesh should be attached to
  96579. */
  96580. attachToPoseControlledCamera(camera: TargetCamera): void;
  96581. /**
  96582. * Disposes of the controller
  96583. */
  96584. dispose(): void;
  96585. /**
  96586. * The mesh that is attached to the controller
  96587. */
  96588. get mesh(): Nullable<AbstractMesh>;
  96589. /**
  96590. * Gets the ray of the controller in the direction the controller is pointing
  96591. * @param length the length the resulting ray should be
  96592. * @returns a ray in the direction the controller is pointing
  96593. */
  96594. getForwardRay(length?: number): Ray;
  96595. }
  96596. }
  96597. declare module BABYLON {
  96598. /**
  96599. * Defines the WebVRController object that represents controllers tracked in 3D space
  96600. */
  96601. export abstract class WebVRController extends PoseEnabledController {
  96602. /**
  96603. * Internal, the default controller model for the controller
  96604. */
  96605. protected _defaultModel: Nullable<AbstractMesh>;
  96606. /**
  96607. * Fired when the trigger state has changed
  96608. */
  96609. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  96610. /**
  96611. * Fired when the main button state has changed
  96612. */
  96613. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  96614. /**
  96615. * Fired when the secondary button state has changed
  96616. */
  96617. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  96618. /**
  96619. * Fired when the pad state has changed
  96620. */
  96621. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  96622. /**
  96623. * Fired when controllers stick values have changed
  96624. */
  96625. onPadValuesChangedObservable: Observable<StickValues>;
  96626. /**
  96627. * Array of button availible on the controller
  96628. */
  96629. protected _buttons: Array<MutableGamepadButton>;
  96630. private _onButtonStateChange;
  96631. /**
  96632. * Fired when a controller button's state has changed
  96633. * @param callback the callback containing the button that was modified
  96634. */
  96635. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  96636. /**
  96637. * X and Y axis corresponding to the controllers joystick
  96638. */
  96639. pad: StickValues;
  96640. /**
  96641. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  96642. */
  96643. hand: string;
  96644. /**
  96645. * The default controller model for the controller
  96646. */
  96647. get defaultModel(): Nullable<AbstractMesh>;
  96648. /**
  96649. * Creates a new WebVRController from a gamepad
  96650. * @param vrGamepad the gamepad that the WebVRController should be created from
  96651. */
  96652. constructor(vrGamepad: any);
  96653. /**
  96654. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  96655. */
  96656. update(): void;
  96657. /**
  96658. * Function to be called when a button is modified
  96659. */
  96660. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  96661. /**
  96662. * Loads a mesh and attaches it to the controller
  96663. * @param scene the scene the mesh should be added to
  96664. * @param meshLoaded callback for when the mesh has been loaded
  96665. */
  96666. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  96667. private _setButtonValue;
  96668. private _changes;
  96669. private _checkChanges;
  96670. /**
  96671. * Disposes of th webVRCOntroller
  96672. */
  96673. dispose(): void;
  96674. }
  96675. }
  96676. declare module BABYLON {
  96677. /**
  96678. * The HemisphericLight simulates the ambient environment light,
  96679. * so the passed direction is the light reflection direction, not the incoming direction.
  96680. */
  96681. export class HemisphericLight extends Light {
  96682. /**
  96683. * The groundColor is the light in the opposite direction to the one specified during creation.
  96684. * 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.
  96685. */
  96686. groundColor: Color3;
  96687. /**
  96688. * The light reflection direction, not the incoming direction.
  96689. */
  96690. direction: Vector3;
  96691. /**
  96692. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  96693. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  96694. * The HemisphericLight can't cast shadows.
  96695. * Documentation : https://doc.babylonjs.com/babylon101/lights
  96696. * @param name The friendly name of the light
  96697. * @param direction The direction of the light reflection
  96698. * @param scene The scene the light belongs to
  96699. */
  96700. constructor(name: string, direction: Vector3, scene: Scene);
  96701. protected _buildUniformLayout(): void;
  96702. /**
  96703. * Returns the string "HemisphericLight".
  96704. * @return The class name
  96705. */
  96706. getClassName(): string;
  96707. /**
  96708. * Sets the HemisphericLight direction towards the passed target (Vector3).
  96709. * Returns the updated direction.
  96710. * @param target The target the direction should point to
  96711. * @return The computed direction
  96712. */
  96713. setDirectionToTarget(target: Vector3): Vector3;
  96714. /**
  96715. * Returns the shadow generator associated to the light.
  96716. * @returns Always null for hemispheric lights because it does not support shadows.
  96717. */
  96718. getShadowGenerator(): Nullable<IShadowGenerator>;
  96719. /**
  96720. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  96721. * @param effect The effect to update
  96722. * @param lightIndex The index of the light in the effect to update
  96723. * @returns The hemispheric light
  96724. */
  96725. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  96726. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  96727. /**
  96728. * Computes the world matrix of the node
  96729. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  96730. * @param useWasUpdatedFlag defines a reserved property
  96731. * @returns the world matrix
  96732. */
  96733. computeWorldMatrix(): Matrix;
  96734. /**
  96735. * Returns the integer 3.
  96736. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  96737. */
  96738. getTypeID(): number;
  96739. /**
  96740. * Prepares the list of defines specific to the light type.
  96741. * @param defines the list of defines
  96742. * @param lightIndex defines the index of the light for the effect
  96743. */
  96744. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  96745. }
  96746. }
  96747. declare module BABYLON {
  96748. /** @hidden */
  96749. export var vrMultiviewToSingleviewPixelShader: {
  96750. name: string;
  96751. shader: string;
  96752. };
  96753. }
  96754. declare module BABYLON {
  96755. /**
  96756. * Renders to multiple views with a single draw call
  96757. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  96758. */
  96759. export class MultiviewRenderTarget extends RenderTargetTexture {
  96760. /**
  96761. * Creates a multiview render target
  96762. * @param scene scene used with the render target
  96763. * @param size the size of the render target (used for each view)
  96764. */
  96765. constructor(scene: Scene, size?: number | {
  96766. width: number;
  96767. height: number;
  96768. } | {
  96769. ratio: number;
  96770. });
  96771. /**
  96772. * @hidden
  96773. * @param faceIndex the face index, if its a cube texture
  96774. */
  96775. _bindFrameBuffer(faceIndex?: number): void;
  96776. /**
  96777. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  96778. * @returns the view count
  96779. */
  96780. getViewCount(): number;
  96781. }
  96782. }
  96783. declare module BABYLON {
  96784. interface Engine {
  96785. /**
  96786. * Creates a new multiview render target
  96787. * @param width defines the width of the texture
  96788. * @param height defines the height of the texture
  96789. * @returns the created multiview texture
  96790. */
  96791. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  96792. /**
  96793. * Binds a multiview framebuffer to be drawn to
  96794. * @param multiviewTexture texture to bind
  96795. */
  96796. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  96797. }
  96798. interface Camera {
  96799. /**
  96800. * @hidden
  96801. * 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)
  96802. */
  96803. _useMultiviewToSingleView: boolean;
  96804. /**
  96805. * @hidden
  96806. * 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)
  96807. */
  96808. _multiviewTexture: Nullable<RenderTargetTexture>;
  96809. /**
  96810. * @hidden
  96811. * ensures the multiview texture of the camera exists and has the specified width/height
  96812. * @param width height to set on the multiview texture
  96813. * @param height width to set on the multiview texture
  96814. */
  96815. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  96816. }
  96817. interface Scene {
  96818. /** @hidden */
  96819. _transformMatrixR: Matrix;
  96820. /** @hidden */
  96821. _multiviewSceneUbo: Nullable<UniformBuffer>;
  96822. /** @hidden */
  96823. _createMultiviewUbo(): void;
  96824. /** @hidden */
  96825. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  96826. /** @hidden */
  96827. _renderMultiviewToSingleView(camera: Camera): void;
  96828. }
  96829. }
  96830. declare module BABYLON {
  96831. /**
  96832. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  96833. * This will not be used for webXR as it supports displaying texture arrays directly
  96834. */
  96835. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  96836. /**
  96837. * Initializes a VRMultiviewToSingleview
  96838. * @param name name of the post process
  96839. * @param camera camera to be applied to
  96840. * @param scaleFactor scaling factor to the size of the output texture
  96841. */
  96842. constructor(name: string, camera: Camera, scaleFactor: number);
  96843. }
  96844. }
  96845. declare module BABYLON {
  96846. /**
  96847. * Interface used to define additional presentation attributes
  96848. */
  96849. export interface IVRPresentationAttributes {
  96850. /**
  96851. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  96852. */
  96853. highRefreshRate: boolean;
  96854. /**
  96855. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  96856. */
  96857. foveationLevel: number;
  96858. }
  96859. interface Engine {
  96860. /** @hidden */
  96861. _vrDisplay: any;
  96862. /** @hidden */
  96863. _vrSupported: boolean;
  96864. /** @hidden */
  96865. _oldSize: Size;
  96866. /** @hidden */
  96867. _oldHardwareScaleFactor: number;
  96868. /** @hidden */
  96869. _vrExclusivePointerMode: boolean;
  96870. /** @hidden */
  96871. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  96872. /** @hidden */
  96873. _onVRDisplayPointerRestricted: () => void;
  96874. /** @hidden */
  96875. _onVRDisplayPointerUnrestricted: () => void;
  96876. /** @hidden */
  96877. _onVrDisplayConnect: Nullable<(display: any) => void>;
  96878. /** @hidden */
  96879. _onVrDisplayDisconnect: Nullable<() => void>;
  96880. /** @hidden */
  96881. _onVrDisplayPresentChange: Nullable<() => void>;
  96882. /**
  96883. * Observable signaled when VR display mode changes
  96884. */
  96885. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  96886. /**
  96887. * Observable signaled when VR request present is complete
  96888. */
  96889. onVRRequestPresentComplete: Observable<boolean>;
  96890. /**
  96891. * Observable signaled when VR request present starts
  96892. */
  96893. onVRRequestPresentStart: Observable<Engine>;
  96894. /**
  96895. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  96896. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  96897. */
  96898. isInVRExclusivePointerMode: boolean;
  96899. /**
  96900. * Gets a boolean indicating if a webVR device was detected
  96901. * @returns true if a webVR device was detected
  96902. */
  96903. isVRDevicePresent(): boolean;
  96904. /**
  96905. * Gets the current webVR device
  96906. * @returns the current webVR device (or null)
  96907. */
  96908. getVRDevice(): any;
  96909. /**
  96910. * Initializes a webVR display and starts listening to display change events
  96911. * The onVRDisplayChangedObservable will be notified upon these changes
  96912. * @returns A promise containing a VRDisplay and if vr is supported
  96913. */
  96914. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  96915. /** @hidden */
  96916. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  96917. /**
  96918. * Gets or sets the presentation attributes used to configure VR rendering
  96919. */
  96920. vrPresentationAttributes?: IVRPresentationAttributes;
  96921. /**
  96922. * Call this function to switch to webVR mode
  96923. * Will do nothing if webVR is not supported or if there is no webVR device
  96924. * @param options the webvr options provided to the camera. mainly used for multiview
  96925. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96926. */
  96927. enableVR(options: WebVROptions): void;
  96928. /** @hidden */
  96929. _onVRFullScreenTriggered(): void;
  96930. }
  96931. }
  96932. declare module BABYLON {
  96933. /**
  96934. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  96935. * IMPORTANT!! The data is right-hand data.
  96936. * @export
  96937. * @interface DevicePose
  96938. */
  96939. export interface DevicePose {
  96940. /**
  96941. * The position of the device, values in array are [x,y,z].
  96942. */
  96943. readonly position: Nullable<Float32Array>;
  96944. /**
  96945. * The linearVelocity of the device, values in array are [x,y,z].
  96946. */
  96947. readonly linearVelocity: Nullable<Float32Array>;
  96948. /**
  96949. * The linearAcceleration of the device, values in array are [x,y,z].
  96950. */
  96951. readonly linearAcceleration: Nullable<Float32Array>;
  96952. /**
  96953. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  96954. */
  96955. readonly orientation: Nullable<Float32Array>;
  96956. /**
  96957. * The angularVelocity of the device, values in array are [x,y,z].
  96958. */
  96959. readonly angularVelocity: Nullable<Float32Array>;
  96960. /**
  96961. * The angularAcceleration of the device, values in array are [x,y,z].
  96962. */
  96963. readonly angularAcceleration: Nullable<Float32Array>;
  96964. }
  96965. /**
  96966. * Interface representing a pose controlled object in Babylon.
  96967. * A pose controlled object has both regular pose values as well as pose values
  96968. * from an external device such as a VR head mounted display
  96969. */
  96970. export interface PoseControlled {
  96971. /**
  96972. * The position of the object in babylon space.
  96973. */
  96974. position: Vector3;
  96975. /**
  96976. * The rotation quaternion of the object in babylon space.
  96977. */
  96978. rotationQuaternion: Quaternion;
  96979. /**
  96980. * The position of the device in babylon space.
  96981. */
  96982. devicePosition?: Vector3;
  96983. /**
  96984. * The rotation quaternion of the device in babylon space.
  96985. */
  96986. deviceRotationQuaternion: Quaternion;
  96987. /**
  96988. * The raw pose coming from the device.
  96989. */
  96990. rawPose: Nullable<DevicePose>;
  96991. /**
  96992. * The scale of the device to be used when translating from device space to babylon space.
  96993. */
  96994. deviceScaleFactor: number;
  96995. /**
  96996. * Updates the poseControlled values based on the input device pose.
  96997. * @param poseData the pose data to update the object with
  96998. */
  96999. updateFromDevice(poseData: DevicePose): void;
  97000. }
  97001. /**
  97002. * Set of options to customize the webVRCamera
  97003. */
  97004. export interface WebVROptions {
  97005. /**
  97006. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  97007. */
  97008. trackPosition?: boolean;
  97009. /**
  97010. * Sets the scale of the vrDevice in babylon space. (default: 1)
  97011. */
  97012. positionScale?: number;
  97013. /**
  97014. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  97015. */
  97016. displayName?: string;
  97017. /**
  97018. * Should the native controller meshes be initialized. (default: true)
  97019. */
  97020. controllerMeshes?: boolean;
  97021. /**
  97022. * Creating a default HemiLight only on controllers. (default: true)
  97023. */
  97024. defaultLightingOnControllers?: boolean;
  97025. /**
  97026. * If you don't want to use the default VR button of the helper. (default: false)
  97027. */
  97028. useCustomVRButton?: boolean;
  97029. /**
  97030. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  97031. */
  97032. customVRButton?: HTMLButtonElement;
  97033. /**
  97034. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  97035. */
  97036. rayLength?: number;
  97037. /**
  97038. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  97039. */
  97040. defaultHeight?: number;
  97041. /**
  97042. * If multiview should be used if availible (default: false)
  97043. */
  97044. useMultiview?: boolean;
  97045. }
  97046. /**
  97047. * This represents a WebVR camera.
  97048. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  97049. * @example http://doc.babylonjs.com/how_to/webvr_camera
  97050. */
  97051. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  97052. private webVROptions;
  97053. /**
  97054. * @hidden
  97055. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  97056. */
  97057. _vrDevice: any;
  97058. /**
  97059. * The rawPose of the vrDevice.
  97060. */
  97061. rawPose: Nullable<DevicePose>;
  97062. private _onVREnabled;
  97063. private _specsVersion;
  97064. private _attached;
  97065. private _frameData;
  97066. protected _descendants: Array<Node>;
  97067. private _deviceRoomPosition;
  97068. /** @hidden */
  97069. _deviceRoomRotationQuaternion: Quaternion;
  97070. private _standingMatrix;
  97071. /**
  97072. * Represents device position in babylon space.
  97073. */
  97074. devicePosition: Vector3;
  97075. /**
  97076. * Represents device rotation in babylon space.
  97077. */
  97078. deviceRotationQuaternion: Quaternion;
  97079. /**
  97080. * The scale of the device to be used when translating from device space to babylon space.
  97081. */
  97082. deviceScaleFactor: number;
  97083. private _deviceToWorld;
  97084. private _worldToDevice;
  97085. /**
  97086. * References to the webVR controllers for the vrDevice.
  97087. */
  97088. controllers: Array<WebVRController>;
  97089. /**
  97090. * Emits an event when a controller is attached.
  97091. */
  97092. onControllersAttachedObservable: Observable<WebVRController[]>;
  97093. /**
  97094. * Emits an event when a controller's mesh has been loaded;
  97095. */
  97096. onControllerMeshLoadedObservable: Observable<WebVRController>;
  97097. /**
  97098. * Emits an event when the HMD's pose has been updated.
  97099. */
  97100. onPoseUpdatedFromDeviceObservable: Observable<any>;
  97101. private _poseSet;
  97102. /**
  97103. * If the rig cameras be used as parent instead of this camera.
  97104. */
  97105. rigParenting: boolean;
  97106. private _lightOnControllers;
  97107. private _defaultHeight?;
  97108. /**
  97109. * Instantiates a WebVRFreeCamera.
  97110. * @param name The name of the WebVRFreeCamera
  97111. * @param position The starting anchor position for the camera
  97112. * @param scene The scene the camera belongs to
  97113. * @param webVROptions a set of customizable options for the webVRCamera
  97114. */
  97115. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  97116. /**
  97117. * Gets the device distance from the ground in meters.
  97118. * @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.
  97119. */
  97120. deviceDistanceToRoomGround(): number;
  97121. /**
  97122. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  97123. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  97124. */
  97125. useStandingMatrix(callback?: (bool: boolean) => void): void;
  97126. /**
  97127. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  97128. * @returns A promise with a boolean set to if the standing matrix is supported.
  97129. */
  97130. useStandingMatrixAsync(): Promise<boolean>;
  97131. /**
  97132. * Disposes the camera
  97133. */
  97134. dispose(): void;
  97135. /**
  97136. * Gets a vrController by name.
  97137. * @param name The name of the controller to retreive
  97138. * @returns the controller matching the name specified or null if not found
  97139. */
  97140. getControllerByName(name: string): Nullable<WebVRController>;
  97141. private _leftController;
  97142. /**
  97143. * The controller corresponding to the users left hand.
  97144. */
  97145. get leftController(): Nullable<WebVRController>;
  97146. private _rightController;
  97147. /**
  97148. * The controller corresponding to the users right hand.
  97149. */
  97150. get rightController(): Nullable<WebVRController>;
  97151. /**
  97152. * Casts a ray forward from the vrCamera's gaze.
  97153. * @param length Length of the ray (default: 100)
  97154. * @returns the ray corresponding to the gaze
  97155. */
  97156. getForwardRay(length?: number): Ray;
  97157. /**
  97158. * @hidden
  97159. * Updates the camera based on device's frame data
  97160. */
  97161. _checkInputs(): void;
  97162. /**
  97163. * Updates the poseControlled values based on the input device pose.
  97164. * @param poseData Pose coming from the device
  97165. */
  97166. updateFromDevice(poseData: DevicePose): void;
  97167. private _htmlElementAttached;
  97168. private _detachIfAttached;
  97169. /**
  97170. * WebVR's attach control will start broadcasting frames to the device.
  97171. * Note that in certain browsers (chrome for example) this function must be called
  97172. * within a user-interaction callback. Example:
  97173. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  97174. *
  97175. * @param element html element to attach the vrDevice to
  97176. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  97177. */
  97178. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97179. /**
  97180. * Detaches the camera from the html element and disables VR
  97181. *
  97182. * @param element html element to detach from
  97183. */
  97184. detachControl(element: HTMLElement): void;
  97185. /**
  97186. * @returns the name of this class
  97187. */
  97188. getClassName(): string;
  97189. /**
  97190. * Calls resetPose on the vrDisplay
  97191. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  97192. */
  97193. resetToCurrentRotation(): void;
  97194. /**
  97195. * @hidden
  97196. * Updates the rig cameras (left and right eye)
  97197. */
  97198. _updateRigCameras(): void;
  97199. private _workingVector;
  97200. private _oneVector;
  97201. private _workingMatrix;
  97202. private updateCacheCalled;
  97203. private _correctPositionIfNotTrackPosition;
  97204. /**
  97205. * @hidden
  97206. * Updates the cached values of the camera
  97207. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  97208. */
  97209. _updateCache(ignoreParentClass?: boolean): void;
  97210. /**
  97211. * @hidden
  97212. * Get current device position in babylon world
  97213. */
  97214. _computeDevicePosition(): void;
  97215. /**
  97216. * Updates the current device position and rotation in the babylon world
  97217. */
  97218. update(): void;
  97219. /**
  97220. * @hidden
  97221. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  97222. * @returns an identity matrix
  97223. */
  97224. _getViewMatrix(): Matrix;
  97225. private _tmpMatrix;
  97226. /**
  97227. * This function is called by the two RIG cameras.
  97228. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  97229. * @hidden
  97230. */
  97231. _getWebVRViewMatrix(): Matrix;
  97232. /** @hidden */
  97233. _getWebVRProjectionMatrix(): Matrix;
  97234. private _onGamepadConnectedObserver;
  97235. private _onGamepadDisconnectedObserver;
  97236. private _updateCacheWhenTrackingDisabledObserver;
  97237. /**
  97238. * Initializes the controllers and their meshes
  97239. */
  97240. initControllers(): void;
  97241. }
  97242. }
  97243. declare module BABYLON {
  97244. /**
  97245. * "Static Class" containing the most commonly used helper while dealing with material for
  97246. * rendering purpose.
  97247. *
  97248. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  97249. *
  97250. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  97251. */
  97252. export class MaterialHelper {
  97253. /**
  97254. * Bind the current view position to an effect.
  97255. * @param effect The effect to be bound
  97256. * @param scene The scene the eyes position is used from
  97257. * @param variableName name of the shader variable that will hold the eye position
  97258. */
  97259. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  97260. /**
  97261. * Helps preparing the defines values about the UVs in used in the effect.
  97262. * UVs are shared as much as we can accross channels in the shaders.
  97263. * @param texture The texture we are preparing the UVs for
  97264. * @param defines The defines to update
  97265. * @param key The channel key "diffuse", "specular"... used in the shader
  97266. */
  97267. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  97268. /**
  97269. * Binds a texture matrix value to its corrsponding uniform
  97270. * @param texture The texture to bind the matrix for
  97271. * @param uniformBuffer The uniform buffer receivin the data
  97272. * @param key The channel key "diffuse", "specular"... used in the shader
  97273. */
  97274. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  97275. /**
  97276. * Gets the current status of the fog (should it be enabled?)
  97277. * @param mesh defines the mesh to evaluate for fog support
  97278. * @param scene defines the hosting scene
  97279. * @returns true if fog must be enabled
  97280. */
  97281. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  97282. /**
  97283. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  97284. * @param mesh defines the current mesh
  97285. * @param scene defines the current scene
  97286. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  97287. * @param pointsCloud defines if point cloud rendering has to be turned on
  97288. * @param fogEnabled defines if fog has to be turned on
  97289. * @param alphaTest defines if alpha testing has to be turned on
  97290. * @param defines defines the current list of defines
  97291. */
  97292. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  97293. /**
  97294. * Helper used to prepare the list of defines associated with frame values for shader compilation
  97295. * @param scene defines the current scene
  97296. * @param engine defines the current engine
  97297. * @param defines specifies the list of active defines
  97298. * @param useInstances defines if instances have to be turned on
  97299. * @param useClipPlane defines if clip plane have to be turned on
  97300. * @param useInstances defines if instances have to be turned on
  97301. * @param useThinInstances defines if thin instances have to be turned on
  97302. */
  97303. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  97304. /**
  97305. * Prepares the defines for bones
  97306. * @param mesh The mesh containing the geometry data we will draw
  97307. * @param defines The defines to update
  97308. */
  97309. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  97310. /**
  97311. * Prepares the defines for morph targets
  97312. * @param mesh The mesh containing the geometry data we will draw
  97313. * @param defines The defines to update
  97314. */
  97315. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  97316. /**
  97317. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  97318. * @param mesh The mesh containing the geometry data we will draw
  97319. * @param defines The defines to update
  97320. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  97321. * @param useBones Precise whether bones should be used or not (override mesh info)
  97322. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  97323. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  97324. * @returns false if defines are considered not dirty and have not been checked
  97325. */
  97326. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  97327. /**
  97328. * Prepares the defines related to multiview
  97329. * @param scene The scene we are intending to draw
  97330. * @param defines The defines to update
  97331. */
  97332. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  97333. /**
  97334. * Prepares the defines related to the light information passed in parameter
  97335. * @param scene The scene we are intending to draw
  97336. * @param mesh The mesh the effect is compiling for
  97337. * @param light The light the effect is compiling for
  97338. * @param lightIndex The index of the light
  97339. * @param defines The defines to update
  97340. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  97341. * @param state Defines the current state regarding what is needed (normals, etc...)
  97342. */
  97343. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  97344. needNormals: boolean;
  97345. needRebuild: boolean;
  97346. shadowEnabled: boolean;
  97347. specularEnabled: boolean;
  97348. lightmapMode: boolean;
  97349. }): void;
  97350. /**
  97351. * Prepares the defines related to the light information passed in parameter
  97352. * @param scene The scene we are intending to draw
  97353. * @param mesh The mesh the effect is compiling for
  97354. * @param defines The defines to update
  97355. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  97356. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  97357. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  97358. * @returns true if normals will be required for the rest of the effect
  97359. */
  97360. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  97361. /**
  97362. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  97363. * @param lightIndex defines the light index
  97364. * @param uniformsList The uniform list
  97365. * @param samplersList The sampler list
  97366. * @param projectedLightTexture defines if projected texture must be used
  97367. * @param uniformBuffersList defines an optional list of uniform buffers
  97368. */
  97369. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  97370. /**
  97371. * Prepares the uniforms and samplers list to be used in the effect
  97372. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  97373. * @param samplersList The sampler list
  97374. * @param defines The defines helping in the list generation
  97375. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  97376. */
  97377. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  97378. /**
  97379. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  97380. * @param defines The defines to update while falling back
  97381. * @param fallbacks The authorized effect fallbacks
  97382. * @param maxSimultaneousLights The maximum number of lights allowed
  97383. * @param rank the current rank of the Effect
  97384. * @returns The newly affected rank
  97385. */
  97386. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  97387. private static _TmpMorphInfluencers;
  97388. /**
  97389. * Prepares the list of attributes required for morph targets according to the effect defines.
  97390. * @param attribs The current list of supported attribs
  97391. * @param mesh The mesh to prepare the morph targets attributes for
  97392. * @param influencers The number of influencers
  97393. */
  97394. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  97395. /**
  97396. * Prepares the list of attributes required for morph targets according to the effect defines.
  97397. * @param attribs The current list of supported attribs
  97398. * @param mesh The mesh to prepare the morph targets attributes for
  97399. * @param defines The current Defines of the effect
  97400. */
  97401. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  97402. /**
  97403. * Prepares the list of attributes required for bones according to the effect defines.
  97404. * @param attribs The current list of supported attribs
  97405. * @param mesh The mesh to prepare the bones attributes for
  97406. * @param defines The current Defines of the effect
  97407. * @param fallbacks The current efffect fallback strategy
  97408. */
  97409. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  97410. /**
  97411. * Check and prepare the list of attributes required for instances according to the effect defines.
  97412. * @param attribs The current list of supported attribs
  97413. * @param defines The current MaterialDefines of the effect
  97414. */
  97415. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  97416. /**
  97417. * Add the list of attributes required for instances to the attribs array.
  97418. * @param attribs The current list of supported attribs
  97419. */
  97420. static PushAttributesForInstances(attribs: string[]): void;
  97421. /**
  97422. * Binds the light information to the effect.
  97423. * @param light The light containing the generator
  97424. * @param effect The effect we are binding the data to
  97425. * @param lightIndex The light index in the effect used to render
  97426. */
  97427. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  97428. /**
  97429. * Binds the lights information from the scene to the effect for the given mesh.
  97430. * @param light Light to bind
  97431. * @param lightIndex Light index
  97432. * @param scene The scene where the light belongs to
  97433. * @param effect The effect we are binding the data to
  97434. * @param useSpecular Defines if specular is supported
  97435. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97436. */
  97437. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  97438. /**
  97439. * Binds the lights information from the scene to the effect for the given mesh.
  97440. * @param scene The scene the lights belongs to
  97441. * @param mesh The mesh we are binding the information to render
  97442. * @param effect The effect we are binding the data to
  97443. * @param defines The generated defines for the effect
  97444. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  97445. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97446. */
  97447. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  97448. private static _tempFogColor;
  97449. /**
  97450. * Binds the fog information from the scene to the effect for the given mesh.
  97451. * @param scene The scene the lights belongs to
  97452. * @param mesh The mesh we are binding the information to render
  97453. * @param effect The effect we are binding the data to
  97454. * @param linearSpace Defines if the fog effect is applied in linear space
  97455. */
  97456. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  97457. /**
  97458. * Binds the bones information from the mesh to the effect.
  97459. * @param mesh The mesh we are binding the information to render
  97460. * @param effect The effect we are binding the data to
  97461. */
  97462. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  97463. /**
  97464. * Binds the morph targets information from the mesh to the effect.
  97465. * @param abstractMesh The mesh we are binding the information to render
  97466. * @param effect The effect we are binding the data to
  97467. */
  97468. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  97469. /**
  97470. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  97471. * @param defines The generated defines used in the effect
  97472. * @param effect The effect we are binding the data to
  97473. * @param scene The scene we are willing to render with logarithmic scale for
  97474. */
  97475. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  97476. /**
  97477. * Binds the clip plane information from the scene to the effect.
  97478. * @param scene The scene the clip plane information are extracted from
  97479. * @param effect The effect we are binding the data to
  97480. */
  97481. static BindClipPlane(effect: Effect, scene: Scene): void;
  97482. }
  97483. }
  97484. declare module BABYLON {
  97485. /**
  97486. * Block used to expose an input value
  97487. */
  97488. export class InputBlock extends NodeMaterialBlock {
  97489. private _mode;
  97490. private _associatedVariableName;
  97491. private _storedValue;
  97492. private _valueCallback;
  97493. private _type;
  97494. private _animationType;
  97495. /** Gets or set a value used to limit the range of float values */
  97496. min: number;
  97497. /** Gets or set a value used to limit the range of float values */
  97498. max: number;
  97499. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  97500. isBoolean: boolean;
  97501. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  97502. matrixMode: number;
  97503. /** @hidden */
  97504. _systemValue: Nullable<NodeMaterialSystemValues>;
  97505. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  97506. visibleInInspector: boolean;
  97507. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  97508. isConstant: boolean;
  97509. /** Gets or sets the group to use to display this block in the Inspector */
  97510. groupInInspector: string;
  97511. /** Gets an observable raised when the value is changed */
  97512. onValueChangedObservable: Observable<InputBlock>;
  97513. /**
  97514. * Gets or sets the connection point type (default is float)
  97515. */
  97516. get type(): NodeMaterialBlockConnectionPointTypes;
  97517. /**
  97518. * Creates a new InputBlock
  97519. * @param name defines the block name
  97520. * @param target defines the target of that block (Vertex by default)
  97521. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  97522. */
  97523. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  97524. /**
  97525. * Gets the output component
  97526. */
  97527. get output(): NodeMaterialConnectionPoint;
  97528. /**
  97529. * Set the source of this connection point to a vertex attribute
  97530. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  97531. * @returns the current connection point
  97532. */
  97533. setAsAttribute(attributeName?: string): InputBlock;
  97534. /**
  97535. * Set the source of this connection point to a system value
  97536. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  97537. * @returns the current connection point
  97538. */
  97539. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  97540. /**
  97541. * Gets or sets the value of that point.
  97542. * Please note that this value will be ignored if valueCallback is defined
  97543. */
  97544. get value(): any;
  97545. set value(value: any);
  97546. /**
  97547. * Gets or sets a callback used to get the value of that point.
  97548. * Please note that setting this value will force the connection point to ignore the value property
  97549. */
  97550. get valueCallback(): () => any;
  97551. set valueCallback(value: () => any);
  97552. /**
  97553. * Gets or sets the associated variable name in the shader
  97554. */
  97555. get associatedVariableName(): string;
  97556. set associatedVariableName(value: string);
  97557. /** Gets or sets the type of animation applied to the input */
  97558. get animationType(): AnimatedInputBlockTypes;
  97559. set animationType(value: AnimatedInputBlockTypes);
  97560. /**
  97561. * Gets a boolean indicating that this connection point not defined yet
  97562. */
  97563. get isUndefined(): boolean;
  97564. /**
  97565. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  97566. * In this case the connection point name must be the name of the uniform to use.
  97567. * Can only be set on inputs
  97568. */
  97569. get isUniform(): boolean;
  97570. set isUniform(value: boolean);
  97571. /**
  97572. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  97573. * In this case the connection point name must be the name of the attribute to use
  97574. * Can only be set on inputs
  97575. */
  97576. get isAttribute(): boolean;
  97577. set isAttribute(value: boolean);
  97578. /**
  97579. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  97580. * Can only be set on exit points
  97581. */
  97582. get isVarying(): boolean;
  97583. set isVarying(value: boolean);
  97584. /**
  97585. * Gets a boolean indicating that the current connection point is a system value
  97586. */
  97587. get isSystemValue(): boolean;
  97588. /**
  97589. * Gets or sets the current well known value or null if not defined as a system value
  97590. */
  97591. get systemValue(): Nullable<NodeMaterialSystemValues>;
  97592. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  97593. /**
  97594. * Gets the current class name
  97595. * @returns the class name
  97596. */
  97597. getClassName(): string;
  97598. /**
  97599. * Animate the input if animationType !== None
  97600. * @param scene defines the rendering scene
  97601. */
  97602. animate(scene: Scene): void;
  97603. private _emitDefine;
  97604. initialize(state: NodeMaterialBuildState): void;
  97605. /**
  97606. * Set the input block to its default value (based on its type)
  97607. */
  97608. setDefaultValue(): void;
  97609. private _emitConstant;
  97610. /** @hidden */
  97611. get _noContextSwitch(): boolean;
  97612. private _emit;
  97613. /** @hidden */
  97614. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  97615. /** @hidden */
  97616. _transmit(effect: Effect, scene: Scene): void;
  97617. protected _buildBlock(state: NodeMaterialBuildState): void;
  97618. protected _dumpPropertiesCode(): string;
  97619. dispose(): void;
  97620. serialize(): any;
  97621. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97622. }
  97623. }
  97624. declare module BABYLON {
  97625. /**
  97626. * Enum used to define the compatibility state between two connection points
  97627. */
  97628. export enum NodeMaterialConnectionPointCompatibilityStates {
  97629. /** Points are compatibles */
  97630. Compatible = 0,
  97631. /** Points are incompatible because of their types */
  97632. TypeIncompatible = 1,
  97633. /** Points are incompatible because of their targets (vertex vs fragment) */
  97634. TargetIncompatible = 2
  97635. }
  97636. /**
  97637. * Defines the direction of a connection point
  97638. */
  97639. export enum NodeMaterialConnectionPointDirection {
  97640. /** Input */
  97641. Input = 0,
  97642. /** Output */
  97643. Output = 1
  97644. }
  97645. /**
  97646. * Defines a connection point for a block
  97647. */
  97648. export class NodeMaterialConnectionPoint {
  97649. /** @hidden */
  97650. _ownerBlock: NodeMaterialBlock;
  97651. /** @hidden */
  97652. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  97653. private _endpoints;
  97654. private _associatedVariableName;
  97655. private _direction;
  97656. /** @hidden */
  97657. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  97658. /** @hidden */
  97659. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  97660. private _type;
  97661. /** @hidden */
  97662. _enforceAssociatedVariableName: boolean;
  97663. /** Gets the direction of the point */
  97664. get direction(): NodeMaterialConnectionPointDirection;
  97665. /** Indicates that this connection point needs dual validation before being connected to another point */
  97666. needDualDirectionValidation: boolean;
  97667. /**
  97668. * Gets or sets the additional types supported by this connection point
  97669. */
  97670. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  97671. /**
  97672. * Gets or sets the additional types excluded by this connection point
  97673. */
  97674. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  97675. /**
  97676. * Observable triggered when this point is connected
  97677. */
  97678. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  97679. /**
  97680. * Gets or sets the associated variable name in the shader
  97681. */
  97682. get associatedVariableName(): string;
  97683. set associatedVariableName(value: string);
  97684. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  97685. get innerType(): NodeMaterialBlockConnectionPointTypes;
  97686. /**
  97687. * Gets or sets the connection point type (default is float)
  97688. */
  97689. get type(): NodeMaterialBlockConnectionPointTypes;
  97690. set type(value: NodeMaterialBlockConnectionPointTypes);
  97691. /**
  97692. * Gets or sets the connection point name
  97693. */
  97694. name: string;
  97695. /**
  97696. * Gets or sets the connection point name
  97697. */
  97698. displayName: string;
  97699. /**
  97700. * Gets or sets a boolean indicating that this connection point can be omitted
  97701. */
  97702. isOptional: boolean;
  97703. /**
  97704. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  97705. */
  97706. define: string;
  97707. /** @hidden */
  97708. _prioritizeVertex: boolean;
  97709. private _target;
  97710. /** Gets or sets the target of that connection point */
  97711. get target(): NodeMaterialBlockTargets;
  97712. set target(value: NodeMaterialBlockTargets);
  97713. /**
  97714. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  97715. */
  97716. get isConnected(): boolean;
  97717. /**
  97718. * Gets a boolean indicating that the current point is connected to an input block
  97719. */
  97720. get isConnectedToInputBlock(): boolean;
  97721. /**
  97722. * Gets a the connected input block (if any)
  97723. */
  97724. get connectInputBlock(): Nullable<InputBlock>;
  97725. /** Get the other side of the connection (if any) */
  97726. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  97727. /** Get the block that owns this connection point */
  97728. get ownerBlock(): NodeMaterialBlock;
  97729. /** Get the block connected on the other side of this connection (if any) */
  97730. get sourceBlock(): Nullable<NodeMaterialBlock>;
  97731. /** Get the block connected on the endpoints of this connection (if any) */
  97732. get connectedBlocks(): Array<NodeMaterialBlock>;
  97733. /** Gets the list of connected endpoints */
  97734. get endpoints(): NodeMaterialConnectionPoint[];
  97735. /** Gets a boolean indicating if that output point is connected to at least one input */
  97736. get hasEndpoints(): boolean;
  97737. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  97738. get isConnectedInVertexShader(): boolean;
  97739. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  97740. get isConnectedInFragmentShader(): boolean;
  97741. /**
  97742. * Creates a block suitable to be used as an input for this input point.
  97743. * If null is returned, a block based on the point type will be created.
  97744. * @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
  97745. */
  97746. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  97747. /**
  97748. * Creates a new connection point
  97749. * @param name defines the connection point name
  97750. * @param ownerBlock defines the block hosting this connection point
  97751. * @param direction defines the direction of the connection point
  97752. */
  97753. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  97754. /**
  97755. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  97756. * @returns the class name
  97757. */
  97758. getClassName(): string;
  97759. /**
  97760. * Gets a boolean indicating if the current point can be connected to another point
  97761. * @param connectionPoint defines the other connection point
  97762. * @returns a boolean
  97763. */
  97764. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  97765. /**
  97766. * Gets a number indicating if the current point can be connected to another point
  97767. * @param connectionPoint defines the other connection point
  97768. * @returns a number defining the compatibility state
  97769. */
  97770. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  97771. /**
  97772. * Connect this point to another connection point
  97773. * @param connectionPoint defines the other connection point
  97774. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  97775. * @returns the current connection point
  97776. */
  97777. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  97778. /**
  97779. * Disconnect this point from one of his endpoint
  97780. * @param endpoint defines the other connection point
  97781. * @returns the current connection point
  97782. */
  97783. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  97784. /**
  97785. * Serializes this point in a JSON representation
  97786. * @param isInput defines if the connection point is an input (default is true)
  97787. * @returns the serialized point object
  97788. */
  97789. serialize(isInput?: boolean): any;
  97790. /**
  97791. * Release resources
  97792. */
  97793. dispose(): void;
  97794. }
  97795. }
  97796. declare module BABYLON {
  97797. /**
  97798. * Enum used to define the material modes
  97799. */
  97800. export enum NodeMaterialModes {
  97801. /** Regular material */
  97802. Material = 0,
  97803. /** For post process */
  97804. PostProcess = 1,
  97805. /** For particle system */
  97806. Particle = 2
  97807. }
  97808. }
  97809. declare module BABYLON {
  97810. /**
  97811. * Block used to read a texture from a sampler
  97812. */
  97813. export class TextureBlock extends NodeMaterialBlock {
  97814. private _defineName;
  97815. private _linearDefineName;
  97816. private _gammaDefineName;
  97817. private _tempTextureRead;
  97818. private _samplerName;
  97819. private _transformedUVName;
  97820. private _textureTransformName;
  97821. private _textureInfoName;
  97822. private _mainUVName;
  97823. private _mainUVDefineName;
  97824. private _fragmentOnly;
  97825. /**
  97826. * Gets or sets the texture associated with the node
  97827. */
  97828. texture: Nullable<Texture>;
  97829. /**
  97830. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  97831. */
  97832. convertToGammaSpace: boolean;
  97833. /**
  97834. * Gets or sets a boolean indicating if content needs to be converted to linear space
  97835. */
  97836. convertToLinearSpace: boolean;
  97837. /**
  97838. * Create a new TextureBlock
  97839. * @param name defines the block name
  97840. */
  97841. constructor(name: string, fragmentOnly?: boolean);
  97842. /**
  97843. * Gets the current class name
  97844. * @returns the class name
  97845. */
  97846. getClassName(): string;
  97847. /**
  97848. * Gets the uv input component
  97849. */
  97850. get uv(): NodeMaterialConnectionPoint;
  97851. /**
  97852. * Gets the rgba output component
  97853. */
  97854. get rgba(): NodeMaterialConnectionPoint;
  97855. /**
  97856. * Gets the rgb output component
  97857. */
  97858. get rgb(): NodeMaterialConnectionPoint;
  97859. /**
  97860. * Gets the r output component
  97861. */
  97862. get r(): NodeMaterialConnectionPoint;
  97863. /**
  97864. * Gets the g output component
  97865. */
  97866. get g(): NodeMaterialConnectionPoint;
  97867. /**
  97868. * Gets the b output component
  97869. */
  97870. get b(): NodeMaterialConnectionPoint;
  97871. /**
  97872. * Gets the a output component
  97873. */
  97874. get a(): NodeMaterialConnectionPoint;
  97875. get target(): NodeMaterialBlockTargets;
  97876. autoConfigure(material: NodeMaterial): void;
  97877. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  97878. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97879. isReady(): boolean;
  97880. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  97881. private get _isMixed();
  97882. private _injectVertexCode;
  97883. private _writeTextureRead;
  97884. private _writeOutput;
  97885. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  97886. protected _dumpPropertiesCode(): string;
  97887. serialize(): any;
  97888. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97889. }
  97890. }
  97891. declare module BABYLON {
  97892. /** @hidden */
  97893. export var reflectionFunction: {
  97894. name: string;
  97895. shader: string;
  97896. };
  97897. }
  97898. declare module BABYLON {
  97899. /**
  97900. * Base block used to read a reflection texture from a sampler
  97901. */
  97902. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  97903. /** @hidden */
  97904. _define3DName: string;
  97905. /** @hidden */
  97906. _defineCubicName: string;
  97907. /** @hidden */
  97908. _defineExplicitName: string;
  97909. /** @hidden */
  97910. _defineProjectionName: string;
  97911. /** @hidden */
  97912. _defineLocalCubicName: string;
  97913. /** @hidden */
  97914. _defineSphericalName: string;
  97915. /** @hidden */
  97916. _definePlanarName: string;
  97917. /** @hidden */
  97918. _defineEquirectangularName: string;
  97919. /** @hidden */
  97920. _defineMirroredEquirectangularFixedName: string;
  97921. /** @hidden */
  97922. _defineEquirectangularFixedName: string;
  97923. /** @hidden */
  97924. _defineSkyboxName: string;
  97925. /** @hidden */
  97926. _defineOppositeZ: string;
  97927. /** @hidden */
  97928. _cubeSamplerName: string;
  97929. /** @hidden */
  97930. _2DSamplerName: string;
  97931. protected _positionUVWName: string;
  97932. protected _directionWName: string;
  97933. protected _reflectionVectorName: string;
  97934. /** @hidden */
  97935. _reflectionCoordsName: string;
  97936. /** @hidden */
  97937. _reflectionMatrixName: string;
  97938. protected _reflectionColorName: string;
  97939. /**
  97940. * Gets or sets the texture associated with the node
  97941. */
  97942. texture: Nullable<BaseTexture>;
  97943. /**
  97944. * Create a new ReflectionTextureBaseBlock
  97945. * @param name defines the block name
  97946. */
  97947. constructor(name: string);
  97948. /**
  97949. * Gets the current class name
  97950. * @returns the class name
  97951. */
  97952. getClassName(): string;
  97953. /**
  97954. * Gets the world position input component
  97955. */
  97956. abstract get position(): NodeMaterialConnectionPoint;
  97957. /**
  97958. * Gets the world position input component
  97959. */
  97960. abstract get worldPosition(): NodeMaterialConnectionPoint;
  97961. /**
  97962. * Gets the world normal input component
  97963. */
  97964. abstract get worldNormal(): NodeMaterialConnectionPoint;
  97965. /**
  97966. * Gets the world input component
  97967. */
  97968. abstract get world(): NodeMaterialConnectionPoint;
  97969. /**
  97970. * Gets the camera (or eye) position component
  97971. */
  97972. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  97973. /**
  97974. * Gets the view input component
  97975. */
  97976. abstract get view(): NodeMaterialConnectionPoint;
  97977. protected _getTexture(): Nullable<BaseTexture>;
  97978. autoConfigure(material: NodeMaterial): void;
  97979. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97980. isReady(): boolean;
  97981. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  97982. /**
  97983. * Gets the code to inject in the vertex shader
  97984. * @param state current state of the node material building
  97985. * @returns the shader code
  97986. */
  97987. handleVertexSide(state: NodeMaterialBuildState): string;
  97988. /**
  97989. * Handles the inits for the fragment code path
  97990. * @param state node material build state
  97991. */
  97992. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  97993. /**
  97994. * Generates the reflection coords code for the fragment code path
  97995. * @param worldNormalVarName name of the world normal variable
  97996. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  97997. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  97998. * @returns the shader code
  97999. */
  98000. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  98001. /**
  98002. * Generates the reflection color code for the fragment code path
  98003. * @param lodVarName name of the lod variable
  98004. * @param swizzleLookupTexture swizzle to use for the final color variable
  98005. * @returns the shader code
  98006. */
  98007. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  98008. /**
  98009. * Generates the code corresponding to the connected output points
  98010. * @param state node material build state
  98011. * @param varName name of the variable to output
  98012. * @returns the shader code
  98013. */
  98014. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  98015. protected _buildBlock(state: NodeMaterialBuildState): this;
  98016. protected _dumpPropertiesCode(): string;
  98017. serialize(): any;
  98018. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98019. }
  98020. }
  98021. declare module BABYLON {
  98022. /**
  98023. * Defines a connection point to be used for points with a custom object type
  98024. */
  98025. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  98026. private _blockType;
  98027. private _blockName;
  98028. private _nameForCheking?;
  98029. /**
  98030. * Creates a new connection point
  98031. * @param name defines the connection point name
  98032. * @param ownerBlock defines the block hosting this connection point
  98033. * @param direction defines the direction of the connection point
  98034. */
  98035. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  98036. /**
  98037. * Gets a number indicating if the current point can be connected to another point
  98038. * @param connectionPoint defines the other connection point
  98039. * @returns a number defining the compatibility state
  98040. */
  98041. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98042. /**
  98043. * Creates a block suitable to be used as an input for this input point.
  98044. * If null is returned, a block based on the point type will be created.
  98045. * @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
  98046. */
  98047. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98048. }
  98049. }
  98050. declare module BABYLON {
  98051. /**
  98052. * Enum defining the type of properties that can be edited in the property pages in the NME
  98053. */
  98054. export enum PropertyTypeForEdition {
  98055. /** property is a boolean */
  98056. Boolean = 0,
  98057. /** property is a float */
  98058. Float = 1,
  98059. /** property is a Vector2 */
  98060. Vector2 = 2,
  98061. /** property is a list of values */
  98062. List = 3
  98063. }
  98064. /**
  98065. * Interface that defines an option in a variable of type list
  98066. */
  98067. export interface IEditablePropertyListOption {
  98068. /** label of the option */
  98069. "label": string;
  98070. /** value of the option */
  98071. "value": number;
  98072. }
  98073. /**
  98074. * Interface that defines the options available for an editable property
  98075. */
  98076. export interface IEditablePropertyOption {
  98077. /** min value */
  98078. "min"?: number;
  98079. /** max value */
  98080. "max"?: number;
  98081. /** notifiers: indicates which actions to take when the property is changed */
  98082. "notifiers"?: {
  98083. /** the material should be rebuilt */
  98084. "rebuild"?: boolean;
  98085. /** the preview should be updated */
  98086. "update"?: boolean;
  98087. };
  98088. /** list of the options for a variable of type list */
  98089. "options"?: IEditablePropertyListOption[];
  98090. }
  98091. /**
  98092. * Interface that describes an editable property
  98093. */
  98094. export interface IPropertyDescriptionForEdition {
  98095. /** name of the property */
  98096. "propertyName": string;
  98097. /** display name of the property */
  98098. "displayName": string;
  98099. /** type of the property */
  98100. "type": PropertyTypeForEdition;
  98101. /** group of the property - all properties with the same group value will be displayed in a specific section */
  98102. "groupName": string;
  98103. /** options for the property */
  98104. "options": IEditablePropertyOption;
  98105. }
  98106. /**
  98107. * Decorator that flags a property in a node material block as being editable
  98108. */
  98109. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  98110. }
  98111. declare module BABYLON {
  98112. /**
  98113. * Block used to implement the refraction part of the sub surface module of the PBR material
  98114. */
  98115. export class RefractionBlock extends NodeMaterialBlock {
  98116. /** @hidden */
  98117. _define3DName: string;
  98118. /** @hidden */
  98119. _refractionMatrixName: string;
  98120. /** @hidden */
  98121. _defineLODRefractionAlpha: string;
  98122. /** @hidden */
  98123. _defineLinearSpecularRefraction: string;
  98124. /** @hidden */
  98125. _defineOppositeZ: string;
  98126. /** @hidden */
  98127. _cubeSamplerName: string;
  98128. /** @hidden */
  98129. _2DSamplerName: string;
  98130. /** @hidden */
  98131. _vRefractionMicrosurfaceInfosName: string;
  98132. /** @hidden */
  98133. _vRefractionInfosName: string;
  98134. private _scene;
  98135. /**
  98136. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  98137. * Materials half opaque for instance using refraction could benefit from this control.
  98138. */
  98139. linkRefractionWithTransparency: boolean;
  98140. /**
  98141. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  98142. */
  98143. invertRefractionY: boolean;
  98144. /**
  98145. * Gets or sets the texture associated with the node
  98146. */
  98147. texture: Nullable<BaseTexture>;
  98148. /**
  98149. * Create a new RefractionBlock
  98150. * @param name defines the block name
  98151. */
  98152. constructor(name: string);
  98153. /**
  98154. * Gets the current class name
  98155. * @returns the class name
  98156. */
  98157. getClassName(): string;
  98158. /**
  98159. * Gets the intensity input component
  98160. */
  98161. get intensity(): NodeMaterialConnectionPoint;
  98162. /**
  98163. * Gets the index of refraction input component
  98164. */
  98165. get indexOfRefraction(): NodeMaterialConnectionPoint;
  98166. /**
  98167. * Gets the tint at distance input component
  98168. */
  98169. get tintAtDistance(): NodeMaterialConnectionPoint;
  98170. /**
  98171. * Gets the view input component
  98172. */
  98173. get view(): NodeMaterialConnectionPoint;
  98174. /**
  98175. * Gets the refraction object output component
  98176. */
  98177. get refraction(): NodeMaterialConnectionPoint;
  98178. /**
  98179. * Returns true if the block has a texture
  98180. */
  98181. get hasTexture(): boolean;
  98182. protected _getTexture(): Nullable<BaseTexture>;
  98183. autoConfigure(material: NodeMaterial): void;
  98184. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98185. isReady(): boolean;
  98186. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  98187. /**
  98188. * Gets the main code of the block (fragment side)
  98189. * @param state current state of the node material building
  98190. * @returns the shader code
  98191. */
  98192. getCode(state: NodeMaterialBuildState): string;
  98193. protected _buildBlock(state: NodeMaterialBuildState): this;
  98194. protected _dumpPropertiesCode(): string;
  98195. serialize(): any;
  98196. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98197. }
  98198. }
  98199. declare module BABYLON {
  98200. /**
  98201. * Base block used as input for post process
  98202. */
  98203. export class CurrentScreenBlock extends NodeMaterialBlock {
  98204. private _samplerName;
  98205. private _linearDefineName;
  98206. private _gammaDefineName;
  98207. private _mainUVName;
  98208. private _tempTextureRead;
  98209. /**
  98210. * Gets or sets the texture associated with the node
  98211. */
  98212. texture: Nullable<BaseTexture>;
  98213. /**
  98214. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98215. */
  98216. convertToGammaSpace: boolean;
  98217. /**
  98218. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98219. */
  98220. convertToLinearSpace: boolean;
  98221. /**
  98222. * Create a new CurrentScreenBlock
  98223. * @param name defines the block name
  98224. */
  98225. constructor(name: string);
  98226. /**
  98227. * Gets the current class name
  98228. * @returns the class name
  98229. */
  98230. getClassName(): string;
  98231. /**
  98232. * Gets the uv input component
  98233. */
  98234. get uv(): NodeMaterialConnectionPoint;
  98235. /**
  98236. * Gets the rgba output component
  98237. */
  98238. get rgba(): NodeMaterialConnectionPoint;
  98239. /**
  98240. * Gets the rgb output component
  98241. */
  98242. get rgb(): NodeMaterialConnectionPoint;
  98243. /**
  98244. * Gets the r output component
  98245. */
  98246. get r(): NodeMaterialConnectionPoint;
  98247. /**
  98248. * Gets the g output component
  98249. */
  98250. get g(): NodeMaterialConnectionPoint;
  98251. /**
  98252. * Gets the b output component
  98253. */
  98254. get b(): NodeMaterialConnectionPoint;
  98255. /**
  98256. * Gets the a output component
  98257. */
  98258. get a(): NodeMaterialConnectionPoint;
  98259. /**
  98260. * Initialize the block and prepare the context for build
  98261. * @param state defines the state that will be used for the build
  98262. */
  98263. initialize(state: NodeMaterialBuildState): void;
  98264. get target(): NodeMaterialBlockTargets;
  98265. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98266. isReady(): boolean;
  98267. private _injectVertexCode;
  98268. private _writeTextureRead;
  98269. private _writeOutput;
  98270. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98271. serialize(): any;
  98272. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98273. }
  98274. }
  98275. declare module BABYLON {
  98276. /**
  98277. * Base block used for the particle texture
  98278. */
  98279. export class ParticleTextureBlock extends NodeMaterialBlock {
  98280. private _samplerName;
  98281. private _linearDefineName;
  98282. private _gammaDefineName;
  98283. private _tempTextureRead;
  98284. /**
  98285. * Gets or sets the texture associated with the node
  98286. */
  98287. texture: Nullable<BaseTexture>;
  98288. /**
  98289. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98290. */
  98291. convertToGammaSpace: boolean;
  98292. /**
  98293. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98294. */
  98295. convertToLinearSpace: boolean;
  98296. /**
  98297. * Create a new ParticleTextureBlock
  98298. * @param name defines the block name
  98299. */
  98300. constructor(name: string);
  98301. /**
  98302. * Gets the current class name
  98303. * @returns the class name
  98304. */
  98305. getClassName(): string;
  98306. /**
  98307. * Gets the uv input component
  98308. */
  98309. get uv(): NodeMaterialConnectionPoint;
  98310. /**
  98311. * Gets the rgba output component
  98312. */
  98313. get rgba(): NodeMaterialConnectionPoint;
  98314. /**
  98315. * Gets the rgb output component
  98316. */
  98317. get rgb(): NodeMaterialConnectionPoint;
  98318. /**
  98319. * Gets the r output component
  98320. */
  98321. get r(): NodeMaterialConnectionPoint;
  98322. /**
  98323. * Gets the g output component
  98324. */
  98325. get g(): NodeMaterialConnectionPoint;
  98326. /**
  98327. * Gets the b output component
  98328. */
  98329. get b(): NodeMaterialConnectionPoint;
  98330. /**
  98331. * Gets the a output component
  98332. */
  98333. get a(): NodeMaterialConnectionPoint;
  98334. /**
  98335. * Initialize the block and prepare the context for build
  98336. * @param state defines the state that will be used for the build
  98337. */
  98338. initialize(state: NodeMaterialBuildState): void;
  98339. autoConfigure(material: NodeMaterial): void;
  98340. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98341. isReady(): boolean;
  98342. private _writeOutput;
  98343. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98344. serialize(): any;
  98345. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98346. }
  98347. }
  98348. declare module BABYLON {
  98349. /**
  98350. * Class used to store shared data between 2 NodeMaterialBuildState
  98351. */
  98352. export class NodeMaterialBuildStateSharedData {
  98353. /**
  98354. * Gets the list of emitted varyings
  98355. */
  98356. temps: string[];
  98357. /**
  98358. * Gets the list of emitted varyings
  98359. */
  98360. varyings: string[];
  98361. /**
  98362. * Gets the varying declaration string
  98363. */
  98364. varyingDeclaration: string;
  98365. /**
  98366. * Input blocks
  98367. */
  98368. inputBlocks: InputBlock[];
  98369. /**
  98370. * Input blocks
  98371. */
  98372. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  98373. /**
  98374. * Bindable blocks (Blocks that need to set data to the effect)
  98375. */
  98376. bindableBlocks: NodeMaterialBlock[];
  98377. /**
  98378. * List of blocks that can provide a compilation fallback
  98379. */
  98380. blocksWithFallbacks: NodeMaterialBlock[];
  98381. /**
  98382. * List of blocks that can provide a define update
  98383. */
  98384. blocksWithDefines: NodeMaterialBlock[];
  98385. /**
  98386. * List of blocks that can provide a repeatable content
  98387. */
  98388. repeatableContentBlocks: NodeMaterialBlock[];
  98389. /**
  98390. * List of blocks that can provide a dynamic list of uniforms
  98391. */
  98392. dynamicUniformBlocks: NodeMaterialBlock[];
  98393. /**
  98394. * List of blocks that can block the isReady function for the material
  98395. */
  98396. blockingBlocks: NodeMaterialBlock[];
  98397. /**
  98398. * Gets the list of animated inputs
  98399. */
  98400. animatedInputs: InputBlock[];
  98401. /**
  98402. * Build Id used to avoid multiple recompilations
  98403. */
  98404. buildId: number;
  98405. /** List of emitted variables */
  98406. variableNames: {
  98407. [key: string]: number;
  98408. };
  98409. /** List of emitted defines */
  98410. defineNames: {
  98411. [key: string]: number;
  98412. };
  98413. /** Should emit comments? */
  98414. emitComments: boolean;
  98415. /** Emit build activity */
  98416. verbose: boolean;
  98417. /** Gets or sets the hosting scene */
  98418. scene: Scene;
  98419. /**
  98420. * Gets the compilation hints emitted at compilation time
  98421. */
  98422. hints: {
  98423. needWorldViewMatrix: boolean;
  98424. needWorldViewProjectionMatrix: boolean;
  98425. needAlphaBlending: boolean;
  98426. needAlphaTesting: boolean;
  98427. };
  98428. /**
  98429. * List of compilation checks
  98430. */
  98431. checks: {
  98432. emitVertex: boolean;
  98433. emitFragment: boolean;
  98434. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  98435. };
  98436. /**
  98437. * Is vertex program allowed to be empty?
  98438. */
  98439. allowEmptyVertexProgram: boolean;
  98440. /** Creates a new shared data */
  98441. constructor();
  98442. /**
  98443. * Emits console errors and exceptions if there is a failing check
  98444. */
  98445. emitErrors(): void;
  98446. }
  98447. }
  98448. declare module BABYLON {
  98449. /**
  98450. * Class used to store node based material build state
  98451. */
  98452. export class NodeMaterialBuildState {
  98453. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  98454. supportUniformBuffers: boolean;
  98455. /**
  98456. * Gets the list of emitted attributes
  98457. */
  98458. attributes: string[];
  98459. /**
  98460. * Gets the list of emitted uniforms
  98461. */
  98462. uniforms: string[];
  98463. /**
  98464. * Gets the list of emitted constants
  98465. */
  98466. constants: string[];
  98467. /**
  98468. * Gets the list of emitted samplers
  98469. */
  98470. samplers: string[];
  98471. /**
  98472. * Gets the list of emitted functions
  98473. */
  98474. functions: {
  98475. [key: string]: string;
  98476. };
  98477. /**
  98478. * Gets the list of emitted extensions
  98479. */
  98480. extensions: {
  98481. [key: string]: string;
  98482. };
  98483. /**
  98484. * Gets the target of the compilation state
  98485. */
  98486. target: NodeMaterialBlockTargets;
  98487. /**
  98488. * Gets the list of emitted counters
  98489. */
  98490. counters: {
  98491. [key: string]: number;
  98492. };
  98493. /**
  98494. * Shared data between multiple NodeMaterialBuildState instances
  98495. */
  98496. sharedData: NodeMaterialBuildStateSharedData;
  98497. /** @hidden */
  98498. _vertexState: NodeMaterialBuildState;
  98499. /** @hidden */
  98500. _attributeDeclaration: string;
  98501. /** @hidden */
  98502. _uniformDeclaration: string;
  98503. /** @hidden */
  98504. _constantDeclaration: string;
  98505. /** @hidden */
  98506. _samplerDeclaration: string;
  98507. /** @hidden */
  98508. _varyingTransfer: string;
  98509. /** @hidden */
  98510. _injectAtEnd: string;
  98511. private _repeatableContentAnchorIndex;
  98512. /** @hidden */
  98513. _builtCompilationString: string;
  98514. /**
  98515. * Gets the emitted compilation strings
  98516. */
  98517. compilationString: string;
  98518. /**
  98519. * Finalize the compilation strings
  98520. * @param state defines the current compilation state
  98521. */
  98522. finalize(state: NodeMaterialBuildState): void;
  98523. /** @hidden */
  98524. get _repeatableContentAnchor(): string;
  98525. /** @hidden */
  98526. _getFreeVariableName(prefix: string): string;
  98527. /** @hidden */
  98528. _getFreeDefineName(prefix: string): string;
  98529. /** @hidden */
  98530. _excludeVariableName(name: string): void;
  98531. /** @hidden */
  98532. _emit2DSampler(name: string): void;
  98533. /** @hidden */
  98534. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  98535. /** @hidden */
  98536. _emitExtension(name: string, extension: string, define?: string): void;
  98537. /** @hidden */
  98538. _emitFunction(name: string, code: string, comments: string): void;
  98539. /** @hidden */
  98540. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  98541. replaceStrings?: {
  98542. search: RegExp;
  98543. replace: string;
  98544. }[];
  98545. repeatKey?: string;
  98546. }): string;
  98547. /** @hidden */
  98548. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  98549. repeatKey?: string;
  98550. removeAttributes?: boolean;
  98551. removeUniforms?: boolean;
  98552. removeVaryings?: boolean;
  98553. removeIfDef?: boolean;
  98554. replaceStrings?: {
  98555. search: RegExp;
  98556. replace: string;
  98557. }[];
  98558. }, storeKey?: string): void;
  98559. /** @hidden */
  98560. _registerTempVariable(name: string): boolean;
  98561. /** @hidden */
  98562. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  98563. /** @hidden */
  98564. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  98565. /** @hidden */
  98566. _emitFloat(value: number): string;
  98567. }
  98568. }
  98569. declare module BABYLON {
  98570. /**
  98571. * Helper class used to generate session unique ID
  98572. */
  98573. export class UniqueIdGenerator {
  98574. private static _UniqueIdCounter;
  98575. /**
  98576. * Gets an unique (relatively to the current scene) Id
  98577. */
  98578. static get UniqueId(): number;
  98579. }
  98580. }
  98581. declare module BABYLON {
  98582. /**
  98583. * Defines a block that can be used inside a node based material
  98584. */
  98585. export class NodeMaterialBlock {
  98586. private _buildId;
  98587. private _buildTarget;
  98588. private _target;
  98589. private _isFinalMerger;
  98590. private _isInput;
  98591. protected _isUnique: boolean;
  98592. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  98593. inputsAreExclusive: boolean;
  98594. /** @hidden */
  98595. _codeVariableName: string;
  98596. /** @hidden */
  98597. _inputs: NodeMaterialConnectionPoint[];
  98598. /** @hidden */
  98599. _outputs: NodeMaterialConnectionPoint[];
  98600. /** @hidden */
  98601. _preparationId: number;
  98602. /**
  98603. * Gets or sets the name of the block
  98604. */
  98605. name: string;
  98606. /**
  98607. * Gets or sets the unique id of the node
  98608. */
  98609. uniqueId: number;
  98610. /**
  98611. * Gets or sets the comments associated with this block
  98612. */
  98613. comments: string;
  98614. /**
  98615. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  98616. */
  98617. get isUnique(): boolean;
  98618. /**
  98619. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  98620. */
  98621. get isFinalMerger(): boolean;
  98622. /**
  98623. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  98624. */
  98625. get isInput(): boolean;
  98626. /**
  98627. * Gets or sets the build Id
  98628. */
  98629. get buildId(): number;
  98630. set buildId(value: number);
  98631. /**
  98632. * Gets or sets the target of the block
  98633. */
  98634. get target(): NodeMaterialBlockTargets;
  98635. set target(value: NodeMaterialBlockTargets);
  98636. /**
  98637. * Gets the list of input points
  98638. */
  98639. get inputs(): NodeMaterialConnectionPoint[];
  98640. /** Gets the list of output points */
  98641. get outputs(): NodeMaterialConnectionPoint[];
  98642. /**
  98643. * Find an input by its name
  98644. * @param name defines the name of the input to look for
  98645. * @returns the input or null if not found
  98646. */
  98647. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  98648. /**
  98649. * Find an output by its name
  98650. * @param name defines the name of the outputto look for
  98651. * @returns the output or null if not found
  98652. */
  98653. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  98654. /**
  98655. * Creates a new NodeMaterialBlock
  98656. * @param name defines the block name
  98657. * @param target defines the target of that block (Vertex by default)
  98658. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  98659. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  98660. */
  98661. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  98662. /**
  98663. * Initialize the block and prepare the context for build
  98664. * @param state defines the state that will be used for the build
  98665. */
  98666. initialize(state: NodeMaterialBuildState): void;
  98667. /**
  98668. * Bind data to effect. Will only be called for blocks with isBindable === true
  98669. * @param effect defines the effect to bind data to
  98670. * @param nodeMaterial defines the hosting NodeMaterial
  98671. * @param mesh defines the mesh that will be rendered
  98672. * @param subMesh defines the submesh that will be rendered
  98673. */
  98674. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  98675. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  98676. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  98677. protected _writeFloat(value: number): string;
  98678. /**
  98679. * Gets the current class name e.g. "NodeMaterialBlock"
  98680. * @returns the class name
  98681. */
  98682. getClassName(): string;
  98683. /**
  98684. * Register a new input. Must be called inside a block constructor
  98685. * @param name defines the connection point name
  98686. * @param type defines the connection point type
  98687. * @param isOptional defines a boolean indicating that this input can be omitted
  98688. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  98689. * @param point an already created connection point. If not provided, create a new one
  98690. * @returns the current block
  98691. */
  98692. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  98693. /**
  98694. * Register a new output. Must be called inside a block constructor
  98695. * @param name defines the connection point name
  98696. * @param type defines the connection point type
  98697. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  98698. * @param point an already created connection point. If not provided, create a new one
  98699. * @returns the current block
  98700. */
  98701. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  98702. /**
  98703. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  98704. * @param forOutput defines an optional connection point to check compatibility with
  98705. * @returns the first available input or null
  98706. */
  98707. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  98708. /**
  98709. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  98710. * @param forBlock defines an optional block to check compatibility with
  98711. * @returns the first available input or null
  98712. */
  98713. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  98714. /**
  98715. * Gets the sibling of the given output
  98716. * @param current defines the current output
  98717. * @returns the next output in the list or null
  98718. */
  98719. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  98720. /**
  98721. * Connect current block with another block
  98722. * @param other defines the block to connect with
  98723. * @param options define the various options to help pick the right connections
  98724. * @returns the current block
  98725. */
  98726. connectTo(other: NodeMaterialBlock, options?: {
  98727. input?: string;
  98728. output?: string;
  98729. outputSwizzle?: string;
  98730. }): this | undefined;
  98731. protected _buildBlock(state: NodeMaterialBuildState): void;
  98732. /**
  98733. * Add uniforms, samplers and uniform buffers at compilation time
  98734. * @param state defines the state to update
  98735. * @param nodeMaterial defines the node material requesting the update
  98736. * @param defines defines the material defines to update
  98737. * @param uniformBuffers defines the list of uniform buffer names
  98738. */
  98739. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  98740. /**
  98741. * Add potential fallbacks if shader compilation fails
  98742. * @param mesh defines the mesh to be rendered
  98743. * @param fallbacks defines the current prioritized list of fallbacks
  98744. */
  98745. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  98746. /**
  98747. * Initialize defines for shader compilation
  98748. * @param mesh defines the mesh to be rendered
  98749. * @param nodeMaterial defines the node material requesting the update
  98750. * @param defines defines the material defines to update
  98751. * @param useInstances specifies that instances should be used
  98752. */
  98753. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  98754. /**
  98755. * Update defines for shader compilation
  98756. * @param mesh defines the mesh to be rendered
  98757. * @param nodeMaterial defines the node material requesting the update
  98758. * @param defines defines the material defines to update
  98759. * @param useInstances specifies that instances should be used
  98760. * @param subMesh defines which submesh to render
  98761. */
  98762. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  98763. /**
  98764. * Lets the block try to connect some inputs automatically
  98765. * @param material defines the hosting NodeMaterial
  98766. */
  98767. autoConfigure(material: NodeMaterial): void;
  98768. /**
  98769. * Function called when a block is declared as repeatable content generator
  98770. * @param vertexShaderState defines the current compilation state for the vertex shader
  98771. * @param fragmentShaderState defines the current compilation state for the fragment shader
  98772. * @param mesh defines the mesh to be rendered
  98773. * @param defines defines the material defines to update
  98774. */
  98775. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  98776. /**
  98777. * Checks if the block is ready
  98778. * @param mesh defines the mesh to be rendered
  98779. * @param nodeMaterial defines the node material requesting the update
  98780. * @param defines defines the material defines to update
  98781. * @param useInstances specifies that instances should be used
  98782. * @returns true if the block is ready
  98783. */
  98784. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  98785. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  98786. private _processBuild;
  98787. /**
  98788. * Compile the current node and generate the shader code
  98789. * @param state defines the current compilation state (uniforms, samplers, current string)
  98790. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  98791. * @returns true if already built
  98792. */
  98793. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  98794. protected _inputRename(name: string): string;
  98795. protected _outputRename(name: string): string;
  98796. protected _dumpPropertiesCode(): string;
  98797. /** @hidden */
  98798. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  98799. /** @hidden */
  98800. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  98801. /**
  98802. * Clone the current block to a new identical block
  98803. * @param scene defines the hosting scene
  98804. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98805. * @returns a copy of the current block
  98806. */
  98807. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  98808. /**
  98809. * Serializes this block in a JSON representation
  98810. * @returns the serialized block object
  98811. */
  98812. serialize(): any;
  98813. /** @hidden */
  98814. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98815. private _deserializePortDisplayNames;
  98816. /**
  98817. * Release resources
  98818. */
  98819. dispose(): void;
  98820. }
  98821. }
  98822. declare module BABYLON {
  98823. /**
  98824. * Base class of materials working in push mode in babylon JS
  98825. * @hidden
  98826. */
  98827. export class PushMaterial extends Material {
  98828. protected _activeEffect: Effect;
  98829. protected _normalMatrix: Matrix;
  98830. /**
  98831. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  98832. * This means that the material can keep using a previous shader while a new one is being compiled.
  98833. * This is mostly used when shader parallel compilation is supported (true by default)
  98834. */
  98835. allowShaderHotSwapping: boolean;
  98836. constructor(name: string, scene: Scene);
  98837. getEffect(): Effect;
  98838. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98839. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  98840. /**
  98841. * Binds the given world matrix to the active effect
  98842. *
  98843. * @param world the matrix to bind
  98844. */
  98845. bindOnlyWorldMatrix(world: Matrix): void;
  98846. /**
  98847. * Binds the given normal matrix to the active effect
  98848. *
  98849. * @param normalMatrix the matrix to bind
  98850. */
  98851. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98852. bind(world: Matrix, mesh?: Mesh): void;
  98853. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98854. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98855. }
  98856. }
  98857. declare module BABYLON {
  98858. /**
  98859. * Root class for all node material optimizers
  98860. */
  98861. export class NodeMaterialOptimizer {
  98862. /**
  98863. * Function used to optimize a NodeMaterial graph
  98864. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  98865. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  98866. */
  98867. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  98868. }
  98869. }
  98870. declare module BABYLON {
  98871. /**
  98872. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  98873. */
  98874. export class TransformBlock extends NodeMaterialBlock {
  98875. /**
  98876. * Defines the value to use to complement W value to transform it to a Vector4
  98877. */
  98878. complementW: number;
  98879. /**
  98880. * Defines the value to use to complement z value to transform it to a Vector4
  98881. */
  98882. complementZ: number;
  98883. /**
  98884. * Creates a new TransformBlock
  98885. * @param name defines the block name
  98886. */
  98887. constructor(name: string);
  98888. /**
  98889. * Gets the current class name
  98890. * @returns the class name
  98891. */
  98892. getClassName(): string;
  98893. /**
  98894. * Gets the vector input
  98895. */
  98896. get vector(): NodeMaterialConnectionPoint;
  98897. /**
  98898. * Gets the output component
  98899. */
  98900. get output(): NodeMaterialConnectionPoint;
  98901. /**
  98902. * Gets the xyz output component
  98903. */
  98904. get xyz(): NodeMaterialConnectionPoint;
  98905. /**
  98906. * Gets the matrix transform input
  98907. */
  98908. get transform(): NodeMaterialConnectionPoint;
  98909. protected _buildBlock(state: NodeMaterialBuildState): this;
  98910. /**
  98911. * Update defines for shader compilation
  98912. * @param mesh defines the mesh to be rendered
  98913. * @param nodeMaterial defines the node material requesting the update
  98914. * @param defines defines the material defines to update
  98915. * @param useInstances specifies that instances should be used
  98916. * @param subMesh defines which submesh to render
  98917. */
  98918. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  98919. serialize(): any;
  98920. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98921. protected _dumpPropertiesCode(): string;
  98922. }
  98923. }
  98924. declare module BABYLON {
  98925. /**
  98926. * Block used to output the vertex position
  98927. */
  98928. export class VertexOutputBlock extends NodeMaterialBlock {
  98929. /**
  98930. * Creates a new VertexOutputBlock
  98931. * @param name defines the block name
  98932. */
  98933. constructor(name: string);
  98934. /**
  98935. * Gets the current class name
  98936. * @returns the class name
  98937. */
  98938. getClassName(): string;
  98939. /**
  98940. * Gets the vector input component
  98941. */
  98942. get vector(): NodeMaterialConnectionPoint;
  98943. protected _buildBlock(state: NodeMaterialBuildState): this;
  98944. }
  98945. }
  98946. declare module BABYLON {
  98947. /**
  98948. * Block used to output the final color
  98949. */
  98950. export class FragmentOutputBlock extends NodeMaterialBlock {
  98951. /**
  98952. * Create a new FragmentOutputBlock
  98953. * @param name defines the block name
  98954. */
  98955. constructor(name: string);
  98956. /**
  98957. * Gets the current class name
  98958. * @returns the class name
  98959. */
  98960. getClassName(): string;
  98961. /**
  98962. * Gets the rgba input component
  98963. */
  98964. get rgba(): NodeMaterialConnectionPoint;
  98965. /**
  98966. * Gets the rgb input component
  98967. */
  98968. get rgb(): NodeMaterialConnectionPoint;
  98969. /**
  98970. * Gets the a input component
  98971. */
  98972. get a(): NodeMaterialConnectionPoint;
  98973. protected _buildBlock(state: NodeMaterialBuildState): this;
  98974. }
  98975. }
  98976. declare module BABYLON {
  98977. /**
  98978. * Block used for the particle ramp gradient section
  98979. */
  98980. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  98981. /**
  98982. * Create a new ParticleRampGradientBlock
  98983. * @param name defines the block name
  98984. */
  98985. constructor(name: string);
  98986. /**
  98987. * Gets the current class name
  98988. * @returns the class name
  98989. */
  98990. getClassName(): string;
  98991. /**
  98992. * Gets the color input component
  98993. */
  98994. get color(): NodeMaterialConnectionPoint;
  98995. /**
  98996. * Gets the rampColor output component
  98997. */
  98998. get rampColor(): NodeMaterialConnectionPoint;
  98999. /**
  99000. * Initialize the block and prepare the context for build
  99001. * @param state defines the state that will be used for the build
  99002. */
  99003. initialize(state: NodeMaterialBuildState): void;
  99004. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99005. }
  99006. }
  99007. declare module BABYLON {
  99008. /**
  99009. * Block used for the particle blend multiply section
  99010. */
  99011. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  99012. /**
  99013. * Create a new ParticleBlendMultiplyBlock
  99014. * @param name defines the block name
  99015. */
  99016. constructor(name: string);
  99017. /**
  99018. * Gets the current class name
  99019. * @returns the class name
  99020. */
  99021. getClassName(): string;
  99022. /**
  99023. * Gets the color input component
  99024. */
  99025. get color(): NodeMaterialConnectionPoint;
  99026. /**
  99027. * Gets the alphaTexture input component
  99028. */
  99029. get alphaTexture(): NodeMaterialConnectionPoint;
  99030. /**
  99031. * Gets the alphaColor input component
  99032. */
  99033. get alphaColor(): NodeMaterialConnectionPoint;
  99034. /**
  99035. * Gets the blendColor output component
  99036. */
  99037. get blendColor(): NodeMaterialConnectionPoint;
  99038. /**
  99039. * Initialize the block and prepare the context for build
  99040. * @param state defines the state that will be used for the build
  99041. */
  99042. initialize(state: NodeMaterialBuildState): void;
  99043. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99044. }
  99045. }
  99046. declare module BABYLON {
  99047. /**
  99048. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  99049. */
  99050. export class VectorMergerBlock extends NodeMaterialBlock {
  99051. /**
  99052. * Create a new VectorMergerBlock
  99053. * @param name defines the block name
  99054. */
  99055. constructor(name: string);
  99056. /**
  99057. * Gets the current class name
  99058. * @returns the class name
  99059. */
  99060. getClassName(): string;
  99061. /**
  99062. * Gets the xyz component (input)
  99063. */
  99064. get xyzIn(): NodeMaterialConnectionPoint;
  99065. /**
  99066. * Gets the xy component (input)
  99067. */
  99068. get xyIn(): NodeMaterialConnectionPoint;
  99069. /**
  99070. * Gets the x component (input)
  99071. */
  99072. get x(): NodeMaterialConnectionPoint;
  99073. /**
  99074. * Gets the y component (input)
  99075. */
  99076. get y(): NodeMaterialConnectionPoint;
  99077. /**
  99078. * Gets the z component (input)
  99079. */
  99080. get z(): NodeMaterialConnectionPoint;
  99081. /**
  99082. * Gets the w component (input)
  99083. */
  99084. get w(): NodeMaterialConnectionPoint;
  99085. /**
  99086. * Gets the xyzw component (output)
  99087. */
  99088. get xyzw(): NodeMaterialConnectionPoint;
  99089. /**
  99090. * Gets the xyz component (output)
  99091. */
  99092. get xyzOut(): NodeMaterialConnectionPoint;
  99093. /**
  99094. * Gets the xy component (output)
  99095. */
  99096. get xyOut(): NodeMaterialConnectionPoint;
  99097. /**
  99098. * Gets the xy component (output)
  99099. * @deprecated Please use xyOut instead.
  99100. */
  99101. get xy(): NodeMaterialConnectionPoint;
  99102. /**
  99103. * Gets the xyz component (output)
  99104. * @deprecated Please use xyzOut instead.
  99105. */
  99106. get xyz(): NodeMaterialConnectionPoint;
  99107. protected _buildBlock(state: NodeMaterialBuildState): this;
  99108. }
  99109. }
  99110. declare module BABYLON {
  99111. /**
  99112. * Block used to remap a float from a range to a new one
  99113. */
  99114. export class RemapBlock extends NodeMaterialBlock {
  99115. /**
  99116. * Gets or sets the source range
  99117. */
  99118. sourceRange: Vector2;
  99119. /**
  99120. * Gets or sets the target range
  99121. */
  99122. targetRange: Vector2;
  99123. /**
  99124. * Creates a new RemapBlock
  99125. * @param name defines the block name
  99126. */
  99127. constructor(name: string);
  99128. /**
  99129. * Gets the current class name
  99130. * @returns the class name
  99131. */
  99132. getClassName(): string;
  99133. /**
  99134. * Gets the input component
  99135. */
  99136. get input(): NodeMaterialConnectionPoint;
  99137. /**
  99138. * Gets the source min input component
  99139. */
  99140. get sourceMin(): NodeMaterialConnectionPoint;
  99141. /**
  99142. * Gets the source max input component
  99143. */
  99144. get sourceMax(): NodeMaterialConnectionPoint;
  99145. /**
  99146. * Gets the target min input component
  99147. */
  99148. get targetMin(): NodeMaterialConnectionPoint;
  99149. /**
  99150. * Gets the target max input component
  99151. */
  99152. get targetMax(): NodeMaterialConnectionPoint;
  99153. /**
  99154. * Gets the output component
  99155. */
  99156. get output(): NodeMaterialConnectionPoint;
  99157. protected _buildBlock(state: NodeMaterialBuildState): this;
  99158. protected _dumpPropertiesCode(): string;
  99159. serialize(): any;
  99160. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99161. }
  99162. }
  99163. declare module BABYLON {
  99164. /**
  99165. * Block used to multiply 2 values
  99166. */
  99167. export class MultiplyBlock extends NodeMaterialBlock {
  99168. /**
  99169. * Creates a new MultiplyBlock
  99170. * @param name defines the block name
  99171. */
  99172. constructor(name: string);
  99173. /**
  99174. * Gets the current class name
  99175. * @returns the class name
  99176. */
  99177. getClassName(): string;
  99178. /**
  99179. * Gets the left operand input component
  99180. */
  99181. get left(): NodeMaterialConnectionPoint;
  99182. /**
  99183. * Gets the right operand input component
  99184. */
  99185. get right(): NodeMaterialConnectionPoint;
  99186. /**
  99187. * Gets the output component
  99188. */
  99189. get output(): NodeMaterialConnectionPoint;
  99190. protected _buildBlock(state: NodeMaterialBuildState): this;
  99191. }
  99192. }
  99193. declare module BABYLON {
  99194. /**
  99195. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  99196. */
  99197. export class ColorSplitterBlock extends NodeMaterialBlock {
  99198. /**
  99199. * Create a new ColorSplitterBlock
  99200. * @param name defines the block name
  99201. */
  99202. constructor(name: string);
  99203. /**
  99204. * Gets the current class name
  99205. * @returns the class name
  99206. */
  99207. getClassName(): string;
  99208. /**
  99209. * Gets the rgba component (input)
  99210. */
  99211. get rgba(): NodeMaterialConnectionPoint;
  99212. /**
  99213. * Gets the rgb component (input)
  99214. */
  99215. get rgbIn(): NodeMaterialConnectionPoint;
  99216. /**
  99217. * Gets the rgb component (output)
  99218. */
  99219. get rgbOut(): NodeMaterialConnectionPoint;
  99220. /**
  99221. * Gets the r component (output)
  99222. */
  99223. get r(): NodeMaterialConnectionPoint;
  99224. /**
  99225. * Gets the g component (output)
  99226. */
  99227. get g(): NodeMaterialConnectionPoint;
  99228. /**
  99229. * Gets the b component (output)
  99230. */
  99231. get b(): NodeMaterialConnectionPoint;
  99232. /**
  99233. * Gets the a component (output)
  99234. */
  99235. get a(): NodeMaterialConnectionPoint;
  99236. protected _inputRename(name: string): string;
  99237. protected _outputRename(name: string): string;
  99238. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99239. }
  99240. }
  99241. declare module BABYLON {
  99242. /**
  99243. * Interface used to configure the node material editor
  99244. */
  99245. export interface INodeMaterialEditorOptions {
  99246. /** Define the URl to load node editor script */
  99247. editorURL?: string;
  99248. }
  99249. /** @hidden */
  99250. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99251. NORMAL: boolean;
  99252. TANGENT: boolean;
  99253. UV1: boolean;
  99254. /** BONES */
  99255. NUM_BONE_INFLUENCERS: number;
  99256. BonesPerMesh: number;
  99257. BONETEXTURE: boolean;
  99258. /** MORPH TARGETS */
  99259. MORPHTARGETS: boolean;
  99260. MORPHTARGETS_NORMAL: boolean;
  99261. MORPHTARGETS_TANGENT: boolean;
  99262. MORPHTARGETS_UV: boolean;
  99263. NUM_MORPH_INFLUENCERS: number;
  99264. /** IMAGE PROCESSING */
  99265. IMAGEPROCESSING: boolean;
  99266. VIGNETTE: boolean;
  99267. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99268. VIGNETTEBLENDMODEOPAQUE: boolean;
  99269. TONEMAPPING: boolean;
  99270. TONEMAPPING_ACES: boolean;
  99271. CONTRAST: boolean;
  99272. EXPOSURE: boolean;
  99273. COLORCURVES: boolean;
  99274. COLORGRADING: boolean;
  99275. COLORGRADING3D: boolean;
  99276. SAMPLER3DGREENDEPTH: boolean;
  99277. SAMPLER3DBGRMAP: boolean;
  99278. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99279. /** MISC. */
  99280. BUMPDIRECTUV: number;
  99281. constructor();
  99282. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  99283. }
  99284. /**
  99285. * Class used to configure NodeMaterial
  99286. */
  99287. export interface INodeMaterialOptions {
  99288. /**
  99289. * Defines if blocks should emit comments
  99290. */
  99291. emitComments: boolean;
  99292. }
  99293. /**
  99294. * Class used to create a node based material built by assembling shader blocks
  99295. */
  99296. export class NodeMaterial extends PushMaterial {
  99297. private static _BuildIdGenerator;
  99298. private _options;
  99299. private _vertexCompilationState;
  99300. private _fragmentCompilationState;
  99301. private _sharedData;
  99302. private _buildId;
  99303. private _buildWasSuccessful;
  99304. private _cachedWorldViewMatrix;
  99305. private _cachedWorldViewProjectionMatrix;
  99306. private _optimizers;
  99307. private _animationFrame;
  99308. /** Define the Url to load node editor script */
  99309. static EditorURL: string;
  99310. /** Define the Url to load snippets */
  99311. static SnippetUrl: string;
  99312. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  99313. static IgnoreTexturesAtLoadTime: boolean;
  99314. private BJSNODEMATERIALEDITOR;
  99315. /** Get the inspector from bundle or global */
  99316. private _getGlobalNodeMaterialEditor;
  99317. /**
  99318. * Snippet ID if the material was created from the snippet server
  99319. */
  99320. snippetId: string;
  99321. /**
  99322. * Gets or sets data used by visual editor
  99323. * @see https://nme.babylonjs.com
  99324. */
  99325. editorData: any;
  99326. /**
  99327. * 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)
  99328. */
  99329. ignoreAlpha: boolean;
  99330. /**
  99331. * Defines the maximum number of lights that can be used in the material
  99332. */
  99333. maxSimultaneousLights: number;
  99334. /**
  99335. * Observable raised when the material is built
  99336. */
  99337. onBuildObservable: Observable<NodeMaterial>;
  99338. /**
  99339. * Gets or sets the root nodes of the material vertex shader
  99340. */
  99341. _vertexOutputNodes: NodeMaterialBlock[];
  99342. /**
  99343. * Gets or sets the root nodes of the material fragment (pixel) shader
  99344. */
  99345. _fragmentOutputNodes: NodeMaterialBlock[];
  99346. /** Gets or sets options to control the node material overall behavior */
  99347. get options(): INodeMaterialOptions;
  99348. set options(options: INodeMaterialOptions);
  99349. /**
  99350. * Default configuration related to image processing available in the standard Material.
  99351. */
  99352. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99353. /**
  99354. * Gets the image processing configuration used either in this material.
  99355. */
  99356. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99357. /**
  99358. * Sets the Default image processing configuration used either in the this material.
  99359. *
  99360. * If sets to null, the scene one is in use.
  99361. */
  99362. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99363. /**
  99364. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  99365. */
  99366. attachedBlocks: NodeMaterialBlock[];
  99367. /**
  99368. * Specifies the mode of the node material
  99369. * @hidden
  99370. */
  99371. _mode: NodeMaterialModes;
  99372. /**
  99373. * Gets the mode property
  99374. */
  99375. get mode(): NodeMaterialModes;
  99376. /**
  99377. * Create a new node based material
  99378. * @param name defines the material name
  99379. * @param scene defines the hosting scene
  99380. * @param options defines creation option
  99381. */
  99382. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  99383. /**
  99384. * Gets the current class name of the material e.g. "NodeMaterial"
  99385. * @returns the class name
  99386. */
  99387. getClassName(): string;
  99388. /**
  99389. * Keep track of the image processing observer to allow dispose and replace.
  99390. */
  99391. private _imageProcessingObserver;
  99392. /**
  99393. * Attaches a new image processing configuration to the Standard Material.
  99394. * @param configuration
  99395. */
  99396. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99397. /**
  99398. * Get a block by its name
  99399. * @param name defines the name of the block to retrieve
  99400. * @returns the required block or null if not found
  99401. */
  99402. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  99403. /**
  99404. * Get a block by its name
  99405. * @param predicate defines the predicate used to find the good candidate
  99406. * @returns the required block or null if not found
  99407. */
  99408. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  99409. /**
  99410. * Get an input block by its name
  99411. * @param predicate defines the predicate used to find the good candidate
  99412. * @returns the required input block or null if not found
  99413. */
  99414. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  99415. /**
  99416. * Gets the list of input blocks attached to this material
  99417. * @returns an array of InputBlocks
  99418. */
  99419. getInputBlocks(): InputBlock[];
  99420. /**
  99421. * Adds a new optimizer to the list of optimizers
  99422. * @param optimizer defines the optimizers to add
  99423. * @returns the current material
  99424. */
  99425. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99426. /**
  99427. * Remove an optimizer from the list of optimizers
  99428. * @param optimizer defines the optimizers to remove
  99429. * @returns the current material
  99430. */
  99431. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99432. /**
  99433. * Add a new block to the list of output nodes
  99434. * @param node defines the node to add
  99435. * @returns the current material
  99436. */
  99437. addOutputNode(node: NodeMaterialBlock): this;
  99438. /**
  99439. * Remove a block from the list of root nodes
  99440. * @param node defines the node to remove
  99441. * @returns the current material
  99442. */
  99443. removeOutputNode(node: NodeMaterialBlock): this;
  99444. private _addVertexOutputNode;
  99445. private _removeVertexOutputNode;
  99446. private _addFragmentOutputNode;
  99447. private _removeFragmentOutputNode;
  99448. /**
  99449. * Specifies if the material will require alpha blending
  99450. * @returns a boolean specifying if alpha blending is needed
  99451. */
  99452. needAlphaBlending(): boolean;
  99453. /**
  99454. * Specifies if this material should be rendered in alpha test mode
  99455. * @returns a boolean specifying if an alpha test is needed.
  99456. */
  99457. needAlphaTesting(): boolean;
  99458. private _initializeBlock;
  99459. private _resetDualBlocks;
  99460. /**
  99461. * Remove a block from the current node material
  99462. * @param block defines the block to remove
  99463. */
  99464. removeBlock(block: NodeMaterialBlock): void;
  99465. /**
  99466. * Build the material and generates the inner effect
  99467. * @param verbose defines if the build should log activity
  99468. */
  99469. build(verbose?: boolean): void;
  99470. /**
  99471. * Runs an otpimization phase to try to improve the shader code
  99472. */
  99473. optimize(): void;
  99474. private _prepareDefinesForAttributes;
  99475. /**
  99476. * Create a post process from the material
  99477. * @param camera The camera to apply the render pass to.
  99478. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99479. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99480. * @param engine The engine which the post process will be applied. (default: current engine)
  99481. * @param reusable If the post process can be reused on the same frame. (default: false)
  99482. * @param textureType Type of textures used when performing the post process. (default: 0)
  99483. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  99484. * @returns the post process created
  99485. */
  99486. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  99487. /**
  99488. * Create the post process effect from the material
  99489. * @param postProcess The post process to create the effect for
  99490. */
  99491. createEffectForPostProcess(postProcess: PostProcess): void;
  99492. private _createEffectOrPostProcess;
  99493. private _createEffectForParticles;
  99494. /**
  99495. * Create the effect to be used as the custom effect for a particle system
  99496. * @param particleSystem Particle system to create the effect for
  99497. * @param onCompiled defines a function to call when the effect creation is successful
  99498. * @param onError defines a function to call when the effect creation has failed
  99499. */
  99500. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  99501. private _processDefines;
  99502. /**
  99503. * Get if the submesh is ready to be used and all its information available.
  99504. * Child classes can use it to update shaders
  99505. * @param mesh defines the mesh to check
  99506. * @param subMesh defines which submesh to check
  99507. * @param useInstances specifies that instances should be used
  99508. * @returns a boolean indicating that the submesh is ready or not
  99509. */
  99510. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99511. /**
  99512. * Get a string representing the shaders built by the current node graph
  99513. */
  99514. get compiledShaders(): string;
  99515. /**
  99516. * Binds the world matrix to the material
  99517. * @param world defines the world transformation matrix
  99518. */
  99519. bindOnlyWorldMatrix(world: Matrix): void;
  99520. /**
  99521. * Binds the submesh to this material by preparing the effect and shader to draw
  99522. * @param world defines the world transformation matrix
  99523. * @param mesh defines the mesh containing the submesh
  99524. * @param subMesh defines the submesh to bind the material to
  99525. */
  99526. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99527. /**
  99528. * Gets the active textures from the material
  99529. * @returns an array of textures
  99530. */
  99531. getActiveTextures(): BaseTexture[];
  99532. /**
  99533. * Gets the list of texture blocks
  99534. * @returns an array of texture blocks
  99535. */
  99536. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  99537. /**
  99538. * Specifies if the material uses a texture
  99539. * @param texture defines the texture to check against the material
  99540. * @returns a boolean specifying if the material uses the texture
  99541. */
  99542. hasTexture(texture: BaseTexture): boolean;
  99543. /**
  99544. * Disposes the material
  99545. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  99546. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  99547. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  99548. */
  99549. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  99550. /** Creates the node editor window. */
  99551. private _createNodeEditor;
  99552. /**
  99553. * Launch the node material editor
  99554. * @param config Define the configuration of the editor
  99555. * @return a promise fulfilled when the node editor is visible
  99556. */
  99557. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  99558. /**
  99559. * Clear the current material
  99560. */
  99561. clear(): void;
  99562. /**
  99563. * Clear the current material and set it to a default state
  99564. */
  99565. setToDefault(): void;
  99566. /**
  99567. * Clear the current material and set it to a default state for post process
  99568. */
  99569. setToDefaultPostProcess(): void;
  99570. /**
  99571. * Clear the current material and set it to a default state for particle
  99572. */
  99573. setToDefaultParticle(): void;
  99574. /**
  99575. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  99576. * @param url defines the url to load from
  99577. * @returns a promise that will fullfil when the material is fully loaded
  99578. */
  99579. loadAsync(url: string): Promise<void>;
  99580. private _gatherBlocks;
  99581. /**
  99582. * Generate a string containing the code declaration required to create an equivalent of this material
  99583. * @returns a string
  99584. */
  99585. generateCode(): string;
  99586. /**
  99587. * Serializes this material in a JSON representation
  99588. * @returns the serialized material object
  99589. */
  99590. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  99591. private _restoreConnections;
  99592. /**
  99593. * Clear the current graph and load a new one from a serialization object
  99594. * @param source defines the JSON representation of the material
  99595. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99596. */
  99597. loadFromSerialization(source: any, rootUrl?: string): void;
  99598. /**
  99599. * Makes a duplicate of the current material.
  99600. * @param name - name to use for the new material.
  99601. */
  99602. clone(name: string): NodeMaterial;
  99603. /**
  99604. * Creates a node material from parsed material data
  99605. * @param source defines the JSON representation of the material
  99606. * @param scene defines the hosting scene
  99607. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99608. * @returns a new node material
  99609. */
  99610. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  99611. /**
  99612. * Creates a node material from a snippet saved in a remote file
  99613. * @param name defines the name of the material to create
  99614. * @param url defines the url to load from
  99615. * @param scene defines the hosting scene
  99616. * @returns a promise that will resolve to the new node material
  99617. */
  99618. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  99619. /**
  99620. * Creates a node material from a snippet saved by the node material editor
  99621. * @param snippetId defines the snippet to load
  99622. * @param scene defines the hosting scene
  99623. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99624. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  99625. * @returns a promise that will resolve to the new node material
  99626. */
  99627. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  99628. /**
  99629. * Creates a new node material set to default basic configuration
  99630. * @param name defines the name of the material
  99631. * @param scene defines the hosting scene
  99632. * @returns a new NodeMaterial
  99633. */
  99634. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  99635. }
  99636. }
  99637. declare module BABYLON {
  99638. /**
  99639. * Size options for a post process
  99640. */
  99641. export type PostProcessOptions = {
  99642. width: number;
  99643. height: number;
  99644. };
  99645. /**
  99646. * PostProcess can be used to apply a shader to a texture after it has been rendered
  99647. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  99648. */
  99649. export class PostProcess {
  99650. /** Name of the PostProcess. */
  99651. name: string;
  99652. /**
  99653. * Gets or sets the unique id of the post process
  99654. */
  99655. uniqueId: number;
  99656. /**
  99657. * Width of the texture to apply the post process on
  99658. */
  99659. width: number;
  99660. /**
  99661. * Height of the texture to apply the post process on
  99662. */
  99663. height: number;
  99664. /**
  99665. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  99666. */
  99667. nodeMaterialSource: Nullable<NodeMaterial>;
  99668. /**
  99669. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  99670. * @hidden
  99671. */
  99672. _outputTexture: Nullable<InternalTexture>;
  99673. /**
  99674. * Sampling mode used by the shader
  99675. * See https://doc.babylonjs.com/classes/3.1/texture
  99676. */
  99677. renderTargetSamplingMode: number;
  99678. /**
  99679. * Clear color to use when screen clearing
  99680. */
  99681. clearColor: Color4;
  99682. /**
  99683. * If the buffer needs to be cleared before applying the post process. (default: true)
  99684. * Should be set to false if shader will overwrite all previous pixels.
  99685. */
  99686. autoClear: boolean;
  99687. /**
  99688. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  99689. */
  99690. alphaMode: number;
  99691. /**
  99692. * Sets the setAlphaBlendConstants of the babylon engine
  99693. */
  99694. alphaConstants: Color4;
  99695. /**
  99696. * Animations to be used for the post processing
  99697. */
  99698. animations: Animation[];
  99699. /**
  99700. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  99701. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  99702. */
  99703. enablePixelPerfectMode: boolean;
  99704. /**
  99705. * Force the postprocess to be applied without taking in account viewport
  99706. */
  99707. forceFullscreenViewport: boolean;
  99708. /**
  99709. * List of inspectable custom properties (used by the Inspector)
  99710. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  99711. */
  99712. inspectableCustomProperties: IInspectable[];
  99713. /**
  99714. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  99715. *
  99716. * | Value | Type | Description |
  99717. * | ----- | ----------------------------------- | ----------- |
  99718. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  99719. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  99720. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  99721. *
  99722. */
  99723. scaleMode: number;
  99724. /**
  99725. * Force textures to be a power of two (default: false)
  99726. */
  99727. alwaysForcePOT: boolean;
  99728. private _samples;
  99729. /**
  99730. * Number of sample textures (default: 1)
  99731. */
  99732. get samples(): number;
  99733. set samples(n: number);
  99734. /**
  99735. * Modify the scale of the post process to be the same as the viewport (default: false)
  99736. */
  99737. adaptScaleToCurrentViewport: boolean;
  99738. private _camera;
  99739. private _scene;
  99740. private _engine;
  99741. private _options;
  99742. private _reusable;
  99743. private _textureType;
  99744. private _textureFormat;
  99745. /**
  99746. * Smart array of input and output textures for the post process.
  99747. * @hidden
  99748. */
  99749. _textures: SmartArray<InternalTexture>;
  99750. /**
  99751. * The index in _textures that corresponds to the output texture.
  99752. * @hidden
  99753. */
  99754. _currentRenderTextureInd: number;
  99755. private _effect;
  99756. private _samplers;
  99757. private _fragmentUrl;
  99758. private _vertexUrl;
  99759. private _parameters;
  99760. private _scaleRatio;
  99761. protected _indexParameters: any;
  99762. private _shareOutputWithPostProcess;
  99763. private _texelSize;
  99764. private _forcedOutputTexture;
  99765. /**
  99766. * Returns the fragment url or shader name used in the post process.
  99767. * @returns the fragment url or name in the shader store.
  99768. */
  99769. getEffectName(): string;
  99770. /**
  99771. * An event triggered when the postprocess is activated.
  99772. */
  99773. onActivateObservable: Observable<Camera>;
  99774. private _onActivateObserver;
  99775. /**
  99776. * A function that is added to the onActivateObservable
  99777. */
  99778. set onActivate(callback: Nullable<(camera: Camera) => void>);
  99779. /**
  99780. * An event triggered when the postprocess changes its size.
  99781. */
  99782. onSizeChangedObservable: Observable<PostProcess>;
  99783. private _onSizeChangedObserver;
  99784. /**
  99785. * A function that is added to the onSizeChangedObservable
  99786. */
  99787. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  99788. /**
  99789. * An event triggered when the postprocess applies its effect.
  99790. */
  99791. onApplyObservable: Observable<Effect>;
  99792. private _onApplyObserver;
  99793. /**
  99794. * A function that is added to the onApplyObservable
  99795. */
  99796. set onApply(callback: (effect: Effect) => void);
  99797. /**
  99798. * An event triggered before rendering the postprocess
  99799. */
  99800. onBeforeRenderObservable: Observable<Effect>;
  99801. private _onBeforeRenderObserver;
  99802. /**
  99803. * A function that is added to the onBeforeRenderObservable
  99804. */
  99805. set onBeforeRender(callback: (effect: Effect) => void);
  99806. /**
  99807. * An event triggered after rendering the postprocess
  99808. */
  99809. onAfterRenderObservable: Observable<Effect>;
  99810. private _onAfterRenderObserver;
  99811. /**
  99812. * A function that is added to the onAfterRenderObservable
  99813. */
  99814. set onAfterRender(callback: (efect: Effect) => void);
  99815. /**
  99816. * 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
  99817. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  99818. */
  99819. get inputTexture(): InternalTexture;
  99820. set inputTexture(value: InternalTexture);
  99821. /**
  99822. * Gets the camera which post process is applied to.
  99823. * @returns The camera the post process is applied to.
  99824. */
  99825. getCamera(): Camera;
  99826. /**
  99827. * Gets the texel size of the postprocess.
  99828. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  99829. */
  99830. get texelSize(): Vector2;
  99831. /**
  99832. * Creates a new instance PostProcess
  99833. * @param name The name of the PostProcess.
  99834. * @param fragmentUrl The url of the fragment shader to be used.
  99835. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  99836. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  99837. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99838. * @param camera The camera to apply the render pass to.
  99839. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99840. * @param engine The engine which the post process will be applied. (default: current engine)
  99841. * @param reusable If the post process can be reused on the same frame. (default: false)
  99842. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  99843. * @param textureType Type of textures used when performing the post process. (default: 0)
  99844. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  99845. * @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
  99846. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  99847. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  99848. */
  99849. constructor(
  99850. /** Name of the PostProcess. */
  99851. 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);
  99852. /**
  99853. * Gets a string idenfifying the name of the class
  99854. * @returns "PostProcess" string
  99855. */
  99856. getClassName(): string;
  99857. /**
  99858. * Gets the engine which this post process belongs to.
  99859. * @returns The engine the post process was enabled with.
  99860. */
  99861. getEngine(): Engine;
  99862. /**
  99863. * The effect that is created when initializing the post process.
  99864. * @returns The created effect corresponding the the postprocess.
  99865. */
  99866. getEffect(): Effect;
  99867. /**
  99868. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  99869. * @param postProcess The post process to share the output with.
  99870. * @returns This post process.
  99871. */
  99872. shareOutputWith(postProcess: PostProcess): PostProcess;
  99873. /**
  99874. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  99875. * This should be called if the post process that shares output with this post process is disabled/disposed.
  99876. */
  99877. useOwnOutput(): void;
  99878. /**
  99879. * Updates the effect with the current post process compile time values and recompiles the shader.
  99880. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  99881. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  99882. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  99883. * @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
  99884. * @param onCompiled Called when the shader has been compiled.
  99885. * @param onError Called if there is an error when compiling a shader.
  99886. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  99887. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  99888. */
  99889. 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;
  99890. /**
  99891. * The post process is reusable if it can be used multiple times within one frame.
  99892. * @returns If the post process is reusable
  99893. */
  99894. isReusable(): boolean;
  99895. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  99896. markTextureDirty(): void;
  99897. /**
  99898. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  99899. * 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.
  99900. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  99901. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  99902. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  99903. * @returns The target texture that was bound to be written to.
  99904. */
  99905. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  99906. /**
  99907. * If the post process is supported.
  99908. */
  99909. get isSupported(): boolean;
  99910. /**
  99911. * The aspect ratio of the output texture.
  99912. */
  99913. get aspectRatio(): number;
  99914. /**
  99915. * Get a value indicating if the post-process is ready to be used
  99916. * @returns true if the post-process is ready (shader is compiled)
  99917. */
  99918. isReady(): boolean;
  99919. /**
  99920. * Binds all textures and uniforms to the shader, this will be run on every pass.
  99921. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  99922. */
  99923. apply(): Nullable<Effect>;
  99924. private _disposeTextures;
  99925. /**
  99926. * Disposes the post process.
  99927. * @param camera The camera to dispose the post process on.
  99928. */
  99929. dispose(camera?: Camera): void;
  99930. }
  99931. }
  99932. declare module BABYLON {
  99933. /** @hidden */
  99934. export var kernelBlurVaryingDeclaration: {
  99935. name: string;
  99936. shader: string;
  99937. };
  99938. }
  99939. declare module BABYLON {
  99940. /** @hidden */
  99941. export var kernelBlurFragment: {
  99942. name: string;
  99943. shader: string;
  99944. };
  99945. }
  99946. declare module BABYLON {
  99947. /** @hidden */
  99948. export var kernelBlurFragment2: {
  99949. name: string;
  99950. shader: string;
  99951. };
  99952. }
  99953. declare module BABYLON {
  99954. /** @hidden */
  99955. export var kernelBlurPixelShader: {
  99956. name: string;
  99957. shader: string;
  99958. };
  99959. }
  99960. declare module BABYLON {
  99961. /** @hidden */
  99962. export var kernelBlurVertex: {
  99963. name: string;
  99964. shader: string;
  99965. };
  99966. }
  99967. declare module BABYLON {
  99968. /** @hidden */
  99969. export var kernelBlurVertexShader: {
  99970. name: string;
  99971. shader: string;
  99972. };
  99973. }
  99974. declare module BABYLON {
  99975. /**
  99976. * The Blur Post Process which blurs an image based on a kernel and direction.
  99977. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  99978. */
  99979. export class BlurPostProcess extends PostProcess {
  99980. /** The direction in which to blur the image. */
  99981. direction: Vector2;
  99982. private blockCompilation;
  99983. protected _kernel: number;
  99984. protected _idealKernel: number;
  99985. protected _packedFloat: boolean;
  99986. private _staticDefines;
  99987. /**
  99988. * Sets the length in pixels of the blur sample region
  99989. */
  99990. set kernel(v: number);
  99991. /**
  99992. * Gets the length in pixels of the blur sample region
  99993. */
  99994. get kernel(): number;
  99995. /**
  99996. * Sets wether or not the blur needs to unpack/repack floats
  99997. */
  99998. set packedFloat(v: boolean);
  99999. /**
  100000. * Gets wether or not the blur is unpacking/repacking floats
  100001. */
  100002. get packedFloat(): boolean;
  100003. /**
  100004. * Creates a new instance BlurPostProcess
  100005. * @param name The name of the effect.
  100006. * @param direction The direction in which to blur the image.
  100007. * @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.
  100008. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100009. * @param camera The camera to apply the render pass to.
  100010. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100011. * @param engine The engine which the post process will be applied. (default: current engine)
  100012. * @param reusable If the post process can be reused on the same frame. (default: false)
  100013. * @param textureType Type of textures used when performing the post process. (default: 0)
  100014. * @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)
  100015. */
  100016. constructor(name: string,
  100017. /** The direction in which to blur the image. */
  100018. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  100019. /**
  100020. * Updates the effect with the current post process compile time values and recompiles the shader.
  100021. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  100022. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  100023. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  100024. * @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
  100025. * @param onCompiled Called when the shader has been compiled.
  100026. * @param onError Called if there is an error when compiling a shader.
  100027. */
  100028. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100029. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100030. /**
  100031. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  100032. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  100033. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  100034. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  100035. * The gaps between physical kernels are compensated for in the weighting of the samples
  100036. * @param idealKernel Ideal blur kernel.
  100037. * @return Nearest best kernel.
  100038. */
  100039. protected _nearestBestKernel(idealKernel: number): number;
  100040. /**
  100041. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  100042. * @param x The point on the Gaussian distribution to sample.
  100043. * @return the value of the Gaussian function at x.
  100044. */
  100045. protected _gaussianWeight(x: number): number;
  100046. /**
  100047. * Generates a string that can be used as a floating point number in GLSL.
  100048. * @param x Value to print.
  100049. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  100050. * @return GLSL float string.
  100051. */
  100052. protected _glslFloat(x: number, decimalFigures?: number): string;
  100053. }
  100054. }
  100055. declare module BABYLON {
  100056. /**
  100057. * Mirror texture can be used to simulate the view from a mirror in a scene.
  100058. * It will dynamically be rendered every frame to adapt to the camera point of view.
  100059. * You can then easily use it as a reflectionTexture on a flat surface.
  100060. * In case the surface is not a plane, please consider relying on reflection probes.
  100061. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100062. */
  100063. export class MirrorTexture extends RenderTargetTexture {
  100064. private scene;
  100065. /**
  100066. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  100067. * 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.
  100068. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100069. */
  100070. mirrorPlane: Plane;
  100071. /**
  100072. * Define the blur ratio used to blur the reflection if needed.
  100073. */
  100074. set blurRatio(value: number);
  100075. get blurRatio(): number;
  100076. /**
  100077. * Define the adaptive blur kernel used to blur the reflection if needed.
  100078. * This will autocompute the closest best match for the `blurKernel`
  100079. */
  100080. set adaptiveBlurKernel(value: number);
  100081. /**
  100082. * Define the blur kernel used to blur the reflection if needed.
  100083. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100084. */
  100085. set blurKernel(value: number);
  100086. /**
  100087. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  100088. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100089. */
  100090. set blurKernelX(value: number);
  100091. get blurKernelX(): number;
  100092. /**
  100093. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  100094. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100095. */
  100096. set blurKernelY(value: number);
  100097. get blurKernelY(): number;
  100098. private _autoComputeBlurKernel;
  100099. protected _onRatioRescale(): void;
  100100. private _updateGammaSpace;
  100101. private _imageProcessingConfigChangeObserver;
  100102. private _transformMatrix;
  100103. private _mirrorMatrix;
  100104. private _savedViewMatrix;
  100105. private _blurX;
  100106. private _blurY;
  100107. private _adaptiveBlurKernel;
  100108. private _blurKernelX;
  100109. private _blurKernelY;
  100110. private _blurRatio;
  100111. /**
  100112. * Instantiates a Mirror Texture.
  100113. * Mirror texture can be used to simulate the view from a mirror in a scene.
  100114. * It will dynamically be rendered every frame to adapt to the camera point of view.
  100115. * You can then easily use it as a reflectionTexture on a flat surface.
  100116. * In case the surface is not a plane, please consider relying on reflection probes.
  100117. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100118. * @param name
  100119. * @param size
  100120. * @param scene
  100121. * @param generateMipMaps
  100122. * @param type
  100123. * @param samplingMode
  100124. * @param generateDepthBuffer
  100125. */
  100126. constructor(name: string, size: number | {
  100127. width: number;
  100128. height: number;
  100129. } | {
  100130. ratio: number;
  100131. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  100132. private _preparePostProcesses;
  100133. /**
  100134. * Clone the mirror texture.
  100135. * @returns the cloned texture
  100136. */
  100137. clone(): MirrorTexture;
  100138. /**
  100139. * Serialize the texture to a JSON representation you could use in Parse later on
  100140. * @returns the serialized JSON representation
  100141. */
  100142. serialize(): any;
  100143. /**
  100144. * Dispose the texture and release its associated resources.
  100145. */
  100146. dispose(): void;
  100147. }
  100148. }
  100149. declare module BABYLON {
  100150. /**
  100151. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  100152. * @see http://doc.babylonjs.com/babylon101/materials#texture
  100153. */
  100154. export class Texture extends BaseTexture {
  100155. /**
  100156. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  100157. */
  100158. static SerializeBuffers: boolean;
  100159. /** @hidden */
  100160. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  100161. /** @hidden */
  100162. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  100163. /** @hidden */
  100164. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  100165. /** nearest is mag = nearest and min = nearest and mip = linear */
  100166. static readonly NEAREST_SAMPLINGMODE: number;
  100167. /** nearest is mag = nearest and min = nearest and mip = linear */
  100168. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  100169. /** Bilinear is mag = linear and min = linear and mip = nearest */
  100170. static readonly BILINEAR_SAMPLINGMODE: number;
  100171. /** Bilinear is mag = linear and min = linear and mip = nearest */
  100172. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  100173. /** Trilinear is mag = linear and min = linear and mip = linear */
  100174. static readonly TRILINEAR_SAMPLINGMODE: number;
  100175. /** Trilinear is mag = linear and min = linear and mip = linear */
  100176. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  100177. /** mag = nearest and min = nearest and mip = nearest */
  100178. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  100179. /** mag = nearest and min = linear and mip = nearest */
  100180. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  100181. /** mag = nearest and min = linear and mip = linear */
  100182. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  100183. /** mag = nearest and min = linear and mip = none */
  100184. static readonly NEAREST_LINEAR: number;
  100185. /** mag = nearest and min = nearest and mip = none */
  100186. static readonly NEAREST_NEAREST: number;
  100187. /** mag = linear and min = nearest and mip = nearest */
  100188. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  100189. /** mag = linear and min = nearest and mip = linear */
  100190. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  100191. /** mag = linear and min = linear and mip = none */
  100192. static readonly LINEAR_LINEAR: number;
  100193. /** mag = linear and min = nearest and mip = none */
  100194. static readonly LINEAR_NEAREST: number;
  100195. /** Explicit coordinates mode */
  100196. static readonly EXPLICIT_MODE: number;
  100197. /** Spherical coordinates mode */
  100198. static readonly SPHERICAL_MODE: number;
  100199. /** Planar coordinates mode */
  100200. static readonly PLANAR_MODE: number;
  100201. /** Cubic coordinates mode */
  100202. static readonly CUBIC_MODE: number;
  100203. /** Projection coordinates mode */
  100204. static readonly PROJECTION_MODE: number;
  100205. /** Inverse Cubic coordinates mode */
  100206. static readonly SKYBOX_MODE: number;
  100207. /** Inverse Cubic coordinates mode */
  100208. static readonly INVCUBIC_MODE: number;
  100209. /** Equirectangular coordinates mode */
  100210. static readonly EQUIRECTANGULAR_MODE: number;
  100211. /** Equirectangular Fixed coordinates mode */
  100212. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  100213. /** Equirectangular Fixed Mirrored coordinates mode */
  100214. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  100215. /** Texture is not repeating outside of 0..1 UVs */
  100216. static readonly CLAMP_ADDRESSMODE: number;
  100217. /** Texture is repeating outside of 0..1 UVs */
  100218. static readonly WRAP_ADDRESSMODE: number;
  100219. /** Texture is repeating and mirrored */
  100220. static readonly MIRROR_ADDRESSMODE: number;
  100221. /**
  100222. * 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
  100223. */
  100224. static UseSerializedUrlIfAny: boolean;
  100225. /**
  100226. * Define the url of the texture.
  100227. */
  100228. url: Nullable<string>;
  100229. /**
  100230. * Define an offset on the texture to offset the u coordinates of the UVs
  100231. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  100232. */
  100233. uOffset: number;
  100234. /**
  100235. * Define an offset on the texture to offset the v coordinates of the UVs
  100236. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  100237. */
  100238. vOffset: number;
  100239. /**
  100240. * Define an offset on the texture to scale the u coordinates of the UVs
  100241. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  100242. */
  100243. uScale: number;
  100244. /**
  100245. * Define an offset on the texture to scale the v coordinates of the UVs
  100246. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  100247. */
  100248. vScale: number;
  100249. /**
  100250. * Define an offset on the texture to rotate around the u coordinates of the UVs
  100251. * @see http://doc.babylonjs.com/how_to/more_materials
  100252. */
  100253. uAng: number;
  100254. /**
  100255. * Define an offset on the texture to rotate around the v coordinates of the UVs
  100256. * @see http://doc.babylonjs.com/how_to/more_materials
  100257. */
  100258. vAng: number;
  100259. /**
  100260. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  100261. * @see http://doc.babylonjs.com/how_to/more_materials
  100262. */
  100263. wAng: number;
  100264. /**
  100265. * Defines the center of rotation (U)
  100266. */
  100267. uRotationCenter: number;
  100268. /**
  100269. * Defines the center of rotation (V)
  100270. */
  100271. vRotationCenter: number;
  100272. /**
  100273. * Defines the center of rotation (W)
  100274. */
  100275. wRotationCenter: number;
  100276. /**
  100277. * Are mip maps generated for this texture or not.
  100278. */
  100279. get noMipmap(): boolean;
  100280. /**
  100281. * List of inspectable custom properties (used by the Inspector)
  100282. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100283. */
  100284. inspectableCustomProperties: Nullable<IInspectable[]>;
  100285. private _noMipmap;
  100286. /** @hidden */
  100287. _invertY: boolean;
  100288. private _rowGenerationMatrix;
  100289. private _cachedTextureMatrix;
  100290. private _projectionModeMatrix;
  100291. private _t0;
  100292. private _t1;
  100293. private _t2;
  100294. private _cachedUOffset;
  100295. private _cachedVOffset;
  100296. private _cachedUScale;
  100297. private _cachedVScale;
  100298. private _cachedUAng;
  100299. private _cachedVAng;
  100300. private _cachedWAng;
  100301. private _cachedProjectionMatrixId;
  100302. private _cachedCoordinatesMode;
  100303. /** @hidden */
  100304. protected _initialSamplingMode: number;
  100305. /** @hidden */
  100306. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  100307. private _deleteBuffer;
  100308. protected _format: Nullable<number>;
  100309. private _delayedOnLoad;
  100310. private _delayedOnError;
  100311. private _mimeType?;
  100312. /**
  100313. * Observable triggered once the texture has been loaded.
  100314. */
  100315. onLoadObservable: Observable<Texture>;
  100316. protected _isBlocking: boolean;
  100317. /**
  100318. * Is the texture preventing material to render while loading.
  100319. * If false, a default texture will be used instead of the loading one during the preparation step.
  100320. */
  100321. set isBlocking(value: boolean);
  100322. get isBlocking(): boolean;
  100323. /**
  100324. * Get the current sampling mode associated with the texture.
  100325. */
  100326. get samplingMode(): number;
  100327. /**
  100328. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  100329. */
  100330. get invertY(): boolean;
  100331. /**
  100332. * Instantiates a new texture.
  100333. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  100334. * @see http://doc.babylonjs.com/babylon101/materials#texture
  100335. * @param url defines the url of the picture to load as a texture
  100336. * @param sceneOrEngine defines the scene or engine the texture will belong to
  100337. * @param noMipmap defines if the texture will require mip maps or not
  100338. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  100339. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100340. * @param onLoad defines a callback triggered when the texture has been loaded
  100341. * @param onError defines a callback triggered when an error occurred during the loading session
  100342. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  100343. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  100344. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100345. * @param mimeType defines an optional mime type information
  100346. */
  100347. 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);
  100348. /**
  100349. * Update the url (and optional buffer) of this texture if url was null during construction.
  100350. * @param url the url of the texture
  100351. * @param buffer the buffer of the texture (defaults to null)
  100352. * @param onLoad callback called when the texture is loaded (defaults to null)
  100353. */
  100354. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  100355. /**
  100356. * Finish the loading sequence of a texture flagged as delayed load.
  100357. * @hidden
  100358. */
  100359. delayLoad(): void;
  100360. private _prepareRowForTextureGeneration;
  100361. /**
  100362. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  100363. * @returns the transform matrix of the texture.
  100364. */
  100365. getTextureMatrix(uBase?: number): Matrix;
  100366. /**
  100367. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  100368. * @returns The reflection texture transform
  100369. */
  100370. getReflectionTextureMatrix(): Matrix;
  100371. /**
  100372. * Clones the texture.
  100373. * @returns the cloned texture
  100374. */
  100375. clone(): Texture;
  100376. /**
  100377. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  100378. * @returns The JSON representation of the texture
  100379. */
  100380. serialize(): any;
  100381. /**
  100382. * Get the current class name of the texture useful for serialization or dynamic coding.
  100383. * @returns "Texture"
  100384. */
  100385. getClassName(): string;
  100386. /**
  100387. * Dispose the texture and release its associated resources.
  100388. */
  100389. dispose(): void;
  100390. /**
  100391. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  100392. * @param parsedTexture Define the JSON representation of the texture
  100393. * @param scene Define the scene the parsed texture should be instantiated in
  100394. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  100395. * @returns The parsed texture if successful
  100396. */
  100397. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  100398. /**
  100399. * Creates a texture from its base 64 representation.
  100400. * @param data Define the base64 payload without the data: prefix
  100401. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  100402. * @param scene Define the scene the texture should belong to
  100403. * @param noMipmap Forces the texture to not create mip map information if true
  100404. * @param invertY define if the texture needs to be inverted on the y axis during loading
  100405. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100406. * @param onLoad define a callback triggered when the texture has been loaded
  100407. * @param onError define a callback triggered when an error occurred during the loading session
  100408. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100409. * @returns the created texture
  100410. */
  100411. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  100412. /**
  100413. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  100414. * @param data Define the base64 payload without the data: prefix
  100415. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  100416. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  100417. * @param scene Define the scene the texture should belong to
  100418. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  100419. * @param noMipmap Forces the texture to not create mip map information if true
  100420. * @param invertY define if the texture needs to be inverted on the y axis during loading
  100421. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100422. * @param onLoad define a callback triggered when the texture has been loaded
  100423. * @param onError define a callback triggered when an error occurred during the loading session
  100424. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100425. * @returns the created texture
  100426. */
  100427. 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;
  100428. }
  100429. }
  100430. declare module BABYLON {
  100431. /**
  100432. * PostProcessManager is used to manage one or more post processes or post process pipelines
  100433. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  100434. */
  100435. export class PostProcessManager {
  100436. private _scene;
  100437. private _indexBuffer;
  100438. private _vertexBuffers;
  100439. /**
  100440. * Creates a new instance PostProcess
  100441. * @param scene The scene that the post process is associated with.
  100442. */
  100443. constructor(scene: Scene);
  100444. private _prepareBuffers;
  100445. private _buildIndexBuffer;
  100446. /**
  100447. * Rebuilds the vertex buffers of the manager.
  100448. * @hidden
  100449. */
  100450. _rebuild(): void;
  100451. /**
  100452. * Prepares a frame to be run through a post process.
  100453. * @param sourceTexture The input texture to the post procesess. (default: null)
  100454. * @param postProcesses An array of post processes to be run. (default: null)
  100455. * @returns True if the post processes were able to be run.
  100456. * @hidden
  100457. */
  100458. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  100459. /**
  100460. * Manually render a set of post processes to a texture.
  100461. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  100462. * @param postProcesses An array of post processes to be run.
  100463. * @param targetTexture The target texture to render to.
  100464. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  100465. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  100466. * @param lodLevel defines which lod of the texture to render to
  100467. */
  100468. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  100469. /**
  100470. * Finalize the result of the output of the postprocesses.
  100471. * @param doNotPresent If true the result will not be displayed to the screen.
  100472. * @param targetTexture The target texture to render to.
  100473. * @param faceIndex The index of the face to bind the target texture to.
  100474. * @param postProcesses The array of post processes to render.
  100475. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  100476. * @hidden
  100477. */
  100478. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  100479. /**
  100480. * Disposes of the post process manager.
  100481. */
  100482. dispose(): void;
  100483. }
  100484. }
  100485. declare module BABYLON {
  100486. /**
  100487. * This Helps creating a texture that will be created from a camera in your scene.
  100488. * It is basically a dynamic texture that could be used to create special effects for instance.
  100489. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  100490. */
  100491. export class RenderTargetTexture extends Texture {
  100492. isCube: boolean;
  100493. /**
  100494. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  100495. */
  100496. static readonly REFRESHRATE_RENDER_ONCE: number;
  100497. /**
  100498. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  100499. */
  100500. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  100501. /**
  100502. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  100503. * the central point of your effect and can save a lot of performances.
  100504. */
  100505. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  100506. /**
  100507. * Use this predicate to dynamically define the list of mesh you want to render.
  100508. * If set, the renderList property will be overwritten.
  100509. */
  100510. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  100511. private _renderList;
  100512. /**
  100513. * Use this list to define the list of mesh you want to render.
  100514. */
  100515. get renderList(): Nullable<Array<AbstractMesh>>;
  100516. set renderList(value: Nullable<Array<AbstractMesh>>);
  100517. /**
  100518. * Use this function to overload the renderList array at rendering time.
  100519. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  100520. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  100521. * the cube (if the RTT is a cube, else layerOrFace=0).
  100522. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  100523. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  100524. * hold dummy elements!
  100525. */
  100526. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  100527. private _hookArray;
  100528. /**
  100529. * Define if particles should be rendered in your texture.
  100530. */
  100531. renderParticles: boolean;
  100532. /**
  100533. * Define if sprites should be rendered in your texture.
  100534. */
  100535. renderSprites: boolean;
  100536. /**
  100537. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  100538. */
  100539. coordinatesMode: number;
  100540. /**
  100541. * Define the camera used to render the texture.
  100542. */
  100543. activeCamera: Nullable<Camera>;
  100544. /**
  100545. * Override the mesh isReady function with your own one.
  100546. */
  100547. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  100548. /**
  100549. * Override the render function of the texture with your own one.
  100550. */
  100551. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  100552. /**
  100553. * Define if camera post processes should be use while rendering the texture.
  100554. */
  100555. useCameraPostProcesses: boolean;
  100556. /**
  100557. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  100558. */
  100559. ignoreCameraViewport: boolean;
  100560. private _postProcessManager;
  100561. private _postProcesses;
  100562. private _resizeObserver;
  100563. /**
  100564. * An event triggered when the texture is unbind.
  100565. */
  100566. onBeforeBindObservable: Observable<RenderTargetTexture>;
  100567. /**
  100568. * An event triggered when the texture is unbind.
  100569. */
  100570. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  100571. private _onAfterUnbindObserver;
  100572. /**
  100573. * Set a after unbind callback in the texture.
  100574. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  100575. */
  100576. set onAfterUnbind(callback: () => void);
  100577. /**
  100578. * An event triggered before rendering the texture
  100579. */
  100580. onBeforeRenderObservable: Observable<number>;
  100581. private _onBeforeRenderObserver;
  100582. /**
  100583. * Set a before render callback in the texture.
  100584. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  100585. */
  100586. set onBeforeRender(callback: (faceIndex: number) => void);
  100587. /**
  100588. * An event triggered after rendering the texture
  100589. */
  100590. onAfterRenderObservable: Observable<number>;
  100591. private _onAfterRenderObserver;
  100592. /**
  100593. * Set a after render callback in the texture.
  100594. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  100595. */
  100596. set onAfterRender(callback: (faceIndex: number) => void);
  100597. /**
  100598. * An event triggered after the texture clear
  100599. */
  100600. onClearObservable: Observable<Engine>;
  100601. private _onClearObserver;
  100602. /**
  100603. * Set a clear callback in the texture.
  100604. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  100605. */
  100606. set onClear(callback: (Engine: Engine) => void);
  100607. /**
  100608. * An event triggered when the texture is resized.
  100609. */
  100610. onResizeObservable: Observable<RenderTargetTexture>;
  100611. /**
  100612. * Define the clear color of the Render Target if it should be different from the scene.
  100613. */
  100614. clearColor: Color4;
  100615. protected _size: number | {
  100616. width: number;
  100617. height: number;
  100618. layers?: number;
  100619. };
  100620. protected _initialSizeParameter: number | {
  100621. width: number;
  100622. height: number;
  100623. } | {
  100624. ratio: number;
  100625. };
  100626. protected _sizeRatio: Nullable<number>;
  100627. /** @hidden */
  100628. _generateMipMaps: boolean;
  100629. protected _renderingManager: RenderingManager;
  100630. /** @hidden */
  100631. _waitingRenderList: string[];
  100632. protected _doNotChangeAspectRatio: boolean;
  100633. protected _currentRefreshId: number;
  100634. protected _refreshRate: number;
  100635. protected _textureMatrix: Matrix;
  100636. protected _samples: number;
  100637. protected _renderTargetOptions: RenderTargetCreationOptions;
  100638. /**
  100639. * Gets render target creation options that were used.
  100640. */
  100641. get renderTargetOptions(): RenderTargetCreationOptions;
  100642. protected _onRatioRescale(): void;
  100643. /**
  100644. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  100645. * It must define where the camera used to render the texture is set
  100646. */
  100647. boundingBoxPosition: Vector3;
  100648. private _boundingBoxSize;
  100649. /**
  100650. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  100651. * When defined, the cubemap will switch to local mode
  100652. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  100653. * @example https://www.babylonjs-playground.com/#RNASML
  100654. */
  100655. set boundingBoxSize(value: Vector3);
  100656. get boundingBoxSize(): Vector3;
  100657. /**
  100658. * In case the RTT has been created with a depth texture, get the associated
  100659. * depth texture.
  100660. * Otherwise, return null.
  100661. */
  100662. get depthStencilTexture(): Nullable<InternalTexture>;
  100663. /**
  100664. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  100665. * or used a shadow, depth texture...
  100666. * @param name The friendly name of the texture
  100667. * @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)
  100668. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  100669. * @param generateMipMaps True if mip maps need to be generated after render.
  100670. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  100671. * @param type The type of the buffer in the RTT (int, half float, float...)
  100672. * @param isCube True if a cube texture needs to be created
  100673. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  100674. * @param generateDepthBuffer True to generate a depth buffer
  100675. * @param generateStencilBuffer True to generate a stencil buffer
  100676. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  100677. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  100678. * @param delayAllocation if the texture allocation should be delayed (default: false)
  100679. */
  100680. constructor(name: string, size: number | {
  100681. width: number;
  100682. height: number;
  100683. layers?: number;
  100684. } | {
  100685. ratio: number;
  100686. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  100687. /**
  100688. * Creates a depth stencil texture.
  100689. * This is only available in WebGL 2 or with the depth texture extension available.
  100690. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  100691. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  100692. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  100693. */
  100694. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  100695. private _processSizeParameter;
  100696. /**
  100697. * Define the number of samples to use in case of MSAA.
  100698. * It defaults to one meaning no MSAA has been enabled.
  100699. */
  100700. get samples(): number;
  100701. set samples(value: number);
  100702. /**
  100703. * Resets the refresh counter of the texture and start bak from scratch.
  100704. * Could be useful to regenerate the texture if it is setup to render only once.
  100705. */
  100706. resetRefreshCounter(): void;
  100707. /**
  100708. * Define the refresh rate of the texture or the rendering frequency.
  100709. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  100710. */
  100711. get refreshRate(): number;
  100712. set refreshRate(value: number);
  100713. /**
  100714. * Adds a post process to the render target rendering passes.
  100715. * @param postProcess define the post process to add
  100716. */
  100717. addPostProcess(postProcess: PostProcess): void;
  100718. /**
  100719. * Clear all the post processes attached to the render target
  100720. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  100721. */
  100722. clearPostProcesses(dispose?: boolean): void;
  100723. /**
  100724. * Remove one of the post process from the list of attached post processes to the texture
  100725. * @param postProcess define the post process to remove from the list
  100726. */
  100727. removePostProcess(postProcess: PostProcess): void;
  100728. /** @hidden */
  100729. _shouldRender(): boolean;
  100730. /**
  100731. * Gets the actual render size of the texture.
  100732. * @returns the width of the render size
  100733. */
  100734. getRenderSize(): number;
  100735. /**
  100736. * Gets the actual render width of the texture.
  100737. * @returns the width of the render size
  100738. */
  100739. getRenderWidth(): number;
  100740. /**
  100741. * Gets the actual render height of the texture.
  100742. * @returns the height of the render size
  100743. */
  100744. getRenderHeight(): number;
  100745. /**
  100746. * Gets the actual number of layers of the texture.
  100747. * @returns the number of layers
  100748. */
  100749. getRenderLayers(): number;
  100750. /**
  100751. * Get if the texture can be rescaled or not.
  100752. */
  100753. get canRescale(): boolean;
  100754. /**
  100755. * Resize the texture using a ratio.
  100756. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  100757. */
  100758. scale(ratio: number): void;
  100759. /**
  100760. * Get the texture reflection matrix used to rotate/transform the reflection.
  100761. * @returns the reflection matrix
  100762. */
  100763. getReflectionTextureMatrix(): Matrix;
  100764. /**
  100765. * Resize the texture to a new desired size.
  100766. * Be carrefull as it will recreate all the data in the new texture.
  100767. * @param size Define the new size. It can be:
  100768. * - a number for squared texture,
  100769. * - an object containing { width: number, height: number }
  100770. * - or an object containing a ratio { ratio: number }
  100771. */
  100772. resize(size: number | {
  100773. width: number;
  100774. height: number;
  100775. } | {
  100776. ratio: number;
  100777. }): void;
  100778. private _defaultRenderListPrepared;
  100779. /**
  100780. * Renders all the objects from the render list into the texture.
  100781. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  100782. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  100783. */
  100784. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  100785. private _bestReflectionRenderTargetDimension;
  100786. private _prepareRenderingManager;
  100787. /**
  100788. * @hidden
  100789. * @param faceIndex face index to bind to if this is a cubetexture
  100790. * @param layer defines the index of the texture to bind in the array
  100791. */
  100792. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  100793. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  100794. private renderToTarget;
  100795. /**
  100796. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  100797. * This allowed control for front to back rendering or reversly depending of the special needs.
  100798. *
  100799. * @param renderingGroupId The rendering group id corresponding to its index
  100800. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  100801. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  100802. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  100803. */
  100804. 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;
  100805. /**
  100806. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  100807. *
  100808. * @param renderingGroupId The rendering group id corresponding to its index
  100809. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  100810. */
  100811. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  100812. /**
  100813. * Clones the texture.
  100814. * @returns the cloned texture
  100815. */
  100816. clone(): RenderTargetTexture;
  100817. /**
  100818. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  100819. * @returns The JSON representation of the texture
  100820. */
  100821. serialize(): any;
  100822. /**
  100823. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  100824. */
  100825. disposeFramebufferObjects(): void;
  100826. /**
  100827. * Dispose the texture and release its associated resources.
  100828. */
  100829. dispose(): void;
  100830. /** @hidden */
  100831. _rebuild(): void;
  100832. /**
  100833. * Clear the info related to rendering groups preventing retention point in material dispose.
  100834. */
  100835. freeRenderingGroups(): void;
  100836. /**
  100837. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  100838. * @returns the view count
  100839. */
  100840. getViewCount(): number;
  100841. }
  100842. }
  100843. declare module BABYLON {
  100844. /**
  100845. * Class used to manipulate GUIDs
  100846. */
  100847. export class GUID {
  100848. /**
  100849. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100850. * Be aware Math.random() could cause collisions, but:
  100851. * "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"
  100852. * @returns a pseudo random id
  100853. */
  100854. static RandomId(): string;
  100855. }
  100856. }
  100857. declare module BABYLON {
  100858. /**
  100859. * Options to be used when creating a shadow depth material
  100860. */
  100861. export interface IIOptionShadowDepthMaterial {
  100862. /** Variables in the vertex shader code that need to have their names remapped.
  100863. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  100864. * "var_name" should be either: worldPos or vNormalW
  100865. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  100866. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  100867. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  100868. */
  100869. remappedVariables?: string[];
  100870. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  100871. standalone?: boolean;
  100872. }
  100873. /**
  100874. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  100875. */
  100876. export class ShadowDepthWrapper {
  100877. private _scene;
  100878. private _options?;
  100879. private _baseMaterial;
  100880. private _onEffectCreatedObserver;
  100881. private _subMeshToEffect;
  100882. private _subMeshToDepthEffect;
  100883. private _meshes;
  100884. /** @hidden */
  100885. _matriceNames: any;
  100886. /** Gets the standalone status of the wrapper */
  100887. get standalone(): boolean;
  100888. /** Gets the base material the wrapper is built upon */
  100889. get baseMaterial(): Material;
  100890. /**
  100891. * Instantiate a new shadow depth wrapper.
  100892. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  100893. * generate the shadow depth map. For more information, please refer to the documentation:
  100894. * https://doc.babylonjs.com/babylon101/shadows
  100895. * @param baseMaterial Material to wrap
  100896. * @param scene Define the scene the material belongs to
  100897. * @param options Options used to create the wrapper
  100898. */
  100899. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  100900. /**
  100901. * Gets the effect to use to generate the depth map
  100902. * @param subMesh subMesh to get the effect for
  100903. * @param shadowGenerator shadow generator to get the effect for
  100904. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  100905. */
  100906. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  100907. /**
  100908. * Specifies that the submesh is ready to be used for depth rendering
  100909. * @param subMesh submesh to check
  100910. * @param defines the list of defines to take into account when checking the effect
  100911. * @param shadowGenerator combined with subMesh, it defines the effect to check
  100912. * @param useInstances specifies that instances should be used
  100913. * @returns a boolean indicating that the submesh is ready or not
  100914. */
  100915. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  100916. /**
  100917. * Disposes the resources
  100918. */
  100919. dispose(): void;
  100920. private _makeEffect;
  100921. }
  100922. }
  100923. declare module BABYLON {
  100924. /**
  100925. * Options for compiling materials.
  100926. */
  100927. export interface IMaterialCompilationOptions {
  100928. /**
  100929. * Defines whether clip planes are enabled.
  100930. */
  100931. clipPlane: boolean;
  100932. /**
  100933. * Defines whether instances are enabled.
  100934. */
  100935. useInstances: boolean;
  100936. }
  100937. /**
  100938. * Options passed when calling customShaderNameResolve
  100939. */
  100940. export interface ICustomShaderNameResolveOptions {
  100941. /**
  100942. * 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
  100943. */
  100944. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  100945. }
  100946. /**
  100947. * Base class for the main features of a material in Babylon.js
  100948. */
  100949. export class Material implements IAnimatable {
  100950. /**
  100951. * Returns the triangle fill mode
  100952. */
  100953. static readonly TriangleFillMode: number;
  100954. /**
  100955. * Returns the wireframe mode
  100956. */
  100957. static readonly WireFrameFillMode: number;
  100958. /**
  100959. * Returns the point fill mode
  100960. */
  100961. static readonly PointFillMode: number;
  100962. /**
  100963. * Returns the point list draw mode
  100964. */
  100965. static readonly PointListDrawMode: number;
  100966. /**
  100967. * Returns the line list draw mode
  100968. */
  100969. static readonly LineListDrawMode: number;
  100970. /**
  100971. * Returns the line loop draw mode
  100972. */
  100973. static readonly LineLoopDrawMode: number;
  100974. /**
  100975. * Returns the line strip draw mode
  100976. */
  100977. static readonly LineStripDrawMode: number;
  100978. /**
  100979. * Returns the triangle strip draw mode
  100980. */
  100981. static readonly TriangleStripDrawMode: number;
  100982. /**
  100983. * Returns the triangle fan draw mode
  100984. */
  100985. static readonly TriangleFanDrawMode: number;
  100986. /**
  100987. * Stores the clock-wise side orientation
  100988. */
  100989. static readonly ClockWiseSideOrientation: number;
  100990. /**
  100991. * Stores the counter clock-wise side orientation
  100992. */
  100993. static readonly CounterClockWiseSideOrientation: number;
  100994. /**
  100995. * The dirty texture flag value
  100996. */
  100997. static readonly TextureDirtyFlag: number;
  100998. /**
  100999. * The dirty light flag value
  101000. */
  101001. static readonly LightDirtyFlag: number;
  101002. /**
  101003. * The dirty fresnel flag value
  101004. */
  101005. static readonly FresnelDirtyFlag: number;
  101006. /**
  101007. * The dirty attribute flag value
  101008. */
  101009. static readonly AttributesDirtyFlag: number;
  101010. /**
  101011. * The dirty misc flag value
  101012. */
  101013. static readonly MiscDirtyFlag: number;
  101014. /**
  101015. * The all dirty flag value
  101016. */
  101017. static readonly AllDirtyFlag: number;
  101018. /**
  101019. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101020. */
  101021. static readonly MATERIAL_OPAQUE: number;
  101022. /**
  101023. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101024. */
  101025. static readonly MATERIAL_ALPHATEST: number;
  101026. /**
  101027. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101028. */
  101029. static readonly MATERIAL_ALPHABLEND: number;
  101030. /**
  101031. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101032. * They are also discarded below the alpha cutoff threshold to improve performances.
  101033. */
  101034. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  101035. /**
  101036. * Custom callback helping to override the default shader used in the material.
  101037. */
  101038. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  101039. /**
  101040. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  101041. */
  101042. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  101043. /**
  101044. * The ID of the material
  101045. */
  101046. id: string;
  101047. /**
  101048. * Gets or sets the unique id of the material
  101049. */
  101050. uniqueId: number;
  101051. /**
  101052. * The name of the material
  101053. */
  101054. name: string;
  101055. /**
  101056. * Gets or sets user defined metadata
  101057. */
  101058. metadata: any;
  101059. /**
  101060. * For internal use only. Please do not use.
  101061. */
  101062. reservedDataStore: any;
  101063. /**
  101064. * Specifies if the ready state should be checked on each call
  101065. */
  101066. checkReadyOnEveryCall: boolean;
  101067. /**
  101068. * Specifies if the ready state should be checked once
  101069. */
  101070. checkReadyOnlyOnce: boolean;
  101071. /**
  101072. * The state of the material
  101073. */
  101074. state: string;
  101075. /**
  101076. * The alpha value of the material
  101077. */
  101078. protected _alpha: number;
  101079. /**
  101080. * List of inspectable custom properties (used by the Inspector)
  101081. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101082. */
  101083. inspectableCustomProperties: IInspectable[];
  101084. /**
  101085. * Sets the alpha value of the material
  101086. */
  101087. set alpha(value: number);
  101088. /**
  101089. * Gets the alpha value of the material
  101090. */
  101091. get alpha(): number;
  101092. /**
  101093. * Specifies if back face culling is enabled
  101094. */
  101095. protected _backFaceCulling: boolean;
  101096. /**
  101097. * Sets the back-face culling state
  101098. */
  101099. set backFaceCulling(value: boolean);
  101100. /**
  101101. * Gets the back-face culling state
  101102. */
  101103. get backFaceCulling(): boolean;
  101104. /**
  101105. * Stores the value for side orientation
  101106. */
  101107. sideOrientation: number;
  101108. /**
  101109. * Callback triggered when the material is compiled
  101110. */
  101111. onCompiled: Nullable<(effect: Effect) => void>;
  101112. /**
  101113. * Callback triggered when an error occurs
  101114. */
  101115. onError: Nullable<(effect: Effect, errors: string) => void>;
  101116. /**
  101117. * Callback triggered to get the render target textures
  101118. */
  101119. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  101120. /**
  101121. * Gets a boolean indicating that current material needs to register RTT
  101122. */
  101123. get hasRenderTargetTextures(): boolean;
  101124. /**
  101125. * Specifies if the material should be serialized
  101126. */
  101127. doNotSerialize: boolean;
  101128. /**
  101129. * @hidden
  101130. */
  101131. _storeEffectOnSubMeshes: boolean;
  101132. /**
  101133. * Stores the animations for the material
  101134. */
  101135. animations: Nullable<Array<Animation>>;
  101136. /**
  101137. * An event triggered when the material is disposed
  101138. */
  101139. onDisposeObservable: Observable<Material>;
  101140. /**
  101141. * An observer which watches for dispose events
  101142. */
  101143. private _onDisposeObserver;
  101144. private _onUnBindObservable;
  101145. /**
  101146. * Called during a dispose event
  101147. */
  101148. set onDispose(callback: () => void);
  101149. private _onBindObservable;
  101150. /**
  101151. * An event triggered when the material is bound
  101152. */
  101153. get onBindObservable(): Observable<AbstractMesh>;
  101154. /**
  101155. * An observer which watches for bind events
  101156. */
  101157. private _onBindObserver;
  101158. /**
  101159. * Called during a bind event
  101160. */
  101161. set onBind(callback: (Mesh: AbstractMesh) => void);
  101162. /**
  101163. * An event triggered when the material is unbound
  101164. */
  101165. get onUnBindObservable(): Observable<Material>;
  101166. protected _onEffectCreatedObservable: Nullable<Observable<{
  101167. effect: Effect;
  101168. subMesh: Nullable<SubMesh>;
  101169. }>>;
  101170. /**
  101171. * An event triggered when the effect is (re)created
  101172. */
  101173. get onEffectCreatedObservable(): Observable<{
  101174. effect: Effect;
  101175. subMesh: Nullable<SubMesh>;
  101176. }>;
  101177. /**
  101178. * Stores the value of the alpha mode
  101179. */
  101180. private _alphaMode;
  101181. /**
  101182. * Sets the value of the alpha mode.
  101183. *
  101184. * | Value | Type | Description |
  101185. * | --- | --- | --- |
  101186. * | 0 | ALPHA_DISABLE | |
  101187. * | 1 | ALPHA_ADD | |
  101188. * | 2 | ALPHA_COMBINE | |
  101189. * | 3 | ALPHA_SUBTRACT | |
  101190. * | 4 | ALPHA_MULTIPLY | |
  101191. * | 5 | ALPHA_MAXIMIZED | |
  101192. * | 6 | ALPHA_ONEONE | |
  101193. * | 7 | ALPHA_PREMULTIPLIED | |
  101194. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  101195. * | 9 | ALPHA_INTERPOLATE | |
  101196. * | 10 | ALPHA_SCREENMODE | |
  101197. *
  101198. */
  101199. set alphaMode(value: number);
  101200. /**
  101201. * Gets the value of the alpha mode
  101202. */
  101203. get alphaMode(): number;
  101204. /**
  101205. * Stores the state of the need depth pre-pass value
  101206. */
  101207. private _needDepthPrePass;
  101208. /**
  101209. * Sets the need depth pre-pass value
  101210. */
  101211. set needDepthPrePass(value: boolean);
  101212. /**
  101213. * Gets the depth pre-pass value
  101214. */
  101215. get needDepthPrePass(): boolean;
  101216. /**
  101217. * Specifies if depth writing should be disabled
  101218. */
  101219. disableDepthWrite: boolean;
  101220. /**
  101221. * Specifies if color writing should be disabled
  101222. */
  101223. disableColorWrite: boolean;
  101224. /**
  101225. * Specifies if depth writing should be forced
  101226. */
  101227. forceDepthWrite: boolean;
  101228. /**
  101229. * Specifies the depth function that should be used. 0 means the default engine function
  101230. */
  101231. depthFunction: number;
  101232. /**
  101233. * Specifies if there should be a separate pass for culling
  101234. */
  101235. separateCullingPass: boolean;
  101236. /**
  101237. * Stores the state specifing if fog should be enabled
  101238. */
  101239. private _fogEnabled;
  101240. /**
  101241. * Sets the state for enabling fog
  101242. */
  101243. set fogEnabled(value: boolean);
  101244. /**
  101245. * Gets the value of the fog enabled state
  101246. */
  101247. get fogEnabled(): boolean;
  101248. /**
  101249. * Stores the size of points
  101250. */
  101251. pointSize: number;
  101252. /**
  101253. * Stores the z offset value
  101254. */
  101255. zOffset: number;
  101256. get wireframe(): boolean;
  101257. /**
  101258. * Sets the state of wireframe mode
  101259. */
  101260. set wireframe(value: boolean);
  101261. /**
  101262. * Gets the value specifying if point clouds are enabled
  101263. */
  101264. get pointsCloud(): boolean;
  101265. /**
  101266. * Sets the state of point cloud mode
  101267. */
  101268. set pointsCloud(value: boolean);
  101269. /**
  101270. * Gets the material fill mode
  101271. */
  101272. get fillMode(): number;
  101273. /**
  101274. * Sets the material fill mode
  101275. */
  101276. set fillMode(value: number);
  101277. /**
  101278. * @hidden
  101279. * Stores the effects for the material
  101280. */
  101281. _effect: Nullable<Effect>;
  101282. /**
  101283. * Specifies if uniform buffers should be used
  101284. */
  101285. private _useUBO;
  101286. /**
  101287. * Stores a reference to the scene
  101288. */
  101289. private _scene;
  101290. /**
  101291. * Stores the fill mode state
  101292. */
  101293. private _fillMode;
  101294. /**
  101295. * Specifies if the depth write state should be cached
  101296. */
  101297. private _cachedDepthWriteState;
  101298. /**
  101299. * Specifies if the color write state should be cached
  101300. */
  101301. private _cachedColorWriteState;
  101302. /**
  101303. * Specifies if the depth function state should be cached
  101304. */
  101305. private _cachedDepthFunctionState;
  101306. /**
  101307. * Stores the uniform buffer
  101308. */
  101309. protected _uniformBuffer: UniformBuffer;
  101310. /** @hidden */
  101311. _indexInSceneMaterialArray: number;
  101312. /** @hidden */
  101313. meshMap: Nullable<{
  101314. [id: string]: AbstractMesh | undefined;
  101315. }>;
  101316. /**
  101317. * Creates a material instance
  101318. * @param name defines the name of the material
  101319. * @param scene defines the scene to reference
  101320. * @param doNotAdd specifies if the material should be added to the scene
  101321. */
  101322. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  101323. /**
  101324. * Returns a string representation of the current material
  101325. * @param fullDetails defines a boolean indicating which levels of logging is desired
  101326. * @returns a string with material information
  101327. */
  101328. toString(fullDetails?: boolean): string;
  101329. /**
  101330. * Gets the class name of the material
  101331. * @returns a string with the class name of the material
  101332. */
  101333. getClassName(): string;
  101334. /**
  101335. * Specifies if updates for the material been locked
  101336. */
  101337. get isFrozen(): boolean;
  101338. /**
  101339. * Locks updates for the material
  101340. */
  101341. freeze(): void;
  101342. /**
  101343. * Unlocks updates for the material
  101344. */
  101345. unfreeze(): void;
  101346. /**
  101347. * Specifies if the material is ready to be used
  101348. * @param mesh defines the mesh to check
  101349. * @param useInstances specifies if instances should be used
  101350. * @returns a boolean indicating if the material is ready to be used
  101351. */
  101352. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101353. /**
  101354. * Specifies that the submesh is ready to be used
  101355. * @param mesh defines the mesh to check
  101356. * @param subMesh defines which submesh to check
  101357. * @param useInstances specifies that instances should be used
  101358. * @returns a boolean indicating that the submesh is ready or not
  101359. */
  101360. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101361. /**
  101362. * Returns the material effect
  101363. * @returns the effect associated with the material
  101364. */
  101365. getEffect(): Nullable<Effect>;
  101366. /**
  101367. * Returns the current scene
  101368. * @returns a Scene
  101369. */
  101370. getScene(): Scene;
  101371. /**
  101372. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101373. */
  101374. protected _forceAlphaTest: boolean;
  101375. /**
  101376. * The transparency mode of the material.
  101377. */
  101378. protected _transparencyMode: Nullable<number>;
  101379. /**
  101380. * Gets the current transparency mode.
  101381. */
  101382. get transparencyMode(): Nullable<number>;
  101383. /**
  101384. * Sets the transparency mode of the material.
  101385. *
  101386. * | Value | Type | Description |
  101387. * | ----- | ----------------------------------- | ----------- |
  101388. * | 0 | OPAQUE | |
  101389. * | 1 | ALPHATEST | |
  101390. * | 2 | ALPHABLEND | |
  101391. * | 3 | ALPHATESTANDBLEND | |
  101392. *
  101393. */
  101394. set transparencyMode(value: Nullable<number>);
  101395. /**
  101396. * Returns true if alpha blending should be disabled.
  101397. */
  101398. protected get _disableAlphaBlending(): boolean;
  101399. /**
  101400. * Specifies whether or not this material should be rendered in alpha blend mode.
  101401. * @returns a boolean specifying if alpha blending is needed
  101402. */
  101403. needAlphaBlending(): boolean;
  101404. /**
  101405. * Specifies if the mesh will require alpha blending
  101406. * @param mesh defines the mesh to check
  101407. * @returns a boolean specifying if alpha blending is needed for the mesh
  101408. */
  101409. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  101410. /**
  101411. * Specifies whether or not this material should be rendered in alpha test mode.
  101412. * @returns a boolean specifying if an alpha test is needed.
  101413. */
  101414. needAlphaTesting(): boolean;
  101415. /**
  101416. * Specifies if material alpha testing should be turned on for the mesh
  101417. * @param mesh defines the mesh to check
  101418. */
  101419. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  101420. /**
  101421. * Gets the texture used for the alpha test
  101422. * @returns the texture to use for alpha testing
  101423. */
  101424. getAlphaTestTexture(): Nullable<BaseTexture>;
  101425. /**
  101426. * Marks the material to indicate that it needs to be re-calculated
  101427. */
  101428. markDirty(): void;
  101429. /** @hidden */
  101430. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  101431. /**
  101432. * Binds the material to the mesh
  101433. * @param world defines the world transformation matrix
  101434. * @param mesh defines the mesh to bind the material to
  101435. */
  101436. bind(world: Matrix, mesh?: Mesh): void;
  101437. /**
  101438. * Binds the submesh to the material
  101439. * @param world defines the world transformation matrix
  101440. * @param mesh defines the mesh containing the submesh
  101441. * @param subMesh defines the submesh to bind the material to
  101442. */
  101443. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101444. /**
  101445. * Binds the world matrix to the material
  101446. * @param world defines the world transformation matrix
  101447. */
  101448. bindOnlyWorldMatrix(world: Matrix): void;
  101449. /**
  101450. * Binds the scene's uniform buffer to the effect.
  101451. * @param effect defines the effect to bind to the scene uniform buffer
  101452. * @param sceneUbo defines the uniform buffer storing scene data
  101453. */
  101454. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  101455. /**
  101456. * Binds the view matrix to the effect
  101457. * @param effect defines the effect to bind the view matrix to
  101458. */
  101459. bindView(effect: Effect): void;
  101460. /**
  101461. * Binds the view projection matrix to the effect
  101462. * @param effect defines the effect to bind the view projection matrix to
  101463. */
  101464. bindViewProjection(effect: Effect): void;
  101465. /**
  101466. * Processes to execute after binding the material to a mesh
  101467. * @param mesh defines the rendered mesh
  101468. */
  101469. protected _afterBind(mesh?: Mesh): void;
  101470. /**
  101471. * Unbinds the material from the mesh
  101472. */
  101473. unbind(): void;
  101474. /**
  101475. * Gets the active textures from the material
  101476. * @returns an array of textures
  101477. */
  101478. getActiveTextures(): BaseTexture[];
  101479. /**
  101480. * Specifies if the material uses a texture
  101481. * @param texture defines the texture to check against the material
  101482. * @returns a boolean specifying if the material uses the texture
  101483. */
  101484. hasTexture(texture: BaseTexture): boolean;
  101485. /**
  101486. * Makes a duplicate of the material, and gives it a new name
  101487. * @param name defines the new name for the duplicated material
  101488. * @returns the cloned material
  101489. */
  101490. clone(name: string): Nullable<Material>;
  101491. /**
  101492. * Gets the meshes bound to the material
  101493. * @returns an array of meshes bound to the material
  101494. */
  101495. getBindedMeshes(): AbstractMesh[];
  101496. /**
  101497. * Force shader compilation
  101498. * @param mesh defines the mesh associated with this material
  101499. * @param onCompiled defines a function to execute once the material is compiled
  101500. * @param options defines the options to configure the compilation
  101501. * @param onError defines a function to execute if the material fails compiling
  101502. */
  101503. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  101504. /**
  101505. * Force shader compilation
  101506. * @param mesh defines the mesh that will use this material
  101507. * @param options defines additional options for compiling the shaders
  101508. * @returns a promise that resolves when the compilation completes
  101509. */
  101510. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  101511. private static readonly _AllDirtyCallBack;
  101512. private static readonly _ImageProcessingDirtyCallBack;
  101513. private static readonly _TextureDirtyCallBack;
  101514. private static readonly _FresnelDirtyCallBack;
  101515. private static readonly _MiscDirtyCallBack;
  101516. private static readonly _LightsDirtyCallBack;
  101517. private static readonly _AttributeDirtyCallBack;
  101518. private static _FresnelAndMiscDirtyCallBack;
  101519. private static _TextureAndMiscDirtyCallBack;
  101520. private static readonly _DirtyCallbackArray;
  101521. private static readonly _RunDirtyCallBacks;
  101522. /**
  101523. * Marks a define in the material to indicate that it needs to be re-computed
  101524. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  101525. */
  101526. markAsDirty(flag: number): void;
  101527. /**
  101528. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  101529. * @param func defines a function which checks material defines against the submeshes
  101530. */
  101531. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  101532. /**
  101533. * Indicates that we need to re-calculated for all submeshes
  101534. */
  101535. protected _markAllSubMeshesAsAllDirty(): void;
  101536. /**
  101537. * Indicates that image processing needs to be re-calculated for all submeshes
  101538. */
  101539. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  101540. /**
  101541. * Indicates that textures need to be re-calculated for all submeshes
  101542. */
  101543. protected _markAllSubMeshesAsTexturesDirty(): void;
  101544. /**
  101545. * Indicates that fresnel needs to be re-calculated for all submeshes
  101546. */
  101547. protected _markAllSubMeshesAsFresnelDirty(): void;
  101548. /**
  101549. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  101550. */
  101551. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  101552. /**
  101553. * Indicates that lights need to be re-calculated for all submeshes
  101554. */
  101555. protected _markAllSubMeshesAsLightsDirty(): void;
  101556. /**
  101557. * Indicates that attributes need to be re-calculated for all submeshes
  101558. */
  101559. protected _markAllSubMeshesAsAttributesDirty(): void;
  101560. /**
  101561. * Indicates that misc needs to be re-calculated for all submeshes
  101562. */
  101563. protected _markAllSubMeshesAsMiscDirty(): void;
  101564. /**
  101565. * Indicates that textures and misc need to be re-calculated for all submeshes
  101566. */
  101567. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  101568. /**
  101569. * Disposes the material
  101570. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101571. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101572. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  101573. */
  101574. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  101575. /** @hidden */
  101576. private releaseVertexArrayObject;
  101577. /**
  101578. * Serializes this material
  101579. * @returns the serialized material object
  101580. */
  101581. serialize(): any;
  101582. /**
  101583. * Creates a material from parsed material data
  101584. * @param parsedMaterial defines parsed material data
  101585. * @param scene defines the hosting scene
  101586. * @param rootUrl defines the root URL to use to load textures
  101587. * @returns a new material
  101588. */
  101589. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  101590. }
  101591. }
  101592. declare module BABYLON {
  101593. /**
  101594. * A multi-material is used to apply different materials to different parts of the same object without the need of
  101595. * separate meshes. This can be use to improve performances.
  101596. * @see http://doc.babylonjs.com/how_to/multi_materials
  101597. */
  101598. export class MultiMaterial extends Material {
  101599. private _subMaterials;
  101600. /**
  101601. * Gets or Sets the list of Materials used within the multi material.
  101602. * They need to be ordered according to the submeshes order in the associated mesh
  101603. */
  101604. get subMaterials(): Nullable<Material>[];
  101605. set subMaterials(value: Nullable<Material>[]);
  101606. /**
  101607. * Function used to align with Node.getChildren()
  101608. * @returns the list of Materials used within the multi material
  101609. */
  101610. getChildren(): Nullable<Material>[];
  101611. /**
  101612. * Instantiates a new Multi Material
  101613. * A multi-material is used to apply different materials to different parts of the same object without the need of
  101614. * separate meshes. This can be use to improve performances.
  101615. * @see http://doc.babylonjs.com/how_to/multi_materials
  101616. * @param name Define the name in the scene
  101617. * @param scene Define the scene the material belongs to
  101618. */
  101619. constructor(name: string, scene: Scene);
  101620. private _hookArray;
  101621. /**
  101622. * Get one of the submaterial by its index in the submaterials array
  101623. * @param index The index to look the sub material at
  101624. * @returns The Material if the index has been defined
  101625. */
  101626. getSubMaterial(index: number): Nullable<Material>;
  101627. /**
  101628. * Get the list of active textures for the whole sub materials list.
  101629. * @returns All the textures that will be used during the rendering
  101630. */
  101631. getActiveTextures(): BaseTexture[];
  101632. /**
  101633. * Gets the current class name of the material e.g. "MultiMaterial"
  101634. * Mainly use in serialization.
  101635. * @returns the class name
  101636. */
  101637. getClassName(): string;
  101638. /**
  101639. * Checks if the material is ready to render the requested sub mesh
  101640. * @param mesh Define the mesh the submesh belongs to
  101641. * @param subMesh Define the sub mesh to look readyness for
  101642. * @param useInstances Define whether or not the material is used with instances
  101643. * @returns true if ready, otherwise false
  101644. */
  101645. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101646. /**
  101647. * Clones the current material and its related sub materials
  101648. * @param name Define the name of the newly cloned material
  101649. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  101650. * @returns the cloned material
  101651. */
  101652. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  101653. /**
  101654. * Serializes the materials into a JSON representation.
  101655. * @returns the JSON representation
  101656. */
  101657. serialize(): any;
  101658. /**
  101659. * Dispose the material and release its associated resources
  101660. * @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)
  101661. * @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)
  101662. * @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)
  101663. */
  101664. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  101665. /**
  101666. * Creates a MultiMaterial from parsed MultiMaterial data.
  101667. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  101668. * @param scene defines the hosting scene
  101669. * @returns a new MultiMaterial
  101670. */
  101671. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  101672. }
  101673. }
  101674. declare module BABYLON {
  101675. /**
  101676. * Defines a subdivision inside a mesh
  101677. */
  101678. export class SubMesh implements ICullable {
  101679. /** the material index to use */
  101680. materialIndex: number;
  101681. /** vertex index start */
  101682. verticesStart: number;
  101683. /** vertices count */
  101684. verticesCount: number;
  101685. /** index start */
  101686. indexStart: number;
  101687. /** indices count */
  101688. indexCount: number;
  101689. /** @hidden */
  101690. _materialDefines: Nullable<MaterialDefines>;
  101691. /** @hidden */
  101692. _materialEffect: Nullable<Effect>;
  101693. /** @hidden */
  101694. _effectOverride: Nullable<Effect>;
  101695. /**
  101696. * Gets material defines used by the effect associated to the sub mesh
  101697. */
  101698. get materialDefines(): Nullable<MaterialDefines>;
  101699. /**
  101700. * Sets material defines used by the effect associated to the sub mesh
  101701. */
  101702. set materialDefines(defines: Nullable<MaterialDefines>);
  101703. /**
  101704. * Gets associated effect
  101705. */
  101706. get effect(): Nullable<Effect>;
  101707. /**
  101708. * Sets associated effect (effect used to render this submesh)
  101709. * @param effect defines the effect to associate with
  101710. * @param defines defines the set of defines used to compile this effect
  101711. */
  101712. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  101713. /** @hidden */
  101714. _linesIndexCount: number;
  101715. private _mesh;
  101716. private _renderingMesh;
  101717. private _boundingInfo;
  101718. private _linesIndexBuffer;
  101719. /** @hidden */
  101720. _lastColliderWorldVertices: Nullable<Vector3[]>;
  101721. /** @hidden */
  101722. _trianglePlanes: Plane[];
  101723. /** @hidden */
  101724. _lastColliderTransformMatrix: Nullable<Matrix>;
  101725. /** @hidden */
  101726. _renderId: number;
  101727. /** @hidden */
  101728. _alphaIndex: number;
  101729. /** @hidden */
  101730. _distanceToCamera: number;
  101731. /** @hidden */
  101732. _id: number;
  101733. private _currentMaterial;
  101734. /**
  101735. * Add a new submesh to a mesh
  101736. * @param materialIndex defines the material index to use
  101737. * @param verticesStart defines vertex index start
  101738. * @param verticesCount defines vertices count
  101739. * @param indexStart defines index start
  101740. * @param indexCount defines indices count
  101741. * @param mesh defines the parent mesh
  101742. * @param renderingMesh defines an optional rendering mesh
  101743. * @param createBoundingBox defines if bounding box should be created for this submesh
  101744. * @returns the new submesh
  101745. */
  101746. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  101747. /**
  101748. * Creates a new submesh
  101749. * @param materialIndex defines the material index to use
  101750. * @param verticesStart defines vertex index start
  101751. * @param verticesCount defines vertices count
  101752. * @param indexStart defines index start
  101753. * @param indexCount defines indices count
  101754. * @param mesh defines the parent mesh
  101755. * @param renderingMesh defines an optional rendering mesh
  101756. * @param createBoundingBox defines if bounding box should be created for this submesh
  101757. */
  101758. constructor(
  101759. /** the material index to use */
  101760. materialIndex: number,
  101761. /** vertex index start */
  101762. verticesStart: number,
  101763. /** vertices count */
  101764. verticesCount: number,
  101765. /** index start */
  101766. indexStart: number,
  101767. /** indices count */
  101768. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  101769. /**
  101770. * Returns true if this submesh covers the entire parent mesh
  101771. * @ignorenaming
  101772. */
  101773. get IsGlobal(): boolean;
  101774. /**
  101775. * Returns the submesh BoudingInfo object
  101776. * @returns current bounding info (or mesh's one if the submesh is global)
  101777. */
  101778. getBoundingInfo(): BoundingInfo;
  101779. /**
  101780. * Sets the submesh BoundingInfo
  101781. * @param boundingInfo defines the new bounding info to use
  101782. * @returns the SubMesh
  101783. */
  101784. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  101785. /**
  101786. * Returns the mesh of the current submesh
  101787. * @return the parent mesh
  101788. */
  101789. getMesh(): AbstractMesh;
  101790. /**
  101791. * Returns the rendering mesh of the submesh
  101792. * @returns the rendering mesh (could be different from parent mesh)
  101793. */
  101794. getRenderingMesh(): Mesh;
  101795. /**
  101796. * Returns the replacement mesh of the submesh
  101797. * @returns the replacement mesh (could be different from parent mesh)
  101798. */
  101799. getReplacementMesh(): Nullable<AbstractMesh>;
  101800. /**
  101801. * Returns the effective mesh of the submesh
  101802. * @returns the effective mesh (could be different from parent mesh)
  101803. */
  101804. getEffectiveMesh(): AbstractMesh;
  101805. /**
  101806. * Returns the submesh material
  101807. * @returns null or the current material
  101808. */
  101809. getMaterial(): Nullable<Material>;
  101810. /**
  101811. * Sets a new updated BoundingInfo object to the submesh
  101812. * @param data defines an optional position array to use to determine the bounding info
  101813. * @returns the SubMesh
  101814. */
  101815. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  101816. /** @hidden */
  101817. _checkCollision(collider: Collider): boolean;
  101818. /**
  101819. * Updates the submesh BoundingInfo
  101820. * @param world defines the world matrix to use to update the bounding info
  101821. * @returns the submesh
  101822. */
  101823. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  101824. /**
  101825. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  101826. * @param frustumPlanes defines the frustum planes
  101827. * @returns true if the submesh is intersecting with the frustum
  101828. */
  101829. isInFrustum(frustumPlanes: Plane[]): boolean;
  101830. /**
  101831. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  101832. * @param frustumPlanes defines the frustum planes
  101833. * @returns true if the submesh is inside the frustum
  101834. */
  101835. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101836. /**
  101837. * Renders the submesh
  101838. * @param enableAlphaMode defines if alpha needs to be used
  101839. * @returns the submesh
  101840. */
  101841. render(enableAlphaMode: boolean): SubMesh;
  101842. /**
  101843. * @hidden
  101844. */
  101845. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  101846. /**
  101847. * Checks if the submesh intersects with a ray
  101848. * @param ray defines the ray to test
  101849. * @returns true is the passed ray intersects the submesh bounding box
  101850. */
  101851. canIntersects(ray: Ray): boolean;
  101852. /**
  101853. * Intersects current submesh with a ray
  101854. * @param ray defines the ray to test
  101855. * @param positions defines mesh's positions array
  101856. * @param indices defines mesh's indices array
  101857. * @param fastCheck defines if the first intersection will be used (and not the closest)
  101858. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101859. * @returns intersection info or null if no intersection
  101860. */
  101861. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  101862. /** @hidden */
  101863. private _intersectLines;
  101864. /** @hidden */
  101865. private _intersectUnIndexedLines;
  101866. /** @hidden */
  101867. private _intersectTriangles;
  101868. /** @hidden */
  101869. private _intersectUnIndexedTriangles;
  101870. /** @hidden */
  101871. _rebuild(): void;
  101872. /**
  101873. * Creates a new submesh from the passed mesh
  101874. * @param newMesh defines the new hosting mesh
  101875. * @param newRenderingMesh defines an optional rendering mesh
  101876. * @returns the new submesh
  101877. */
  101878. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  101879. /**
  101880. * Release associated resources
  101881. */
  101882. dispose(): void;
  101883. /**
  101884. * Gets the class name
  101885. * @returns the string "SubMesh".
  101886. */
  101887. getClassName(): string;
  101888. /**
  101889. * Creates a new submesh from indices data
  101890. * @param materialIndex the index of the main mesh material
  101891. * @param startIndex the index where to start the copy in the mesh indices array
  101892. * @param indexCount the number of indices to copy then from the startIndex
  101893. * @param mesh the main mesh to create the submesh from
  101894. * @param renderingMesh the optional rendering mesh
  101895. * @returns a new submesh
  101896. */
  101897. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  101898. }
  101899. }
  101900. declare module BABYLON {
  101901. /**
  101902. * Class used to represent data loading progression
  101903. */
  101904. export class SceneLoaderFlags {
  101905. private static _ForceFullSceneLoadingForIncremental;
  101906. private static _ShowLoadingScreen;
  101907. private static _CleanBoneMatrixWeights;
  101908. private static _loggingLevel;
  101909. /**
  101910. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  101911. */
  101912. static get ForceFullSceneLoadingForIncremental(): boolean;
  101913. static set ForceFullSceneLoadingForIncremental(value: boolean);
  101914. /**
  101915. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  101916. */
  101917. static get ShowLoadingScreen(): boolean;
  101918. static set ShowLoadingScreen(value: boolean);
  101919. /**
  101920. * Defines the current logging level (while loading the scene)
  101921. * @ignorenaming
  101922. */
  101923. static get loggingLevel(): number;
  101924. static set loggingLevel(value: number);
  101925. /**
  101926. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  101927. */
  101928. static get CleanBoneMatrixWeights(): boolean;
  101929. static set CleanBoneMatrixWeights(value: boolean);
  101930. }
  101931. }
  101932. declare module BABYLON {
  101933. /**
  101934. * Class used to store geometry data (vertex buffers + index buffer)
  101935. */
  101936. export class Geometry implements IGetSetVerticesData {
  101937. /**
  101938. * Gets or sets the ID of the geometry
  101939. */
  101940. id: string;
  101941. /**
  101942. * Gets or sets the unique ID of the geometry
  101943. */
  101944. uniqueId: number;
  101945. /**
  101946. * Gets the delay loading state of the geometry (none by default which means not delayed)
  101947. */
  101948. delayLoadState: number;
  101949. /**
  101950. * Gets the file containing the data to load when running in delay load state
  101951. */
  101952. delayLoadingFile: Nullable<string>;
  101953. /**
  101954. * Callback called when the geometry is updated
  101955. */
  101956. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  101957. private _scene;
  101958. private _engine;
  101959. private _meshes;
  101960. private _totalVertices;
  101961. /** @hidden */
  101962. _indices: IndicesArray;
  101963. /** @hidden */
  101964. _vertexBuffers: {
  101965. [key: string]: VertexBuffer;
  101966. };
  101967. private _isDisposed;
  101968. private _extend;
  101969. private _boundingBias;
  101970. /** @hidden */
  101971. _delayInfo: Array<string>;
  101972. private _indexBuffer;
  101973. private _indexBufferIsUpdatable;
  101974. /** @hidden */
  101975. _boundingInfo: Nullable<BoundingInfo>;
  101976. /** @hidden */
  101977. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  101978. /** @hidden */
  101979. _softwareSkinningFrameId: number;
  101980. private _vertexArrayObjects;
  101981. private _updatable;
  101982. /** @hidden */
  101983. _positions: Nullable<Vector3[]>;
  101984. /**
  101985. * 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
  101986. */
  101987. get boundingBias(): Vector2;
  101988. /**
  101989. * 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
  101990. */
  101991. set boundingBias(value: Vector2);
  101992. /**
  101993. * Static function used to attach a new empty geometry to a mesh
  101994. * @param mesh defines the mesh to attach the geometry to
  101995. * @returns the new Geometry
  101996. */
  101997. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  101998. /** Get the list of meshes using this geometry */
  101999. get meshes(): Mesh[];
  102000. /**
  102001. * Creates a new geometry
  102002. * @param id defines the unique ID
  102003. * @param scene defines the hosting scene
  102004. * @param vertexData defines the VertexData used to get geometry data
  102005. * @param updatable defines if geometry must be updatable (false by default)
  102006. * @param mesh defines the mesh that will be associated with the geometry
  102007. */
  102008. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  102009. /**
  102010. * Gets the current extend of the geometry
  102011. */
  102012. get extend(): {
  102013. minimum: Vector3;
  102014. maximum: Vector3;
  102015. };
  102016. /**
  102017. * Gets the hosting scene
  102018. * @returns the hosting Scene
  102019. */
  102020. getScene(): Scene;
  102021. /**
  102022. * Gets the hosting engine
  102023. * @returns the hosting Engine
  102024. */
  102025. getEngine(): Engine;
  102026. /**
  102027. * Defines if the geometry is ready to use
  102028. * @returns true if the geometry is ready to be used
  102029. */
  102030. isReady(): boolean;
  102031. /**
  102032. * Gets a value indicating that the geometry should not be serialized
  102033. */
  102034. get doNotSerialize(): boolean;
  102035. /** @hidden */
  102036. _rebuild(): void;
  102037. /**
  102038. * Affects all geometry data in one call
  102039. * @param vertexData defines the geometry data
  102040. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  102041. */
  102042. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  102043. /**
  102044. * Set specific vertex data
  102045. * @param kind defines the data kind (Position, normal, etc...)
  102046. * @param data defines the vertex data to use
  102047. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  102048. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  102049. */
  102050. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  102051. /**
  102052. * Removes a specific vertex data
  102053. * @param kind defines the data kind (Position, normal, etc...)
  102054. */
  102055. removeVerticesData(kind: string): void;
  102056. /**
  102057. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  102058. * @param buffer defines the vertex buffer to use
  102059. * @param totalVertices defines the total number of vertices for position kind (could be null)
  102060. */
  102061. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  102062. /**
  102063. * Update a specific vertex buffer
  102064. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  102065. * It will do nothing if the buffer is not updatable
  102066. * @param kind defines the data kind (Position, normal, etc...)
  102067. * @param data defines the data to use
  102068. * @param offset defines the offset in the target buffer where to store the data
  102069. * @param useBytes set to true if the offset is in bytes
  102070. */
  102071. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  102072. /**
  102073. * Update a specific vertex buffer
  102074. * This function will create a new buffer if the current one is not updatable
  102075. * @param kind defines the data kind (Position, normal, etc...)
  102076. * @param data defines the data to use
  102077. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  102078. */
  102079. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  102080. private _updateBoundingInfo;
  102081. /** @hidden */
  102082. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  102083. /**
  102084. * Gets total number of vertices
  102085. * @returns the total number of vertices
  102086. */
  102087. getTotalVertices(): number;
  102088. /**
  102089. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  102090. * @param kind defines the data kind (Position, normal, etc...)
  102091. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102092. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102093. * @returns a float array containing vertex data
  102094. */
  102095. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  102096. /**
  102097. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  102098. * @param kind defines the data kind (Position, normal, etc...)
  102099. * @returns true if the vertex buffer with the specified kind is updatable
  102100. */
  102101. isVertexBufferUpdatable(kind: string): boolean;
  102102. /**
  102103. * Gets a specific vertex buffer
  102104. * @param kind defines the data kind (Position, normal, etc...)
  102105. * @returns a VertexBuffer
  102106. */
  102107. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  102108. /**
  102109. * Returns all vertex buffers
  102110. * @return an object holding all vertex buffers indexed by kind
  102111. */
  102112. getVertexBuffers(): Nullable<{
  102113. [key: string]: VertexBuffer;
  102114. }>;
  102115. /**
  102116. * Gets a boolean indicating if specific vertex buffer is present
  102117. * @param kind defines the data kind (Position, normal, etc...)
  102118. * @returns true if data is present
  102119. */
  102120. isVerticesDataPresent(kind: string): boolean;
  102121. /**
  102122. * Gets a list of all attached data kinds (Position, normal, etc...)
  102123. * @returns a list of string containing all kinds
  102124. */
  102125. getVerticesDataKinds(): string[];
  102126. /**
  102127. * Update index buffer
  102128. * @param indices defines the indices to store in the index buffer
  102129. * @param offset defines the offset in the target buffer where to store the data
  102130. * @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)
  102131. */
  102132. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  102133. /**
  102134. * Creates a new index buffer
  102135. * @param indices defines the indices to store in the index buffer
  102136. * @param totalVertices defines the total number of vertices (could be null)
  102137. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  102138. */
  102139. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  102140. /**
  102141. * Return the total number of indices
  102142. * @returns the total number of indices
  102143. */
  102144. getTotalIndices(): number;
  102145. /**
  102146. * Gets the index buffer array
  102147. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102148. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102149. * @returns the index buffer array
  102150. */
  102151. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  102152. /**
  102153. * Gets the index buffer
  102154. * @return the index buffer
  102155. */
  102156. getIndexBuffer(): Nullable<DataBuffer>;
  102157. /** @hidden */
  102158. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  102159. /**
  102160. * Release the associated resources for a specific mesh
  102161. * @param mesh defines the source mesh
  102162. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  102163. */
  102164. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  102165. /**
  102166. * Apply current geometry to a given mesh
  102167. * @param mesh defines the mesh to apply geometry to
  102168. */
  102169. applyToMesh(mesh: Mesh): void;
  102170. private _updateExtend;
  102171. private _applyToMesh;
  102172. private notifyUpdate;
  102173. /**
  102174. * Load the geometry if it was flagged as delay loaded
  102175. * @param scene defines the hosting scene
  102176. * @param onLoaded defines a callback called when the geometry is loaded
  102177. */
  102178. load(scene: Scene, onLoaded?: () => void): void;
  102179. private _queueLoad;
  102180. /**
  102181. * Invert the geometry to move from a right handed system to a left handed one.
  102182. */
  102183. toLeftHanded(): void;
  102184. /** @hidden */
  102185. _resetPointsArrayCache(): void;
  102186. /** @hidden */
  102187. _generatePointsArray(): boolean;
  102188. /**
  102189. * Gets a value indicating if the geometry is disposed
  102190. * @returns true if the geometry was disposed
  102191. */
  102192. isDisposed(): boolean;
  102193. private _disposeVertexArrayObjects;
  102194. /**
  102195. * Free all associated resources
  102196. */
  102197. dispose(): void;
  102198. /**
  102199. * Clone the current geometry into a new geometry
  102200. * @param id defines the unique ID of the new geometry
  102201. * @returns a new geometry object
  102202. */
  102203. copy(id: string): Geometry;
  102204. /**
  102205. * Serialize the current geometry info (and not the vertices data) into a JSON object
  102206. * @return a JSON representation of the current geometry data (without the vertices data)
  102207. */
  102208. serialize(): any;
  102209. private toNumberArray;
  102210. /**
  102211. * Serialize all vertices data into a JSON oject
  102212. * @returns a JSON representation of the current geometry data
  102213. */
  102214. serializeVerticeData(): any;
  102215. /**
  102216. * Extracts a clone of a mesh geometry
  102217. * @param mesh defines the source mesh
  102218. * @param id defines the unique ID of the new geometry object
  102219. * @returns the new geometry object
  102220. */
  102221. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  102222. /**
  102223. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  102224. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102225. * Be aware Math.random() could cause collisions, but:
  102226. * "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"
  102227. * @returns a string containing a new GUID
  102228. */
  102229. static RandomId(): string;
  102230. /** @hidden */
  102231. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  102232. private static _CleanMatricesWeights;
  102233. /**
  102234. * Create a new geometry from persisted data (Using .babylon file format)
  102235. * @param parsedVertexData defines the persisted data
  102236. * @param scene defines the hosting scene
  102237. * @param rootUrl defines the root url to use to load assets (like delayed data)
  102238. * @returns the new geometry object
  102239. */
  102240. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  102241. }
  102242. }
  102243. declare module BABYLON {
  102244. /**
  102245. * Define an interface for all classes that will get and set the data on vertices
  102246. */
  102247. export interface IGetSetVerticesData {
  102248. /**
  102249. * Gets a boolean indicating if specific vertex data is present
  102250. * @param kind defines the vertex data kind to use
  102251. * @returns true is data kind is present
  102252. */
  102253. isVerticesDataPresent(kind: string): boolean;
  102254. /**
  102255. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  102256. * @param kind defines the data kind (Position, normal, etc...)
  102257. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102258. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102259. * @returns a float array containing vertex data
  102260. */
  102261. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  102262. /**
  102263. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  102264. * @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.
  102265. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102266. * @returns the indices array or an empty array if the mesh has no geometry
  102267. */
  102268. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  102269. /**
  102270. * Set specific vertex data
  102271. * @param kind defines the data kind (Position, normal, etc...)
  102272. * @param data defines the vertex data to use
  102273. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  102274. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  102275. */
  102276. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  102277. /**
  102278. * Update a specific associated vertex buffer
  102279. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  102280. * - VertexBuffer.PositionKind
  102281. * - VertexBuffer.UVKind
  102282. * - VertexBuffer.UV2Kind
  102283. * - VertexBuffer.UV3Kind
  102284. * - VertexBuffer.UV4Kind
  102285. * - VertexBuffer.UV5Kind
  102286. * - VertexBuffer.UV6Kind
  102287. * - VertexBuffer.ColorKind
  102288. * - VertexBuffer.MatricesIndicesKind
  102289. * - VertexBuffer.MatricesIndicesExtraKind
  102290. * - VertexBuffer.MatricesWeightsKind
  102291. * - VertexBuffer.MatricesWeightsExtraKind
  102292. * @param data defines the data source
  102293. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  102294. * @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)
  102295. */
  102296. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  102297. /**
  102298. * Creates a new index buffer
  102299. * @param indices defines the indices to store in the index buffer
  102300. * @param totalVertices defines the total number of vertices (could be null)
  102301. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  102302. */
  102303. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  102304. }
  102305. /**
  102306. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  102307. */
  102308. export class VertexData {
  102309. /**
  102310. * Mesh side orientation : usually the external or front surface
  102311. */
  102312. static readonly FRONTSIDE: number;
  102313. /**
  102314. * Mesh side orientation : usually the internal or back surface
  102315. */
  102316. static readonly BACKSIDE: number;
  102317. /**
  102318. * Mesh side orientation : both internal and external or front and back surfaces
  102319. */
  102320. static readonly DOUBLESIDE: number;
  102321. /**
  102322. * Mesh side orientation : by default, `FRONTSIDE`
  102323. */
  102324. static readonly DEFAULTSIDE: number;
  102325. /**
  102326. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  102327. */
  102328. positions: Nullable<FloatArray>;
  102329. /**
  102330. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  102331. */
  102332. normals: Nullable<FloatArray>;
  102333. /**
  102334. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  102335. */
  102336. tangents: Nullable<FloatArray>;
  102337. /**
  102338. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102339. */
  102340. uvs: Nullable<FloatArray>;
  102341. /**
  102342. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102343. */
  102344. uvs2: Nullable<FloatArray>;
  102345. /**
  102346. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102347. */
  102348. uvs3: Nullable<FloatArray>;
  102349. /**
  102350. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102351. */
  102352. uvs4: Nullable<FloatArray>;
  102353. /**
  102354. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102355. */
  102356. uvs5: Nullable<FloatArray>;
  102357. /**
  102358. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102359. */
  102360. uvs6: Nullable<FloatArray>;
  102361. /**
  102362. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  102363. */
  102364. colors: Nullable<FloatArray>;
  102365. /**
  102366. * 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).
  102367. */
  102368. matricesIndices: Nullable<FloatArray>;
  102369. /**
  102370. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  102371. */
  102372. matricesWeights: Nullable<FloatArray>;
  102373. /**
  102374. * An array extending the number of possible indices
  102375. */
  102376. matricesIndicesExtra: Nullable<FloatArray>;
  102377. /**
  102378. * An array extending the number of possible weights when the number of indices is extended
  102379. */
  102380. matricesWeightsExtra: Nullable<FloatArray>;
  102381. /**
  102382. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  102383. */
  102384. indices: Nullable<IndicesArray>;
  102385. /**
  102386. * Uses the passed data array to set the set the values for the specified kind of data
  102387. * @param data a linear array of floating numbers
  102388. * @param kind the type of data that is being set, eg positions, colors etc
  102389. */
  102390. set(data: FloatArray, kind: string): void;
  102391. /**
  102392. * Associates the vertexData to the passed Mesh.
  102393. * Sets it as updatable or not (default `false`)
  102394. * @param mesh the mesh the vertexData is applied to
  102395. * @param updatable when used and having the value true allows new data to update the vertexData
  102396. * @returns the VertexData
  102397. */
  102398. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  102399. /**
  102400. * Associates the vertexData to the passed Geometry.
  102401. * Sets it as updatable or not (default `false`)
  102402. * @param geometry the geometry the vertexData is applied to
  102403. * @param updatable when used and having the value true allows new data to update the vertexData
  102404. * @returns VertexData
  102405. */
  102406. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  102407. /**
  102408. * Updates the associated mesh
  102409. * @param mesh the mesh to be updated
  102410. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  102411. * @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
  102412. * @returns VertexData
  102413. */
  102414. updateMesh(mesh: Mesh): VertexData;
  102415. /**
  102416. * Updates the associated geometry
  102417. * @param geometry the geometry to be updated
  102418. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  102419. * @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
  102420. * @returns VertexData.
  102421. */
  102422. updateGeometry(geometry: Geometry): VertexData;
  102423. private _applyTo;
  102424. private _update;
  102425. /**
  102426. * Transforms each position and each normal of the vertexData according to the passed Matrix
  102427. * @param matrix the transforming matrix
  102428. * @returns the VertexData
  102429. */
  102430. transform(matrix: Matrix): VertexData;
  102431. /**
  102432. * Merges the passed VertexData into the current one
  102433. * @param other the VertexData to be merged into the current one
  102434. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  102435. * @returns the modified VertexData
  102436. */
  102437. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  102438. private _mergeElement;
  102439. private _validate;
  102440. /**
  102441. * Serializes the VertexData
  102442. * @returns a serialized object
  102443. */
  102444. serialize(): any;
  102445. /**
  102446. * Extracts the vertexData from a mesh
  102447. * @param mesh the mesh from which to extract the VertexData
  102448. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  102449. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102450. * @returns the object VertexData associated to the passed mesh
  102451. */
  102452. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  102453. /**
  102454. * Extracts the vertexData from the geometry
  102455. * @param geometry the geometry from which to extract the VertexData
  102456. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  102457. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102458. * @returns the object VertexData associated to the passed mesh
  102459. */
  102460. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  102461. private static _ExtractFrom;
  102462. /**
  102463. * Creates the VertexData for a Ribbon
  102464. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  102465. * * pathArray array of paths, each of which an array of successive Vector3
  102466. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  102467. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  102468. * * 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
  102469. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102470. * * 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)
  102471. * * 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)
  102472. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  102473. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  102474. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  102475. * @returns the VertexData of the ribbon
  102476. */
  102477. static CreateRibbon(options: {
  102478. pathArray: Vector3[][];
  102479. closeArray?: boolean;
  102480. closePath?: boolean;
  102481. offset?: number;
  102482. sideOrientation?: number;
  102483. frontUVs?: Vector4;
  102484. backUVs?: Vector4;
  102485. invertUV?: boolean;
  102486. uvs?: Vector2[];
  102487. colors?: Color4[];
  102488. }): VertexData;
  102489. /**
  102490. * Creates the VertexData for a box
  102491. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102492. * * size sets the width, height and depth of the box to the value of size, optional default 1
  102493. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  102494. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  102495. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  102496. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  102497. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  102498. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102499. * * 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)
  102500. * * 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)
  102501. * @returns the VertexData of the box
  102502. */
  102503. static CreateBox(options: {
  102504. size?: number;
  102505. width?: number;
  102506. height?: number;
  102507. depth?: number;
  102508. faceUV?: Vector4[];
  102509. faceColors?: Color4[];
  102510. sideOrientation?: number;
  102511. frontUVs?: Vector4;
  102512. backUVs?: Vector4;
  102513. }): VertexData;
  102514. /**
  102515. * Creates the VertexData for a tiled box
  102516. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102517. * * faceTiles sets the pattern, tile size and number of tiles for a face
  102518. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  102519. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  102520. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102521. * @returns the VertexData of the box
  102522. */
  102523. static CreateTiledBox(options: {
  102524. pattern?: number;
  102525. width?: number;
  102526. height?: number;
  102527. depth?: number;
  102528. tileSize?: number;
  102529. tileWidth?: number;
  102530. tileHeight?: number;
  102531. alignHorizontal?: number;
  102532. alignVertical?: number;
  102533. faceUV?: Vector4[];
  102534. faceColors?: Color4[];
  102535. sideOrientation?: number;
  102536. }): VertexData;
  102537. /**
  102538. * Creates the VertexData for a tiled plane
  102539. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102540. * * pattern a limited pattern arrangement depending on the number
  102541. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  102542. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  102543. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  102544. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102545. * * 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)
  102546. * * 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)
  102547. * @returns the VertexData of the tiled plane
  102548. */
  102549. static CreateTiledPlane(options: {
  102550. pattern?: number;
  102551. tileSize?: number;
  102552. tileWidth?: number;
  102553. tileHeight?: number;
  102554. size?: number;
  102555. width?: number;
  102556. height?: number;
  102557. alignHorizontal?: number;
  102558. alignVertical?: number;
  102559. sideOrientation?: number;
  102560. frontUVs?: Vector4;
  102561. backUVs?: Vector4;
  102562. }): VertexData;
  102563. /**
  102564. * Creates the VertexData for an ellipsoid, defaults to a sphere
  102565. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102566. * * segments sets the number of horizontal strips optional, default 32
  102567. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  102568. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  102569. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  102570. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  102571. * * 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
  102572. * * 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
  102573. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102574. * * 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)
  102575. * * 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)
  102576. * @returns the VertexData of the ellipsoid
  102577. */
  102578. static CreateSphere(options: {
  102579. segments?: number;
  102580. diameter?: number;
  102581. diameterX?: number;
  102582. diameterY?: number;
  102583. diameterZ?: number;
  102584. arc?: number;
  102585. slice?: number;
  102586. sideOrientation?: number;
  102587. frontUVs?: Vector4;
  102588. backUVs?: Vector4;
  102589. }): VertexData;
  102590. /**
  102591. * Creates the VertexData for a cylinder, cone or prism
  102592. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102593. * * height sets the height (y direction) of the cylinder, optional, default 2
  102594. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  102595. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  102596. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  102597. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  102598. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  102599. * * 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
  102600. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  102601. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  102602. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  102603. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  102604. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102605. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  102606. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  102607. * @returns the VertexData of the cylinder, cone or prism
  102608. */
  102609. static CreateCylinder(options: {
  102610. height?: number;
  102611. diameterTop?: number;
  102612. diameterBottom?: number;
  102613. diameter?: number;
  102614. tessellation?: number;
  102615. subdivisions?: number;
  102616. arc?: number;
  102617. faceColors?: Color4[];
  102618. faceUV?: Vector4[];
  102619. hasRings?: boolean;
  102620. enclose?: boolean;
  102621. sideOrientation?: number;
  102622. frontUVs?: Vector4;
  102623. backUVs?: Vector4;
  102624. }): VertexData;
  102625. /**
  102626. * Creates the VertexData for a torus
  102627. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102628. * * diameter the diameter of the torus, optional default 1
  102629. * * thickness the diameter of the tube forming the torus, optional default 0.5
  102630. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  102631. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102632. * * 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)
  102633. * * 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)
  102634. * @returns the VertexData of the torus
  102635. */
  102636. static CreateTorus(options: {
  102637. diameter?: number;
  102638. thickness?: number;
  102639. tessellation?: number;
  102640. sideOrientation?: number;
  102641. frontUVs?: Vector4;
  102642. backUVs?: Vector4;
  102643. }): VertexData;
  102644. /**
  102645. * Creates the VertexData of the LineSystem
  102646. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  102647. * - lines an array of lines, each line being an array of successive Vector3
  102648. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  102649. * @returns the VertexData of the LineSystem
  102650. */
  102651. static CreateLineSystem(options: {
  102652. lines: Vector3[][];
  102653. colors?: Nullable<Color4[][]>;
  102654. }): VertexData;
  102655. /**
  102656. * Create the VertexData for a DashedLines
  102657. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  102658. * - points an array successive Vector3
  102659. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  102660. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  102661. * - dashNb the intended total number of dashes, optional, default 200
  102662. * @returns the VertexData for the DashedLines
  102663. */
  102664. static CreateDashedLines(options: {
  102665. points: Vector3[];
  102666. dashSize?: number;
  102667. gapSize?: number;
  102668. dashNb?: number;
  102669. }): VertexData;
  102670. /**
  102671. * Creates the VertexData for a Ground
  102672. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  102673. * - width the width (x direction) of the ground, optional, default 1
  102674. * - height the height (z direction) of the ground, optional, default 1
  102675. * - subdivisions the number of subdivisions per side, optional, default 1
  102676. * @returns the VertexData of the Ground
  102677. */
  102678. static CreateGround(options: {
  102679. width?: number;
  102680. height?: number;
  102681. subdivisions?: number;
  102682. subdivisionsX?: number;
  102683. subdivisionsY?: number;
  102684. }): VertexData;
  102685. /**
  102686. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  102687. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  102688. * * xmin the ground minimum X coordinate, optional, default -1
  102689. * * zmin the ground minimum Z coordinate, optional, default -1
  102690. * * xmax the ground maximum X coordinate, optional, default 1
  102691. * * zmax the ground maximum Z coordinate, optional, default 1
  102692. * * 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}
  102693. * * 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}
  102694. * @returns the VertexData of the TiledGround
  102695. */
  102696. static CreateTiledGround(options: {
  102697. xmin: number;
  102698. zmin: number;
  102699. xmax: number;
  102700. zmax: number;
  102701. subdivisions?: {
  102702. w: number;
  102703. h: number;
  102704. };
  102705. precision?: {
  102706. w: number;
  102707. h: number;
  102708. };
  102709. }): VertexData;
  102710. /**
  102711. * Creates the VertexData of the Ground designed from a heightmap
  102712. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  102713. * * width the width (x direction) of the ground
  102714. * * height the height (z direction) of the ground
  102715. * * subdivisions the number of subdivisions per side
  102716. * * minHeight the minimum altitude on the ground, optional, default 0
  102717. * * maxHeight the maximum altitude on the ground, optional default 1
  102718. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  102719. * * buffer the array holding the image color data
  102720. * * bufferWidth the width of image
  102721. * * bufferHeight the height of image
  102722. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  102723. * @returns the VertexData of the Ground designed from a heightmap
  102724. */
  102725. static CreateGroundFromHeightMap(options: {
  102726. width: number;
  102727. height: number;
  102728. subdivisions: number;
  102729. minHeight: number;
  102730. maxHeight: number;
  102731. colorFilter: Color3;
  102732. buffer: Uint8Array;
  102733. bufferWidth: number;
  102734. bufferHeight: number;
  102735. alphaFilter: number;
  102736. }): VertexData;
  102737. /**
  102738. * Creates the VertexData for a Plane
  102739. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  102740. * * size sets the width and height of the plane to the value of size, optional default 1
  102741. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  102742. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  102743. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102744. * * 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)
  102745. * * 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)
  102746. * @returns the VertexData of the box
  102747. */
  102748. static CreatePlane(options: {
  102749. size?: number;
  102750. width?: number;
  102751. height?: number;
  102752. sideOrientation?: number;
  102753. frontUVs?: Vector4;
  102754. backUVs?: Vector4;
  102755. }): VertexData;
  102756. /**
  102757. * Creates the VertexData of the Disc or regular Polygon
  102758. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  102759. * * radius the radius of the disc, optional default 0.5
  102760. * * tessellation the number of polygon sides, optional, default 64
  102761. * * 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
  102762. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102763. * * 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)
  102764. * * 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)
  102765. * @returns the VertexData of the box
  102766. */
  102767. static CreateDisc(options: {
  102768. radius?: number;
  102769. tessellation?: number;
  102770. arc?: number;
  102771. sideOrientation?: number;
  102772. frontUVs?: Vector4;
  102773. backUVs?: Vector4;
  102774. }): VertexData;
  102775. /**
  102776. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  102777. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  102778. * @param polygon a mesh built from polygonTriangulation.build()
  102779. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102780. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  102781. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  102782. * @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)
  102783. * @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)
  102784. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  102785. * @returns the VertexData of the Polygon
  102786. */
  102787. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  102788. /**
  102789. * Creates the VertexData of the IcoSphere
  102790. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  102791. * * radius the radius of the IcoSphere, optional default 1
  102792. * * radiusX allows stretching in the x direction, optional, default radius
  102793. * * radiusY allows stretching in the y direction, optional, default radius
  102794. * * radiusZ allows stretching in the z direction, optional, default radius
  102795. * * flat when true creates a flat shaded mesh, optional, default true
  102796. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  102797. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102798. * * 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)
  102799. * * 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)
  102800. * @returns the VertexData of the IcoSphere
  102801. */
  102802. static CreateIcoSphere(options: {
  102803. radius?: number;
  102804. radiusX?: number;
  102805. radiusY?: number;
  102806. radiusZ?: number;
  102807. flat?: boolean;
  102808. subdivisions?: number;
  102809. sideOrientation?: number;
  102810. frontUVs?: Vector4;
  102811. backUVs?: Vector4;
  102812. }): VertexData;
  102813. /**
  102814. * Creates the VertexData for a Polyhedron
  102815. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  102816. * * type provided types are:
  102817. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  102818. * * 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)
  102819. * * size the size of the IcoSphere, optional default 1
  102820. * * sizeX allows stretching in the x direction, optional, default size
  102821. * * sizeY allows stretching in the y direction, optional, default size
  102822. * * sizeZ allows stretching in the z direction, optional, default size
  102823. * * 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
  102824. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  102825. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  102826. * * flat when true creates a flat shaded mesh, optional, default true
  102827. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  102828. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102829. * * 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)
  102830. * * 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)
  102831. * @returns the VertexData of the Polyhedron
  102832. */
  102833. static CreatePolyhedron(options: {
  102834. type?: number;
  102835. size?: number;
  102836. sizeX?: number;
  102837. sizeY?: number;
  102838. sizeZ?: number;
  102839. custom?: any;
  102840. faceUV?: Vector4[];
  102841. faceColors?: Color4[];
  102842. flat?: boolean;
  102843. sideOrientation?: number;
  102844. frontUVs?: Vector4;
  102845. backUVs?: Vector4;
  102846. }): VertexData;
  102847. /**
  102848. * Creates the VertexData for a TorusKnot
  102849. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  102850. * * radius the radius of the torus knot, optional, default 2
  102851. * * tube the thickness of the tube, optional, default 0.5
  102852. * * radialSegments the number of sides on each tube segments, optional, default 32
  102853. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  102854. * * p the number of windings around the z axis, optional, default 2
  102855. * * q the number of windings around the x axis, optional, default 3
  102856. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102857. * * 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)
  102858. * * 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)
  102859. * @returns the VertexData of the Torus Knot
  102860. */
  102861. static CreateTorusKnot(options: {
  102862. radius?: number;
  102863. tube?: number;
  102864. radialSegments?: number;
  102865. tubularSegments?: number;
  102866. p?: number;
  102867. q?: number;
  102868. sideOrientation?: number;
  102869. frontUVs?: Vector4;
  102870. backUVs?: Vector4;
  102871. }): VertexData;
  102872. /**
  102873. * Compute normals for given positions and indices
  102874. * @param positions an array of vertex positions, [...., x, y, z, ......]
  102875. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  102876. * @param normals an array of vertex normals, [...., x, y, z, ......]
  102877. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  102878. * * facetNormals : optional array of facet normals (vector3)
  102879. * * facetPositions : optional array of facet positions (vector3)
  102880. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  102881. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  102882. * * bInfo : optional bounding info, required for facetPartitioning computation
  102883. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  102884. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  102885. * * useRightHandedSystem: optional boolean to for right handed system computation
  102886. * * depthSort : optional boolean to enable the facet depth sort computation
  102887. * * distanceTo : optional Vector3 to compute the facet depth from this location
  102888. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  102889. */
  102890. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  102891. facetNormals?: any;
  102892. facetPositions?: any;
  102893. facetPartitioning?: any;
  102894. ratio?: number;
  102895. bInfo?: any;
  102896. bbSize?: Vector3;
  102897. subDiv?: any;
  102898. useRightHandedSystem?: boolean;
  102899. depthSort?: boolean;
  102900. distanceTo?: Vector3;
  102901. depthSortedFacets?: any;
  102902. }): void;
  102903. /** @hidden */
  102904. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  102905. /**
  102906. * Applies VertexData created from the imported parameters to the geometry
  102907. * @param parsedVertexData the parsed data from an imported file
  102908. * @param geometry the geometry to apply the VertexData to
  102909. */
  102910. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  102911. }
  102912. }
  102913. declare module BABYLON {
  102914. /**
  102915. * Defines a target to use with MorphTargetManager
  102916. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  102917. */
  102918. export class MorphTarget implements IAnimatable {
  102919. /** defines the name of the target */
  102920. name: string;
  102921. /**
  102922. * Gets or sets the list of animations
  102923. */
  102924. animations: Animation[];
  102925. private _scene;
  102926. private _positions;
  102927. private _normals;
  102928. private _tangents;
  102929. private _uvs;
  102930. private _influence;
  102931. private _uniqueId;
  102932. /**
  102933. * Observable raised when the influence changes
  102934. */
  102935. onInfluenceChanged: Observable<boolean>;
  102936. /** @hidden */
  102937. _onDataLayoutChanged: Observable<void>;
  102938. /**
  102939. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  102940. */
  102941. get influence(): number;
  102942. set influence(influence: number);
  102943. /**
  102944. * Gets or sets the id of the morph Target
  102945. */
  102946. id: string;
  102947. private _animationPropertiesOverride;
  102948. /**
  102949. * Gets or sets the animation properties override
  102950. */
  102951. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102952. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102953. /**
  102954. * Creates a new MorphTarget
  102955. * @param name defines the name of the target
  102956. * @param influence defines the influence to use
  102957. * @param scene defines the scene the morphtarget belongs to
  102958. */
  102959. constructor(
  102960. /** defines the name of the target */
  102961. name: string, influence?: number, scene?: Nullable<Scene>);
  102962. /**
  102963. * Gets the unique ID of this manager
  102964. */
  102965. get uniqueId(): number;
  102966. /**
  102967. * Gets a boolean defining if the target contains position data
  102968. */
  102969. get hasPositions(): boolean;
  102970. /**
  102971. * Gets a boolean defining if the target contains normal data
  102972. */
  102973. get hasNormals(): boolean;
  102974. /**
  102975. * Gets a boolean defining if the target contains tangent data
  102976. */
  102977. get hasTangents(): boolean;
  102978. /**
  102979. * Gets a boolean defining if the target contains texture coordinates data
  102980. */
  102981. get hasUVs(): boolean;
  102982. /**
  102983. * Affects position data to this target
  102984. * @param data defines the position data to use
  102985. */
  102986. setPositions(data: Nullable<FloatArray>): void;
  102987. /**
  102988. * Gets the position data stored in this target
  102989. * @returns a FloatArray containing the position data (or null if not present)
  102990. */
  102991. getPositions(): Nullable<FloatArray>;
  102992. /**
  102993. * Affects normal data to this target
  102994. * @param data defines the normal data to use
  102995. */
  102996. setNormals(data: Nullable<FloatArray>): void;
  102997. /**
  102998. * Gets the normal data stored in this target
  102999. * @returns a FloatArray containing the normal data (or null if not present)
  103000. */
  103001. getNormals(): Nullable<FloatArray>;
  103002. /**
  103003. * Affects tangent data to this target
  103004. * @param data defines the tangent data to use
  103005. */
  103006. setTangents(data: Nullable<FloatArray>): void;
  103007. /**
  103008. * Gets the tangent data stored in this target
  103009. * @returns a FloatArray containing the tangent data (or null if not present)
  103010. */
  103011. getTangents(): Nullable<FloatArray>;
  103012. /**
  103013. * Affects texture coordinates data to this target
  103014. * @param data defines the texture coordinates data to use
  103015. */
  103016. setUVs(data: Nullable<FloatArray>): void;
  103017. /**
  103018. * Gets the texture coordinates data stored in this target
  103019. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  103020. */
  103021. getUVs(): Nullable<FloatArray>;
  103022. /**
  103023. * Clone the current target
  103024. * @returns a new MorphTarget
  103025. */
  103026. clone(): MorphTarget;
  103027. /**
  103028. * Serializes the current target into a Serialization object
  103029. * @returns the serialized object
  103030. */
  103031. serialize(): any;
  103032. /**
  103033. * Returns the string "MorphTarget"
  103034. * @returns "MorphTarget"
  103035. */
  103036. getClassName(): string;
  103037. /**
  103038. * Creates a new target from serialized data
  103039. * @param serializationObject defines the serialized data to use
  103040. * @returns a new MorphTarget
  103041. */
  103042. static Parse(serializationObject: any): MorphTarget;
  103043. /**
  103044. * Creates a MorphTarget from mesh data
  103045. * @param mesh defines the source mesh
  103046. * @param name defines the name to use for the new target
  103047. * @param influence defines the influence to attach to the target
  103048. * @returns a new MorphTarget
  103049. */
  103050. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  103051. }
  103052. }
  103053. declare module BABYLON {
  103054. /**
  103055. * This class is used to deform meshes using morphing between different targets
  103056. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103057. */
  103058. export class MorphTargetManager {
  103059. private _targets;
  103060. private _targetInfluenceChangedObservers;
  103061. private _targetDataLayoutChangedObservers;
  103062. private _activeTargets;
  103063. private _scene;
  103064. private _influences;
  103065. private _supportsNormals;
  103066. private _supportsTangents;
  103067. private _supportsUVs;
  103068. private _vertexCount;
  103069. private _uniqueId;
  103070. private _tempInfluences;
  103071. /**
  103072. * Gets or sets a boolean indicating if normals must be morphed
  103073. */
  103074. enableNormalMorphing: boolean;
  103075. /**
  103076. * Gets or sets a boolean indicating if tangents must be morphed
  103077. */
  103078. enableTangentMorphing: boolean;
  103079. /**
  103080. * Gets or sets a boolean indicating if UV must be morphed
  103081. */
  103082. enableUVMorphing: boolean;
  103083. /**
  103084. * Creates a new MorphTargetManager
  103085. * @param scene defines the current scene
  103086. */
  103087. constructor(scene?: Nullable<Scene>);
  103088. /**
  103089. * Gets the unique ID of this manager
  103090. */
  103091. get uniqueId(): number;
  103092. /**
  103093. * Gets the number of vertices handled by this manager
  103094. */
  103095. get vertexCount(): number;
  103096. /**
  103097. * Gets a boolean indicating if this manager supports morphing of normals
  103098. */
  103099. get supportsNormals(): boolean;
  103100. /**
  103101. * Gets a boolean indicating if this manager supports morphing of tangents
  103102. */
  103103. get supportsTangents(): boolean;
  103104. /**
  103105. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  103106. */
  103107. get supportsUVs(): boolean;
  103108. /**
  103109. * Gets the number of targets stored in this manager
  103110. */
  103111. get numTargets(): number;
  103112. /**
  103113. * Gets the number of influencers (ie. the number of targets with influences > 0)
  103114. */
  103115. get numInfluencers(): number;
  103116. /**
  103117. * Gets the list of influences (one per target)
  103118. */
  103119. get influences(): Float32Array;
  103120. /**
  103121. * Gets the active target at specified index. An active target is a target with an influence > 0
  103122. * @param index defines the index to check
  103123. * @returns the requested target
  103124. */
  103125. getActiveTarget(index: number): MorphTarget;
  103126. /**
  103127. * Gets the target at specified index
  103128. * @param index defines the index to check
  103129. * @returns the requested target
  103130. */
  103131. getTarget(index: number): MorphTarget;
  103132. /**
  103133. * Add a new target to this manager
  103134. * @param target defines the target to add
  103135. */
  103136. addTarget(target: MorphTarget): void;
  103137. /**
  103138. * Removes a target from the manager
  103139. * @param target defines the target to remove
  103140. */
  103141. removeTarget(target: MorphTarget): void;
  103142. /**
  103143. * Clone the current manager
  103144. * @returns a new MorphTargetManager
  103145. */
  103146. clone(): MorphTargetManager;
  103147. /**
  103148. * Serializes the current manager into a Serialization object
  103149. * @returns the serialized object
  103150. */
  103151. serialize(): any;
  103152. private _syncActiveTargets;
  103153. /**
  103154. * Syncrhonize the targets with all the meshes using this morph target manager
  103155. */
  103156. synchronize(): void;
  103157. /**
  103158. * Creates a new MorphTargetManager from serialized data
  103159. * @param serializationObject defines the serialized data
  103160. * @param scene defines the hosting scene
  103161. * @returns the new MorphTargetManager
  103162. */
  103163. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  103164. }
  103165. }
  103166. declare module BABYLON {
  103167. /**
  103168. * Class used to represent a specific level of detail of a mesh
  103169. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  103170. */
  103171. export class MeshLODLevel {
  103172. /** Defines the distance where this level should start being displayed */
  103173. distance: number;
  103174. /** Defines the mesh to use to render this level */
  103175. mesh: Nullable<Mesh>;
  103176. /**
  103177. * Creates a new LOD level
  103178. * @param distance defines the distance where this level should star being displayed
  103179. * @param mesh defines the mesh to use to render this level
  103180. */
  103181. constructor(
  103182. /** Defines the distance where this level should start being displayed */
  103183. distance: number,
  103184. /** Defines the mesh to use to render this level */
  103185. mesh: Nullable<Mesh>);
  103186. }
  103187. }
  103188. declare module BABYLON {
  103189. /**
  103190. * Mesh representing the gorund
  103191. */
  103192. export class GroundMesh extends Mesh {
  103193. /** If octree should be generated */
  103194. generateOctree: boolean;
  103195. private _heightQuads;
  103196. /** @hidden */
  103197. _subdivisionsX: number;
  103198. /** @hidden */
  103199. _subdivisionsY: number;
  103200. /** @hidden */
  103201. _width: number;
  103202. /** @hidden */
  103203. _height: number;
  103204. /** @hidden */
  103205. _minX: number;
  103206. /** @hidden */
  103207. _maxX: number;
  103208. /** @hidden */
  103209. _minZ: number;
  103210. /** @hidden */
  103211. _maxZ: number;
  103212. constructor(name: string, scene: Scene);
  103213. /**
  103214. * "GroundMesh"
  103215. * @returns "GroundMesh"
  103216. */
  103217. getClassName(): string;
  103218. /**
  103219. * The minimum of x and y subdivisions
  103220. */
  103221. get subdivisions(): number;
  103222. /**
  103223. * X subdivisions
  103224. */
  103225. get subdivisionsX(): number;
  103226. /**
  103227. * Y subdivisions
  103228. */
  103229. get subdivisionsY(): number;
  103230. /**
  103231. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  103232. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  103233. * @param chunksCount the number of subdivisions for x and y
  103234. * @param octreeBlocksSize (Default: 32)
  103235. */
  103236. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  103237. /**
  103238. * Returns a height (y) value in the Worl system :
  103239. * the ground altitude at the coordinates (x, z) expressed in the World system.
  103240. * @param x x coordinate
  103241. * @param z z coordinate
  103242. * @returns the ground y position if (x, z) are outside the ground surface.
  103243. */
  103244. getHeightAtCoordinates(x: number, z: number): number;
  103245. /**
  103246. * Returns a normalized vector (Vector3) orthogonal to the ground
  103247. * at the ground coordinates (x, z) expressed in the World system.
  103248. * @param x x coordinate
  103249. * @param z z coordinate
  103250. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  103251. */
  103252. getNormalAtCoordinates(x: number, z: number): Vector3;
  103253. /**
  103254. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  103255. * at the ground coordinates (x, z) expressed in the World system.
  103256. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  103257. * @param x x coordinate
  103258. * @param z z coordinate
  103259. * @param ref vector to store the result
  103260. * @returns the GroundMesh.
  103261. */
  103262. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  103263. /**
  103264. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  103265. * if the ground has been updated.
  103266. * This can be used in the render loop.
  103267. * @returns the GroundMesh.
  103268. */
  103269. updateCoordinateHeights(): GroundMesh;
  103270. private _getFacetAt;
  103271. private _initHeightQuads;
  103272. private _computeHeightQuads;
  103273. /**
  103274. * Serializes this ground mesh
  103275. * @param serializationObject object to write serialization to
  103276. */
  103277. serialize(serializationObject: any): void;
  103278. /**
  103279. * Parses a serialized ground mesh
  103280. * @param parsedMesh the serialized mesh
  103281. * @param scene the scene to create the ground mesh in
  103282. * @returns the created ground mesh
  103283. */
  103284. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  103285. }
  103286. }
  103287. declare module BABYLON {
  103288. /**
  103289. * Interface for Physics-Joint data
  103290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103291. */
  103292. export interface PhysicsJointData {
  103293. /**
  103294. * The main pivot of the joint
  103295. */
  103296. mainPivot?: Vector3;
  103297. /**
  103298. * The connected pivot of the joint
  103299. */
  103300. connectedPivot?: Vector3;
  103301. /**
  103302. * The main axis of the joint
  103303. */
  103304. mainAxis?: Vector3;
  103305. /**
  103306. * The connected axis of the joint
  103307. */
  103308. connectedAxis?: Vector3;
  103309. /**
  103310. * The collision of the joint
  103311. */
  103312. collision?: boolean;
  103313. /**
  103314. * Native Oimo/Cannon/Energy data
  103315. */
  103316. nativeParams?: any;
  103317. }
  103318. /**
  103319. * This is a holder class for the physics joint created by the physics plugin
  103320. * It holds a set of functions to control the underlying joint
  103321. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103322. */
  103323. export class PhysicsJoint {
  103324. /**
  103325. * The type of the physics joint
  103326. */
  103327. type: number;
  103328. /**
  103329. * The data for the physics joint
  103330. */
  103331. jointData: PhysicsJointData;
  103332. private _physicsJoint;
  103333. protected _physicsPlugin: IPhysicsEnginePlugin;
  103334. /**
  103335. * Initializes the physics joint
  103336. * @param type The type of the physics joint
  103337. * @param jointData The data for the physics joint
  103338. */
  103339. constructor(
  103340. /**
  103341. * The type of the physics joint
  103342. */
  103343. type: number,
  103344. /**
  103345. * The data for the physics joint
  103346. */
  103347. jointData: PhysicsJointData);
  103348. /**
  103349. * Gets the physics joint
  103350. */
  103351. get physicsJoint(): any;
  103352. /**
  103353. * Sets the physics joint
  103354. */
  103355. set physicsJoint(newJoint: any);
  103356. /**
  103357. * Sets the physics plugin
  103358. */
  103359. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  103360. /**
  103361. * Execute a function that is physics-plugin specific.
  103362. * @param {Function} func the function that will be executed.
  103363. * It accepts two parameters: the physics world and the physics joint
  103364. */
  103365. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  103366. /**
  103367. * Distance-Joint type
  103368. */
  103369. static DistanceJoint: number;
  103370. /**
  103371. * Hinge-Joint type
  103372. */
  103373. static HingeJoint: number;
  103374. /**
  103375. * Ball-and-Socket joint type
  103376. */
  103377. static BallAndSocketJoint: number;
  103378. /**
  103379. * Wheel-Joint type
  103380. */
  103381. static WheelJoint: number;
  103382. /**
  103383. * Slider-Joint type
  103384. */
  103385. static SliderJoint: number;
  103386. /**
  103387. * Prismatic-Joint type
  103388. */
  103389. static PrismaticJoint: number;
  103390. /**
  103391. * Universal-Joint type
  103392. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  103393. */
  103394. static UniversalJoint: number;
  103395. /**
  103396. * Hinge-Joint 2 type
  103397. */
  103398. static Hinge2Joint: number;
  103399. /**
  103400. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  103401. */
  103402. static PointToPointJoint: number;
  103403. /**
  103404. * Spring-Joint type
  103405. */
  103406. static SpringJoint: number;
  103407. /**
  103408. * Lock-Joint type
  103409. */
  103410. static LockJoint: number;
  103411. }
  103412. /**
  103413. * A class representing a physics distance joint
  103414. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103415. */
  103416. export class DistanceJoint extends PhysicsJoint {
  103417. /**
  103418. *
  103419. * @param jointData The data for the Distance-Joint
  103420. */
  103421. constructor(jointData: DistanceJointData);
  103422. /**
  103423. * Update the predefined distance.
  103424. * @param maxDistance The maximum preferred distance
  103425. * @param minDistance The minimum preferred distance
  103426. */
  103427. updateDistance(maxDistance: number, minDistance?: number): void;
  103428. }
  103429. /**
  103430. * Represents a Motor-Enabled Joint
  103431. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103432. */
  103433. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  103434. /**
  103435. * Initializes the Motor-Enabled Joint
  103436. * @param type The type of the joint
  103437. * @param jointData The physica joint data for the joint
  103438. */
  103439. constructor(type: number, jointData: PhysicsJointData);
  103440. /**
  103441. * Set the motor values.
  103442. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103443. * @param force the force to apply
  103444. * @param maxForce max force for this motor.
  103445. */
  103446. setMotor(force?: number, maxForce?: number): void;
  103447. /**
  103448. * Set the motor's limits.
  103449. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103450. * @param upperLimit The upper limit of the motor
  103451. * @param lowerLimit The lower limit of the motor
  103452. */
  103453. setLimit(upperLimit: number, lowerLimit?: number): void;
  103454. }
  103455. /**
  103456. * This class represents a single physics Hinge-Joint
  103457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103458. */
  103459. export class HingeJoint extends MotorEnabledJoint {
  103460. /**
  103461. * Initializes the Hinge-Joint
  103462. * @param jointData The joint data for the Hinge-Joint
  103463. */
  103464. constructor(jointData: PhysicsJointData);
  103465. /**
  103466. * Set the motor values.
  103467. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103468. * @param {number} force the force to apply
  103469. * @param {number} maxForce max force for this motor.
  103470. */
  103471. setMotor(force?: number, maxForce?: number): void;
  103472. /**
  103473. * Set the motor's limits.
  103474. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103475. * @param upperLimit The upper limit of the motor
  103476. * @param lowerLimit The lower limit of the motor
  103477. */
  103478. setLimit(upperLimit: number, lowerLimit?: number): void;
  103479. }
  103480. /**
  103481. * This class represents a dual hinge physics joint (same as wheel joint)
  103482. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103483. */
  103484. export class Hinge2Joint extends MotorEnabledJoint {
  103485. /**
  103486. * Initializes the Hinge2-Joint
  103487. * @param jointData The joint data for the Hinge2-Joint
  103488. */
  103489. constructor(jointData: PhysicsJointData);
  103490. /**
  103491. * Set the motor values.
  103492. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103493. * @param {number} targetSpeed the speed the motor is to reach
  103494. * @param {number} maxForce max force for this motor.
  103495. * @param {motorIndex} the motor's index, 0 or 1.
  103496. */
  103497. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  103498. /**
  103499. * Set the motor limits.
  103500. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103501. * @param {number} upperLimit the upper limit
  103502. * @param {number} lowerLimit lower limit
  103503. * @param {motorIndex} the motor's index, 0 or 1.
  103504. */
  103505. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103506. }
  103507. /**
  103508. * Interface for a motor enabled joint
  103509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103510. */
  103511. export interface IMotorEnabledJoint {
  103512. /**
  103513. * Physics joint
  103514. */
  103515. physicsJoint: any;
  103516. /**
  103517. * Sets the motor of the motor-enabled joint
  103518. * @param force The force of the motor
  103519. * @param maxForce The maximum force of the motor
  103520. * @param motorIndex The index of the motor
  103521. */
  103522. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  103523. /**
  103524. * Sets the limit of the motor
  103525. * @param upperLimit The upper limit of the motor
  103526. * @param lowerLimit The lower limit of the motor
  103527. * @param motorIndex The index of the motor
  103528. */
  103529. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103530. }
  103531. /**
  103532. * Joint data for a Distance-Joint
  103533. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103534. */
  103535. export interface DistanceJointData extends PhysicsJointData {
  103536. /**
  103537. * Max distance the 2 joint objects can be apart
  103538. */
  103539. maxDistance: number;
  103540. }
  103541. /**
  103542. * Joint data from a spring joint
  103543. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103544. */
  103545. export interface SpringJointData extends PhysicsJointData {
  103546. /**
  103547. * Length of the spring
  103548. */
  103549. length: number;
  103550. /**
  103551. * Stiffness of the spring
  103552. */
  103553. stiffness: number;
  103554. /**
  103555. * Damping of the spring
  103556. */
  103557. damping: number;
  103558. /** this callback will be called when applying the force to the impostors. */
  103559. forceApplicationCallback: () => void;
  103560. }
  103561. }
  103562. declare module BABYLON {
  103563. /**
  103564. * Holds the data for the raycast result
  103565. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103566. */
  103567. export class PhysicsRaycastResult {
  103568. private _hasHit;
  103569. private _hitDistance;
  103570. private _hitNormalWorld;
  103571. private _hitPointWorld;
  103572. private _rayFromWorld;
  103573. private _rayToWorld;
  103574. /**
  103575. * Gets if there was a hit
  103576. */
  103577. get hasHit(): boolean;
  103578. /**
  103579. * Gets the distance from the hit
  103580. */
  103581. get hitDistance(): number;
  103582. /**
  103583. * Gets the hit normal/direction in the world
  103584. */
  103585. get hitNormalWorld(): Vector3;
  103586. /**
  103587. * Gets the hit point in the world
  103588. */
  103589. get hitPointWorld(): Vector3;
  103590. /**
  103591. * Gets the ray "start point" of the ray in the world
  103592. */
  103593. get rayFromWorld(): Vector3;
  103594. /**
  103595. * Gets the ray "end point" of the ray in the world
  103596. */
  103597. get rayToWorld(): Vector3;
  103598. /**
  103599. * Sets the hit data (normal & point in world space)
  103600. * @param hitNormalWorld defines the normal in world space
  103601. * @param hitPointWorld defines the point in world space
  103602. */
  103603. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  103604. /**
  103605. * Sets the distance from the start point to the hit point
  103606. * @param distance
  103607. */
  103608. setHitDistance(distance: number): void;
  103609. /**
  103610. * Calculates the distance manually
  103611. */
  103612. calculateHitDistance(): void;
  103613. /**
  103614. * Resets all the values to default
  103615. * @param from The from point on world space
  103616. * @param to The to point on world space
  103617. */
  103618. reset(from?: Vector3, to?: Vector3): void;
  103619. }
  103620. /**
  103621. * Interface for the size containing width and height
  103622. */
  103623. interface IXYZ {
  103624. /**
  103625. * X
  103626. */
  103627. x: number;
  103628. /**
  103629. * Y
  103630. */
  103631. y: number;
  103632. /**
  103633. * Z
  103634. */
  103635. z: number;
  103636. }
  103637. }
  103638. declare module BABYLON {
  103639. /**
  103640. * Interface used to describe a physics joint
  103641. */
  103642. export interface PhysicsImpostorJoint {
  103643. /** Defines the main impostor to which the joint is linked */
  103644. mainImpostor: PhysicsImpostor;
  103645. /** Defines the impostor that is connected to the main impostor using this joint */
  103646. connectedImpostor: PhysicsImpostor;
  103647. /** Defines the joint itself */
  103648. joint: PhysicsJoint;
  103649. }
  103650. /** @hidden */
  103651. export interface IPhysicsEnginePlugin {
  103652. world: any;
  103653. name: string;
  103654. setGravity(gravity: Vector3): void;
  103655. setTimeStep(timeStep: number): void;
  103656. getTimeStep(): number;
  103657. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  103658. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103659. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103660. generatePhysicsBody(impostor: PhysicsImpostor): void;
  103661. removePhysicsBody(impostor: PhysicsImpostor): void;
  103662. generateJoint(joint: PhysicsImpostorJoint): void;
  103663. removeJoint(joint: PhysicsImpostorJoint): void;
  103664. isSupported(): boolean;
  103665. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  103666. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  103667. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  103668. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  103669. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103670. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103671. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  103672. getBodyMass(impostor: PhysicsImpostor): number;
  103673. getBodyFriction(impostor: PhysicsImpostor): number;
  103674. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  103675. getBodyRestitution(impostor: PhysicsImpostor): number;
  103676. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  103677. getBodyPressure?(impostor: PhysicsImpostor): number;
  103678. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  103679. getBodyStiffness?(impostor: PhysicsImpostor): number;
  103680. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  103681. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  103682. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  103683. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  103684. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  103685. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  103686. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  103687. sleepBody(impostor: PhysicsImpostor): void;
  103688. wakeUpBody(impostor: PhysicsImpostor): void;
  103689. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  103690. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  103691. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  103692. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103693. getRadius(impostor: PhysicsImpostor): number;
  103694. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  103695. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  103696. dispose(): void;
  103697. }
  103698. /**
  103699. * Interface used to define a physics engine
  103700. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  103701. */
  103702. export interface IPhysicsEngine {
  103703. /**
  103704. * Gets the gravity vector used by the simulation
  103705. */
  103706. gravity: Vector3;
  103707. /**
  103708. * Sets the gravity vector used by the simulation
  103709. * @param gravity defines the gravity vector to use
  103710. */
  103711. setGravity(gravity: Vector3): void;
  103712. /**
  103713. * Set the time step of the physics engine.
  103714. * Default is 1/60.
  103715. * To slow it down, enter 1/600 for example.
  103716. * To speed it up, 1/30
  103717. * @param newTimeStep the new timestep to apply to this world.
  103718. */
  103719. setTimeStep(newTimeStep: number): void;
  103720. /**
  103721. * Get the time step of the physics engine.
  103722. * @returns the current time step
  103723. */
  103724. getTimeStep(): number;
  103725. /**
  103726. * Set the sub time step of the physics engine.
  103727. * Default is 0 meaning there is no sub steps
  103728. * To increase physics resolution precision, set a small value (like 1 ms)
  103729. * @param subTimeStep defines the new sub timestep used for physics resolution.
  103730. */
  103731. setSubTimeStep(subTimeStep: number): void;
  103732. /**
  103733. * Get the sub time step of the physics engine.
  103734. * @returns the current sub time step
  103735. */
  103736. getSubTimeStep(): number;
  103737. /**
  103738. * Release all resources
  103739. */
  103740. dispose(): void;
  103741. /**
  103742. * Gets the name of the current physics plugin
  103743. * @returns the name of the plugin
  103744. */
  103745. getPhysicsPluginName(): string;
  103746. /**
  103747. * Adding a new impostor for the impostor tracking.
  103748. * This will be done by the impostor itself.
  103749. * @param impostor the impostor to add
  103750. */
  103751. addImpostor(impostor: PhysicsImpostor): void;
  103752. /**
  103753. * Remove an impostor from the engine.
  103754. * This impostor and its mesh will not longer be updated by the physics engine.
  103755. * @param impostor the impostor to remove
  103756. */
  103757. removeImpostor(impostor: PhysicsImpostor): void;
  103758. /**
  103759. * Add a joint to the physics engine
  103760. * @param mainImpostor defines the main impostor to which the joint is added.
  103761. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  103762. * @param joint defines the joint that will connect both impostors.
  103763. */
  103764. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  103765. /**
  103766. * Removes a joint from the simulation
  103767. * @param mainImpostor defines the impostor used with the joint
  103768. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  103769. * @param joint defines the joint to remove
  103770. */
  103771. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  103772. /**
  103773. * Gets the current plugin used to run the simulation
  103774. * @returns current plugin
  103775. */
  103776. getPhysicsPlugin(): IPhysicsEnginePlugin;
  103777. /**
  103778. * Gets the list of physic impostors
  103779. * @returns an array of PhysicsImpostor
  103780. */
  103781. getImpostors(): Array<PhysicsImpostor>;
  103782. /**
  103783. * Gets the impostor for a physics enabled object
  103784. * @param object defines the object impersonated by the impostor
  103785. * @returns the PhysicsImpostor or null if not found
  103786. */
  103787. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  103788. /**
  103789. * Gets the impostor for a physics body object
  103790. * @param body defines physics body used by the impostor
  103791. * @returns the PhysicsImpostor or null if not found
  103792. */
  103793. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  103794. /**
  103795. * Does a raycast in the physics world
  103796. * @param from when should the ray start?
  103797. * @param to when should the ray end?
  103798. * @returns PhysicsRaycastResult
  103799. */
  103800. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  103801. /**
  103802. * Called by the scene. No need to call it.
  103803. * @param delta defines the timespam between frames
  103804. */
  103805. _step(delta: number): void;
  103806. }
  103807. }
  103808. declare module BABYLON {
  103809. /**
  103810. * The interface for the physics imposter parameters
  103811. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103812. */
  103813. export interface PhysicsImpostorParameters {
  103814. /**
  103815. * The mass of the physics imposter
  103816. */
  103817. mass: number;
  103818. /**
  103819. * The friction of the physics imposter
  103820. */
  103821. friction?: number;
  103822. /**
  103823. * The coefficient of restitution of the physics imposter
  103824. */
  103825. restitution?: number;
  103826. /**
  103827. * The native options of the physics imposter
  103828. */
  103829. nativeOptions?: any;
  103830. /**
  103831. * Specifies if the parent should be ignored
  103832. */
  103833. ignoreParent?: boolean;
  103834. /**
  103835. * Specifies if bi-directional transformations should be disabled
  103836. */
  103837. disableBidirectionalTransformation?: boolean;
  103838. /**
  103839. * The pressure inside the physics imposter, soft object only
  103840. */
  103841. pressure?: number;
  103842. /**
  103843. * The stiffness the physics imposter, soft object only
  103844. */
  103845. stiffness?: number;
  103846. /**
  103847. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  103848. */
  103849. velocityIterations?: number;
  103850. /**
  103851. * The number of iterations used in maintaining consistent vertex positions, soft object only
  103852. */
  103853. positionIterations?: number;
  103854. /**
  103855. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  103856. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  103857. * Add to fix multiple points
  103858. */
  103859. fixedPoints?: number;
  103860. /**
  103861. * The collision margin around a soft object
  103862. */
  103863. margin?: number;
  103864. /**
  103865. * The collision margin around a soft object
  103866. */
  103867. damping?: number;
  103868. /**
  103869. * The path for a rope based on an extrusion
  103870. */
  103871. path?: any;
  103872. /**
  103873. * The shape of an extrusion used for a rope based on an extrusion
  103874. */
  103875. shape?: any;
  103876. }
  103877. /**
  103878. * Interface for a physics-enabled object
  103879. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103880. */
  103881. export interface IPhysicsEnabledObject {
  103882. /**
  103883. * The position of the physics-enabled object
  103884. */
  103885. position: Vector3;
  103886. /**
  103887. * The rotation of the physics-enabled object
  103888. */
  103889. rotationQuaternion: Nullable<Quaternion>;
  103890. /**
  103891. * The scale of the physics-enabled object
  103892. */
  103893. scaling: Vector3;
  103894. /**
  103895. * The rotation of the physics-enabled object
  103896. */
  103897. rotation?: Vector3;
  103898. /**
  103899. * The parent of the physics-enabled object
  103900. */
  103901. parent?: any;
  103902. /**
  103903. * The bounding info of the physics-enabled object
  103904. * @returns The bounding info of the physics-enabled object
  103905. */
  103906. getBoundingInfo(): BoundingInfo;
  103907. /**
  103908. * Computes the world matrix
  103909. * @param force Specifies if the world matrix should be computed by force
  103910. * @returns A world matrix
  103911. */
  103912. computeWorldMatrix(force: boolean): Matrix;
  103913. /**
  103914. * Gets the world matrix
  103915. * @returns A world matrix
  103916. */
  103917. getWorldMatrix?(): Matrix;
  103918. /**
  103919. * Gets the child meshes
  103920. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  103921. * @returns An array of abstract meshes
  103922. */
  103923. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  103924. /**
  103925. * Gets the vertex data
  103926. * @param kind The type of vertex data
  103927. * @returns A nullable array of numbers, or a float32 array
  103928. */
  103929. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  103930. /**
  103931. * Gets the indices from the mesh
  103932. * @returns A nullable array of index arrays
  103933. */
  103934. getIndices?(): Nullable<IndicesArray>;
  103935. /**
  103936. * Gets the scene from the mesh
  103937. * @returns the indices array or null
  103938. */
  103939. getScene?(): Scene;
  103940. /**
  103941. * Gets the absolute position from the mesh
  103942. * @returns the absolute position
  103943. */
  103944. getAbsolutePosition(): Vector3;
  103945. /**
  103946. * Gets the absolute pivot point from the mesh
  103947. * @returns the absolute pivot point
  103948. */
  103949. getAbsolutePivotPoint(): Vector3;
  103950. /**
  103951. * Rotates the mesh
  103952. * @param axis The axis of rotation
  103953. * @param amount The amount of rotation
  103954. * @param space The space of the rotation
  103955. * @returns The rotation transform node
  103956. */
  103957. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  103958. /**
  103959. * Translates the mesh
  103960. * @param axis The axis of translation
  103961. * @param distance The distance of translation
  103962. * @param space The space of the translation
  103963. * @returns The transform node
  103964. */
  103965. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  103966. /**
  103967. * Sets the absolute position of the mesh
  103968. * @param absolutePosition The absolute position of the mesh
  103969. * @returns The transform node
  103970. */
  103971. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  103972. /**
  103973. * Gets the class name of the mesh
  103974. * @returns The class name
  103975. */
  103976. getClassName(): string;
  103977. }
  103978. /**
  103979. * Represents a physics imposter
  103980. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103981. */
  103982. export class PhysicsImpostor {
  103983. /**
  103984. * The physics-enabled object used as the physics imposter
  103985. */
  103986. object: IPhysicsEnabledObject;
  103987. /**
  103988. * The type of the physics imposter
  103989. */
  103990. type: number;
  103991. private _options;
  103992. private _scene?;
  103993. /**
  103994. * The default object size of the imposter
  103995. */
  103996. static DEFAULT_OBJECT_SIZE: Vector3;
  103997. /**
  103998. * The identity quaternion of the imposter
  103999. */
  104000. static IDENTITY_QUATERNION: Quaternion;
  104001. /** @hidden */
  104002. _pluginData: any;
  104003. private _physicsEngine;
  104004. private _physicsBody;
  104005. private _bodyUpdateRequired;
  104006. private _onBeforePhysicsStepCallbacks;
  104007. private _onAfterPhysicsStepCallbacks;
  104008. /** @hidden */
  104009. _onPhysicsCollideCallbacks: Array<{
  104010. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  104011. otherImpostors: Array<PhysicsImpostor>;
  104012. }>;
  104013. private _deltaPosition;
  104014. private _deltaRotation;
  104015. private _deltaRotationConjugated;
  104016. /** @hidden */
  104017. _isFromLine: boolean;
  104018. private _parent;
  104019. private _isDisposed;
  104020. private static _tmpVecs;
  104021. private static _tmpQuat;
  104022. /**
  104023. * Specifies if the physics imposter is disposed
  104024. */
  104025. get isDisposed(): boolean;
  104026. /**
  104027. * Gets the mass of the physics imposter
  104028. */
  104029. get mass(): number;
  104030. set mass(value: number);
  104031. /**
  104032. * Gets the coefficient of friction
  104033. */
  104034. get friction(): number;
  104035. /**
  104036. * Sets the coefficient of friction
  104037. */
  104038. set friction(value: number);
  104039. /**
  104040. * Gets the coefficient of restitution
  104041. */
  104042. get restitution(): number;
  104043. /**
  104044. * Sets the coefficient of restitution
  104045. */
  104046. set restitution(value: number);
  104047. /**
  104048. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  104049. */
  104050. get pressure(): number;
  104051. /**
  104052. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  104053. */
  104054. set pressure(value: number);
  104055. /**
  104056. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  104057. */
  104058. get stiffness(): number;
  104059. /**
  104060. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  104061. */
  104062. set stiffness(value: number);
  104063. /**
  104064. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  104065. */
  104066. get velocityIterations(): number;
  104067. /**
  104068. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  104069. */
  104070. set velocityIterations(value: number);
  104071. /**
  104072. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  104073. */
  104074. get positionIterations(): number;
  104075. /**
  104076. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  104077. */
  104078. set positionIterations(value: number);
  104079. /**
  104080. * The unique id of the physics imposter
  104081. * set by the physics engine when adding this impostor to the array
  104082. */
  104083. uniqueId: number;
  104084. /**
  104085. * @hidden
  104086. */
  104087. soft: boolean;
  104088. /**
  104089. * @hidden
  104090. */
  104091. segments: number;
  104092. private _joints;
  104093. /**
  104094. * Initializes the physics imposter
  104095. * @param object The physics-enabled object used as the physics imposter
  104096. * @param type The type of the physics imposter
  104097. * @param _options The options for the physics imposter
  104098. * @param _scene The Babylon scene
  104099. */
  104100. constructor(
  104101. /**
  104102. * The physics-enabled object used as the physics imposter
  104103. */
  104104. object: IPhysicsEnabledObject,
  104105. /**
  104106. * The type of the physics imposter
  104107. */
  104108. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  104109. /**
  104110. * This function will completly initialize this impostor.
  104111. * It will create a new body - but only if this mesh has no parent.
  104112. * If it has, this impostor will not be used other than to define the impostor
  104113. * of the child mesh.
  104114. * @hidden
  104115. */
  104116. _init(): void;
  104117. private _getPhysicsParent;
  104118. /**
  104119. * Should a new body be generated.
  104120. * @returns boolean specifying if body initialization is required
  104121. */
  104122. isBodyInitRequired(): boolean;
  104123. /**
  104124. * Sets the updated scaling
  104125. * @param updated Specifies if the scaling is updated
  104126. */
  104127. setScalingUpdated(): void;
  104128. /**
  104129. * Force a regeneration of this or the parent's impostor's body.
  104130. * Use under cautious - This will remove all joints already implemented.
  104131. */
  104132. forceUpdate(): void;
  104133. /**
  104134. * Gets the body that holds this impostor. Either its own, or its parent.
  104135. */
  104136. get physicsBody(): any;
  104137. /**
  104138. * Get the parent of the physics imposter
  104139. * @returns Physics imposter or null
  104140. */
  104141. get parent(): Nullable<PhysicsImpostor>;
  104142. /**
  104143. * Sets the parent of the physics imposter
  104144. */
  104145. set parent(value: Nullable<PhysicsImpostor>);
  104146. /**
  104147. * Set the physics body. Used mainly by the physics engine/plugin
  104148. */
  104149. set physicsBody(physicsBody: any);
  104150. /**
  104151. * Resets the update flags
  104152. */
  104153. resetUpdateFlags(): void;
  104154. /**
  104155. * Gets the object extend size
  104156. * @returns the object extend size
  104157. */
  104158. getObjectExtendSize(): Vector3;
  104159. /**
  104160. * Gets the object center
  104161. * @returns The object center
  104162. */
  104163. getObjectCenter(): Vector3;
  104164. /**
  104165. * Get a specific parameter from the options parameters
  104166. * @param paramName The object parameter name
  104167. * @returns The object parameter
  104168. */
  104169. getParam(paramName: string): any;
  104170. /**
  104171. * Sets a specific parameter in the options given to the physics plugin
  104172. * @param paramName The parameter name
  104173. * @param value The value of the parameter
  104174. */
  104175. setParam(paramName: string, value: number): void;
  104176. /**
  104177. * Specifically change the body's mass option. Won't recreate the physics body object
  104178. * @param mass The mass of the physics imposter
  104179. */
  104180. setMass(mass: number): void;
  104181. /**
  104182. * Gets the linear velocity
  104183. * @returns linear velocity or null
  104184. */
  104185. getLinearVelocity(): Nullable<Vector3>;
  104186. /**
  104187. * Sets the linear velocity
  104188. * @param velocity linear velocity or null
  104189. */
  104190. setLinearVelocity(velocity: Nullable<Vector3>): void;
  104191. /**
  104192. * Gets the angular velocity
  104193. * @returns angular velocity or null
  104194. */
  104195. getAngularVelocity(): Nullable<Vector3>;
  104196. /**
  104197. * Sets the angular velocity
  104198. * @param velocity The velocity or null
  104199. */
  104200. setAngularVelocity(velocity: Nullable<Vector3>): void;
  104201. /**
  104202. * Execute a function with the physics plugin native code
  104203. * Provide a function the will have two variables - the world object and the physics body object
  104204. * @param func The function to execute with the physics plugin native code
  104205. */
  104206. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  104207. /**
  104208. * Register a function that will be executed before the physics world is stepping forward
  104209. * @param func The function to execute before the physics world is stepped forward
  104210. */
  104211. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104212. /**
  104213. * Unregister a function that will be executed before the physics world is stepping forward
  104214. * @param func The function to execute before the physics world is stepped forward
  104215. */
  104216. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104217. /**
  104218. * Register a function that will be executed after the physics step
  104219. * @param func The function to execute after physics step
  104220. */
  104221. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104222. /**
  104223. * Unregisters a function that will be executed after the physics step
  104224. * @param func The function to execute after physics step
  104225. */
  104226. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104227. /**
  104228. * register a function that will be executed when this impostor collides against a different body
  104229. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  104230. * @param func Callback that is executed on collision
  104231. */
  104232. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  104233. /**
  104234. * Unregisters the physics imposter on contact
  104235. * @param collideAgainst The physics object to collide against
  104236. * @param func Callback to execute on collision
  104237. */
  104238. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  104239. private _tmpQuat;
  104240. private _tmpQuat2;
  104241. /**
  104242. * Get the parent rotation
  104243. * @returns The parent rotation
  104244. */
  104245. getParentsRotation(): Quaternion;
  104246. /**
  104247. * this function is executed by the physics engine.
  104248. */
  104249. beforeStep: () => void;
  104250. /**
  104251. * this function is executed by the physics engine
  104252. */
  104253. afterStep: () => void;
  104254. /**
  104255. * Legacy collision detection event support
  104256. */
  104257. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  104258. /**
  104259. * event and body object due to cannon's event-based architecture.
  104260. */
  104261. onCollide: (e: {
  104262. body: any;
  104263. }) => void;
  104264. /**
  104265. * Apply a force
  104266. * @param force The force to apply
  104267. * @param contactPoint The contact point for the force
  104268. * @returns The physics imposter
  104269. */
  104270. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  104271. /**
  104272. * Apply an impulse
  104273. * @param force The impulse force
  104274. * @param contactPoint The contact point for the impulse force
  104275. * @returns The physics imposter
  104276. */
  104277. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  104278. /**
  104279. * A help function to create a joint
  104280. * @param otherImpostor A physics imposter used to create a joint
  104281. * @param jointType The type of joint
  104282. * @param jointData The data for the joint
  104283. * @returns The physics imposter
  104284. */
  104285. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  104286. /**
  104287. * Add a joint to this impostor with a different impostor
  104288. * @param otherImpostor A physics imposter used to add a joint
  104289. * @param joint The joint to add
  104290. * @returns The physics imposter
  104291. */
  104292. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  104293. /**
  104294. * Add an anchor to a cloth impostor
  104295. * @param otherImpostor rigid impostor to anchor to
  104296. * @param width ratio across width from 0 to 1
  104297. * @param height ratio up height from 0 to 1
  104298. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  104299. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  104300. * @returns impostor the soft imposter
  104301. */
  104302. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  104303. /**
  104304. * Add a hook to a rope impostor
  104305. * @param otherImpostor rigid impostor to anchor to
  104306. * @param length ratio across rope from 0 to 1
  104307. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  104308. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  104309. * @returns impostor the rope imposter
  104310. */
  104311. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  104312. /**
  104313. * Will keep this body still, in a sleep mode.
  104314. * @returns the physics imposter
  104315. */
  104316. sleep(): PhysicsImpostor;
  104317. /**
  104318. * Wake the body up.
  104319. * @returns The physics imposter
  104320. */
  104321. wakeUp(): PhysicsImpostor;
  104322. /**
  104323. * Clones the physics imposter
  104324. * @param newObject The physics imposter clones to this physics-enabled object
  104325. * @returns A nullable physics imposter
  104326. */
  104327. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104328. /**
  104329. * Disposes the physics imposter
  104330. */
  104331. dispose(): void;
  104332. /**
  104333. * Sets the delta position
  104334. * @param position The delta position amount
  104335. */
  104336. setDeltaPosition(position: Vector3): void;
  104337. /**
  104338. * Sets the delta rotation
  104339. * @param rotation The delta rotation amount
  104340. */
  104341. setDeltaRotation(rotation: Quaternion): void;
  104342. /**
  104343. * Gets the box size of the physics imposter and stores the result in the input parameter
  104344. * @param result Stores the box size
  104345. * @returns The physics imposter
  104346. */
  104347. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  104348. /**
  104349. * Gets the radius of the physics imposter
  104350. * @returns Radius of the physics imposter
  104351. */
  104352. getRadius(): number;
  104353. /**
  104354. * Sync a bone with this impostor
  104355. * @param bone The bone to sync to the impostor.
  104356. * @param boneMesh The mesh that the bone is influencing.
  104357. * @param jointPivot The pivot of the joint / bone in local space.
  104358. * @param distToJoint Optional distance from the impostor to the joint.
  104359. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  104360. */
  104361. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  104362. /**
  104363. * Sync impostor to a bone
  104364. * @param bone The bone that the impostor will be synced to.
  104365. * @param boneMesh The mesh that the bone is influencing.
  104366. * @param jointPivot The pivot of the joint / bone in local space.
  104367. * @param distToJoint Optional distance from the impostor to the joint.
  104368. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  104369. * @param boneAxis Optional vector3 axis the bone is aligned with
  104370. */
  104371. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  104372. /**
  104373. * No-Imposter type
  104374. */
  104375. static NoImpostor: number;
  104376. /**
  104377. * Sphere-Imposter type
  104378. */
  104379. static SphereImpostor: number;
  104380. /**
  104381. * Box-Imposter type
  104382. */
  104383. static BoxImpostor: number;
  104384. /**
  104385. * Plane-Imposter type
  104386. */
  104387. static PlaneImpostor: number;
  104388. /**
  104389. * Mesh-imposter type
  104390. */
  104391. static MeshImpostor: number;
  104392. /**
  104393. * Capsule-Impostor type (Ammo.js plugin only)
  104394. */
  104395. static CapsuleImpostor: number;
  104396. /**
  104397. * Cylinder-Imposter type
  104398. */
  104399. static CylinderImpostor: number;
  104400. /**
  104401. * Particle-Imposter type
  104402. */
  104403. static ParticleImpostor: number;
  104404. /**
  104405. * Heightmap-Imposter type
  104406. */
  104407. static HeightmapImpostor: number;
  104408. /**
  104409. * ConvexHull-Impostor type (Ammo.js plugin only)
  104410. */
  104411. static ConvexHullImpostor: number;
  104412. /**
  104413. * Custom-Imposter type (Ammo.js plugin only)
  104414. */
  104415. static CustomImpostor: number;
  104416. /**
  104417. * Rope-Imposter type
  104418. */
  104419. static RopeImpostor: number;
  104420. /**
  104421. * Cloth-Imposter type
  104422. */
  104423. static ClothImpostor: number;
  104424. /**
  104425. * Softbody-Imposter type
  104426. */
  104427. static SoftbodyImpostor: number;
  104428. }
  104429. }
  104430. declare module BABYLON {
  104431. /**
  104432. * @hidden
  104433. **/
  104434. export class _CreationDataStorage {
  104435. closePath?: boolean;
  104436. closeArray?: boolean;
  104437. idx: number[];
  104438. dashSize: number;
  104439. gapSize: number;
  104440. path3D: Path3D;
  104441. pathArray: Vector3[][];
  104442. arc: number;
  104443. radius: number;
  104444. cap: number;
  104445. tessellation: number;
  104446. }
  104447. /**
  104448. * @hidden
  104449. **/
  104450. class _InstanceDataStorage {
  104451. visibleInstances: any;
  104452. batchCache: _InstancesBatch;
  104453. instancesBufferSize: number;
  104454. instancesBuffer: Nullable<Buffer>;
  104455. instancesData: Float32Array;
  104456. overridenInstanceCount: number;
  104457. isFrozen: boolean;
  104458. previousBatch: Nullable<_InstancesBatch>;
  104459. hardwareInstancedRendering: boolean;
  104460. sideOrientation: number;
  104461. manualUpdate: boolean;
  104462. }
  104463. /**
  104464. * @hidden
  104465. **/
  104466. export class _InstancesBatch {
  104467. mustReturn: boolean;
  104468. visibleInstances: Nullable<InstancedMesh[]>[];
  104469. renderSelf: boolean[];
  104470. hardwareInstancedRendering: boolean[];
  104471. }
  104472. /**
  104473. * @hidden
  104474. **/
  104475. class _ThinInstanceDataStorage {
  104476. instancesCount: number;
  104477. matrixBuffer: Nullable<Buffer>;
  104478. matrixBufferSize: number;
  104479. matrixData: Nullable<Float32Array>;
  104480. boundingVectors: Array<Vector3>;
  104481. }
  104482. /**
  104483. * Class used to represent renderable models
  104484. */
  104485. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  104486. /**
  104487. * Mesh side orientation : usually the external or front surface
  104488. */
  104489. static readonly FRONTSIDE: number;
  104490. /**
  104491. * Mesh side orientation : usually the internal or back surface
  104492. */
  104493. static readonly BACKSIDE: number;
  104494. /**
  104495. * Mesh side orientation : both internal and external or front and back surfaces
  104496. */
  104497. static readonly DOUBLESIDE: number;
  104498. /**
  104499. * Mesh side orientation : by default, `FRONTSIDE`
  104500. */
  104501. static readonly DEFAULTSIDE: number;
  104502. /**
  104503. * Mesh cap setting : no cap
  104504. */
  104505. static readonly NO_CAP: number;
  104506. /**
  104507. * Mesh cap setting : one cap at the beginning of the mesh
  104508. */
  104509. static readonly CAP_START: number;
  104510. /**
  104511. * Mesh cap setting : one cap at the end of the mesh
  104512. */
  104513. static readonly CAP_END: number;
  104514. /**
  104515. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  104516. */
  104517. static readonly CAP_ALL: number;
  104518. /**
  104519. * Mesh pattern setting : no flip or rotate
  104520. */
  104521. static readonly NO_FLIP: number;
  104522. /**
  104523. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  104524. */
  104525. static readonly FLIP_TILE: number;
  104526. /**
  104527. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  104528. */
  104529. static readonly ROTATE_TILE: number;
  104530. /**
  104531. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  104532. */
  104533. static readonly FLIP_ROW: number;
  104534. /**
  104535. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  104536. */
  104537. static readonly ROTATE_ROW: number;
  104538. /**
  104539. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  104540. */
  104541. static readonly FLIP_N_ROTATE_TILE: number;
  104542. /**
  104543. * Mesh pattern setting : rotate pattern and rotate
  104544. */
  104545. static readonly FLIP_N_ROTATE_ROW: number;
  104546. /**
  104547. * Mesh tile positioning : part tiles same on left/right or top/bottom
  104548. */
  104549. static readonly CENTER: number;
  104550. /**
  104551. * Mesh tile positioning : part tiles on left
  104552. */
  104553. static readonly LEFT: number;
  104554. /**
  104555. * Mesh tile positioning : part tiles on right
  104556. */
  104557. static readonly RIGHT: number;
  104558. /**
  104559. * Mesh tile positioning : part tiles on top
  104560. */
  104561. static readonly TOP: number;
  104562. /**
  104563. * Mesh tile positioning : part tiles on bottom
  104564. */
  104565. static readonly BOTTOM: number;
  104566. /**
  104567. * Gets the default side orientation.
  104568. * @param orientation the orientation to value to attempt to get
  104569. * @returns the default orientation
  104570. * @hidden
  104571. */
  104572. static _GetDefaultSideOrientation(orientation?: number): number;
  104573. private _internalMeshDataInfo;
  104574. /**
  104575. * An event triggered before rendering the mesh
  104576. */
  104577. get onBeforeRenderObservable(): Observable<Mesh>;
  104578. /**
  104579. * An event triggered before binding the mesh
  104580. */
  104581. get onBeforeBindObservable(): Observable<Mesh>;
  104582. /**
  104583. * An event triggered after rendering the mesh
  104584. */
  104585. get onAfterRenderObservable(): Observable<Mesh>;
  104586. /**
  104587. * An event triggered before drawing the mesh
  104588. */
  104589. get onBeforeDrawObservable(): Observable<Mesh>;
  104590. private _onBeforeDrawObserver;
  104591. /**
  104592. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  104593. */
  104594. set onBeforeDraw(callback: () => void);
  104595. get hasInstances(): boolean;
  104596. get hasThinInstances(): boolean;
  104597. /**
  104598. * Gets the delay loading state of the mesh (when delay loading is turned on)
  104599. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  104600. */
  104601. delayLoadState: number;
  104602. /**
  104603. * Gets the list of instances created from this mesh
  104604. * it is not supposed to be modified manually.
  104605. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  104606. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  104607. */
  104608. instances: InstancedMesh[];
  104609. /**
  104610. * Gets the file containing delay loading data for this mesh
  104611. */
  104612. delayLoadingFile: string;
  104613. /** @hidden */
  104614. _binaryInfo: any;
  104615. /**
  104616. * User defined function used to change how LOD level selection is done
  104617. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  104618. */
  104619. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  104620. /**
  104621. * Gets or sets the morph target manager
  104622. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  104623. */
  104624. get morphTargetManager(): Nullable<MorphTargetManager>;
  104625. set morphTargetManager(value: Nullable<MorphTargetManager>);
  104626. /** @hidden */
  104627. _creationDataStorage: Nullable<_CreationDataStorage>;
  104628. /** @hidden */
  104629. _geometry: Nullable<Geometry>;
  104630. /** @hidden */
  104631. _delayInfo: Array<string>;
  104632. /** @hidden */
  104633. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  104634. /** @hidden */
  104635. _instanceDataStorage: _InstanceDataStorage;
  104636. /** @hidden */
  104637. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  104638. private _effectiveMaterial;
  104639. /** @hidden */
  104640. _shouldGenerateFlatShading: boolean;
  104641. /** @hidden */
  104642. _originalBuilderSideOrientation: number;
  104643. /**
  104644. * Use this property to change the original side orientation defined at construction time
  104645. */
  104646. overrideMaterialSideOrientation: Nullable<number>;
  104647. /**
  104648. * Gets the source mesh (the one used to clone this one from)
  104649. */
  104650. get source(): Nullable<Mesh>;
  104651. /**
  104652. * Gets or sets a boolean indicating that this mesh does not use index buffer
  104653. */
  104654. get isUnIndexed(): boolean;
  104655. set isUnIndexed(value: boolean);
  104656. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  104657. get worldMatrixInstancedBuffer(): Float32Array;
  104658. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  104659. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  104660. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  104661. /**
  104662. * @constructor
  104663. * @param name The value used by scene.getMeshByName() to do a lookup.
  104664. * @param scene The scene to add this mesh to.
  104665. * @param parent The parent of this mesh, if it has one
  104666. * @param source An optional Mesh from which geometry is shared, cloned.
  104667. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  104668. * When false, achieved by calling a clone(), also passing False.
  104669. * This will make creation of children, recursive.
  104670. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  104671. */
  104672. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  104673. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  104674. doNotInstantiate: boolean;
  104675. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  104676. /**
  104677. * Gets the class name
  104678. * @returns the string "Mesh".
  104679. */
  104680. getClassName(): string;
  104681. /** @hidden */
  104682. get _isMesh(): boolean;
  104683. /**
  104684. * Returns a description of this mesh
  104685. * @param fullDetails define if full details about this mesh must be used
  104686. * @returns a descriptive string representing this mesh
  104687. */
  104688. toString(fullDetails?: boolean): string;
  104689. /** @hidden */
  104690. _unBindEffect(): void;
  104691. /**
  104692. * Gets a boolean indicating if this mesh has LOD
  104693. */
  104694. get hasLODLevels(): boolean;
  104695. /**
  104696. * Gets the list of MeshLODLevel associated with the current mesh
  104697. * @returns an array of MeshLODLevel
  104698. */
  104699. getLODLevels(): MeshLODLevel[];
  104700. private _sortLODLevels;
  104701. /**
  104702. * Add a mesh as LOD level triggered at the given distance.
  104703. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104704. * @param distance The distance from the center of the object to show this level
  104705. * @param mesh The mesh to be added as LOD level (can be null)
  104706. * @return This mesh (for chaining)
  104707. */
  104708. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  104709. /**
  104710. * Returns the LOD level mesh at the passed distance or null if not found.
  104711. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104712. * @param distance The distance from the center of the object to show this level
  104713. * @returns a Mesh or `null`
  104714. */
  104715. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  104716. /**
  104717. * Remove a mesh from the LOD array
  104718. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104719. * @param mesh defines the mesh to be removed
  104720. * @return This mesh (for chaining)
  104721. */
  104722. removeLODLevel(mesh: Mesh): Mesh;
  104723. /**
  104724. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  104725. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104726. * @param camera defines the camera to use to compute distance
  104727. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  104728. * @return This mesh (for chaining)
  104729. */
  104730. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  104731. /**
  104732. * Gets the mesh internal Geometry object
  104733. */
  104734. get geometry(): Nullable<Geometry>;
  104735. /**
  104736. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  104737. * @returns the total number of vertices
  104738. */
  104739. getTotalVertices(): number;
  104740. /**
  104741. * Returns the content of an associated vertex buffer
  104742. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  104743. * - VertexBuffer.PositionKind
  104744. * - VertexBuffer.UVKind
  104745. * - VertexBuffer.UV2Kind
  104746. * - VertexBuffer.UV3Kind
  104747. * - VertexBuffer.UV4Kind
  104748. * - VertexBuffer.UV5Kind
  104749. * - VertexBuffer.UV6Kind
  104750. * - VertexBuffer.ColorKind
  104751. * - VertexBuffer.MatricesIndicesKind
  104752. * - VertexBuffer.MatricesIndicesExtraKind
  104753. * - VertexBuffer.MatricesWeightsKind
  104754. * - VertexBuffer.MatricesWeightsExtraKind
  104755. * @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
  104756. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  104757. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  104758. */
  104759. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  104760. /**
  104761. * Returns the mesh VertexBuffer object from the requested `kind`
  104762. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  104763. * - VertexBuffer.PositionKind
  104764. * - VertexBuffer.NormalKind
  104765. * - VertexBuffer.UVKind
  104766. * - VertexBuffer.UV2Kind
  104767. * - VertexBuffer.UV3Kind
  104768. * - VertexBuffer.UV4Kind
  104769. * - VertexBuffer.UV5Kind
  104770. * - VertexBuffer.UV6Kind
  104771. * - VertexBuffer.ColorKind
  104772. * - VertexBuffer.MatricesIndicesKind
  104773. * - VertexBuffer.MatricesIndicesExtraKind
  104774. * - VertexBuffer.MatricesWeightsKind
  104775. * - VertexBuffer.MatricesWeightsExtraKind
  104776. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  104777. */
  104778. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  104779. /**
  104780. * Tests if a specific vertex buffer is associated with this mesh
  104781. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  104782. * - VertexBuffer.PositionKind
  104783. * - VertexBuffer.NormalKind
  104784. * - VertexBuffer.UVKind
  104785. * - VertexBuffer.UV2Kind
  104786. * - VertexBuffer.UV3Kind
  104787. * - VertexBuffer.UV4Kind
  104788. * - VertexBuffer.UV5Kind
  104789. * - VertexBuffer.UV6Kind
  104790. * - VertexBuffer.ColorKind
  104791. * - VertexBuffer.MatricesIndicesKind
  104792. * - VertexBuffer.MatricesIndicesExtraKind
  104793. * - VertexBuffer.MatricesWeightsKind
  104794. * - VertexBuffer.MatricesWeightsExtraKind
  104795. * @returns a boolean
  104796. */
  104797. isVerticesDataPresent(kind: string): boolean;
  104798. /**
  104799. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  104800. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  104801. * - VertexBuffer.PositionKind
  104802. * - VertexBuffer.UVKind
  104803. * - VertexBuffer.UV2Kind
  104804. * - VertexBuffer.UV3Kind
  104805. * - VertexBuffer.UV4Kind
  104806. * - VertexBuffer.UV5Kind
  104807. * - VertexBuffer.UV6Kind
  104808. * - VertexBuffer.ColorKind
  104809. * - VertexBuffer.MatricesIndicesKind
  104810. * - VertexBuffer.MatricesIndicesExtraKind
  104811. * - VertexBuffer.MatricesWeightsKind
  104812. * - VertexBuffer.MatricesWeightsExtraKind
  104813. * @returns a boolean
  104814. */
  104815. isVertexBufferUpdatable(kind: string): boolean;
  104816. /**
  104817. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  104818. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  104819. * - VertexBuffer.PositionKind
  104820. * - VertexBuffer.NormalKind
  104821. * - VertexBuffer.UVKind
  104822. * - VertexBuffer.UV2Kind
  104823. * - VertexBuffer.UV3Kind
  104824. * - VertexBuffer.UV4Kind
  104825. * - VertexBuffer.UV5Kind
  104826. * - VertexBuffer.UV6Kind
  104827. * - VertexBuffer.ColorKind
  104828. * - VertexBuffer.MatricesIndicesKind
  104829. * - VertexBuffer.MatricesIndicesExtraKind
  104830. * - VertexBuffer.MatricesWeightsKind
  104831. * - VertexBuffer.MatricesWeightsExtraKind
  104832. * @returns an array of strings
  104833. */
  104834. getVerticesDataKinds(): string[];
  104835. /**
  104836. * Returns a positive integer : the total number of indices in this mesh geometry.
  104837. * @returns the numner of indices or zero if the mesh has no geometry.
  104838. */
  104839. getTotalIndices(): number;
  104840. /**
  104841. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  104842. * @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.
  104843. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104844. * @returns the indices array or an empty array if the mesh has no geometry
  104845. */
  104846. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  104847. get isBlocked(): boolean;
  104848. /**
  104849. * Determine if the current mesh is ready to be rendered
  104850. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  104851. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  104852. * @returns true if all associated assets are ready (material, textures, shaders)
  104853. */
  104854. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  104855. /**
  104856. * 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.
  104857. */
  104858. get areNormalsFrozen(): boolean;
  104859. /**
  104860. * 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.
  104861. * @returns the current mesh
  104862. */
  104863. freezeNormals(): Mesh;
  104864. /**
  104865. * 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
  104866. * @returns the current mesh
  104867. */
  104868. unfreezeNormals(): Mesh;
  104869. /**
  104870. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  104871. */
  104872. set overridenInstanceCount(count: number);
  104873. /** @hidden */
  104874. _preActivate(): Mesh;
  104875. /** @hidden */
  104876. _preActivateForIntermediateRendering(renderId: number): Mesh;
  104877. /** @hidden */
  104878. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  104879. protected _afterComputeWorldMatrix(): void;
  104880. /**
  104881. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  104882. * This means the mesh underlying bounding box and sphere are recomputed.
  104883. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  104884. * @returns the current mesh
  104885. */
  104886. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  104887. /** @hidden */
  104888. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  104889. /**
  104890. * This function will subdivide the mesh into multiple submeshes
  104891. * @param count defines the expected number of submeshes
  104892. */
  104893. subdivide(count: number): void;
  104894. /**
  104895. * Copy a FloatArray into a specific associated vertex buffer
  104896. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  104897. * - VertexBuffer.PositionKind
  104898. * - VertexBuffer.UVKind
  104899. * - VertexBuffer.UV2Kind
  104900. * - VertexBuffer.UV3Kind
  104901. * - VertexBuffer.UV4Kind
  104902. * - VertexBuffer.UV5Kind
  104903. * - VertexBuffer.UV6Kind
  104904. * - VertexBuffer.ColorKind
  104905. * - VertexBuffer.MatricesIndicesKind
  104906. * - VertexBuffer.MatricesIndicesExtraKind
  104907. * - VertexBuffer.MatricesWeightsKind
  104908. * - VertexBuffer.MatricesWeightsExtraKind
  104909. * @param data defines the data source
  104910. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  104911. * @param stride defines the data stride size (can be null)
  104912. * @returns the current mesh
  104913. */
  104914. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  104915. /**
  104916. * Delete a vertex buffer associated with this mesh
  104917. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  104918. * - VertexBuffer.PositionKind
  104919. * - VertexBuffer.UVKind
  104920. * - VertexBuffer.UV2Kind
  104921. * - VertexBuffer.UV3Kind
  104922. * - VertexBuffer.UV4Kind
  104923. * - VertexBuffer.UV5Kind
  104924. * - VertexBuffer.UV6Kind
  104925. * - VertexBuffer.ColorKind
  104926. * - VertexBuffer.MatricesIndicesKind
  104927. * - VertexBuffer.MatricesIndicesExtraKind
  104928. * - VertexBuffer.MatricesWeightsKind
  104929. * - VertexBuffer.MatricesWeightsExtraKind
  104930. */
  104931. removeVerticesData(kind: string): void;
  104932. /**
  104933. * Flags an associated vertex buffer as updatable
  104934. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  104935. * - VertexBuffer.PositionKind
  104936. * - VertexBuffer.UVKind
  104937. * - VertexBuffer.UV2Kind
  104938. * - VertexBuffer.UV3Kind
  104939. * - VertexBuffer.UV4Kind
  104940. * - VertexBuffer.UV5Kind
  104941. * - VertexBuffer.UV6Kind
  104942. * - VertexBuffer.ColorKind
  104943. * - VertexBuffer.MatricesIndicesKind
  104944. * - VertexBuffer.MatricesIndicesExtraKind
  104945. * - VertexBuffer.MatricesWeightsKind
  104946. * - VertexBuffer.MatricesWeightsExtraKind
  104947. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  104948. */
  104949. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  104950. /**
  104951. * Sets the mesh global Vertex Buffer
  104952. * @param buffer defines the buffer to use
  104953. * @returns the current mesh
  104954. */
  104955. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  104956. /**
  104957. * Update a specific associated vertex buffer
  104958. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  104959. * - VertexBuffer.PositionKind
  104960. * - VertexBuffer.UVKind
  104961. * - VertexBuffer.UV2Kind
  104962. * - VertexBuffer.UV3Kind
  104963. * - VertexBuffer.UV4Kind
  104964. * - VertexBuffer.UV5Kind
  104965. * - VertexBuffer.UV6Kind
  104966. * - VertexBuffer.ColorKind
  104967. * - VertexBuffer.MatricesIndicesKind
  104968. * - VertexBuffer.MatricesIndicesExtraKind
  104969. * - VertexBuffer.MatricesWeightsKind
  104970. * - VertexBuffer.MatricesWeightsExtraKind
  104971. * @param data defines the data source
  104972. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  104973. * @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)
  104974. * @returns the current mesh
  104975. */
  104976. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  104977. /**
  104978. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  104979. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  104980. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  104981. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  104982. * @returns the current mesh
  104983. */
  104984. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  104985. /**
  104986. * Creates a un-shared specific occurence of the geometry for the mesh.
  104987. * @returns the current mesh
  104988. */
  104989. makeGeometryUnique(): Mesh;
  104990. /**
  104991. * Set the index buffer of this mesh
  104992. * @param indices defines the source data
  104993. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  104994. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  104995. * @returns the current mesh
  104996. */
  104997. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  104998. /**
  104999. * Update the current index buffer
  105000. * @param indices defines the source data
  105001. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  105002. * @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)
  105003. * @returns the current mesh
  105004. */
  105005. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  105006. /**
  105007. * Invert the geometry to move from a right handed system to a left handed one.
  105008. * @returns the current mesh
  105009. */
  105010. toLeftHanded(): Mesh;
  105011. /** @hidden */
  105012. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  105013. /** @hidden */
  105014. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  105015. /**
  105016. * Registers for this mesh a javascript function called just before the rendering process
  105017. * @param func defines the function to call before rendering this mesh
  105018. * @returns the current mesh
  105019. */
  105020. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  105021. /**
  105022. * Disposes a previously registered javascript function called before the rendering
  105023. * @param func defines the function to remove
  105024. * @returns the current mesh
  105025. */
  105026. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  105027. /**
  105028. * Registers for this mesh a javascript function called just after the rendering is complete
  105029. * @param func defines the function to call after rendering this mesh
  105030. * @returns the current mesh
  105031. */
  105032. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  105033. /**
  105034. * Disposes a previously registered javascript function called after the rendering.
  105035. * @param func defines the function to remove
  105036. * @returns the current mesh
  105037. */
  105038. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  105039. /** @hidden */
  105040. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  105041. /** @hidden */
  105042. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  105043. /** @hidden */
  105044. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  105045. /** @hidden */
  105046. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  105047. /** @hidden */
  105048. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  105049. /** @hidden */
  105050. _rebuild(): void;
  105051. /** @hidden */
  105052. _freeze(): void;
  105053. /** @hidden */
  105054. _unFreeze(): void;
  105055. /**
  105056. * 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
  105057. * @param subMesh defines the subMesh to render
  105058. * @param enableAlphaMode defines if alpha mode can be changed
  105059. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  105060. * @returns the current mesh
  105061. */
  105062. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  105063. private _onBeforeDraw;
  105064. /**
  105065. * Renormalize the mesh and patch it up if there are no weights
  105066. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  105067. * However in the case of zero weights then we set just a single influence to 1.
  105068. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  105069. */
  105070. cleanMatrixWeights(): void;
  105071. private normalizeSkinFourWeights;
  105072. private normalizeSkinWeightsAndExtra;
  105073. /**
  105074. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  105075. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  105076. * the user know there was an issue with importing the mesh
  105077. * @returns a validation object with skinned, valid and report string
  105078. */
  105079. validateSkinning(): {
  105080. skinned: boolean;
  105081. valid: boolean;
  105082. report: string;
  105083. };
  105084. /** @hidden */
  105085. _checkDelayState(): Mesh;
  105086. private _queueLoad;
  105087. /**
  105088. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  105089. * A mesh is in the frustum if its bounding box intersects the frustum
  105090. * @param frustumPlanes defines the frustum to test
  105091. * @returns true if the mesh is in the frustum planes
  105092. */
  105093. isInFrustum(frustumPlanes: Plane[]): boolean;
  105094. /**
  105095. * Sets the mesh material by the material or multiMaterial `id` property
  105096. * @param id is a string identifying the material or the multiMaterial
  105097. * @returns the current mesh
  105098. */
  105099. setMaterialByID(id: string): Mesh;
  105100. /**
  105101. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  105102. * @returns an array of IAnimatable
  105103. */
  105104. getAnimatables(): IAnimatable[];
  105105. /**
  105106. * Modifies the mesh geometry according to the passed transformation matrix.
  105107. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  105108. * The mesh normals are modified using the same transformation.
  105109. * Note that, under the hood, this method sets a new VertexBuffer each call.
  105110. * @param transform defines the transform matrix to use
  105111. * @see http://doc.babylonjs.com/resources/baking_transformations
  105112. * @returns the current mesh
  105113. */
  105114. bakeTransformIntoVertices(transform: Matrix): Mesh;
  105115. /**
  105116. * Modifies the mesh geometry according to its own current World Matrix.
  105117. * The mesh World Matrix is then reset.
  105118. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  105119. * Note that, under the hood, this method sets a new VertexBuffer each call.
  105120. * @see http://doc.babylonjs.com/resources/baking_transformations
  105121. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  105122. * @returns the current mesh
  105123. */
  105124. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  105125. /** @hidden */
  105126. get _positions(): Nullable<Vector3[]>;
  105127. /** @hidden */
  105128. _resetPointsArrayCache(): Mesh;
  105129. /** @hidden */
  105130. _generatePointsArray(): boolean;
  105131. /**
  105132. * Returns a new Mesh object generated from the current mesh properties.
  105133. * This method must not get confused with createInstance()
  105134. * @param name is a string, the name given to the new mesh
  105135. * @param newParent can be any Node object (default `null`)
  105136. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  105137. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  105138. * @returns a new mesh
  105139. */
  105140. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  105141. /**
  105142. * Releases resources associated with this mesh.
  105143. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105144. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105145. */
  105146. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105147. /** @hidden */
  105148. _disposeInstanceSpecificData(): void;
  105149. /** @hidden */
  105150. _disposeThinInstanceSpecificData(): void;
  105151. /**
  105152. * Modifies the mesh geometry according to a displacement map.
  105153. * 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.
  105154. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  105155. * @param url is a string, the URL from the image file is to be downloaded.
  105156. * @param minHeight is the lower limit of the displacement.
  105157. * @param maxHeight is the upper limit of the displacement.
  105158. * @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.
  105159. * @param uvOffset is an optional vector2 used to offset UV.
  105160. * @param uvScale is an optional vector2 used to scale UV.
  105161. * @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.
  105162. * @returns the Mesh.
  105163. */
  105164. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  105165. /**
  105166. * Modifies the mesh geometry according to a displacementMap buffer.
  105167. * 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.
  105168. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  105169. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  105170. * @param heightMapWidth is the width of the buffer image.
  105171. * @param heightMapHeight is the height of the buffer image.
  105172. * @param minHeight is the lower limit of the displacement.
  105173. * @param maxHeight is the upper limit of the displacement.
  105174. * @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.
  105175. * @param uvOffset is an optional vector2 used to offset UV.
  105176. * @param uvScale is an optional vector2 used to scale UV.
  105177. * @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.
  105178. * @returns the Mesh.
  105179. */
  105180. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  105181. /**
  105182. * Modify the mesh to get a flat shading rendering.
  105183. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  105184. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  105185. * @returns current mesh
  105186. */
  105187. convertToFlatShadedMesh(): Mesh;
  105188. /**
  105189. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  105190. * In other words, more vertices, no more indices and a single bigger VBO.
  105191. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  105192. * @returns current mesh
  105193. */
  105194. convertToUnIndexedMesh(): Mesh;
  105195. /**
  105196. * Inverses facet orientations.
  105197. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105198. * @param flipNormals will also inverts the normals
  105199. * @returns current mesh
  105200. */
  105201. flipFaces(flipNormals?: boolean): Mesh;
  105202. /**
  105203. * Increase the number of facets and hence vertices in a mesh
  105204. * Vertex normals are interpolated from existing vertex normals
  105205. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105206. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  105207. */
  105208. increaseVertices(numberPerEdge: number): void;
  105209. /**
  105210. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  105211. * This will undo any application of covertToFlatShadedMesh
  105212. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105213. */
  105214. forceSharedVertices(): void;
  105215. /** @hidden */
  105216. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  105217. /** @hidden */
  105218. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  105219. /**
  105220. * Creates a new InstancedMesh object from the mesh model.
  105221. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  105222. * @param name defines the name of the new instance
  105223. * @returns a new InstancedMesh
  105224. */
  105225. createInstance(name: string): InstancedMesh;
  105226. /**
  105227. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  105228. * After this call, all the mesh instances have the same submeshes than the current mesh.
  105229. * @returns the current mesh
  105230. */
  105231. synchronizeInstances(): Mesh;
  105232. /**
  105233. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  105234. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  105235. * This should be used together with the simplification to avoid disappearing triangles.
  105236. * @param successCallback an optional success callback to be called after the optimization finished.
  105237. * @returns the current mesh
  105238. */
  105239. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  105240. /**
  105241. * Serialize current mesh
  105242. * @param serializationObject defines the object which will receive the serialization data
  105243. */
  105244. serialize(serializationObject: any): void;
  105245. /** @hidden */
  105246. _syncGeometryWithMorphTargetManager(): void;
  105247. /** @hidden */
  105248. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  105249. /**
  105250. * Returns a new Mesh object parsed from the source provided.
  105251. * @param parsedMesh is the source
  105252. * @param scene defines the hosting scene
  105253. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  105254. * @returns a new Mesh
  105255. */
  105256. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  105257. /**
  105258. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  105259. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105260. * @param name defines the name of the mesh to create
  105261. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  105262. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  105263. * @param closePath creates a seam between the first and the last points of each path of the path array
  105264. * @param offset is taken in account only if the `pathArray` is containing a single path
  105265. * @param scene defines the hosting scene
  105266. * @param updatable defines if the mesh must be flagged as updatable
  105267. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105268. * @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)
  105269. * @returns a new Mesh
  105270. */
  105271. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105272. /**
  105273. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  105274. * @param name defines the name of the mesh to create
  105275. * @param radius sets the radius size (float) of the polygon (default 0.5)
  105276. * @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
  105277. * @param scene defines the hosting scene
  105278. * @param updatable defines if the mesh must be flagged as updatable
  105279. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105280. * @returns a new Mesh
  105281. */
  105282. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  105283. /**
  105284. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  105285. * @param name defines the name of the mesh to create
  105286. * @param size sets the size (float) of each box side (default 1)
  105287. * @param scene defines the hosting scene
  105288. * @param updatable defines if the mesh must be flagged as updatable
  105289. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105290. * @returns a new Mesh
  105291. */
  105292. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  105293. /**
  105294. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  105295. * @param name defines the name of the mesh to create
  105296. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  105297. * @param diameter sets the diameter size (float) of the sphere (default 1)
  105298. * @param scene defines the hosting scene
  105299. * @param updatable defines if the mesh must be flagged as updatable
  105300. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105301. * @returns a new Mesh
  105302. */
  105303. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105304. /**
  105305. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  105306. * @param name defines the name of the mesh to create
  105307. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  105308. * @param diameter sets the diameter size (float) of the sphere (default 1)
  105309. * @param scene defines the hosting scene
  105310. * @returns a new Mesh
  105311. */
  105312. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  105313. /**
  105314. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  105315. * @param name defines the name of the mesh to create
  105316. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  105317. * @param diameterTop set the top cap diameter (floats, default 1)
  105318. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  105319. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  105320. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  105321. * @param scene defines the hosting scene
  105322. * @param updatable defines if the mesh must be flagged as updatable
  105323. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105324. * @returns a new Mesh
  105325. */
  105326. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  105327. /**
  105328. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  105329. * @param name defines the name of the mesh to create
  105330. * @param diameter sets the diameter size (float) of the torus (default 1)
  105331. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  105332. * @param tessellation sets the number of torus sides (postive integer, default 16)
  105333. * @param scene defines the hosting scene
  105334. * @param updatable defines if the mesh must be flagged as updatable
  105335. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105336. * @returns a new Mesh
  105337. */
  105338. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105339. /**
  105340. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  105341. * @param name defines the name of the mesh to create
  105342. * @param radius sets the global radius size (float) of the torus knot (default 2)
  105343. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  105344. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  105345. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  105346. * @param p the number of windings on X axis (positive integers, default 2)
  105347. * @param q the number of windings on Y axis (positive integers, default 3)
  105348. * @param scene defines the hosting scene
  105349. * @param updatable defines if the mesh must be flagged as updatable
  105350. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105351. * @returns a new Mesh
  105352. */
  105353. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105354. /**
  105355. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  105356. * @param name defines the name of the mesh to create
  105357. * @param points is an array successive Vector3
  105358. * @param scene defines the hosting scene
  105359. * @param updatable defines if the mesh must be flagged as updatable
  105360. * @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).
  105361. * @returns a new Mesh
  105362. */
  105363. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  105364. /**
  105365. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  105366. * @param name defines the name of the mesh to create
  105367. * @param points is an array successive Vector3
  105368. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  105369. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  105370. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  105371. * @param scene defines the hosting scene
  105372. * @param updatable defines if the mesh must be flagged as updatable
  105373. * @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)
  105374. * @returns a new Mesh
  105375. */
  105376. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  105377. /**
  105378. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  105379. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  105380. * 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.
  105381. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105382. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105383. * Remember you can only change the shape positions, not their number when updating a polygon.
  105384. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  105385. * @param name defines the name of the mesh to create
  105386. * @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
  105387. * @param scene defines the hosting scene
  105388. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  105389. * @param updatable defines if the mesh must be flagged as updatable
  105390. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105391. * @param earcutInjection can be used to inject your own earcut reference
  105392. * @returns a new Mesh
  105393. */
  105394. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  105395. /**
  105396. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  105397. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  105398. * @param name defines the name of the mesh to create
  105399. * @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
  105400. * @param depth defines the height of extrusion
  105401. * @param scene defines the hosting scene
  105402. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  105403. * @param updatable defines if the mesh must be flagged as updatable
  105404. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105405. * @param earcutInjection can be used to inject your own earcut reference
  105406. * @returns a new Mesh
  105407. */
  105408. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  105409. /**
  105410. * Creates an extruded shape mesh.
  105411. * 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
  105412. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105413. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105414. * @param name defines the name of the mesh to create
  105415. * @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
  105416. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  105417. * @param scale is the value to scale the shape
  105418. * @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
  105419. * @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
  105420. * @param scene defines the hosting scene
  105421. * @param updatable defines if the mesh must be flagged as updatable
  105422. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105423. * @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)
  105424. * @returns a new Mesh
  105425. */
  105426. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105427. /**
  105428. * Creates an custom extruded shape mesh.
  105429. * The custom extrusion is a parametric shape.
  105430. * It has no predefined shape. Its final shape will depend on the input parameters.
  105431. * Please consider using the same method from the MeshBuilder class instead
  105432. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105433. * @param name defines the name of the mesh to create
  105434. * @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
  105435. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  105436. * @param scaleFunction is a custom Javascript function called on each path point
  105437. * @param rotationFunction is a custom Javascript function called on each path point
  105438. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105439. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  105440. * @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
  105441. * @param scene defines the hosting scene
  105442. * @param updatable defines if the mesh must be flagged as updatable
  105443. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105444. * @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)
  105445. * @returns a new Mesh
  105446. */
  105447. 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;
  105448. /**
  105449. * Creates lathe mesh.
  105450. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  105451. * Please consider using the same method from the MeshBuilder class instead
  105452. * @param name defines the name of the mesh to create
  105453. * @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
  105454. * @param radius is the radius value of the lathe
  105455. * @param tessellation is the side number of the lathe.
  105456. * @param scene defines the hosting scene
  105457. * @param updatable defines if the mesh must be flagged as updatable
  105458. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105459. * @returns a new Mesh
  105460. */
  105461. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105462. /**
  105463. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  105464. * @param name defines the name of the mesh to create
  105465. * @param size sets the size (float) of both sides of the plane at once (default 1)
  105466. * @param scene defines the hosting scene
  105467. * @param updatable defines if the mesh must be flagged as updatable
  105468. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105469. * @returns a new Mesh
  105470. */
  105471. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105472. /**
  105473. * Creates a ground mesh.
  105474. * Please consider using the same method from the MeshBuilder class instead
  105475. * @param name defines the name of the mesh to create
  105476. * @param width set the width of the ground
  105477. * @param height set the height of the ground
  105478. * @param subdivisions sets the number of subdivisions per side
  105479. * @param scene defines the hosting scene
  105480. * @param updatable defines if the mesh must be flagged as updatable
  105481. * @returns a new Mesh
  105482. */
  105483. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  105484. /**
  105485. * Creates a tiled ground mesh.
  105486. * Please consider using the same method from the MeshBuilder class instead
  105487. * @param name defines the name of the mesh to create
  105488. * @param xmin set the ground minimum X coordinate
  105489. * @param zmin set the ground minimum Y coordinate
  105490. * @param xmax set the ground maximum X coordinate
  105491. * @param zmax set the ground maximum Z coordinate
  105492. * @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
  105493. * @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
  105494. * @param scene defines the hosting scene
  105495. * @param updatable defines if the mesh must be flagged as updatable
  105496. * @returns a new Mesh
  105497. */
  105498. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  105499. w: number;
  105500. h: number;
  105501. }, precision: {
  105502. w: number;
  105503. h: number;
  105504. }, scene: Scene, updatable?: boolean): Mesh;
  105505. /**
  105506. * Creates a ground mesh from a height map.
  105507. * Please consider using the same method from the MeshBuilder class instead
  105508. * @see http://doc.babylonjs.com/babylon101/height_map
  105509. * @param name defines the name of the mesh to create
  105510. * @param url sets the URL of the height map image resource
  105511. * @param width set the ground width size
  105512. * @param height set the ground height size
  105513. * @param subdivisions sets the number of subdivision per side
  105514. * @param minHeight is the minimum altitude on the ground
  105515. * @param maxHeight is the maximum altitude on the ground
  105516. * @param scene defines the hosting scene
  105517. * @param updatable defines if the mesh must be flagged as updatable
  105518. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  105519. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  105520. * @returns a new Mesh
  105521. */
  105522. 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;
  105523. /**
  105524. * Creates a tube mesh.
  105525. * The tube is a parametric shape.
  105526. * It has no predefined shape. Its final shape will depend on the input parameters.
  105527. * Please consider using the same method from the MeshBuilder class instead
  105528. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105529. * @param name defines the name of the mesh to create
  105530. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  105531. * @param radius sets the tube radius size
  105532. * @param tessellation is the number of sides on the tubular surface
  105533. * @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
  105534. * @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
  105535. * @param scene defines the hosting scene
  105536. * @param updatable defines if the mesh must be flagged as updatable
  105537. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105538. * @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)
  105539. * @returns a new Mesh
  105540. */
  105541. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  105542. (i: number, distance: number): number;
  105543. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105544. /**
  105545. * Creates a polyhedron mesh.
  105546. * Please consider using the same method from the MeshBuilder class instead.
  105547. * * 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
  105548. * * The parameter `size` (positive float, default 1) sets the polygon size
  105549. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  105550. * * 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`
  105551. * * 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
  105552. * * 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)`)
  105553. * * 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
  105554. * * 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
  105555. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105556. * * If you create a double-sided mesh, you can choose what parts of 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
  105557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105558. * @param name defines the name of the mesh to create
  105559. * @param options defines the options used to create the mesh
  105560. * @param scene defines the hosting scene
  105561. * @returns a new Mesh
  105562. */
  105563. static CreatePolyhedron(name: string, options: {
  105564. type?: number;
  105565. size?: number;
  105566. sizeX?: number;
  105567. sizeY?: number;
  105568. sizeZ?: number;
  105569. custom?: any;
  105570. faceUV?: Vector4[];
  105571. faceColors?: Color4[];
  105572. updatable?: boolean;
  105573. sideOrientation?: number;
  105574. }, scene: Scene): Mesh;
  105575. /**
  105576. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105577. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105578. * * 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`)
  105579. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105580. * * 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
  105581. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105582. * * If you create a double-sided mesh, you can choose what parts of 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
  105583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105584. * @param name defines the name of the mesh
  105585. * @param options defines the options used to create the mesh
  105586. * @param scene defines the hosting scene
  105587. * @returns a new Mesh
  105588. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105589. */
  105590. static CreateIcoSphere(name: string, options: {
  105591. radius?: number;
  105592. flat?: boolean;
  105593. subdivisions?: number;
  105594. sideOrientation?: number;
  105595. updatable?: boolean;
  105596. }, scene: Scene): Mesh;
  105597. /**
  105598. * Creates a decal mesh.
  105599. * Please consider using the same method from the MeshBuilder class instead.
  105600. * A decal is a mesh usually applied as a model onto the surface of another mesh
  105601. * @param name defines the name of the mesh
  105602. * @param sourceMesh defines the mesh receiving the decal
  105603. * @param position sets the position of the decal in world coordinates
  105604. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  105605. * @param size sets the decal scaling
  105606. * @param angle sets the angle to rotate the decal
  105607. * @returns a new Mesh
  105608. */
  105609. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  105610. /**
  105611. * Prepare internal position array for software CPU skinning
  105612. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  105613. */
  105614. setPositionsForCPUSkinning(): Float32Array;
  105615. /**
  105616. * Prepare internal normal array for software CPU skinning
  105617. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  105618. */
  105619. setNormalsForCPUSkinning(): Float32Array;
  105620. /**
  105621. * Updates the vertex buffer by applying transformation from the bones
  105622. * @param skeleton defines the skeleton to apply to current mesh
  105623. * @returns the current mesh
  105624. */
  105625. applySkeleton(skeleton: Skeleton): Mesh;
  105626. /**
  105627. * 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
  105628. * @param meshes defines the list of meshes to scan
  105629. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  105630. */
  105631. static MinMax(meshes: AbstractMesh[]): {
  105632. min: Vector3;
  105633. max: Vector3;
  105634. };
  105635. /**
  105636. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  105637. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  105638. * @returns a vector3
  105639. */
  105640. static Center(meshesOrMinMaxVector: {
  105641. min: Vector3;
  105642. max: Vector3;
  105643. } | AbstractMesh[]): Vector3;
  105644. /**
  105645. * Merge the array of meshes into a single mesh for performance reasons.
  105646. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  105647. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  105648. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  105649. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  105650. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  105651. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  105652. * @returns a new mesh
  105653. */
  105654. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  105655. /** @hidden */
  105656. addInstance(instance: InstancedMesh): void;
  105657. /** @hidden */
  105658. removeInstance(instance: InstancedMesh): void;
  105659. }
  105660. }
  105661. declare module BABYLON {
  105662. /**
  105663. * This is the base class of all the camera used in the application.
  105664. * @see http://doc.babylonjs.com/features/cameras
  105665. */
  105666. export class Camera extends Node {
  105667. /** @hidden */
  105668. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  105669. /**
  105670. * This is the default projection mode used by the cameras.
  105671. * It helps recreating a feeling of perspective and better appreciate depth.
  105672. * This is the best way to simulate real life cameras.
  105673. */
  105674. static readonly PERSPECTIVE_CAMERA: number;
  105675. /**
  105676. * This helps creating camera with an orthographic mode.
  105677. * 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.
  105678. */
  105679. static readonly ORTHOGRAPHIC_CAMERA: number;
  105680. /**
  105681. * This is the default FOV mode for perspective cameras.
  105682. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  105683. */
  105684. static readonly FOVMODE_VERTICAL_FIXED: number;
  105685. /**
  105686. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  105687. */
  105688. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  105689. /**
  105690. * This specifies ther is no need for a camera rig.
  105691. * Basically only one eye is rendered corresponding to the camera.
  105692. */
  105693. static readonly RIG_MODE_NONE: number;
  105694. /**
  105695. * Simulates a camera Rig with one blue eye and one red eye.
  105696. * This can be use with 3d blue and red glasses.
  105697. */
  105698. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  105699. /**
  105700. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  105701. */
  105702. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  105703. /**
  105704. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  105705. */
  105706. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  105707. /**
  105708. * Defines that both eyes of the camera will be rendered over under each other.
  105709. */
  105710. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  105711. /**
  105712. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  105713. */
  105714. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  105715. /**
  105716. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  105717. */
  105718. static readonly RIG_MODE_VR: number;
  105719. /**
  105720. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  105721. */
  105722. static readonly RIG_MODE_WEBVR: number;
  105723. /**
  105724. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  105725. */
  105726. static readonly RIG_MODE_CUSTOM: number;
  105727. /**
  105728. * Defines if by default attaching controls should prevent the default javascript event to continue.
  105729. */
  105730. static ForceAttachControlToAlwaysPreventDefault: boolean;
  105731. /**
  105732. * Define the input manager associated with the camera.
  105733. */
  105734. inputs: CameraInputsManager<Camera>;
  105735. /** @hidden */
  105736. _position: Vector3;
  105737. /**
  105738. * Define the current local position of the camera in the scene
  105739. */
  105740. get position(): Vector3;
  105741. set position(newPosition: Vector3);
  105742. /**
  105743. * The vector the camera should consider as up.
  105744. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  105745. */
  105746. upVector: Vector3;
  105747. /**
  105748. * Define the current limit on the left side for an orthographic camera
  105749. * In scene unit
  105750. */
  105751. orthoLeft: Nullable<number>;
  105752. /**
  105753. * Define the current limit on the right side for an orthographic camera
  105754. * In scene unit
  105755. */
  105756. orthoRight: Nullable<number>;
  105757. /**
  105758. * Define the current limit on the bottom side for an orthographic camera
  105759. * In scene unit
  105760. */
  105761. orthoBottom: Nullable<number>;
  105762. /**
  105763. * Define the current limit on the top side for an orthographic camera
  105764. * In scene unit
  105765. */
  105766. orthoTop: Nullable<number>;
  105767. /**
  105768. * Field Of View is set in Radians. (default is 0.8)
  105769. */
  105770. fov: number;
  105771. /**
  105772. * Define the minimum distance the camera can see from.
  105773. * This is important to note that the depth buffer are not infinite and the closer it starts
  105774. * the more your scene might encounter depth fighting issue.
  105775. */
  105776. minZ: number;
  105777. /**
  105778. * Define the maximum distance the camera can see to.
  105779. * This is important to note that the depth buffer are not infinite and the further it end
  105780. * the more your scene might encounter depth fighting issue.
  105781. */
  105782. maxZ: number;
  105783. /**
  105784. * Define the default inertia of the camera.
  105785. * This helps giving a smooth feeling to the camera movement.
  105786. */
  105787. inertia: number;
  105788. /**
  105789. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  105790. */
  105791. mode: number;
  105792. /**
  105793. * Define whether the camera is intermediate.
  105794. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  105795. */
  105796. isIntermediate: boolean;
  105797. /**
  105798. * Define the viewport of the camera.
  105799. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  105800. */
  105801. viewport: Viewport;
  105802. /**
  105803. * Restricts the camera to viewing objects with the same layerMask.
  105804. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  105805. */
  105806. layerMask: number;
  105807. /**
  105808. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  105809. */
  105810. fovMode: number;
  105811. /**
  105812. * Rig mode of the camera.
  105813. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  105814. * This is normally controlled byt the camera themselves as internal use.
  105815. */
  105816. cameraRigMode: number;
  105817. /**
  105818. * Defines the distance between both "eyes" in case of a RIG
  105819. */
  105820. interaxialDistance: number;
  105821. /**
  105822. * Defines if stereoscopic rendering is done side by side or over under.
  105823. */
  105824. isStereoscopicSideBySide: boolean;
  105825. /**
  105826. * 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
  105827. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  105828. * else in the scene. (Eg. security camera)
  105829. *
  105830. * 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)
  105831. */
  105832. customRenderTargets: RenderTargetTexture[];
  105833. /**
  105834. * When set, the camera will render to this render target instead of the default canvas
  105835. *
  105836. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  105837. */
  105838. outputRenderTarget: Nullable<RenderTargetTexture>;
  105839. /**
  105840. * Observable triggered when the camera view matrix has changed.
  105841. */
  105842. onViewMatrixChangedObservable: Observable<Camera>;
  105843. /**
  105844. * Observable triggered when the camera Projection matrix has changed.
  105845. */
  105846. onProjectionMatrixChangedObservable: Observable<Camera>;
  105847. /**
  105848. * Observable triggered when the inputs have been processed.
  105849. */
  105850. onAfterCheckInputsObservable: Observable<Camera>;
  105851. /**
  105852. * Observable triggered when reset has been called and applied to the camera.
  105853. */
  105854. onRestoreStateObservable: Observable<Camera>;
  105855. /**
  105856. * Is this camera a part of a rig system?
  105857. */
  105858. isRigCamera: boolean;
  105859. /**
  105860. * If isRigCamera set to true this will be set with the parent camera.
  105861. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  105862. */
  105863. rigParent?: Camera;
  105864. /** @hidden */
  105865. _cameraRigParams: any;
  105866. /** @hidden */
  105867. _rigCameras: Camera[];
  105868. /** @hidden */
  105869. _rigPostProcess: Nullable<PostProcess>;
  105870. protected _webvrViewMatrix: Matrix;
  105871. /** @hidden */
  105872. _skipRendering: boolean;
  105873. /** @hidden */
  105874. _projectionMatrix: Matrix;
  105875. /** @hidden */
  105876. _postProcesses: Nullable<PostProcess>[];
  105877. /** @hidden */
  105878. _activeMeshes: SmartArray<AbstractMesh>;
  105879. protected _globalPosition: Vector3;
  105880. /** @hidden */
  105881. _computedViewMatrix: Matrix;
  105882. private _doNotComputeProjectionMatrix;
  105883. private _transformMatrix;
  105884. private _frustumPlanes;
  105885. private _refreshFrustumPlanes;
  105886. private _storedFov;
  105887. private _stateStored;
  105888. /**
  105889. * Instantiates a new camera object.
  105890. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  105891. * @see http://doc.babylonjs.com/features/cameras
  105892. * @param name Defines the name of the camera in the scene
  105893. * @param position Defines the position of the camera
  105894. * @param scene Defines the scene the camera belongs too
  105895. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  105896. */
  105897. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  105898. /**
  105899. * Store current camera state (fov, position, etc..)
  105900. * @returns the camera
  105901. */
  105902. storeState(): Camera;
  105903. /**
  105904. * Restores the camera state values if it has been stored. You must call storeState() first
  105905. */
  105906. protected _restoreStateValues(): boolean;
  105907. /**
  105908. * Restored camera state. You must call storeState() first.
  105909. * @returns true if restored and false otherwise
  105910. */
  105911. restoreState(): boolean;
  105912. /**
  105913. * Gets the class name of the camera.
  105914. * @returns the class name
  105915. */
  105916. getClassName(): string;
  105917. /** @hidden */
  105918. readonly _isCamera: boolean;
  105919. /**
  105920. * Gets a string representation of the camera useful for debug purpose.
  105921. * @param fullDetails Defines that a more verboe level of logging is required
  105922. * @returns the string representation
  105923. */
  105924. toString(fullDetails?: boolean): string;
  105925. /**
  105926. * Gets the current world space position of the camera.
  105927. */
  105928. get globalPosition(): Vector3;
  105929. /**
  105930. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  105931. * @returns the active meshe list
  105932. */
  105933. getActiveMeshes(): SmartArray<AbstractMesh>;
  105934. /**
  105935. * Check whether a mesh is part of the current active mesh list of the camera
  105936. * @param mesh Defines the mesh to check
  105937. * @returns true if active, false otherwise
  105938. */
  105939. isActiveMesh(mesh: Mesh): boolean;
  105940. /**
  105941. * Is this camera ready to be used/rendered
  105942. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  105943. * @return true if the camera is ready
  105944. */
  105945. isReady(completeCheck?: boolean): boolean;
  105946. /** @hidden */
  105947. _initCache(): void;
  105948. /** @hidden */
  105949. _updateCache(ignoreParentClass?: boolean): void;
  105950. /** @hidden */
  105951. _isSynchronized(): boolean;
  105952. /** @hidden */
  105953. _isSynchronizedViewMatrix(): boolean;
  105954. /** @hidden */
  105955. _isSynchronizedProjectionMatrix(): boolean;
  105956. /**
  105957. * Attach the input controls to a specific dom element to get the input from.
  105958. * @param element Defines the element the controls should be listened from
  105959. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105960. */
  105961. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105962. /**
  105963. * Detach the current controls from the specified dom element.
  105964. * @param element Defines the element to stop listening the inputs from
  105965. */
  105966. detachControl(element: HTMLElement): void;
  105967. /**
  105968. * Update the camera state according to the different inputs gathered during the frame.
  105969. */
  105970. update(): void;
  105971. /** @hidden */
  105972. _checkInputs(): void;
  105973. /** @hidden */
  105974. get rigCameras(): Camera[];
  105975. /**
  105976. * Gets the post process used by the rig cameras
  105977. */
  105978. get rigPostProcess(): Nullable<PostProcess>;
  105979. /**
  105980. * Internal, gets the first post proces.
  105981. * @returns the first post process to be run on this camera.
  105982. */
  105983. _getFirstPostProcess(): Nullable<PostProcess>;
  105984. private _cascadePostProcessesToRigCams;
  105985. /**
  105986. * Attach a post process to the camera.
  105987. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  105988. * @param postProcess The post process to attach to the camera
  105989. * @param insertAt The position of the post process in case several of them are in use in the scene
  105990. * @returns the position the post process has been inserted at
  105991. */
  105992. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  105993. /**
  105994. * Detach a post process to the camera.
  105995. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  105996. * @param postProcess The post process to detach from the camera
  105997. */
  105998. detachPostProcess(postProcess: PostProcess): void;
  105999. /**
  106000. * Gets the current world matrix of the camera
  106001. */
  106002. getWorldMatrix(): Matrix;
  106003. /** @hidden */
  106004. _getViewMatrix(): Matrix;
  106005. /**
  106006. * Gets the current view matrix of the camera.
  106007. * @param force forces the camera to recompute the matrix without looking at the cached state
  106008. * @returns the view matrix
  106009. */
  106010. getViewMatrix(force?: boolean): Matrix;
  106011. /**
  106012. * Freeze the projection matrix.
  106013. * It will prevent the cache check of the camera projection compute and can speed up perf
  106014. * if no parameter of the camera are meant to change
  106015. * @param projection Defines manually a projection if necessary
  106016. */
  106017. freezeProjectionMatrix(projection?: Matrix): void;
  106018. /**
  106019. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  106020. */
  106021. unfreezeProjectionMatrix(): void;
  106022. /**
  106023. * Gets the current projection matrix of the camera.
  106024. * @param force forces the camera to recompute the matrix without looking at the cached state
  106025. * @returns the projection matrix
  106026. */
  106027. getProjectionMatrix(force?: boolean): Matrix;
  106028. /**
  106029. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  106030. * @returns a Matrix
  106031. */
  106032. getTransformationMatrix(): Matrix;
  106033. private _updateFrustumPlanes;
  106034. /**
  106035. * Checks if a cullable object (mesh...) is in the camera frustum
  106036. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  106037. * @param target The object to check
  106038. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  106039. * @returns true if the object is in frustum otherwise false
  106040. */
  106041. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  106042. /**
  106043. * Checks if a cullable object (mesh...) is in the camera frustum
  106044. * Unlike isInFrustum this cheks the full bounding box
  106045. * @param target The object to check
  106046. * @returns true if the object is in frustum otherwise false
  106047. */
  106048. isCompletelyInFrustum(target: ICullable): boolean;
  106049. /**
  106050. * Gets a ray in the forward direction from the camera.
  106051. * @param length Defines the length of the ray to create
  106052. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  106053. * @param origin Defines the start point of the ray which defaults to the camera position
  106054. * @returns the forward ray
  106055. */
  106056. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  106057. /**
  106058. * Releases resources associated with this node.
  106059. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106060. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106061. */
  106062. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106063. /** @hidden */
  106064. _isLeftCamera: boolean;
  106065. /**
  106066. * Gets the left camera of a rig setup in case of Rigged Camera
  106067. */
  106068. get isLeftCamera(): boolean;
  106069. /** @hidden */
  106070. _isRightCamera: boolean;
  106071. /**
  106072. * Gets the right camera of a rig setup in case of Rigged Camera
  106073. */
  106074. get isRightCamera(): boolean;
  106075. /**
  106076. * Gets the left camera of a rig setup in case of Rigged Camera
  106077. */
  106078. get leftCamera(): Nullable<FreeCamera>;
  106079. /**
  106080. * Gets the right camera of a rig setup in case of Rigged Camera
  106081. */
  106082. get rightCamera(): Nullable<FreeCamera>;
  106083. /**
  106084. * Gets the left camera target of a rig setup in case of Rigged Camera
  106085. * @returns the target position
  106086. */
  106087. getLeftTarget(): Nullable<Vector3>;
  106088. /**
  106089. * Gets the right camera target of a rig setup in case of Rigged Camera
  106090. * @returns the target position
  106091. */
  106092. getRightTarget(): Nullable<Vector3>;
  106093. /**
  106094. * @hidden
  106095. */
  106096. setCameraRigMode(mode: number, rigParams: any): void;
  106097. /** @hidden */
  106098. static _setStereoscopicRigMode(camera: Camera): void;
  106099. /** @hidden */
  106100. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  106101. /** @hidden */
  106102. static _setVRRigMode(camera: Camera, rigParams: any): void;
  106103. /** @hidden */
  106104. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  106105. /** @hidden */
  106106. _getVRProjectionMatrix(): Matrix;
  106107. protected _updateCameraRotationMatrix(): void;
  106108. protected _updateWebVRCameraRotationMatrix(): void;
  106109. /**
  106110. * This function MUST be overwritten by the different WebVR cameras available.
  106111. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  106112. * @hidden
  106113. */
  106114. _getWebVRProjectionMatrix(): Matrix;
  106115. /**
  106116. * This function MUST be overwritten by the different WebVR cameras available.
  106117. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  106118. * @hidden
  106119. */
  106120. _getWebVRViewMatrix(): Matrix;
  106121. /** @hidden */
  106122. setCameraRigParameter(name: string, value: any): void;
  106123. /**
  106124. * needs to be overridden by children so sub has required properties to be copied
  106125. * @hidden
  106126. */
  106127. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  106128. /**
  106129. * May need to be overridden by children
  106130. * @hidden
  106131. */
  106132. _updateRigCameras(): void;
  106133. /** @hidden */
  106134. _setupInputs(): void;
  106135. /**
  106136. * Serialiaze the camera setup to a json represention
  106137. * @returns the JSON representation
  106138. */
  106139. serialize(): any;
  106140. /**
  106141. * Clones the current camera.
  106142. * @param name The cloned camera name
  106143. * @returns the cloned camera
  106144. */
  106145. clone(name: string): Camera;
  106146. /**
  106147. * Gets the direction of the camera relative to a given local axis.
  106148. * @param localAxis Defines the reference axis to provide a relative direction.
  106149. * @return the direction
  106150. */
  106151. getDirection(localAxis: Vector3): Vector3;
  106152. /**
  106153. * Returns the current camera absolute rotation
  106154. */
  106155. get absoluteRotation(): Quaternion;
  106156. /**
  106157. * Gets the direction of the camera relative to a given local axis into a passed vector.
  106158. * @param localAxis Defines the reference axis to provide a relative direction.
  106159. * @param result Defines the vector to store the result in
  106160. */
  106161. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  106162. /**
  106163. * Gets a camera constructor for a given camera type
  106164. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  106165. * @param name The name of the camera the result will be able to instantiate
  106166. * @param scene The scene the result will construct the camera in
  106167. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  106168. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  106169. * @returns a factory method to construc the camera
  106170. */
  106171. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  106172. /**
  106173. * Compute the world matrix of the camera.
  106174. * @returns the camera world matrix
  106175. */
  106176. computeWorldMatrix(): Matrix;
  106177. /**
  106178. * Parse a JSON and creates the camera from the parsed information
  106179. * @param parsedCamera The JSON to parse
  106180. * @param scene The scene to instantiate the camera in
  106181. * @returns the newly constructed camera
  106182. */
  106183. static Parse(parsedCamera: any, scene: Scene): Camera;
  106184. }
  106185. }
  106186. declare module BABYLON {
  106187. /**
  106188. * Class containing static functions to help procedurally build meshes
  106189. */
  106190. export class DiscBuilder {
  106191. /**
  106192. * Creates a plane polygonal mesh. By default, this is a disc
  106193. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  106194. * * 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
  106195. * * 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
  106196. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106197. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106199. * @param name defines the name of the mesh
  106200. * @param options defines the options used to create the mesh
  106201. * @param scene defines the hosting scene
  106202. * @returns the plane polygonal mesh
  106203. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  106204. */
  106205. static CreateDisc(name: string, options: {
  106206. radius?: number;
  106207. tessellation?: number;
  106208. arc?: number;
  106209. updatable?: boolean;
  106210. sideOrientation?: number;
  106211. frontUVs?: Vector4;
  106212. backUVs?: Vector4;
  106213. }, scene?: Nullable<Scene>): Mesh;
  106214. }
  106215. }
  106216. declare module BABYLON {
  106217. /**
  106218. * Options to be used when creating a FresnelParameters.
  106219. */
  106220. export type IFresnelParametersCreationOptions = {
  106221. /**
  106222. * Define the color used on edges (grazing angle)
  106223. */
  106224. leftColor?: Color3;
  106225. /**
  106226. * Define the color used on center
  106227. */
  106228. rightColor?: Color3;
  106229. /**
  106230. * Define bias applied to computed fresnel term
  106231. */
  106232. bias?: number;
  106233. /**
  106234. * Defined the power exponent applied to fresnel term
  106235. */
  106236. power?: number;
  106237. /**
  106238. * Define if the fresnel effect is enable or not.
  106239. */
  106240. isEnabled?: boolean;
  106241. };
  106242. /**
  106243. * Serialized format for FresnelParameters.
  106244. */
  106245. export type IFresnelParametersSerialized = {
  106246. /**
  106247. * Define the color used on edges (grazing angle) [as an array]
  106248. */
  106249. leftColor: number[];
  106250. /**
  106251. * Define the color used on center [as an array]
  106252. */
  106253. rightColor: number[];
  106254. /**
  106255. * Define bias applied to computed fresnel term
  106256. */
  106257. bias: number;
  106258. /**
  106259. * Defined the power exponent applied to fresnel term
  106260. */
  106261. power?: number;
  106262. /**
  106263. * Define if the fresnel effect is enable or not.
  106264. */
  106265. isEnabled: boolean;
  106266. };
  106267. /**
  106268. * This represents all the required information to add a fresnel effect on a material:
  106269. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106270. */
  106271. export class FresnelParameters {
  106272. private _isEnabled;
  106273. /**
  106274. * Define if the fresnel effect is enable or not.
  106275. */
  106276. get isEnabled(): boolean;
  106277. set isEnabled(value: boolean);
  106278. /**
  106279. * Define the color used on edges (grazing angle)
  106280. */
  106281. leftColor: Color3;
  106282. /**
  106283. * Define the color used on center
  106284. */
  106285. rightColor: Color3;
  106286. /**
  106287. * Define bias applied to computed fresnel term
  106288. */
  106289. bias: number;
  106290. /**
  106291. * Defined the power exponent applied to fresnel term
  106292. */
  106293. power: number;
  106294. /**
  106295. * Creates a new FresnelParameters object.
  106296. *
  106297. * @param options provide your own settings to optionally to override defaults
  106298. */
  106299. constructor(options?: IFresnelParametersCreationOptions);
  106300. /**
  106301. * Clones the current fresnel and its valuues
  106302. * @returns a clone fresnel configuration
  106303. */
  106304. clone(): FresnelParameters;
  106305. /**
  106306. * Determines equality between FresnelParameters objects
  106307. * @param otherFresnelParameters defines the second operand
  106308. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  106309. */
  106310. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  106311. /**
  106312. * Serializes the current fresnel parameters to a JSON representation.
  106313. * @return the JSON serialization
  106314. */
  106315. serialize(): IFresnelParametersSerialized;
  106316. /**
  106317. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  106318. * @param parsedFresnelParameters Define the JSON representation
  106319. * @returns the parsed parameters
  106320. */
  106321. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  106322. }
  106323. }
  106324. declare module BABYLON {
  106325. /**
  106326. * This groups all the flags used to control the materials channel.
  106327. */
  106328. export class MaterialFlags {
  106329. private static _DiffuseTextureEnabled;
  106330. /**
  106331. * Are diffuse textures enabled in the application.
  106332. */
  106333. static get DiffuseTextureEnabled(): boolean;
  106334. static set DiffuseTextureEnabled(value: boolean);
  106335. private static _AmbientTextureEnabled;
  106336. /**
  106337. * Are ambient textures enabled in the application.
  106338. */
  106339. static get AmbientTextureEnabled(): boolean;
  106340. static set AmbientTextureEnabled(value: boolean);
  106341. private static _OpacityTextureEnabled;
  106342. /**
  106343. * Are opacity textures enabled in the application.
  106344. */
  106345. static get OpacityTextureEnabled(): boolean;
  106346. static set OpacityTextureEnabled(value: boolean);
  106347. private static _ReflectionTextureEnabled;
  106348. /**
  106349. * Are reflection textures enabled in the application.
  106350. */
  106351. static get ReflectionTextureEnabled(): boolean;
  106352. static set ReflectionTextureEnabled(value: boolean);
  106353. private static _EmissiveTextureEnabled;
  106354. /**
  106355. * Are emissive textures enabled in the application.
  106356. */
  106357. static get EmissiveTextureEnabled(): boolean;
  106358. static set EmissiveTextureEnabled(value: boolean);
  106359. private static _SpecularTextureEnabled;
  106360. /**
  106361. * Are specular textures enabled in the application.
  106362. */
  106363. static get SpecularTextureEnabled(): boolean;
  106364. static set SpecularTextureEnabled(value: boolean);
  106365. private static _BumpTextureEnabled;
  106366. /**
  106367. * Are bump textures enabled in the application.
  106368. */
  106369. static get BumpTextureEnabled(): boolean;
  106370. static set BumpTextureEnabled(value: boolean);
  106371. private static _LightmapTextureEnabled;
  106372. /**
  106373. * Are lightmap textures enabled in the application.
  106374. */
  106375. static get LightmapTextureEnabled(): boolean;
  106376. static set LightmapTextureEnabled(value: boolean);
  106377. private static _RefractionTextureEnabled;
  106378. /**
  106379. * Are refraction textures enabled in the application.
  106380. */
  106381. static get RefractionTextureEnabled(): boolean;
  106382. static set RefractionTextureEnabled(value: boolean);
  106383. private static _ColorGradingTextureEnabled;
  106384. /**
  106385. * Are color grading textures enabled in the application.
  106386. */
  106387. static get ColorGradingTextureEnabled(): boolean;
  106388. static set ColorGradingTextureEnabled(value: boolean);
  106389. private static _FresnelEnabled;
  106390. /**
  106391. * Are fresnels enabled in the application.
  106392. */
  106393. static get FresnelEnabled(): boolean;
  106394. static set FresnelEnabled(value: boolean);
  106395. private static _ClearCoatTextureEnabled;
  106396. /**
  106397. * Are clear coat textures enabled in the application.
  106398. */
  106399. static get ClearCoatTextureEnabled(): boolean;
  106400. static set ClearCoatTextureEnabled(value: boolean);
  106401. private static _ClearCoatBumpTextureEnabled;
  106402. /**
  106403. * Are clear coat bump textures enabled in the application.
  106404. */
  106405. static get ClearCoatBumpTextureEnabled(): boolean;
  106406. static set ClearCoatBumpTextureEnabled(value: boolean);
  106407. private static _ClearCoatTintTextureEnabled;
  106408. /**
  106409. * Are clear coat tint textures enabled in the application.
  106410. */
  106411. static get ClearCoatTintTextureEnabled(): boolean;
  106412. static set ClearCoatTintTextureEnabled(value: boolean);
  106413. private static _SheenTextureEnabled;
  106414. /**
  106415. * Are sheen textures enabled in the application.
  106416. */
  106417. static get SheenTextureEnabled(): boolean;
  106418. static set SheenTextureEnabled(value: boolean);
  106419. private static _AnisotropicTextureEnabled;
  106420. /**
  106421. * Are anisotropic textures enabled in the application.
  106422. */
  106423. static get AnisotropicTextureEnabled(): boolean;
  106424. static set AnisotropicTextureEnabled(value: boolean);
  106425. private static _ThicknessTextureEnabled;
  106426. /**
  106427. * Are thickness textures enabled in the application.
  106428. */
  106429. static get ThicknessTextureEnabled(): boolean;
  106430. static set ThicknessTextureEnabled(value: boolean);
  106431. }
  106432. }
  106433. declare module BABYLON {
  106434. /** @hidden */
  106435. export var defaultFragmentDeclaration: {
  106436. name: string;
  106437. shader: string;
  106438. };
  106439. }
  106440. declare module BABYLON {
  106441. /** @hidden */
  106442. export var defaultUboDeclaration: {
  106443. name: string;
  106444. shader: string;
  106445. };
  106446. }
  106447. declare module BABYLON {
  106448. /** @hidden */
  106449. export var lightFragmentDeclaration: {
  106450. name: string;
  106451. shader: string;
  106452. };
  106453. }
  106454. declare module BABYLON {
  106455. /** @hidden */
  106456. export var lightUboDeclaration: {
  106457. name: string;
  106458. shader: string;
  106459. };
  106460. }
  106461. declare module BABYLON {
  106462. /** @hidden */
  106463. export var lightsFragmentFunctions: {
  106464. name: string;
  106465. shader: string;
  106466. };
  106467. }
  106468. declare module BABYLON {
  106469. /** @hidden */
  106470. export var shadowsFragmentFunctions: {
  106471. name: string;
  106472. shader: string;
  106473. };
  106474. }
  106475. declare module BABYLON {
  106476. /** @hidden */
  106477. export var fresnelFunction: {
  106478. name: string;
  106479. shader: string;
  106480. };
  106481. }
  106482. declare module BABYLON {
  106483. /** @hidden */
  106484. export var bumpFragmentMainFunctions: {
  106485. name: string;
  106486. shader: string;
  106487. };
  106488. }
  106489. declare module BABYLON {
  106490. /** @hidden */
  106491. export var bumpFragmentFunctions: {
  106492. name: string;
  106493. shader: string;
  106494. };
  106495. }
  106496. declare module BABYLON {
  106497. /** @hidden */
  106498. export var logDepthDeclaration: {
  106499. name: string;
  106500. shader: string;
  106501. };
  106502. }
  106503. declare module BABYLON {
  106504. /** @hidden */
  106505. export var bumpFragment: {
  106506. name: string;
  106507. shader: string;
  106508. };
  106509. }
  106510. declare module BABYLON {
  106511. /** @hidden */
  106512. export var depthPrePass: {
  106513. name: string;
  106514. shader: string;
  106515. };
  106516. }
  106517. declare module BABYLON {
  106518. /** @hidden */
  106519. export var lightFragment: {
  106520. name: string;
  106521. shader: string;
  106522. };
  106523. }
  106524. declare module BABYLON {
  106525. /** @hidden */
  106526. export var logDepthFragment: {
  106527. name: string;
  106528. shader: string;
  106529. };
  106530. }
  106531. declare module BABYLON {
  106532. /** @hidden */
  106533. export var defaultPixelShader: {
  106534. name: string;
  106535. shader: string;
  106536. };
  106537. }
  106538. declare module BABYLON {
  106539. /** @hidden */
  106540. export var defaultVertexDeclaration: {
  106541. name: string;
  106542. shader: string;
  106543. };
  106544. }
  106545. declare module BABYLON {
  106546. /** @hidden */
  106547. export var bumpVertexDeclaration: {
  106548. name: string;
  106549. shader: string;
  106550. };
  106551. }
  106552. declare module BABYLON {
  106553. /** @hidden */
  106554. export var bumpVertex: {
  106555. name: string;
  106556. shader: string;
  106557. };
  106558. }
  106559. declare module BABYLON {
  106560. /** @hidden */
  106561. export var fogVertex: {
  106562. name: string;
  106563. shader: string;
  106564. };
  106565. }
  106566. declare module BABYLON {
  106567. /** @hidden */
  106568. export var shadowsVertex: {
  106569. name: string;
  106570. shader: string;
  106571. };
  106572. }
  106573. declare module BABYLON {
  106574. /** @hidden */
  106575. export var pointCloudVertex: {
  106576. name: string;
  106577. shader: string;
  106578. };
  106579. }
  106580. declare module BABYLON {
  106581. /** @hidden */
  106582. export var logDepthVertex: {
  106583. name: string;
  106584. shader: string;
  106585. };
  106586. }
  106587. declare module BABYLON {
  106588. /** @hidden */
  106589. export var defaultVertexShader: {
  106590. name: string;
  106591. shader: string;
  106592. };
  106593. }
  106594. declare module BABYLON {
  106595. /** @hidden */
  106596. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  106597. MAINUV1: boolean;
  106598. MAINUV2: boolean;
  106599. DIFFUSE: boolean;
  106600. DIFFUSEDIRECTUV: number;
  106601. AMBIENT: boolean;
  106602. AMBIENTDIRECTUV: number;
  106603. OPACITY: boolean;
  106604. OPACITYDIRECTUV: number;
  106605. OPACITYRGB: boolean;
  106606. REFLECTION: boolean;
  106607. EMISSIVE: boolean;
  106608. EMISSIVEDIRECTUV: number;
  106609. SPECULAR: boolean;
  106610. SPECULARDIRECTUV: number;
  106611. BUMP: boolean;
  106612. BUMPDIRECTUV: number;
  106613. PARALLAX: boolean;
  106614. PARALLAXOCCLUSION: boolean;
  106615. SPECULAROVERALPHA: boolean;
  106616. CLIPPLANE: boolean;
  106617. CLIPPLANE2: boolean;
  106618. CLIPPLANE3: boolean;
  106619. CLIPPLANE4: boolean;
  106620. CLIPPLANE5: boolean;
  106621. CLIPPLANE6: boolean;
  106622. ALPHATEST: boolean;
  106623. DEPTHPREPASS: boolean;
  106624. ALPHAFROMDIFFUSE: boolean;
  106625. POINTSIZE: boolean;
  106626. FOG: boolean;
  106627. SPECULARTERM: boolean;
  106628. DIFFUSEFRESNEL: boolean;
  106629. OPACITYFRESNEL: boolean;
  106630. REFLECTIONFRESNEL: boolean;
  106631. REFRACTIONFRESNEL: boolean;
  106632. EMISSIVEFRESNEL: boolean;
  106633. FRESNEL: boolean;
  106634. NORMAL: boolean;
  106635. UV1: boolean;
  106636. UV2: boolean;
  106637. VERTEXCOLOR: boolean;
  106638. VERTEXALPHA: boolean;
  106639. NUM_BONE_INFLUENCERS: number;
  106640. BonesPerMesh: number;
  106641. BONETEXTURE: boolean;
  106642. INSTANCES: boolean;
  106643. THIN_INSTANCES: boolean;
  106644. GLOSSINESS: boolean;
  106645. ROUGHNESS: boolean;
  106646. EMISSIVEASILLUMINATION: boolean;
  106647. LINKEMISSIVEWITHDIFFUSE: boolean;
  106648. REFLECTIONFRESNELFROMSPECULAR: boolean;
  106649. LIGHTMAP: boolean;
  106650. LIGHTMAPDIRECTUV: number;
  106651. OBJECTSPACE_NORMALMAP: boolean;
  106652. USELIGHTMAPASSHADOWMAP: boolean;
  106653. REFLECTIONMAP_3D: boolean;
  106654. REFLECTIONMAP_SPHERICAL: boolean;
  106655. REFLECTIONMAP_PLANAR: boolean;
  106656. REFLECTIONMAP_CUBIC: boolean;
  106657. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106658. REFLECTIONMAP_PROJECTION: boolean;
  106659. REFLECTIONMAP_SKYBOX: boolean;
  106660. REFLECTIONMAP_EXPLICIT: boolean;
  106661. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106662. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106663. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106664. INVERTCUBICMAP: boolean;
  106665. LOGARITHMICDEPTH: boolean;
  106666. REFRACTION: boolean;
  106667. REFRACTIONMAP_3D: boolean;
  106668. REFLECTIONOVERALPHA: boolean;
  106669. TWOSIDEDLIGHTING: boolean;
  106670. SHADOWFLOAT: boolean;
  106671. MORPHTARGETS: boolean;
  106672. MORPHTARGETS_NORMAL: boolean;
  106673. MORPHTARGETS_TANGENT: boolean;
  106674. MORPHTARGETS_UV: boolean;
  106675. NUM_MORPH_INFLUENCERS: number;
  106676. NONUNIFORMSCALING: boolean;
  106677. PREMULTIPLYALPHA: boolean;
  106678. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  106679. ALPHABLEND: boolean;
  106680. RGBDLIGHTMAP: boolean;
  106681. RGBDREFLECTION: boolean;
  106682. RGBDREFRACTION: boolean;
  106683. IMAGEPROCESSING: boolean;
  106684. VIGNETTE: boolean;
  106685. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106686. VIGNETTEBLENDMODEOPAQUE: boolean;
  106687. TONEMAPPING: boolean;
  106688. TONEMAPPING_ACES: boolean;
  106689. CONTRAST: boolean;
  106690. COLORCURVES: boolean;
  106691. COLORGRADING: boolean;
  106692. COLORGRADING3D: boolean;
  106693. SAMPLER3DGREENDEPTH: boolean;
  106694. SAMPLER3DBGRMAP: boolean;
  106695. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106696. MULTIVIEW: boolean;
  106697. /**
  106698. * If the reflection texture on this material is in linear color space
  106699. * @hidden
  106700. */
  106701. IS_REFLECTION_LINEAR: boolean;
  106702. /**
  106703. * If the refraction texture on this material is in linear color space
  106704. * @hidden
  106705. */
  106706. IS_REFRACTION_LINEAR: boolean;
  106707. EXPOSURE: boolean;
  106708. constructor();
  106709. setReflectionMode(modeToEnable: string): void;
  106710. }
  106711. /**
  106712. * This is the default material used in Babylon. It is the best trade off between quality
  106713. * and performances.
  106714. * @see http://doc.babylonjs.com/babylon101/materials
  106715. */
  106716. export class StandardMaterial extends PushMaterial {
  106717. private _diffuseTexture;
  106718. /**
  106719. * The basic texture of the material as viewed under a light.
  106720. */
  106721. diffuseTexture: Nullable<BaseTexture>;
  106722. private _ambientTexture;
  106723. /**
  106724. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  106725. */
  106726. ambientTexture: Nullable<BaseTexture>;
  106727. private _opacityTexture;
  106728. /**
  106729. * Define the transparency of the material from a texture.
  106730. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  106731. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  106732. */
  106733. opacityTexture: Nullable<BaseTexture>;
  106734. private _reflectionTexture;
  106735. /**
  106736. * Define the texture used to display the reflection.
  106737. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106738. */
  106739. reflectionTexture: Nullable<BaseTexture>;
  106740. private _emissiveTexture;
  106741. /**
  106742. * Define texture of the material as if self lit.
  106743. * This will be mixed in the final result even in the absence of light.
  106744. */
  106745. emissiveTexture: Nullable<BaseTexture>;
  106746. private _specularTexture;
  106747. /**
  106748. * Define how the color and intensity of the highlight given by the light in the material.
  106749. */
  106750. specularTexture: Nullable<BaseTexture>;
  106751. private _bumpTexture;
  106752. /**
  106753. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  106754. * 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.
  106755. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  106756. */
  106757. bumpTexture: Nullable<BaseTexture>;
  106758. private _lightmapTexture;
  106759. /**
  106760. * Complex lighting can be computationally expensive to compute at runtime.
  106761. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  106762. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  106763. */
  106764. lightmapTexture: Nullable<BaseTexture>;
  106765. private _refractionTexture;
  106766. /**
  106767. * Define the texture used to display the refraction.
  106768. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106769. */
  106770. refractionTexture: Nullable<BaseTexture>;
  106771. /**
  106772. * The color of the material lit by the environmental background lighting.
  106773. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  106774. */
  106775. ambientColor: Color3;
  106776. /**
  106777. * The basic color of the material as viewed under a light.
  106778. */
  106779. diffuseColor: Color3;
  106780. /**
  106781. * Define how the color and intensity of the highlight given by the light in the material.
  106782. */
  106783. specularColor: Color3;
  106784. /**
  106785. * Define the color of the material as if self lit.
  106786. * This will be mixed in the final result even in the absence of light.
  106787. */
  106788. emissiveColor: Color3;
  106789. /**
  106790. * Defines how sharp are the highlights in the material.
  106791. * The bigger the value the sharper giving a more glossy feeling to the result.
  106792. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  106793. */
  106794. specularPower: number;
  106795. private _useAlphaFromDiffuseTexture;
  106796. /**
  106797. * Does the transparency come from the diffuse texture alpha channel.
  106798. */
  106799. useAlphaFromDiffuseTexture: boolean;
  106800. private _useEmissiveAsIllumination;
  106801. /**
  106802. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  106803. */
  106804. useEmissiveAsIllumination: boolean;
  106805. private _linkEmissiveWithDiffuse;
  106806. /**
  106807. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  106808. * the emissive level when the final color is close to one.
  106809. */
  106810. linkEmissiveWithDiffuse: boolean;
  106811. private _useSpecularOverAlpha;
  106812. /**
  106813. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  106814. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  106815. */
  106816. useSpecularOverAlpha: boolean;
  106817. private _useReflectionOverAlpha;
  106818. /**
  106819. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  106820. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  106821. */
  106822. useReflectionOverAlpha: boolean;
  106823. private _disableLighting;
  106824. /**
  106825. * Does lights from the scene impacts this material.
  106826. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  106827. */
  106828. disableLighting: boolean;
  106829. private _useObjectSpaceNormalMap;
  106830. /**
  106831. * Allows using an object space normal map (instead of tangent space).
  106832. */
  106833. useObjectSpaceNormalMap: boolean;
  106834. private _useParallax;
  106835. /**
  106836. * Is parallax enabled or not.
  106837. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106838. */
  106839. useParallax: boolean;
  106840. private _useParallaxOcclusion;
  106841. /**
  106842. * Is parallax occlusion enabled or not.
  106843. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  106844. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106845. */
  106846. useParallaxOcclusion: boolean;
  106847. /**
  106848. * 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.
  106849. */
  106850. parallaxScaleBias: number;
  106851. private _roughness;
  106852. /**
  106853. * Helps to define how blurry the reflections should appears in the material.
  106854. */
  106855. roughness: number;
  106856. /**
  106857. * In case of refraction, define the value of the index of refraction.
  106858. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106859. */
  106860. indexOfRefraction: number;
  106861. /**
  106862. * Invert the refraction texture alongside the y axis.
  106863. * It can be useful with procedural textures or probe for instance.
  106864. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106865. */
  106866. invertRefractionY: boolean;
  106867. /**
  106868. * Defines the alpha limits in alpha test mode.
  106869. */
  106870. alphaCutOff: number;
  106871. private _useLightmapAsShadowmap;
  106872. /**
  106873. * In case of light mapping, define whether the map contains light or shadow informations.
  106874. */
  106875. useLightmapAsShadowmap: boolean;
  106876. private _diffuseFresnelParameters;
  106877. /**
  106878. * Define the diffuse fresnel parameters of the material.
  106879. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106880. */
  106881. diffuseFresnelParameters: FresnelParameters;
  106882. private _opacityFresnelParameters;
  106883. /**
  106884. * Define the opacity fresnel parameters of the material.
  106885. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106886. */
  106887. opacityFresnelParameters: FresnelParameters;
  106888. private _reflectionFresnelParameters;
  106889. /**
  106890. * Define the reflection fresnel parameters of the material.
  106891. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106892. */
  106893. reflectionFresnelParameters: FresnelParameters;
  106894. private _refractionFresnelParameters;
  106895. /**
  106896. * Define the refraction fresnel parameters of the material.
  106897. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106898. */
  106899. refractionFresnelParameters: FresnelParameters;
  106900. private _emissiveFresnelParameters;
  106901. /**
  106902. * Define the emissive fresnel parameters of the material.
  106903. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106904. */
  106905. emissiveFresnelParameters: FresnelParameters;
  106906. private _useReflectionFresnelFromSpecular;
  106907. /**
  106908. * If true automatically deducts the fresnels values from the material specularity.
  106909. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106910. */
  106911. useReflectionFresnelFromSpecular: boolean;
  106912. private _useGlossinessFromSpecularMapAlpha;
  106913. /**
  106914. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  106915. */
  106916. useGlossinessFromSpecularMapAlpha: boolean;
  106917. private _maxSimultaneousLights;
  106918. /**
  106919. * Defines the maximum number of lights that can be used in the material
  106920. */
  106921. maxSimultaneousLights: number;
  106922. private _invertNormalMapX;
  106923. /**
  106924. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  106925. */
  106926. invertNormalMapX: boolean;
  106927. private _invertNormalMapY;
  106928. /**
  106929. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  106930. */
  106931. invertNormalMapY: boolean;
  106932. private _twoSidedLighting;
  106933. /**
  106934. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106935. */
  106936. twoSidedLighting: boolean;
  106937. /**
  106938. * Default configuration related to image processing available in the standard Material.
  106939. */
  106940. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106941. /**
  106942. * Gets the image processing configuration used either in this material.
  106943. */
  106944. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  106945. /**
  106946. * Sets the Default image processing configuration used either in the this material.
  106947. *
  106948. * If sets to null, the scene one is in use.
  106949. */
  106950. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  106951. /**
  106952. * Keep track of the image processing observer to allow dispose and replace.
  106953. */
  106954. private _imageProcessingObserver;
  106955. /**
  106956. * Attaches a new image processing configuration to the Standard Material.
  106957. * @param configuration
  106958. */
  106959. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106960. /**
  106961. * Gets wether the color curves effect is enabled.
  106962. */
  106963. get cameraColorCurvesEnabled(): boolean;
  106964. /**
  106965. * Sets wether the color curves effect is enabled.
  106966. */
  106967. set cameraColorCurvesEnabled(value: boolean);
  106968. /**
  106969. * Gets wether the color grading effect is enabled.
  106970. */
  106971. get cameraColorGradingEnabled(): boolean;
  106972. /**
  106973. * Gets wether the color grading effect is enabled.
  106974. */
  106975. set cameraColorGradingEnabled(value: boolean);
  106976. /**
  106977. * Gets wether tonemapping is enabled or not.
  106978. */
  106979. get cameraToneMappingEnabled(): boolean;
  106980. /**
  106981. * Sets wether tonemapping is enabled or not
  106982. */
  106983. set cameraToneMappingEnabled(value: boolean);
  106984. /**
  106985. * The camera exposure used on this material.
  106986. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106987. * This corresponds to a photographic exposure.
  106988. */
  106989. get cameraExposure(): number;
  106990. /**
  106991. * The camera exposure used on this material.
  106992. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106993. * This corresponds to a photographic exposure.
  106994. */
  106995. set cameraExposure(value: number);
  106996. /**
  106997. * Gets The camera contrast used on this material.
  106998. */
  106999. get cameraContrast(): number;
  107000. /**
  107001. * Sets The camera contrast used on this material.
  107002. */
  107003. set cameraContrast(value: number);
  107004. /**
  107005. * Gets the Color Grading 2D Lookup Texture.
  107006. */
  107007. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  107008. /**
  107009. * Sets the Color Grading 2D Lookup Texture.
  107010. */
  107011. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  107012. /**
  107013. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107014. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107015. * 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;
  107016. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107017. */
  107018. get cameraColorCurves(): Nullable<ColorCurves>;
  107019. /**
  107020. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107021. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107022. * 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;
  107023. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107024. */
  107025. set cameraColorCurves(value: Nullable<ColorCurves>);
  107026. protected _renderTargets: SmartArray<RenderTargetTexture>;
  107027. protected _worldViewProjectionMatrix: Matrix;
  107028. protected _globalAmbientColor: Color3;
  107029. protected _useLogarithmicDepth: boolean;
  107030. protected _rebuildInParallel: boolean;
  107031. /**
  107032. * Instantiates a new standard material.
  107033. * This is the default material used in Babylon. It is the best trade off between quality
  107034. * and performances.
  107035. * @see http://doc.babylonjs.com/babylon101/materials
  107036. * @param name Define the name of the material in the scene
  107037. * @param scene Define the scene the material belong to
  107038. */
  107039. constructor(name: string, scene: Scene);
  107040. /**
  107041. * Gets a boolean indicating that current material needs to register RTT
  107042. */
  107043. get hasRenderTargetTextures(): boolean;
  107044. /**
  107045. * Gets the current class name of the material e.g. "StandardMaterial"
  107046. * Mainly use in serialization.
  107047. * @returns the class name
  107048. */
  107049. getClassName(): string;
  107050. /**
  107051. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  107052. * You can try switching to logarithmic depth.
  107053. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  107054. */
  107055. get useLogarithmicDepth(): boolean;
  107056. set useLogarithmicDepth(value: boolean);
  107057. /**
  107058. * Specifies if the material will require alpha blending
  107059. * @returns a boolean specifying if alpha blending is needed
  107060. */
  107061. needAlphaBlending(): boolean;
  107062. /**
  107063. * Specifies if this material should be rendered in alpha test mode
  107064. * @returns a boolean specifying if an alpha test is needed.
  107065. */
  107066. needAlphaTesting(): boolean;
  107067. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  107068. /**
  107069. * Get the texture used for alpha test purpose.
  107070. * @returns the diffuse texture in case of the standard material.
  107071. */
  107072. getAlphaTestTexture(): Nullable<BaseTexture>;
  107073. /**
  107074. * Get if the submesh is ready to be used and all its information available.
  107075. * Child classes can use it to update shaders
  107076. * @param mesh defines the mesh to check
  107077. * @param subMesh defines which submesh to check
  107078. * @param useInstances specifies that instances should be used
  107079. * @returns a boolean indicating that the submesh is ready or not
  107080. */
  107081. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107082. /**
  107083. * Builds the material UBO layouts.
  107084. * Used internally during the effect preparation.
  107085. */
  107086. buildUniformLayout(): void;
  107087. /**
  107088. * Unbinds the material from the mesh
  107089. */
  107090. unbind(): void;
  107091. /**
  107092. * Binds the submesh to this material by preparing the effect and shader to draw
  107093. * @param world defines the world transformation matrix
  107094. * @param mesh defines the mesh containing the submesh
  107095. * @param subMesh defines the submesh to bind the material to
  107096. */
  107097. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107098. /**
  107099. * Get the list of animatables in the material.
  107100. * @returns the list of animatables object used in the material
  107101. */
  107102. getAnimatables(): IAnimatable[];
  107103. /**
  107104. * Gets the active textures from the material
  107105. * @returns an array of textures
  107106. */
  107107. getActiveTextures(): BaseTexture[];
  107108. /**
  107109. * Specifies if the material uses a texture
  107110. * @param texture defines the texture to check against the material
  107111. * @returns a boolean specifying if the material uses the texture
  107112. */
  107113. hasTexture(texture: BaseTexture): boolean;
  107114. /**
  107115. * Disposes the material
  107116. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  107117. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  107118. */
  107119. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107120. /**
  107121. * Makes a duplicate of the material, and gives it a new name
  107122. * @param name defines the new name for the duplicated material
  107123. * @returns the cloned material
  107124. */
  107125. clone(name: string): StandardMaterial;
  107126. /**
  107127. * Serializes this material in a JSON representation
  107128. * @returns the serialized material object
  107129. */
  107130. serialize(): any;
  107131. /**
  107132. * Creates a standard material from parsed material data
  107133. * @param source defines the JSON representation of the material
  107134. * @param scene defines the hosting scene
  107135. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107136. * @returns a new standard material
  107137. */
  107138. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107139. /**
  107140. * Are diffuse textures enabled in the application.
  107141. */
  107142. static get DiffuseTextureEnabled(): boolean;
  107143. static set DiffuseTextureEnabled(value: boolean);
  107144. /**
  107145. * Are ambient textures enabled in the application.
  107146. */
  107147. static get AmbientTextureEnabled(): boolean;
  107148. static set AmbientTextureEnabled(value: boolean);
  107149. /**
  107150. * Are opacity textures enabled in the application.
  107151. */
  107152. static get OpacityTextureEnabled(): boolean;
  107153. static set OpacityTextureEnabled(value: boolean);
  107154. /**
  107155. * Are reflection textures enabled in the application.
  107156. */
  107157. static get ReflectionTextureEnabled(): boolean;
  107158. static set ReflectionTextureEnabled(value: boolean);
  107159. /**
  107160. * Are emissive textures enabled in the application.
  107161. */
  107162. static get EmissiveTextureEnabled(): boolean;
  107163. static set EmissiveTextureEnabled(value: boolean);
  107164. /**
  107165. * Are specular textures enabled in the application.
  107166. */
  107167. static get SpecularTextureEnabled(): boolean;
  107168. static set SpecularTextureEnabled(value: boolean);
  107169. /**
  107170. * Are bump textures enabled in the application.
  107171. */
  107172. static get BumpTextureEnabled(): boolean;
  107173. static set BumpTextureEnabled(value: boolean);
  107174. /**
  107175. * Are lightmap textures enabled in the application.
  107176. */
  107177. static get LightmapTextureEnabled(): boolean;
  107178. static set LightmapTextureEnabled(value: boolean);
  107179. /**
  107180. * Are refraction textures enabled in the application.
  107181. */
  107182. static get RefractionTextureEnabled(): boolean;
  107183. static set RefractionTextureEnabled(value: boolean);
  107184. /**
  107185. * Are color grading textures enabled in the application.
  107186. */
  107187. static get ColorGradingTextureEnabled(): boolean;
  107188. static set ColorGradingTextureEnabled(value: boolean);
  107189. /**
  107190. * Are fresnels enabled in the application.
  107191. */
  107192. static get FresnelEnabled(): boolean;
  107193. static set FresnelEnabled(value: boolean);
  107194. }
  107195. }
  107196. declare module BABYLON {
  107197. /**
  107198. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  107199. *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.
  107200. * The SPS is also a particle system. It provides some methods to manage the particles.
  107201. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  107202. *
  107203. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  107204. */
  107205. export class SolidParticleSystem implements IDisposable {
  107206. /**
  107207. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  107208. * Example : var p = SPS.particles[i];
  107209. */
  107210. particles: SolidParticle[];
  107211. /**
  107212. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  107213. */
  107214. nbParticles: number;
  107215. /**
  107216. * If the particles must ever face the camera (default false). Useful for planar particles.
  107217. */
  107218. billboard: boolean;
  107219. /**
  107220. * Recompute normals when adding a shape
  107221. */
  107222. recomputeNormals: boolean;
  107223. /**
  107224. * This a counter ofr your own usage. It's not set by any SPS functions.
  107225. */
  107226. counter: number;
  107227. /**
  107228. * The SPS name. This name is also given to the underlying mesh.
  107229. */
  107230. name: string;
  107231. /**
  107232. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  107233. */
  107234. mesh: Mesh;
  107235. /**
  107236. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  107237. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  107238. */
  107239. vars: any;
  107240. /**
  107241. * This array is populated when the SPS is set as 'pickable'.
  107242. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  107243. * Each element of this array is an object `{idx: int, faceId: int}`.
  107244. * `idx` is the picked particle index in the `SPS.particles` array
  107245. * `faceId` is the picked face index counted within this particle.
  107246. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  107247. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  107248. * Use the method SPS.pickedParticle(pickingInfo) instead.
  107249. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  107250. */
  107251. pickedParticles: {
  107252. idx: number;
  107253. faceId: number;
  107254. }[];
  107255. /**
  107256. * This array is populated when the SPS is set as 'pickable'
  107257. * Each key of this array is a submesh index.
  107258. * Each element of this array is a second array defined like this :
  107259. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  107260. * Each element of this second array is an object `{idx: int, faceId: int}`.
  107261. * `idx` is the picked particle index in the `SPS.particles` array
  107262. * `faceId` is the picked face index counted within this particle.
  107263. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  107264. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  107265. */
  107266. pickedBySubMesh: {
  107267. idx: number;
  107268. faceId: number;
  107269. }[][];
  107270. /**
  107271. * This array is populated when `enableDepthSort` is set to true.
  107272. * Each element of this array is an instance of the class DepthSortedParticle.
  107273. */
  107274. depthSortedParticles: DepthSortedParticle[];
  107275. /**
  107276. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  107277. * @hidden
  107278. */
  107279. _bSphereOnly: boolean;
  107280. /**
  107281. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  107282. * @hidden
  107283. */
  107284. _bSphereRadiusFactor: number;
  107285. private _scene;
  107286. private _positions;
  107287. private _indices;
  107288. private _normals;
  107289. private _colors;
  107290. private _uvs;
  107291. private _indices32;
  107292. private _positions32;
  107293. private _normals32;
  107294. private _fixedNormal32;
  107295. private _colors32;
  107296. private _uvs32;
  107297. private _index;
  107298. private _updatable;
  107299. private _pickable;
  107300. private _isVisibilityBoxLocked;
  107301. private _alwaysVisible;
  107302. private _depthSort;
  107303. private _expandable;
  107304. private _shapeCounter;
  107305. private _copy;
  107306. private _color;
  107307. private _computeParticleColor;
  107308. private _computeParticleTexture;
  107309. private _computeParticleRotation;
  107310. private _computeParticleVertex;
  107311. private _computeBoundingBox;
  107312. private _depthSortParticles;
  107313. private _camera;
  107314. private _mustUnrotateFixedNormals;
  107315. private _particlesIntersect;
  107316. private _needs32Bits;
  107317. private _isNotBuilt;
  107318. private _lastParticleId;
  107319. private _idxOfId;
  107320. private _multimaterialEnabled;
  107321. private _useModelMaterial;
  107322. private _indicesByMaterial;
  107323. private _materialIndexes;
  107324. private _depthSortFunction;
  107325. private _materialSortFunction;
  107326. private _materials;
  107327. private _multimaterial;
  107328. private _materialIndexesById;
  107329. private _defaultMaterial;
  107330. private _autoUpdateSubMeshes;
  107331. private _tmpVertex;
  107332. /**
  107333. * Creates a SPS (Solid Particle System) object.
  107334. * @param name (String) is the SPS name, this will be the underlying mesh name.
  107335. * @param scene (Scene) is the scene in which the SPS is added.
  107336. * @param options defines the options of the sps e.g.
  107337. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  107338. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  107339. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  107340. * * 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.
  107341. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  107342. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  107343. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  107344. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  107345. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  107346. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  107347. */
  107348. constructor(name: string, scene: Scene, options?: {
  107349. updatable?: boolean;
  107350. isPickable?: boolean;
  107351. enableDepthSort?: boolean;
  107352. particleIntersection?: boolean;
  107353. boundingSphereOnly?: boolean;
  107354. bSphereRadiusFactor?: number;
  107355. expandable?: boolean;
  107356. useModelMaterial?: boolean;
  107357. enableMultiMaterial?: boolean;
  107358. });
  107359. /**
  107360. * Builds the SPS underlying mesh. Returns a standard Mesh.
  107361. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  107362. * @returns the created mesh
  107363. */
  107364. buildMesh(): Mesh;
  107365. /**
  107366. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  107367. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  107368. * Thus the particles generated from `digest()` have their property `position` set yet.
  107369. * @param mesh ( Mesh ) is the mesh to be digested
  107370. * @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
  107371. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  107372. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  107373. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  107374. * @returns the current SPS
  107375. */
  107376. digest(mesh: Mesh, options?: {
  107377. facetNb?: number;
  107378. number?: number;
  107379. delta?: number;
  107380. storage?: [];
  107381. }): SolidParticleSystem;
  107382. /**
  107383. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  107384. * @hidden
  107385. */
  107386. private _unrotateFixedNormals;
  107387. /**
  107388. * Resets the temporary working copy particle
  107389. * @hidden
  107390. */
  107391. private _resetCopy;
  107392. /**
  107393. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  107394. * @param p the current index in the positions array to be updated
  107395. * @param ind the current index in the indices array
  107396. * @param shape a Vector3 array, the shape geometry
  107397. * @param positions the positions array to be updated
  107398. * @param meshInd the shape indices array
  107399. * @param indices the indices array to be updated
  107400. * @param meshUV the shape uv array
  107401. * @param uvs the uv array to be updated
  107402. * @param meshCol the shape color array
  107403. * @param colors the color array to be updated
  107404. * @param meshNor the shape normals array
  107405. * @param normals the normals array to be updated
  107406. * @param idx the particle index
  107407. * @param idxInShape the particle index in its shape
  107408. * @param options the addShape() method passed options
  107409. * @model the particle model
  107410. * @hidden
  107411. */
  107412. private _meshBuilder;
  107413. /**
  107414. * Returns a shape Vector3 array from positions float array
  107415. * @param positions float array
  107416. * @returns a vector3 array
  107417. * @hidden
  107418. */
  107419. private _posToShape;
  107420. /**
  107421. * Returns a shapeUV array from a float uvs (array deep copy)
  107422. * @param uvs as a float array
  107423. * @returns a shapeUV array
  107424. * @hidden
  107425. */
  107426. private _uvsToShapeUV;
  107427. /**
  107428. * Adds a new particle object in the particles array
  107429. * @param idx particle index in particles array
  107430. * @param id particle id
  107431. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  107432. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  107433. * @param model particle ModelShape object
  107434. * @param shapeId model shape identifier
  107435. * @param idxInShape index of the particle in the current model
  107436. * @param bInfo model bounding info object
  107437. * @param storage target storage array, if any
  107438. * @hidden
  107439. */
  107440. private _addParticle;
  107441. /**
  107442. * Adds some particles to the SPS from the model shape. Returns the shape id.
  107443. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  107444. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  107445. * @param nb (positive integer) the number of particles to be created from this model
  107446. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  107447. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  107448. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  107449. * @returns the number of shapes in the system
  107450. */
  107451. addShape(mesh: Mesh, nb: number, options?: {
  107452. positionFunction?: any;
  107453. vertexFunction?: any;
  107454. storage?: [];
  107455. }): number;
  107456. /**
  107457. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  107458. * @hidden
  107459. */
  107460. private _rebuildParticle;
  107461. /**
  107462. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  107463. * @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.
  107464. * @returns the SPS.
  107465. */
  107466. rebuildMesh(reset?: boolean): SolidParticleSystem;
  107467. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  107468. * Returns an array with the removed particles.
  107469. * 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.
  107470. * The SPS can't be empty so at least one particle needs to remain in place.
  107471. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  107472. * @param start index of the first particle to remove
  107473. * @param end index of the last particle to remove (included)
  107474. * @returns an array populated with the removed particles
  107475. */
  107476. removeParticles(start: number, end: number): SolidParticle[];
  107477. /**
  107478. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  107479. * @param solidParticleArray an array populated with Solid Particles objects
  107480. * @returns the SPS
  107481. */
  107482. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  107483. /**
  107484. * Creates a new particle and modifies the SPS mesh geometry :
  107485. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  107486. * - calls _addParticle() to populate the particle array
  107487. * factorized code from addShape() and insertParticlesFromArray()
  107488. * @param idx particle index in the particles array
  107489. * @param i particle index in its shape
  107490. * @param modelShape particle ModelShape object
  107491. * @param shape shape vertex array
  107492. * @param meshInd shape indices array
  107493. * @param meshUV shape uv array
  107494. * @param meshCol shape color array
  107495. * @param meshNor shape normals array
  107496. * @param bbInfo shape bounding info
  107497. * @param storage target particle storage
  107498. * @options addShape() passed options
  107499. * @hidden
  107500. */
  107501. private _insertNewParticle;
  107502. /**
  107503. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  107504. * This method calls `updateParticle()` for each particle of the SPS.
  107505. * For an animated SPS, it is usually called within the render loop.
  107506. * 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.
  107507. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  107508. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  107509. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  107510. * @returns the SPS.
  107511. */
  107512. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  107513. /**
  107514. * Disposes the SPS.
  107515. */
  107516. dispose(): void;
  107517. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  107518. * idx is the particle index in the SPS
  107519. * faceId is the picked face index counted within this particle.
  107520. * Returns null if the pickInfo can't identify a picked particle.
  107521. * @param pickingInfo (PickingInfo object)
  107522. * @returns {idx: number, faceId: number} or null
  107523. */
  107524. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  107525. idx: number;
  107526. faceId: number;
  107527. }>;
  107528. /**
  107529. * Returns a SolidParticle object from its identifier : particle.id
  107530. * @param id (integer) the particle Id
  107531. * @returns the searched particle or null if not found in the SPS.
  107532. */
  107533. getParticleById(id: number): Nullable<SolidParticle>;
  107534. /**
  107535. * Returns a new array populated with the particles having the passed shapeId.
  107536. * @param shapeId (integer) the shape identifier
  107537. * @returns a new solid particle array
  107538. */
  107539. getParticlesByShapeId(shapeId: number): SolidParticle[];
  107540. /**
  107541. * Populates the passed array "ref" with the particles having the passed shapeId.
  107542. * @param shapeId the shape identifier
  107543. * @returns the SPS
  107544. * @param ref
  107545. */
  107546. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  107547. /**
  107548. * Computes the required SubMeshes according the materials assigned to the particles.
  107549. * @returns the solid particle system.
  107550. * Does nothing if called before the SPS mesh is built.
  107551. */
  107552. computeSubMeshes(): SolidParticleSystem;
  107553. /**
  107554. * Sorts the solid particles by material when MultiMaterial is enabled.
  107555. * Updates the indices32 array.
  107556. * Updates the indicesByMaterial array.
  107557. * Updates the mesh indices array.
  107558. * @returns the SPS
  107559. * @hidden
  107560. */
  107561. private _sortParticlesByMaterial;
  107562. /**
  107563. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  107564. * @hidden
  107565. */
  107566. private _setMaterialIndexesById;
  107567. /**
  107568. * Returns an array with unique values of Materials from the passed array
  107569. * @param array the material array to be checked and filtered
  107570. * @hidden
  107571. */
  107572. private _filterUniqueMaterialId;
  107573. /**
  107574. * Sets a new Standard Material as _defaultMaterial if not already set.
  107575. * @hidden
  107576. */
  107577. private _setDefaultMaterial;
  107578. /**
  107579. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  107580. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107581. * @returns the SPS.
  107582. */
  107583. refreshVisibleSize(): SolidParticleSystem;
  107584. /**
  107585. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  107586. * @param size the size (float) of the visibility box
  107587. * note : this doesn't lock the SPS mesh bounding box.
  107588. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107589. */
  107590. setVisibilityBox(size: number): void;
  107591. /**
  107592. * Gets whether the SPS as always visible or not
  107593. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107594. */
  107595. get isAlwaysVisible(): boolean;
  107596. /**
  107597. * Sets the SPS as always visible or not
  107598. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107599. */
  107600. set isAlwaysVisible(val: boolean);
  107601. /**
  107602. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  107603. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107604. */
  107605. set isVisibilityBoxLocked(val: boolean);
  107606. /**
  107607. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  107608. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107609. */
  107610. get isVisibilityBoxLocked(): boolean;
  107611. /**
  107612. * Tells to `setParticles()` to compute the particle rotations or not.
  107613. * Default value : true. The SPS is faster when it's set to false.
  107614. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  107615. */
  107616. set computeParticleRotation(val: boolean);
  107617. /**
  107618. * Tells to `setParticles()` to compute the particle colors or not.
  107619. * Default value : true. The SPS is faster when it's set to false.
  107620. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  107621. */
  107622. set computeParticleColor(val: boolean);
  107623. set computeParticleTexture(val: boolean);
  107624. /**
  107625. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  107626. * Default value : false. The SPS is faster when it's set to false.
  107627. * Note : the particle custom vertex positions aren't stored values.
  107628. */
  107629. set computeParticleVertex(val: boolean);
  107630. /**
  107631. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  107632. */
  107633. set computeBoundingBox(val: boolean);
  107634. /**
  107635. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  107636. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  107637. * Default : `true`
  107638. */
  107639. set depthSortParticles(val: boolean);
  107640. /**
  107641. * Gets if `setParticles()` computes the particle rotations or not.
  107642. * Default value : true. The SPS is faster when it's set to false.
  107643. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  107644. */
  107645. get computeParticleRotation(): boolean;
  107646. /**
  107647. * Gets if `setParticles()` computes the particle colors or not.
  107648. * Default value : true. The SPS is faster when it's set to false.
  107649. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  107650. */
  107651. get computeParticleColor(): boolean;
  107652. /**
  107653. * Gets if `setParticles()` computes the particle textures or not.
  107654. * Default value : true. The SPS is faster when it's set to false.
  107655. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  107656. */
  107657. get computeParticleTexture(): boolean;
  107658. /**
  107659. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  107660. * Default value : false. The SPS is faster when it's set to false.
  107661. * Note : the particle custom vertex positions aren't stored values.
  107662. */
  107663. get computeParticleVertex(): boolean;
  107664. /**
  107665. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  107666. */
  107667. get computeBoundingBox(): boolean;
  107668. /**
  107669. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  107670. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  107671. * Default : `true`
  107672. */
  107673. get depthSortParticles(): boolean;
  107674. /**
  107675. * Gets if the SPS is created as expandable at construction time.
  107676. * Default : `false`
  107677. */
  107678. get expandable(): boolean;
  107679. /**
  107680. * Gets if the SPS supports the Multi Materials
  107681. */
  107682. get multimaterialEnabled(): boolean;
  107683. /**
  107684. * Gets if the SPS uses the model materials for its own multimaterial.
  107685. */
  107686. get useModelMaterial(): boolean;
  107687. /**
  107688. * The SPS used material array.
  107689. */
  107690. get materials(): Material[];
  107691. /**
  107692. * Sets the SPS MultiMaterial from the passed materials.
  107693. * Note : the passed array is internally copied and not used then by reference.
  107694. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  107695. */
  107696. setMultiMaterial(materials: Material[]): void;
  107697. /**
  107698. * The SPS computed multimaterial object
  107699. */
  107700. get multimaterial(): MultiMaterial;
  107701. set multimaterial(mm: MultiMaterial);
  107702. /**
  107703. * If the subMeshes must be updated on the next call to setParticles()
  107704. */
  107705. get autoUpdateSubMeshes(): boolean;
  107706. set autoUpdateSubMeshes(val: boolean);
  107707. /**
  107708. * This function does nothing. It may be overwritten to set all the particle first values.
  107709. * The SPS doesn't call this function, you may have to call it by your own.
  107710. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  107711. */
  107712. initParticles(): void;
  107713. /**
  107714. * This function does nothing. It may be overwritten to recycle a particle.
  107715. * The SPS doesn't call this function, you may have to call it by your own.
  107716. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  107717. * @param particle The particle to recycle
  107718. * @returns the recycled particle
  107719. */
  107720. recycleParticle(particle: SolidParticle): SolidParticle;
  107721. /**
  107722. * Updates a particle : this function should be overwritten by the user.
  107723. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  107724. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  107725. * @example : just set a particle position or velocity and recycle conditions
  107726. * @param particle The particle to update
  107727. * @returns the updated particle
  107728. */
  107729. updateParticle(particle: SolidParticle): SolidParticle;
  107730. /**
  107731. * Updates a vertex of a particle : it can be overwritten by the user.
  107732. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  107733. * @param particle the current particle
  107734. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  107735. * @param pt the index of the current vertex in the particle shape
  107736. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  107737. * @example : just set a vertex particle position or color
  107738. * @returns the sps
  107739. */
  107740. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  107741. /**
  107742. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  107743. * This does nothing and may be overwritten by the user.
  107744. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107745. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107746. * @param update the boolean update value actually passed to setParticles()
  107747. */
  107748. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  107749. /**
  107750. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  107751. * This will be passed three parameters.
  107752. * This does nothing and may be overwritten by the user.
  107753. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107754. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107755. * @param update the boolean update value actually passed to setParticles()
  107756. */
  107757. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  107758. }
  107759. }
  107760. declare module BABYLON {
  107761. /**
  107762. * Represents one particle of a solid particle system.
  107763. */
  107764. export class SolidParticle {
  107765. /**
  107766. * particle global index
  107767. */
  107768. idx: number;
  107769. /**
  107770. * particle identifier
  107771. */
  107772. id: number;
  107773. /**
  107774. * The color of the particle
  107775. */
  107776. color: Nullable<Color4>;
  107777. /**
  107778. * The world space position of the particle.
  107779. */
  107780. position: Vector3;
  107781. /**
  107782. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  107783. */
  107784. rotation: Vector3;
  107785. /**
  107786. * The world space rotation quaternion of the particle.
  107787. */
  107788. rotationQuaternion: Nullable<Quaternion>;
  107789. /**
  107790. * The scaling of the particle.
  107791. */
  107792. scaling: Vector3;
  107793. /**
  107794. * The uvs of the particle.
  107795. */
  107796. uvs: Vector4;
  107797. /**
  107798. * The current speed of the particle.
  107799. */
  107800. velocity: Vector3;
  107801. /**
  107802. * The pivot point in the particle local space.
  107803. */
  107804. pivot: Vector3;
  107805. /**
  107806. * Must the particle be translated from its pivot point in its local space ?
  107807. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  107808. * Default : false
  107809. */
  107810. translateFromPivot: boolean;
  107811. /**
  107812. * Is the particle active or not ?
  107813. */
  107814. alive: boolean;
  107815. /**
  107816. * Is the particle visible or not ?
  107817. */
  107818. isVisible: boolean;
  107819. /**
  107820. * Index of this particle in the global "positions" array (Internal use)
  107821. * @hidden
  107822. */
  107823. _pos: number;
  107824. /**
  107825. * @hidden Index of this particle in the global "indices" array (Internal use)
  107826. */
  107827. _ind: number;
  107828. /**
  107829. * @hidden ModelShape of this particle (Internal use)
  107830. */
  107831. _model: ModelShape;
  107832. /**
  107833. * ModelShape id of this particle
  107834. */
  107835. shapeId: number;
  107836. /**
  107837. * Index of the particle in its shape id
  107838. */
  107839. idxInShape: number;
  107840. /**
  107841. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  107842. */
  107843. _modelBoundingInfo: BoundingInfo;
  107844. /**
  107845. * @hidden Particle BoundingInfo object (Internal use)
  107846. */
  107847. _boundingInfo: BoundingInfo;
  107848. /**
  107849. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  107850. */
  107851. _sps: SolidParticleSystem;
  107852. /**
  107853. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  107854. */
  107855. _stillInvisible: boolean;
  107856. /**
  107857. * @hidden Last computed particle rotation matrix
  107858. */
  107859. _rotationMatrix: number[];
  107860. /**
  107861. * Parent particle Id, if any.
  107862. * Default null.
  107863. */
  107864. parentId: Nullable<number>;
  107865. /**
  107866. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  107867. */
  107868. materialIndex: Nullable<number>;
  107869. /**
  107870. * Custom object or properties.
  107871. */
  107872. props: Nullable<any>;
  107873. /**
  107874. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  107875. * The possible values are :
  107876. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  107877. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  107878. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  107879. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  107880. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  107881. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  107882. * */
  107883. cullingStrategy: number;
  107884. /**
  107885. * @hidden Internal global position in the SPS.
  107886. */
  107887. _globalPosition: Vector3;
  107888. /**
  107889. * Creates a Solid Particle object.
  107890. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  107891. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  107892. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  107893. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  107894. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  107895. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  107896. * @param shapeId (integer) is the model shape identifier in the SPS.
  107897. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  107898. * @param sps defines the sps it is associated to
  107899. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  107900. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  107901. */
  107902. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  107903. /**
  107904. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  107905. * @param target the particle target
  107906. * @returns the current particle
  107907. */
  107908. copyToRef(target: SolidParticle): SolidParticle;
  107909. /**
  107910. * Legacy support, changed scale to scaling
  107911. */
  107912. get scale(): Vector3;
  107913. /**
  107914. * Legacy support, changed scale to scaling
  107915. */
  107916. set scale(scale: Vector3);
  107917. /**
  107918. * Legacy support, changed quaternion to rotationQuaternion
  107919. */
  107920. get quaternion(): Nullable<Quaternion>;
  107921. /**
  107922. * Legacy support, changed quaternion to rotationQuaternion
  107923. */
  107924. set quaternion(q: Nullable<Quaternion>);
  107925. /**
  107926. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  107927. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  107928. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  107929. * @returns true if it intersects
  107930. */
  107931. intersectsMesh(target: Mesh | SolidParticle): boolean;
  107932. /**
  107933. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  107934. * A particle is in the frustum if its bounding box intersects the frustum
  107935. * @param frustumPlanes defines the frustum to test
  107936. * @returns true if the particle is in the frustum planes
  107937. */
  107938. isInFrustum(frustumPlanes: Plane[]): boolean;
  107939. /**
  107940. * get the rotation matrix of the particle
  107941. * @hidden
  107942. */
  107943. getRotationMatrix(m: Matrix): void;
  107944. }
  107945. /**
  107946. * Represents the shape of the model used by one particle of a solid particle system.
  107947. * SPS internal tool, don't use it manually.
  107948. */
  107949. export class ModelShape {
  107950. /**
  107951. * The shape id
  107952. * @hidden
  107953. */
  107954. shapeID: number;
  107955. /**
  107956. * flat array of model positions (internal use)
  107957. * @hidden
  107958. */
  107959. _shape: Vector3[];
  107960. /**
  107961. * flat array of model UVs (internal use)
  107962. * @hidden
  107963. */
  107964. _shapeUV: number[];
  107965. /**
  107966. * color array of the model
  107967. * @hidden
  107968. */
  107969. _shapeColors: number[];
  107970. /**
  107971. * indices array of the model
  107972. * @hidden
  107973. */
  107974. _indices: number[];
  107975. /**
  107976. * normals array of the model
  107977. * @hidden
  107978. */
  107979. _normals: number[];
  107980. /**
  107981. * length of the shape in the model indices array (internal use)
  107982. * @hidden
  107983. */
  107984. _indicesLength: number;
  107985. /**
  107986. * Custom position function (internal use)
  107987. * @hidden
  107988. */
  107989. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  107990. /**
  107991. * Custom vertex function (internal use)
  107992. * @hidden
  107993. */
  107994. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  107995. /**
  107996. * Model material (internal use)
  107997. * @hidden
  107998. */
  107999. _material: Nullable<Material>;
  108000. /**
  108001. * 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.
  108002. * SPS internal tool, don't use it manually.
  108003. * @hidden
  108004. */
  108005. 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>);
  108006. }
  108007. /**
  108008. * Represents a Depth Sorted Particle in the solid particle system.
  108009. * @hidden
  108010. */
  108011. export class DepthSortedParticle {
  108012. /**
  108013. * Particle index
  108014. */
  108015. idx: number;
  108016. /**
  108017. * Index of the particle in the "indices" array
  108018. */
  108019. ind: number;
  108020. /**
  108021. * Length of the particle shape in the "indices" array
  108022. */
  108023. indicesLength: number;
  108024. /**
  108025. * Squared distance from the particle to the camera
  108026. */
  108027. sqDistance: number;
  108028. /**
  108029. * Material index when used with MultiMaterials
  108030. */
  108031. materialIndex: number;
  108032. /**
  108033. * Creates a new sorted particle
  108034. * @param materialIndex
  108035. */
  108036. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  108037. }
  108038. /**
  108039. * Represents a solid particle vertex
  108040. */
  108041. export class SolidParticleVertex {
  108042. /**
  108043. * Vertex position
  108044. */
  108045. position: Vector3;
  108046. /**
  108047. * Vertex color
  108048. */
  108049. color: Color4;
  108050. /**
  108051. * Vertex UV
  108052. */
  108053. uv: Vector2;
  108054. /**
  108055. * Creates a new solid particle vertex
  108056. */
  108057. constructor();
  108058. /** Vertex x coordinate */
  108059. get x(): number;
  108060. set x(val: number);
  108061. /** Vertex y coordinate */
  108062. get y(): number;
  108063. set y(val: number);
  108064. /** Vertex z coordinate */
  108065. get z(): number;
  108066. set z(val: number);
  108067. }
  108068. }
  108069. declare module BABYLON {
  108070. /**
  108071. * @hidden
  108072. */
  108073. export class _MeshCollisionData {
  108074. _checkCollisions: boolean;
  108075. _collisionMask: number;
  108076. _collisionGroup: number;
  108077. _surroundingMeshes: Nullable<AbstractMesh[]>;
  108078. _collider: Nullable<Collider>;
  108079. _oldPositionForCollisions: Vector3;
  108080. _diffPositionForCollisions: Vector3;
  108081. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  108082. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  108083. }
  108084. }
  108085. declare module BABYLON {
  108086. /** @hidden */
  108087. class _FacetDataStorage {
  108088. facetPositions: Vector3[];
  108089. facetNormals: Vector3[];
  108090. facetPartitioning: number[][];
  108091. facetNb: number;
  108092. partitioningSubdivisions: number;
  108093. partitioningBBoxRatio: number;
  108094. facetDataEnabled: boolean;
  108095. facetParameters: any;
  108096. bbSize: Vector3;
  108097. subDiv: {
  108098. max: number;
  108099. X: number;
  108100. Y: number;
  108101. Z: number;
  108102. };
  108103. facetDepthSort: boolean;
  108104. facetDepthSortEnabled: boolean;
  108105. depthSortedIndices: IndicesArray;
  108106. depthSortedFacets: {
  108107. ind: number;
  108108. sqDistance: number;
  108109. }[];
  108110. facetDepthSortFunction: (f1: {
  108111. ind: number;
  108112. sqDistance: number;
  108113. }, f2: {
  108114. ind: number;
  108115. sqDistance: number;
  108116. }) => number;
  108117. facetDepthSortFrom: Vector3;
  108118. facetDepthSortOrigin: Vector3;
  108119. invertedMatrix: Matrix;
  108120. }
  108121. /**
  108122. * @hidden
  108123. **/
  108124. class _InternalAbstractMeshDataInfo {
  108125. _hasVertexAlpha: boolean;
  108126. _useVertexColors: boolean;
  108127. _numBoneInfluencers: number;
  108128. _applyFog: boolean;
  108129. _receiveShadows: boolean;
  108130. _facetData: _FacetDataStorage;
  108131. _visibility: number;
  108132. _skeleton: Nullable<Skeleton>;
  108133. _layerMask: number;
  108134. _computeBonesUsingShaders: boolean;
  108135. _isActive: boolean;
  108136. _onlyForInstances: boolean;
  108137. _isActiveIntermediate: boolean;
  108138. _onlyForInstancesIntermediate: boolean;
  108139. _actAsRegularMesh: boolean;
  108140. }
  108141. /**
  108142. * Class used to store all common mesh properties
  108143. */
  108144. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  108145. /** No occlusion */
  108146. static OCCLUSION_TYPE_NONE: number;
  108147. /** Occlusion set to optimisitic */
  108148. static OCCLUSION_TYPE_OPTIMISTIC: number;
  108149. /** Occlusion set to strict */
  108150. static OCCLUSION_TYPE_STRICT: number;
  108151. /** Use an accurante occlusion algorithm */
  108152. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  108153. /** Use a conservative occlusion algorithm */
  108154. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  108155. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  108156. * Test order :
  108157. * Is the bounding sphere outside the frustum ?
  108158. * If not, are the bounding box vertices outside the frustum ?
  108159. * It not, then the cullable object is in the frustum.
  108160. */
  108161. static readonly CULLINGSTRATEGY_STANDARD: number;
  108162. /** Culling strategy : Bounding Sphere Only.
  108163. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  108164. * It's also less accurate than the standard because some not visible objects can still be selected.
  108165. * Test : is the bounding sphere outside the frustum ?
  108166. * If not, then the cullable object is in the frustum.
  108167. */
  108168. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  108169. /** Culling strategy : Optimistic Inclusion.
  108170. * This in an inclusion test first, then the standard exclusion test.
  108171. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  108172. * 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.
  108173. * Anyway, it's as accurate as the standard strategy.
  108174. * Test :
  108175. * Is the cullable object bounding sphere center in the frustum ?
  108176. * If not, apply the default culling strategy.
  108177. */
  108178. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  108179. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  108180. * This in an inclusion test first, then the bounding sphere only exclusion test.
  108181. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  108182. * 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.
  108183. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  108184. * Test :
  108185. * Is the cullable object bounding sphere center in the frustum ?
  108186. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  108187. */
  108188. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  108189. /**
  108190. * No billboard
  108191. */
  108192. static get BILLBOARDMODE_NONE(): number;
  108193. /** Billboard on X axis */
  108194. static get BILLBOARDMODE_X(): number;
  108195. /** Billboard on Y axis */
  108196. static get BILLBOARDMODE_Y(): number;
  108197. /** Billboard on Z axis */
  108198. static get BILLBOARDMODE_Z(): number;
  108199. /** Billboard on all axes */
  108200. static get BILLBOARDMODE_ALL(): number;
  108201. /** Billboard on using position instead of orientation */
  108202. static get BILLBOARDMODE_USE_POSITION(): number;
  108203. /** @hidden */
  108204. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  108205. /**
  108206. * The culling strategy to use to check whether the mesh must be rendered or not.
  108207. * This value can be changed at any time and will be used on the next render mesh selection.
  108208. * The possible values are :
  108209. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  108210. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108211. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  108212. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  108213. * Please read each static variable documentation to get details about the culling process.
  108214. * */
  108215. cullingStrategy: number;
  108216. /**
  108217. * Gets the number of facets in the mesh
  108218. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  108219. */
  108220. get facetNb(): number;
  108221. /**
  108222. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  108223. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  108224. */
  108225. get partitioningSubdivisions(): number;
  108226. set partitioningSubdivisions(nb: number);
  108227. /**
  108228. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  108229. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  108230. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  108231. */
  108232. get partitioningBBoxRatio(): number;
  108233. set partitioningBBoxRatio(ratio: number);
  108234. /**
  108235. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  108236. * Works only for updatable meshes.
  108237. * Doesn't work with multi-materials
  108238. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  108239. */
  108240. get mustDepthSortFacets(): boolean;
  108241. set mustDepthSortFacets(sort: boolean);
  108242. /**
  108243. * The location (Vector3) where the facet depth sort must be computed from.
  108244. * By default, the active camera position.
  108245. * Used only when facet depth sort is enabled
  108246. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  108247. */
  108248. get facetDepthSortFrom(): Vector3;
  108249. set facetDepthSortFrom(location: Vector3);
  108250. /**
  108251. * gets a boolean indicating if facetData is enabled
  108252. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  108253. */
  108254. get isFacetDataEnabled(): boolean;
  108255. /** @hidden */
  108256. _updateNonUniformScalingState(value: boolean): boolean;
  108257. /**
  108258. * An event triggered when this mesh collides with another one
  108259. */
  108260. onCollideObservable: Observable<AbstractMesh>;
  108261. /** Set a function to call when this mesh collides with another one */
  108262. set onCollide(callback: () => void);
  108263. /**
  108264. * An event triggered when the collision's position changes
  108265. */
  108266. onCollisionPositionChangeObservable: Observable<Vector3>;
  108267. /** Set a function to call when the collision's position changes */
  108268. set onCollisionPositionChange(callback: () => void);
  108269. /**
  108270. * An event triggered when material is changed
  108271. */
  108272. onMaterialChangedObservable: Observable<AbstractMesh>;
  108273. /**
  108274. * Gets or sets the orientation for POV movement & rotation
  108275. */
  108276. definedFacingForward: boolean;
  108277. /** @hidden */
  108278. _occlusionQuery: Nullable<WebGLQuery>;
  108279. /** @hidden */
  108280. _renderingGroup: Nullable<RenderingGroup>;
  108281. /**
  108282. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  108283. */
  108284. get visibility(): number;
  108285. /**
  108286. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  108287. */
  108288. set visibility(value: number);
  108289. /** Gets or sets the alpha index used to sort transparent meshes
  108290. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  108291. */
  108292. alphaIndex: number;
  108293. /**
  108294. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  108295. */
  108296. isVisible: boolean;
  108297. /**
  108298. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  108299. */
  108300. isPickable: boolean;
  108301. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  108302. showSubMeshesBoundingBox: boolean;
  108303. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  108304. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  108305. */
  108306. isBlocker: boolean;
  108307. /**
  108308. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  108309. */
  108310. enablePointerMoveEvents: boolean;
  108311. /**
  108312. * Specifies the rendering group id for this mesh (0 by default)
  108313. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  108314. */
  108315. renderingGroupId: number;
  108316. private _material;
  108317. /** Gets or sets current material */
  108318. get material(): Nullable<Material>;
  108319. set material(value: Nullable<Material>);
  108320. /**
  108321. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  108322. * @see http://doc.babylonjs.com/babylon101/shadows
  108323. */
  108324. get receiveShadows(): boolean;
  108325. set receiveShadows(value: boolean);
  108326. /** Defines color to use when rendering outline */
  108327. outlineColor: Color3;
  108328. /** Define width to use when rendering outline */
  108329. outlineWidth: number;
  108330. /** Defines color to use when rendering overlay */
  108331. overlayColor: Color3;
  108332. /** Defines alpha to use when rendering overlay */
  108333. overlayAlpha: number;
  108334. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  108335. get hasVertexAlpha(): boolean;
  108336. set hasVertexAlpha(value: boolean);
  108337. /** 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) */
  108338. get useVertexColors(): boolean;
  108339. set useVertexColors(value: boolean);
  108340. /**
  108341. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  108342. */
  108343. get computeBonesUsingShaders(): boolean;
  108344. set computeBonesUsingShaders(value: boolean);
  108345. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  108346. get numBoneInfluencers(): number;
  108347. set numBoneInfluencers(value: number);
  108348. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  108349. get applyFog(): boolean;
  108350. set applyFog(value: boolean);
  108351. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  108352. useOctreeForRenderingSelection: boolean;
  108353. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  108354. useOctreeForPicking: boolean;
  108355. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  108356. useOctreeForCollisions: boolean;
  108357. /**
  108358. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  108359. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  108360. */
  108361. get layerMask(): number;
  108362. set layerMask(value: number);
  108363. /**
  108364. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  108365. */
  108366. alwaysSelectAsActiveMesh: boolean;
  108367. /**
  108368. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  108369. */
  108370. doNotSyncBoundingInfo: boolean;
  108371. /**
  108372. * Gets or sets the current action manager
  108373. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108374. */
  108375. actionManager: Nullable<AbstractActionManager>;
  108376. private _meshCollisionData;
  108377. /**
  108378. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  108379. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108380. */
  108381. ellipsoid: Vector3;
  108382. /**
  108383. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  108384. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108385. */
  108386. ellipsoidOffset: Vector3;
  108387. /**
  108388. * Gets or sets a collision mask used to mask collisions (default is -1).
  108389. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  108390. */
  108391. get collisionMask(): number;
  108392. set collisionMask(mask: number);
  108393. /**
  108394. * Gets or sets the current collision group mask (-1 by default).
  108395. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  108396. */
  108397. get collisionGroup(): number;
  108398. set collisionGroup(mask: number);
  108399. /**
  108400. * Gets or sets current surrounding meshes (null by default).
  108401. *
  108402. * By default collision detection is tested against every mesh in the scene.
  108403. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  108404. * meshes will be tested for the collision.
  108405. *
  108406. * Note: if set to an empty array no collision will happen when this mesh is moved.
  108407. */
  108408. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  108409. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  108410. /**
  108411. * Defines edge width used when edgesRenderer is enabled
  108412. * @see https://www.babylonjs-playground.com/#10OJSG#13
  108413. */
  108414. edgesWidth: number;
  108415. /**
  108416. * Defines edge color used when edgesRenderer is enabled
  108417. * @see https://www.babylonjs-playground.com/#10OJSG#13
  108418. */
  108419. edgesColor: Color4;
  108420. /** @hidden */
  108421. _edgesRenderer: Nullable<IEdgesRenderer>;
  108422. /** @hidden */
  108423. _masterMesh: Nullable<AbstractMesh>;
  108424. /** @hidden */
  108425. _boundingInfo: Nullable<BoundingInfo>;
  108426. /** @hidden */
  108427. _renderId: number;
  108428. /**
  108429. * Gets or sets the list of subMeshes
  108430. * @see http://doc.babylonjs.com/how_to/multi_materials
  108431. */
  108432. subMeshes: SubMesh[];
  108433. /** @hidden */
  108434. _intersectionsInProgress: AbstractMesh[];
  108435. /** @hidden */
  108436. _unIndexed: boolean;
  108437. /** @hidden */
  108438. _lightSources: Light[];
  108439. /** Gets the list of lights affecting that mesh */
  108440. get lightSources(): Light[];
  108441. /** @hidden */
  108442. get _positions(): Nullable<Vector3[]>;
  108443. /** @hidden */
  108444. _waitingData: {
  108445. lods: Nullable<any>;
  108446. actions: Nullable<any>;
  108447. freezeWorldMatrix: Nullable<boolean>;
  108448. };
  108449. /** @hidden */
  108450. _bonesTransformMatrices: Nullable<Float32Array>;
  108451. /** @hidden */
  108452. _transformMatrixTexture: Nullable<RawTexture>;
  108453. /**
  108454. * Gets or sets a skeleton to apply skining transformations
  108455. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  108456. */
  108457. set skeleton(value: Nullable<Skeleton>);
  108458. get skeleton(): Nullable<Skeleton>;
  108459. /**
  108460. * An event triggered when the mesh is rebuilt.
  108461. */
  108462. onRebuildObservable: Observable<AbstractMesh>;
  108463. /**
  108464. * Creates a new AbstractMesh
  108465. * @param name defines the name of the mesh
  108466. * @param scene defines the hosting scene
  108467. */
  108468. constructor(name: string, scene?: Nullable<Scene>);
  108469. /**
  108470. * Returns the string "AbstractMesh"
  108471. * @returns "AbstractMesh"
  108472. */
  108473. getClassName(): string;
  108474. /**
  108475. * Gets a string representation of the current mesh
  108476. * @param fullDetails defines a boolean indicating if full details must be included
  108477. * @returns a string representation of the current mesh
  108478. */
  108479. toString(fullDetails?: boolean): string;
  108480. /**
  108481. * @hidden
  108482. */
  108483. protected _getEffectiveParent(): Nullable<Node>;
  108484. /** @hidden */
  108485. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  108486. /** @hidden */
  108487. _rebuild(): void;
  108488. /** @hidden */
  108489. _resyncLightSources(): void;
  108490. /** @hidden */
  108491. _resyncLightSource(light: Light): void;
  108492. /** @hidden */
  108493. _unBindEffect(): void;
  108494. /** @hidden */
  108495. _removeLightSource(light: Light, dispose: boolean): void;
  108496. private _markSubMeshesAsDirty;
  108497. /** @hidden */
  108498. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  108499. /** @hidden */
  108500. _markSubMeshesAsAttributesDirty(): void;
  108501. /** @hidden */
  108502. _markSubMeshesAsMiscDirty(): void;
  108503. /**
  108504. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  108505. */
  108506. get scaling(): Vector3;
  108507. set scaling(newScaling: Vector3);
  108508. /**
  108509. * Returns true if the mesh is blocked. Implemented by child classes
  108510. */
  108511. get isBlocked(): boolean;
  108512. /**
  108513. * Returns the mesh itself by default. Implemented by child classes
  108514. * @param camera defines the camera to use to pick the right LOD level
  108515. * @returns the currentAbstractMesh
  108516. */
  108517. getLOD(camera: Camera): Nullable<AbstractMesh>;
  108518. /**
  108519. * Returns 0 by default. Implemented by child classes
  108520. * @returns an integer
  108521. */
  108522. getTotalVertices(): number;
  108523. /**
  108524. * Returns a positive integer : the total number of indices in this mesh geometry.
  108525. * @returns the numner of indices or zero if the mesh has no geometry.
  108526. */
  108527. getTotalIndices(): number;
  108528. /**
  108529. * Returns null by default. Implemented by child classes
  108530. * @returns null
  108531. */
  108532. getIndices(): Nullable<IndicesArray>;
  108533. /**
  108534. * Returns the array of the requested vertex data kind. Implemented by child classes
  108535. * @param kind defines the vertex data kind to use
  108536. * @returns null
  108537. */
  108538. getVerticesData(kind: string): Nullable<FloatArray>;
  108539. /**
  108540. * Sets the vertex data of the mesh geometry for the requested `kind`.
  108541. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  108542. * Note that a new underlying VertexBuffer object is created each call.
  108543. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  108544. * @param kind defines vertex data kind:
  108545. * * VertexBuffer.PositionKind
  108546. * * VertexBuffer.UVKind
  108547. * * VertexBuffer.UV2Kind
  108548. * * VertexBuffer.UV3Kind
  108549. * * VertexBuffer.UV4Kind
  108550. * * VertexBuffer.UV5Kind
  108551. * * VertexBuffer.UV6Kind
  108552. * * VertexBuffer.ColorKind
  108553. * * VertexBuffer.MatricesIndicesKind
  108554. * * VertexBuffer.MatricesIndicesExtraKind
  108555. * * VertexBuffer.MatricesWeightsKind
  108556. * * VertexBuffer.MatricesWeightsExtraKind
  108557. * @param data defines the data source
  108558. * @param updatable defines if the data must be flagged as updatable (or static)
  108559. * @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
  108560. * @returns the current mesh
  108561. */
  108562. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  108563. /**
  108564. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  108565. * If the mesh has no geometry, it is simply returned as it is.
  108566. * @param kind defines vertex data kind:
  108567. * * VertexBuffer.PositionKind
  108568. * * VertexBuffer.UVKind
  108569. * * VertexBuffer.UV2Kind
  108570. * * VertexBuffer.UV3Kind
  108571. * * VertexBuffer.UV4Kind
  108572. * * VertexBuffer.UV5Kind
  108573. * * VertexBuffer.UV6Kind
  108574. * * VertexBuffer.ColorKind
  108575. * * VertexBuffer.MatricesIndicesKind
  108576. * * VertexBuffer.MatricesIndicesExtraKind
  108577. * * VertexBuffer.MatricesWeightsKind
  108578. * * VertexBuffer.MatricesWeightsExtraKind
  108579. * @param data defines the data source
  108580. * @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
  108581. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  108582. * @returns the current mesh
  108583. */
  108584. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  108585. /**
  108586. * Sets the mesh indices,
  108587. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  108588. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  108589. * @param totalVertices Defines the total number of vertices
  108590. * @returns the current mesh
  108591. */
  108592. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  108593. /**
  108594. * Gets a boolean indicating if specific vertex data is present
  108595. * @param kind defines the vertex data kind to use
  108596. * @returns true is data kind is present
  108597. */
  108598. isVerticesDataPresent(kind: string): boolean;
  108599. /**
  108600. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  108601. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  108602. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  108603. * @returns a BoundingInfo
  108604. */
  108605. getBoundingInfo(): BoundingInfo;
  108606. /**
  108607. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  108608. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  108609. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  108610. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  108611. * @returns the current mesh
  108612. */
  108613. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  108614. /**
  108615. * Overwrite the current bounding info
  108616. * @param boundingInfo defines the new bounding info
  108617. * @returns the current mesh
  108618. */
  108619. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  108620. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  108621. get useBones(): boolean;
  108622. /** @hidden */
  108623. _preActivate(): void;
  108624. /** @hidden */
  108625. _preActivateForIntermediateRendering(renderId: number): void;
  108626. /** @hidden */
  108627. _activate(renderId: number, intermediateRendering: boolean): boolean;
  108628. /** @hidden */
  108629. _postActivate(): void;
  108630. /** @hidden */
  108631. _freeze(): void;
  108632. /** @hidden */
  108633. _unFreeze(): void;
  108634. /**
  108635. * Gets the current world matrix
  108636. * @returns a Matrix
  108637. */
  108638. getWorldMatrix(): Matrix;
  108639. /** @hidden */
  108640. _getWorldMatrixDeterminant(): number;
  108641. /**
  108642. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  108643. */
  108644. get isAnInstance(): boolean;
  108645. /**
  108646. * Gets a boolean indicating if this mesh has instances
  108647. */
  108648. get hasInstances(): boolean;
  108649. /**
  108650. * Gets a boolean indicating if this mesh has thin instances
  108651. */
  108652. get hasThinInstances(): boolean;
  108653. /**
  108654. * Perform relative position change from the point of view of behind the front of the mesh.
  108655. * This is performed taking into account the meshes current rotation, so you do not have to care.
  108656. * Supports definition of mesh facing forward or backward
  108657. * @param amountRight defines the distance on the right axis
  108658. * @param amountUp defines the distance on the up axis
  108659. * @param amountForward defines the distance on the forward axis
  108660. * @returns the current mesh
  108661. */
  108662. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  108663. /**
  108664. * Calculate relative position change from the point of view of behind the front of the mesh.
  108665. * This is performed taking into account the meshes current rotation, so you do not have to care.
  108666. * Supports definition of mesh facing forward or backward
  108667. * @param amountRight defines the distance on the right axis
  108668. * @param amountUp defines the distance on the up axis
  108669. * @param amountForward defines the distance on the forward axis
  108670. * @returns the new displacement vector
  108671. */
  108672. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  108673. /**
  108674. * Perform relative rotation change from the point of view of behind the front of the mesh.
  108675. * Supports definition of mesh facing forward or backward
  108676. * @param flipBack defines the flip
  108677. * @param twirlClockwise defines the twirl
  108678. * @param tiltRight defines the tilt
  108679. * @returns the current mesh
  108680. */
  108681. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  108682. /**
  108683. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  108684. * Supports definition of mesh facing forward or backward.
  108685. * @param flipBack defines the flip
  108686. * @param twirlClockwise defines the twirl
  108687. * @param tiltRight defines the tilt
  108688. * @returns the new rotation vector
  108689. */
  108690. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  108691. /**
  108692. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  108693. * This means the mesh underlying bounding box and sphere are recomputed.
  108694. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  108695. * @returns the current mesh
  108696. */
  108697. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  108698. /** @hidden */
  108699. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  108700. /** @hidden */
  108701. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  108702. /** @hidden */
  108703. _updateBoundingInfo(): AbstractMesh;
  108704. /** @hidden */
  108705. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  108706. /** @hidden */
  108707. protected _afterComputeWorldMatrix(): void;
  108708. /** @hidden */
  108709. get _effectiveMesh(): AbstractMesh;
  108710. /**
  108711. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  108712. * A mesh is in the frustum if its bounding box intersects the frustum
  108713. * @param frustumPlanes defines the frustum to test
  108714. * @returns true if the mesh is in the frustum planes
  108715. */
  108716. isInFrustum(frustumPlanes: Plane[]): boolean;
  108717. /**
  108718. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  108719. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  108720. * @param frustumPlanes defines the frustum to test
  108721. * @returns true if the mesh is completely in the frustum planes
  108722. */
  108723. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  108724. /**
  108725. * True if the mesh intersects another mesh or a SolidParticle object
  108726. * @param mesh defines a target mesh or SolidParticle to test
  108727. * @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)
  108728. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  108729. * @returns true if there is an intersection
  108730. */
  108731. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  108732. /**
  108733. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  108734. * @param point defines the point to test
  108735. * @returns true if there is an intersection
  108736. */
  108737. intersectsPoint(point: Vector3): boolean;
  108738. /**
  108739. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  108740. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108741. */
  108742. get checkCollisions(): boolean;
  108743. set checkCollisions(collisionEnabled: boolean);
  108744. /**
  108745. * Gets Collider object used to compute collisions (not physics)
  108746. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108747. */
  108748. get collider(): Nullable<Collider>;
  108749. /**
  108750. * Move the mesh using collision engine
  108751. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108752. * @param displacement defines the requested displacement vector
  108753. * @returns the current mesh
  108754. */
  108755. moveWithCollisions(displacement: Vector3): AbstractMesh;
  108756. private _onCollisionPositionChange;
  108757. /** @hidden */
  108758. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  108759. /** @hidden */
  108760. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  108761. /** @hidden */
  108762. _checkCollision(collider: Collider): AbstractMesh;
  108763. /** @hidden */
  108764. _generatePointsArray(): boolean;
  108765. /**
  108766. * Checks if the passed Ray intersects with the mesh
  108767. * @param ray defines the ray to use
  108768. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  108769. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  108770. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  108771. * @returns the picking info
  108772. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  108773. */
  108774. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  108775. /**
  108776. * Clones the current mesh
  108777. * @param name defines the mesh name
  108778. * @param newParent defines the new mesh parent
  108779. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  108780. * @returns the new mesh
  108781. */
  108782. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  108783. /**
  108784. * Disposes all the submeshes of the current meshnp
  108785. * @returns the current mesh
  108786. */
  108787. releaseSubMeshes(): AbstractMesh;
  108788. /**
  108789. * Releases resources associated with this abstract mesh.
  108790. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108791. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108792. */
  108793. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108794. /**
  108795. * Adds the passed mesh as a child to the current mesh
  108796. * @param mesh defines the child mesh
  108797. * @returns the current mesh
  108798. */
  108799. addChild(mesh: AbstractMesh): AbstractMesh;
  108800. /**
  108801. * Removes the passed mesh from the current mesh children list
  108802. * @param mesh defines the child mesh
  108803. * @returns the current mesh
  108804. */
  108805. removeChild(mesh: AbstractMesh): AbstractMesh;
  108806. /** @hidden */
  108807. private _initFacetData;
  108808. /**
  108809. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  108810. * This method can be called within the render loop.
  108811. * 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
  108812. * @returns the current mesh
  108813. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108814. */
  108815. updateFacetData(): AbstractMesh;
  108816. /**
  108817. * Returns the facetLocalNormals array.
  108818. * The normals are expressed in the mesh local spac
  108819. * @returns an array of Vector3
  108820. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108821. */
  108822. getFacetLocalNormals(): Vector3[];
  108823. /**
  108824. * Returns the facetLocalPositions array.
  108825. * The facet positions are expressed in the mesh local space
  108826. * @returns an array of Vector3
  108827. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108828. */
  108829. getFacetLocalPositions(): Vector3[];
  108830. /**
  108831. * Returns the facetLocalPartioning array
  108832. * @returns an array of array of numbers
  108833. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108834. */
  108835. getFacetLocalPartitioning(): number[][];
  108836. /**
  108837. * Returns the i-th facet position in the world system.
  108838. * This method allocates a new Vector3 per call
  108839. * @param i defines the facet index
  108840. * @returns a new Vector3
  108841. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108842. */
  108843. getFacetPosition(i: number): Vector3;
  108844. /**
  108845. * Sets the reference Vector3 with the i-th facet position in the world system
  108846. * @param i defines the facet index
  108847. * @param ref defines the target vector
  108848. * @returns the current mesh
  108849. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108850. */
  108851. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  108852. /**
  108853. * Returns the i-th facet normal in the world system.
  108854. * This method allocates a new Vector3 per call
  108855. * @param i defines the facet index
  108856. * @returns a new Vector3
  108857. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108858. */
  108859. getFacetNormal(i: number): Vector3;
  108860. /**
  108861. * Sets the reference Vector3 with the i-th facet normal in the world system
  108862. * @param i defines the facet index
  108863. * @param ref defines the target vector
  108864. * @returns the current mesh
  108865. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108866. */
  108867. getFacetNormalToRef(i: number, ref: Vector3): this;
  108868. /**
  108869. * 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)
  108870. * @param x defines x coordinate
  108871. * @param y defines y coordinate
  108872. * @param z defines z coordinate
  108873. * @returns the array of facet indexes
  108874. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108875. */
  108876. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  108877. /**
  108878. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  108879. * @param projected sets as the (x,y,z) world projection on the facet
  108880. * @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
  108881. * @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
  108882. * @param x defines x coordinate
  108883. * @param y defines y coordinate
  108884. * @param z defines z coordinate
  108885. * @returns the face index if found (or null instead)
  108886. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108887. */
  108888. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  108889. /**
  108890. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  108891. * @param projected sets as the (x,y,z) local projection on the facet
  108892. * @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
  108893. * @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
  108894. * @param x defines x coordinate
  108895. * @param y defines y coordinate
  108896. * @param z defines z coordinate
  108897. * @returns the face index if found (or null instead)
  108898. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108899. */
  108900. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  108901. /**
  108902. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  108903. * @returns the parameters
  108904. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108905. */
  108906. getFacetDataParameters(): any;
  108907. /**
  108908. * Disables the feature FacetData and frees the related memory
  108909. * @returns the current mesh
  108910. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108911. */
  108912. disableFacetData(): AbstractMesh;
  108913. /**
  108914. * Updates the AbstractMesh indices array
  108915. * @param indices defines the data source
  108916. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  108917. * @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)
  108918. * @returns the current mesh
  108919. */
  108920. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  108921. /**
  108922. * Creates new normals data for the mesh
  108923. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  108924. * @returns the current mesh
  108925. */
  108926. createNormals(updatable: boolean): AbstractMesh;
  108927. /**
  108928. * Align the mesh with a normal
  108929. * @param normal defines the normal to use
  108930. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  108931. * @returns the current mesh
  108932. */
  108933. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  108934. /** @hidden */
  108935. _checkOcclusionQuery(): boolean;
  108936. /**
  108937. * Disables the mesh edge rendering mode
  108938. * @returns the currentAbstractMesh
  108939. */
  108940. disableEdgesRendering(): AbstractMesh;
  108941. /**
  108942. * Enables the edge rendering mode on the mesh.
  108943. * This mode makes the mesh edges visible
  108944. * @param epsilon defines the maximal distance between two angles to detect a face
  108945. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  108946. * @returns the currentAbstractMesh
  108947. * @see https://www.babylonjs-playground.com/#19O9TU#0
  108948. */
  108949. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  108950. }
  108951. }
  108952. declare module BABYLON {
  108953. /**
  108954. * Interface used to define ActionEvent
  108955. */
  108956. export interface IActionEvent {
  108957. /** The mesh or sprite that triggered the action */
  108958. source: any;
  108959. /** The X mouse cursor position at the time of the event */
  108960. pointerX: number;
  108961. /** The Y mouse cursor position at the time of the event */
  108962. pointerY: number;
  108963. /** The mesh that is currently pointed at (can be null) */
  108964. meshUnderPointer: Nullable<AbstractMesh>;
  108965. /** the original (browser) event that triggered the ActionEvent */
  108966. sourceEvent?: any;
  108967. /** additional data for the event */
  108968. additionalData?: any;
  108969. }
  108970. /**
  108971. * ActionEvent is the event being sent when an action is triggered.
  108972. */
  108973. export class ActionEvent implements IActionEvent {
  108974. /** The mesh or sprite that triggered the action */
  108975. source: any;
  108976. /** The X mouse cursor position at the time of the event */
  108977. pointerX: number;
  108978. /** The Y mouse cursor position at the time of the event */
  108979. pointerY: number;
  108980. /** The mesh that is currently pointed at (can be null) */
  108981. meshUnderPointer: Nullable<AbstractMesh>;
  108982. /** the original (browser) event that triggered the ActionEvent */
  108983. sourceEvent?: any;
  108984. /** additional data for the event */
  108985. additionalData?: any;
  108986. /**
  108987. * Creates a new ActionEvent
  108988. * @param source The mesh or sprite that triggered the action
  108989. * @param pointerX The X mouse cursor position at the time of the event
  108990. * @param pointerY The Y mouse cursor position at the time of the event
  108991. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  108992. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  108993. * @param additionalData additional data for the event
  108994. */
  108995. constructor(
  108996. /** The mesh or sprite that triggered the action */
  108997. source: any,
  108998. /** The X mouse cursor position at the time of the event */
  108999. pointerX: number,
  109000. /** The Y mouse cursor position at the time of the event */
  109001. pointerY: number,
  109002. /** The mesh that is currently pointed at (can be null) */
  109003. meshUnderPointer: Nullable<AbstractMesh>,
  109004. /** the original (browser) event that triggered the ActionEvent */
  109005. sourceEvent?: any,
  109006. /** additional data for the event */
  109007. additionalData?: any);
  109008. /**
  109009. * Helper function to auto-create an ActionEvent from a source mesh.
  109010. * @param source The source mesh that triggered the event
  109011. * @param evt The original (browser) event
  109012. * @param additionalData additional data for the event
  109013. * @returns the new ActionEvent
  109014. */
  109015. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  109016. /**
  109017. * Helper function to auto-create an ActionEvent from a source sprite
  109018. * @param source The source sprite that triggered the event
  109019. * @param scene Scene associated with the sprite
  109020. * @param evt The original (browser) event
  109021. * @param additionalData additional data for the event
  109022. * @returns the new ActionEvent
  109023. */
  109024. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  109025. /**
  109026. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  109027. * @param scene the scene where the event occurred
  109028. * @param evt The original (browser) event
  109029. * @returns the new ActionEvent
  109030. */
  109031. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  109032. /**
  109033. * Helper function to auto-create an ActionEvent from a primitive
  109034. * @param prim defines the target primitive
  109035. * @param pointerPos defines the pointer position
  109036. * @param evt The original (browser) event
  109037. * @param additionalData additional data for the event
  109038. * @returns the new ActionEvent
  109039. */
  109040. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  109041. }
  109042. }
  109043. declare module BABYLON {
  109044. /**
  109045. * Abstract class used to decouple action Manager from scene and meshes.
  109046. * Do not instantiate.
  109047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  109048. */
  109049. export abstract class AbstractActionManager implements IDisposable {
  109050. /** Gets the list of active triggers */
  109051. static Triggers: {
  109052. [key: string]: number;
  109053. };
  109054. /** Gets the cursor to use when hovering items */
  109055. hoverCursor: string;
  109056. /** Gets the list of actions */
  109057. actions: IAction[];
  109058. /**
  109059. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  109060. */
  109061. isRecursive: boolean;
  109062. /**
  109063. * Releases all associated resources
  109064. */
  109065. abstract dispose(): void;
  109066. /**
  109067. * Does this action manager has pointer triggers
  109068. */
  109069. abstract get hasPointerTriggers(): boolean;
  109070. /**
  109071. * Does this action manager has pick triggers
  109072. */
  109073. abstract get hasPickTriggers(): boolean;
  109074. /**
  109075. * Process a specific trigger
  109076. * @param trigger defines the trigger to process
  109077. * @param evt defines the event details to be processed
  109078. */
  109079. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  109080. /**
  109081. * Does this action manager handles actions of any of the given triggers
  109082. * @param triggers defines the triggers to be tested
  109083. * @return a boolean indicating whether one (or more) of the triggers is handled
  109084. */
  109085. abstract hasSpecificTriggers(triggers: number[]): boolean;
  109086. /**
  109087. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  109088. * speed.
  109089. * @param triggerA defines the trigger to be tested
  109090. * @param triggerB defines the trigger to be tested
  109091. * @return a boolean indicating whether one (or more) of the triggers is handled
  109092. */
  109093. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  109094. /**
  109095. * Does this action manager handles actions of a given trigger
  109096. * @param trigger defines the trigger to be tested
  109097. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  109098. * @return whether the trigger is handled
  109099. */
  109100. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  109101. /**
  109102. * Serialize this manager to a JSON object
  109103. * @param name defines the property name to store this manager
  109104. * @returns a JSON representation of this manager
  109105. */
  109106. abstract serialize(name: string): any;
  109107. /**
  109108. * Registers an action to this action manager
  109109. * @param action defines the action to be registered
  109110. * @return the action amended (prepared) after registration
  109111. */
  109112. abstract registerAction(action: IAction): Nullable<IAction>;
  109113. /**
  109114. * Unregisters an action to this action manager
  109115. * @param action defines the action to be unregistered
  109116. * @return a boolean indicating whether the action has been unregistered
  109117. */
  109118. abstract unregisterAction(action: IAction): Boolean;
  109119. /**
  109120. * Does exist one action manager with at least one trigger
  109121. **/
  109122. static get HasTriggers(): boolean;
  109123. /**
  109124. * Does exist one action manager with at least one pick trigger
  109125. **/
  109126. static get HasPickTriggers(): boolean;
  109127. /**
  109128. * Does exist one action manager that handles actions of a given trigger
  109129. * @param trigger defines the trigger to be tested
  109130. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  109131. **/
  109132. static HasSpecificTrigger(trigger: number): boolean;
  109133. }
  109134. }
  109135. declare module BABYLON {
  109136. /**
  109137. * Defines how a node can be built from a string name.
  109138. */
  109139. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  109140. /**
  109141. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  109142. */
  109143. export class Node implements IBehaviorAware<Node> {
  109144. /** @hidden */
  109145. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  109146. private static _NodeConstructors;
  109147. /**
  109148. * Add a new node constructor
  109149. * @param type defines the type name of the node to construct
  109150. * @param constructorFunc defines the constructor function
  109151. */
  109152. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  109153. /**
  109154. * Returns a node constructor based on type name
  109155. * @param type defines the type name
  109156. * @param name defines the new node name
  109157. * @param scene defines the hosting scene
  109158. * @param options defines optional options to transmit to constructors
  109159. * @returns the new constructor or null
  109160. */
  109161. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  109162. /**
  109163. * Gets or sets the name of the node
  109164. */
  109165. name: string;
  109166. /**
  109167. * Gets or sets the id of the node
  109168. */
  109169. id: string;
  109170. /**
  109171. * Gets or sets the unique id of the node
  109172. */
  109173. uniqueId: number;
  109174. /**
  109175. * Gets or sets a string used to store user defined state for the node
  109176. */
  109177. state: string;
  109178. /**
  109179. * Gets or sets an object used to store user defined information for the node
  109180. */
  109181. metadata: any;
  109182. /**
  109183. * For internal use only. Please do not use.
  109184. */
  109185. reservedDataStore: any;
  109186. /**
  109187. * List of inspectable custom properties (used by the Inspector)
  109188. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109189. */
  109190. inspectableCustomProperties: IInspectable[];
  109191. private _doNotSerialize;
  109192. /**
  109193. * Gets or sets a boolean used to define if the node must be serialized
  109194. */
  109195. get doNotSerialize(): boolean;
  109196. set doNotSerialize(value: boolean);
  109197. /** @hidden */
  109198. _isDisposed: boolean;
  109199. /**
  109200. * Gets a list of Animations associated with the node
  109201. */
  109202. animations: Animation[];
  109203. protected _ranges: {
  109204. [name: string]: Nullable<AnimationRange>;
  109205. };
  109206. /**
  109207. * Callback raised when the node is ready to be used
  109208. */
  109209. onReady: Nullable<(node: Node) => void>;
  109210. private _isEnabled;
  109211. private _isParentEnabled;
  109212. private _isReady;
  109213. /** @hidden */
  109214. _currentRenderId: number;
  109215. private _parentUpdateId;
  109216. /** @hidden */
  109217. _childUpdateId: number;
  109218. /** @hidden */
  109219. _waitingParentId: Nullable<string>;
  109220. /** @hidden */
  109221. _scene: Scene;
  109222. /** @hidden */
  109223. _cache: any;
  109224. private _parentNode;
  109225. private _children;
  109226. /** @hidden */
  109227. _worldMatrix: Matrix;
  109228. /** @hidden */
  109229. _worldMatrixDeterminant: number;
  109230. /** @hidden */
  109231. _worldMatrixDeterminantIsDirty: boolean;
  109232. /** @hidden */
  109233. private _sceneRootNodesIndex;
  109234. /**
  109235. * Gets a boolean indicating if the node has been disposed
  109236. * @returns true if the node was disposed
  109237. */
  109238. isDisposed(): boolean;
  109239. /**
  109240. * Gets or sets the parent of the node (without keeping the current position in the scene)
  109241. * @see https://doc.babylonjs.com/how_to/parenting
  109242. */
  109243. set parent(parent: Nullable<Node>);
  109244. get parent(): Nullable<Node>;
  109245. /** @hidden */
  109246. _addToSceneRootNodes(): void;
  109247. /** @hidden */
  109248. _removeFromSceneRootNodes(): void;
  109249. private _animationPropertiesOverride;
  109250. /**
  109251. * Gets or sets the animation properties override
  109252. */
  109253. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  109254. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  109255. /**
  109256. * Gets a string idenfifying the name of the class
  109257. * @returns "Node" string
  109258. */
  109259. getClassName(): string;
  109260. /** @hidden */
  109261. readonly _isNode: boolean;
  109262. /**
  109263. * An event triggered when the mesh is disposed
  109264. */
  109265. onDisposeObservable: Observable<Node>;
  109266. private _onDisposeObserver;
  109267. /**
  109268. * Sets a callback that will be raised when the node will be disposed
  109269. */
  109270. set onDispose(callback: () => void);
  109271. /**
  109272. * Creates a new Node
  109273. * @param name the name and id to be given to this node
  109274. * @param scene the scene this node will be added to
  109275. */
  109276. constructor(name: string, scene?: Nullable<Scene>);
  109277. /**
  109278. * Gets the scene of the node
  109279. * @returns a scene
  109280. */
  109281. getScene(): Scene;
  109282. /**
  109283. * Gets the engine of the node
  109284. * @returns a Engine
  109285. */
  109286. getEngine(): Engine;
  109287. private _behaviors;
  109288. /**
  109289. * Attach a behavior to the node
  109290. * @see http://doc.babylonjs.com/features/behaviour
  109291. * @param behavior defines the behavior to attach
  109292. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  109293. * @returns the current Node
  109294. */
  109295. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  109296. /**
  109297. * Remove an attached behavior
  109298. * @see http://doc.babylonjs.com/features/behaviour
  109299. * @param behavior defines the behavior to attach
  109300. * @returns the current Node
  109301. */
  109302. removeBehavior(behavior: Behavior<Node>): Node;
  109303. /**
  109304. * Gets the list of attached behaviors
  109305. * @see http://doc.babylonjs.com/features/behaviour
  109306. */
  109307. get behaviors(): Behavior<Node>[];
  109308. /**
  109309. * Gets an attached behavior by name
  109310. * @param name defines the name of the behavior to look for
  109311. * @see http://doc.babylonjs.com/features/behaviour
  109312. * @returns null if behavior was not found else the requested behavior
  109313. */
  109314. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  109315. /**
  109316. * Returns the latest update of the World matrix
  109317. * @returns a Matrix
  109318. */
  109319. getWorldMatrix(): Matrix;
  109320. /** @hidden */
  109321. _getWorldMatrixDeterminant(): number;
  109322. /**
  109323. * Returns directly the latest state of the mesh World matrix.
  109324. * A Matrix is returned.
  109325. */
  109326. get worldMatrixFromCache(): Matrix;
  109327. /** @hidden */
  109328. _initCache(): void;
  109329. /** @hidden */
  109330. updateCache(force?: boolean): void;
  109331. /** @hidden */
  109332. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  109333. /** @hidden */
  109334. _updateCache(ignoreParentClass?: boolean): void;
  109335. /** @hidden */
  109336. _isSynchronized(): boolean;
  109337. /** @hidden */
  109338. _markSyncedWithParent(): void;
  109339. /** @hidden */
  109340. isSynchronizedWithParent(): boolean;
  109341. /** @hidden */
  109342. isSynchronized(): boolean;
  109343. /**
  109344. * Is this node ready to be used/rendered
  109345. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  109346. * @return true if the node is ready
  109347. */
  109348. isReady(completeCheck?: boolean): boolean;
  109349. /**
  109350. * Is this node enabled?
  109351. * 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
  109352. * @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
  109353. * @return whether this node (and its parent) is enabled
  109354. */
  109355. isEnabled(checkAncestors?: boolean): boolean;
  109356. /** @hidden */
  109357. protected _syncParentEnabledState(): void;
  109358. /**
  109359. * Set the enabled state of this node
  109360. * @param value defines the new enabled state
  109361. */
  109362. setEnabled(value: boolean): void;
  109363. /**
  109364. * Is this node a descendant of the given node?
  109365. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  109366. * @param ancestor defines the parent node to inspect
  109367. * @returns a boolean indicating if this node is a descendant of the given node
  109368. */
  109369. isDescendantOf(ancestor: Node): boolean;
  109370. /** @hidden */
  109371. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  109372. /**
  109373. * Will return all nodes that have this node as ascendant
  109374. * @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
  109375. * @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
  109376. * @return all children nodes of all types
  109377. */
  109378. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  109379. /**
  109380. * Get all child-meshes of this node
  109381. * @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)
  109382. * @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
  109383. * @returns an array of AbstractMesh
  109384. */
  109385. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  109386. /**
  109387. * Get all direct children of this node
  109388. * @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
  109389. * @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)
  109390. * @returns an array of Node
  109391. */
  109392. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  109393. /** @hidden */
  109394. _setReady(state: boolean): void;
  109395. /**
  109396. * Get an animation by name
  109397. * @param name defines the name of the animation to look for
  109398. * @returns null if not found else the requested animation
  109399. */
  109400. getAnimationByName(name: string): Nullable<Animation>;
  109401. /**
  109402. * Creates an animation range for this node
  109403. * @param name defines the name of the range
  109404. * @param from defines the starting key
  109405. * @param to defines the end key
  109406. */
  109407. createAnimationRange(name: string, from: number, to: number): void;
  109408. /**
  109409. * Delete a specific animation range
  109410. * @param name defines the name of the range to delete
  109411. * @param deleteFrames defines if animation frames from the range must be deleted as well
  109412. */
  109413. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  109414. /**
  109415. * Get an animation range by name
  109416. * @param name defines the name of the animation range to look for
  109417. * @returns null if not found else the requested animation range
  109418. */
  109419. getAnimationRange(name: string): Nullable<AnimationRange>;
  109420. /**
  109421. * Gets the list of all animation ranges defined on this node
  109422. * @returns an array
  109423. */
  109424. getAnimationRanges(): Nullable<AnimationRange>[];
  109425. /**
  109426. * Will start the animation sequence
  109427. * @param name defines the range frames for animation sequence
  109428. * @param loop defines if the animation should loop (false by default)
  109429. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  109430. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  109431. * @returns the object created for this animation. If range does not exist, it will return null
  109432. */
  109433. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  109434. /**
  109435. * Serialize animation ranges into a JSON compatible object
  109436. * @returns serialization object
  109437. */
  109438. serializeAnimationRanges(): any;
  109439. /**
  109440. * Computes the world matrix of the node
  109441. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  109442. * @returns the world matrix
  109443. */
  109444. computeWorldMatrix(force?: boolean): Matrix;
  109445. /**
  109446. * Releases resources associated with this node.
  109447. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109448. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109449. */
  109450. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109451. /**
  109452. * Parse animation range data from a serialization object and store them into a given node
  109453. * @param node defines where to store the animation ranges
  109454. * @param parsedNode defines the serialization object to read data from
  109455. * @param scene defines the hosting scene
  109456. */
  109457. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  109458. /**
  109459. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  109460. * @param includeDescendants Include bounding info from descendants as well (true by default)
  109461. * @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
  109462. * @returns the new bounding vectors
  109463. */
  109464. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  109465. min: Vector3;
  109466. max: Vector3;
  109467. };
  109468. }
  109469. }
  109470. declare module BABYLON {
  109471. /**
  109472. * @hidden
  109473. */
  109474. export class _IAnimationState {
  109475. key: number;
  109476. repeatCount: number;
  109477. workValue?: any;
  109478. loopMode?: number;
  109479. offsetValue?: any;
  109480. highLimitValue?: any;
  109481. }
  109482. /**
  109483. * Class used to store any kind of animation
  109484. */
  109485. export class Animation {
  109486. /**Name of the animation */
  109487. name: string;
  109488. /**Property to animate */
  109489. targetProperty: string;
  109490. /**The frames per second of the animation */
  109491. framePerSecond: number;
  109492. /**The data type of the animation */
  109493. dataType: number;
  109494. /**The loop mode of the animation */
  109495. loopMode?: number | undefined;
  109496. /**Specifies if blending should be enabled */
  109497. enableBlending?: boolean | undefined;
  109498. /**
  109499. * Use matrix interpolation instead of using direct key value when animating matrices
  109500. */
  109501. static AllowMatricesInterpolation: boolean;
  109502. /**
  109503. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  109504. */
  109505. static AllowMatrixDecomposeForInterpolation: boolean;
  109506. /**
  109507. * Stores the key frames of the animation
  109508. */
  109509. private _keys;
  109510. /**
  109511. * Stores the easing function of the animation
  109512. */
  109513. private _easingFunction;
  109514. /**
  109515. * @hidden Internal use only
  109516. */
  109517. _runtimeAnimations: RuntimeAnimation[];
  109518. /**
  109519. * The set of event that will be linked to this animation
  109520. */
  109521. private _events;
  109522. /**
  109523. * Stores an array of target property paths
  109524. */
  109525. targetPropertyPath: string[];
  109526. /**
  109527. * Stores the blending speed of the animation
  109528. */
  109529. blendingSpeed: number;
  109530. /**
  109531. * Stores the animation ranges for the animation
  109532. */
  109533. private _ranges;
  109534. /**
  109535. * @hidden Internal use
  109536. */
  109537. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  109538. /**
  109539. * Sets up an animation
  109540. * @param property The property to animate
  109541. * @param animationType The animation type to apply
  109542. * @param framePerSecond The frames per second of the animation
  109543. * @param easingFunction The easing function used in the animation
  109544. * @returns The created animation
  109545. */
  109546. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  109547. /**
  109548. * Create and start an animation on a node
  109549. * @param name defines the name of the global animation that will be run on all nodes
  109550. * @param node defines the root node where the animation will take place
  109551. * @param targetProperty defines property to animate
  109552. * @param framePerSecond defines the number of frame per second yo use
  109553. * @param totalFrame defines the number of frames in total
  109554. * @param from defines the initial value
  109555. * @param to defines the final value
  109556. * @param loopMode defines which loop mode you want to use (off by default)
  109557. * @param easingFunction defines the easing function to use (linear by default)
  109558. * @param onAnimationEnd defines the callback to call when animation end
  109559. * @returns the animatable created for this animation
  109560. */
  109561. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  109562. /**
  109563. * Create and start an animation on a node and its descendants
  109564. * @param name defines the name of the global animation that will be run on all nodes
  109565. * @param node defines the root node where the animation will take place
  109566. * @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
  109567. * @param targetProperty defines property to animate
  109568. * @param framePerSecond defines the number of frame per second to use
  109569. * @param totalFrame defines the number of frames in total
  109570. * @param from defines the initial value
  109571. * @param to defines the final value
  109572. * @param loopMode defines which loop mode you want to use (off by default)
  109573. * @param easingFunction defines the easing function to use (linear by default)
  109574. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  109575. * @returns the list of animatables created for all nodes
  109576. * @example https://www.babylonjs-playground.com/#MH0VLI
  109577. */
  109578. 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[]>;
  109579. /**
  109580. * Creates a new animation, merges it with the existing animations and starts it
  109581. * @param name Name of the animation
  109582. * @param node Node which contains the scene that begins the animations
  109583. * @param targetProperty Specifies which property to animate
  109584. * @param framePerSecond The frames per second of the animation
  109585. * @param totalFrame The total number of frames
  109586. * @param from The frame at the beginning of the animation
  109587. * @param to The frame at the end of the animation
  109588. * @param loopMode Specifies the loop mode of the animation
  109589. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  109590. * @param onAnimationEnd Callback to run once the animation is complete
  109591. * @returns Nullable animation
  109592. */
  109593. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  109594. /**
  109595. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  109596. * @param sourceAnimation defines the Animation containing keyframes to convert
  109597. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  109598. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  109599. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  109600. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  109601. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  109602. */
  109603. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  109604. /**
  109605. * Transition property of an host to the target Value
  109606. * @param property The property to transition
  109607. * @param targetValue The target Value of the property
  109608. * @param host The object where the property to animate belongs
  109609. * @param scene Scene used to run the animation
  109610. * @param frameRate Framerate (in frame/s) to use
  109611. * @param transition The transition type we want to use
  109612. * @param duration The duration of the animation, in milliseconds
  109613. * @param onAnimationEnd Callback trigger at the end of the animation
  109614. * @returns Nullable animation
  109615. */
  109616. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  109617. /**
  109618. * Return the array of runtime animations currently using this animation
  109619. */
  109620. get runtimeAnimations(): RuntimeAnimation[];
  109621. /**
  109622. * Specifies if any of the runtime animations are currently running
  109623. */
  109624. get hasRunningRuntimeAnimations(): boolean;
  109625. /**
  109626. * Initializes the animation
  109627. * @param name Name of the animation
  109628. * @param targetProperty Property to animate
  109629. * @param framePerSecond The frames per second of the animation
  109630. * @param dataType The data type of the animation
  109631. * @param loopMode The loop mode of the animation
  109632. * @param enableBlending Specifies if blending should be enabled
  109633. */
  109634. constructor(
  109635. /**Name of the animation */
  109636. name: string,
  109637. /**Property to animate */
  109638. targetProperty: string,
  109639. /**The frames per second of the animation */
  109640. framePerSecond: number,
  109641. /**The data type of the animation */
  109642. dataType: number,
  109643. /**The loop mode of the animation */
  109644. loopMode?: number | undefined,
  109645. /**Specifies if blending should be enabled */
  109646. enableBlending?: boolean | undefined);
  109647. /**
  109648. * Converts the animation to a string
  109649. * @param fullDetails support for multiple levels of logging within scene loading
  109650. * @returns String form of the animation
  109651. */
  109652. toString(fullDetails?: boolean): string;
  109653. /**
  109654. * Add an event to this animation
  109655. * @param event Event to add
  109656. */
  109657. addEvent(event: AnimationEvent): void;
  109658. /**
  109659. * Remove all events found at the given frame
  109660. * @param frame The frame to remove events from
  109661. */
  109662. removeEvents(frame: number): void;
  109663. /**
  109664. * Retrieves all the events from the animation
  109665. * @returns Events from the animation
  109666. */
  109667. getEvents(): AnimationEvent[];
  109668. /**
  109669. * Creates an animation range
  109670. * @param name Name of the animation range
  109671. * @param from Starting frame of the animation range
  109672. * @param to Ending frame of the animation
  109673. */
  109674. createRange(name: string, from: number, to: number): void;
  109675. /**
  109676. * Deletes an animation range by name
  109677. * @param name Name of the animation range to delete
  109678. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  109679. */
  109680. deleteRange(name: string, deleteFrames?: boolean): void;
  109681. /**
  109682. * Gets the animation range by name, or null if not defined
  109683. * @param name Name of the animation range
  109684. * @returns Nullable animation range
  109685. */
  109686. getRange(name: string): Nullable<AnimationRange>;
  109687. /**
  109688. * Gets the key frames from the animation
  109689. * @returns The key frames of the animation
  109690. */
  109691. getKeys(): Array<IAnimationKey>;
  109692. /**
  109693. * Gets the highest frame rate of the animation
  109694. * @returns Highest frame rate of the animation
  109695. */
  109696. getHighestFrame(): number;
  109697. /**
  109698. * Gets the easing function of the animation
  109699. * @returns Easing function of the animation
  109700. */
  109701. getEasingFunction(): IEasingFunction;
  109702. /**
  109703. * Sets the easing function of the animation
  109704. * @param easingFunction A custom mathematical formula for animation
  109705. */
  109706. setEasingFunction(easingFunction: EasingFunction): void;
  109707. /**
  109708. * Interpolates a scalar linearly
  109709. * @param startValue Start value of the animation curve
  109710. * @param endValue End value of the animation curve
  109711. * @param gradient Scalar amount to interpolate
  109712. * @returns Interpolated scalar value
  109713. */
  109714. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  109715. /**
  109716. * Interpolates a scalar cubically
  109717. * @param startValue Start value of the animation curve
  109718. * @param outTangent End tangent of the animation
  109719. * @param endValue End value of the animation curve
  109720. * @param inTangent Start tangent of the animation curve
  109721. * @param gradient Scalar amount to interpolate
  109722. * @returns Interpolated scalar value
  109723. */
  109724. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  109725. /**
  109726. * Interpolates a quaternion using a spherical linear interpolation
  109727. * @param startValue Start value of the animation curve
  109728. * @param endValue End value of the animation curve
  109729. * @param gradient Scalar amount to interpolate
  109730. * @returns Interpolated quaternion value
  109731. */
  109732. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  109733. /**
  109734. * Interpolates a quaternion cubically
  109735. * @param startValue Start value of the animation curve
  109736. * @param outTangent End tangent of the animation curve
  109737. * @param endValue End value of the animation curve
  109738. * @param inTangent Start tangent of the animation curve
  109739. * @param gradient Scalar amount to interpolate
  109740. * @returns Interpolated quaternion value
  109741. */
  109742. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  109743. /**
  109744. * Interpolates a Vector3 linearl
  109745. * @param startValue Start value of the animation curve
  109746. * @param endValue End value of the animation curve
  109747. * @param gradient Scalar amount to interpolate
  109748. * @returns Interpolated scalar value
  109749. */
  109750. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  109751. /**
  109752. * Interpolates a Vector3 cubically
  109753. * @param startValue Start value of the animation curve
  109754. * @param outTangent End tangent of the animation
  109755. * @param endValue End value of the animation curve
  109756. * @param inTangent Start tangent of the animation curve
  109757. * @param gradient Scalar amount to interpolate
  109758. * @returns InterpolatedVector3 value
  109759. */
  109760. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  109761. /**
  109762. * Interpolates a Vector2 linearly
  109763. * @param startValue Start value of the animation curve
  109764. * @param endValue End value of the animation curve
  109765. * @param gradient Scalar amount to interpolate
  109766. * @returns Interpolated Vector2 value
  109767. */
  109768. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  109769. /**
  109770. * Interpolates a Vector2 cubically
  109771. * @param startValue Start value of the animation curve
  109772. * @param outTangent End tangent of the animation
  109773. * @param endValue End value of the animation curve
  109774. * @param inTangent Start tangent of the animation curve
  109775. * @param gradient Scalar amount to interpolate
  109776. * @returns Interpolated Vector2 value
  109777. */
  109778. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  109779. /**
  109780. * Interpolates a size linearly
  109781. * @param startValue Start value of the animation curve
  109782. * @param endValue End value of the animation curve
  109783. * @param gradient Scalar amount to interpolate
  109784. * @returns Interpolated Size value
  109785. */
  109786. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  109787. /**
  109788. * Interpolates a Color3 linearly
  109789. * @param startValue Start value of the animation curve
  109790. * @param endValue End value of the animation curve
  109791. * @param gradient Scalar amount to interpolate
  109792. * @returns Interpolated Color3 value
  109793. */
  109794. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  109795. /**
  109796. * Interpolates a Color4 linearly
  109797. * @param startValue Start value of the animation curve
  109798. * @param endValue End value of the animation curve
  109799. * @param gradient Scalar amount to interpolate
  109800. * @returns Interpolated Color3 value
  109801. */
  109802. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  109803. /**
  109804. * @hidden Internal use only
  109805. */
  109806. _getKeyValue(value: any): any;
  109807. /**
  109808. * @hidden Internal use only
  109809. */
  109810. _interpolate(currentFrame: number, state: _IAnimationState): any;
  109811. /**
  109812. * Defines the function to use to interpolate matrices
  109813. * @param startValue defines the start matrix
  109814. * @param endValue defines the end matrix
  109815. * @param gradient defines the gradient between both matrices
  109816. * @param result defines an optional target matrix where to store the interpolation
  109817. * @returns the interpolated matrix
  109818. */
  109819. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  109820. /**
  109821. * Makes a copy of the animation
  109822. * @returns Cloned animation
  109823. */
  109824. clone(): Animation;
  109825. /**
  109826. * Sets the key frames of the animation
  109827. * @param values The animation key frames to set
  109828. */
  109829. setKeys(values: Array<IAnimationKey>): void;
  109830. /**
  109831. * Serializes the animation to an object
  109832. * @returns Serialized object
  109833. */
  109834. serialize(): any;
  109835. /**
  109836. * Float animation type
  109837. */
  109838. static readonly ANIMATIONTYPE_FLOAT: number;
  109839. /**
  109840. * Vector3 animation type
  109841. */
  109842. static readonly ANIMATIONTYPE_VECTOR3: number;
  109843. /**
  109844. * Quaternion animation type
  109845. */
  109846. static readonly ANIMATIONTYPE_QUATERNION: number;
  109847. /**
  109848. * Matrix animation type
  109849. */
  109850. static readonly ANIMATIONTYPE_MATRIX: number;
  109851. /**
  109852. * Color3 animation type
  109853. */
  109854. static readonly ANIMATIONTYPE_COLOR3: number;
  109855. /**
  109856. * Color3 animation type
  109857. */
  109858. static readonly ANIMATIONTYPE_COLOR4: number;
  109859. /**
  109860. * Vector2 animation type
  109861. */
  109862. static readonly ANIMATIONTYPE_VECTOR2: number;
  109863. /**
  109864. * Size animation type
  109865. */
  109866. static readonly ANIMATIONTYPE_SIZE: number;
  109867. /**
  109868. * Relative Loop Mode
  109869. */
  109870. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  109871. /**
  109872. * Cycle Loop Mode
  109873. */
  109874. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  109875. /**
  109876. * Constant Loop Mode
  109877. */
  109878. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  109879. /** @hidden */
  109880. static _UniversalLerp(left: any, right: any, amount: number): any;
  109881. /**
  109882. * Parses an animation object and creates an animation
  109883. * @param parsedAnimation Parsed animation object
  109884. * @returns Animation object
  109885. */
  109886. static Parse(parsedAnimation: any): Animation;
  109887. /**
  109888. * Appends the serialized animations from the source animations
  109889. * @param source Source containing the animations
  109890. * @param destination Target to store the animations
  109891. */
  109892. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  109893. }
  109894. }
  109895. declare module BABYLON {
  109896. /**
  109897. * Interface containing an array of animations
  109898. */
  109899. export interface IAnimatable {
  109900. /**
  109901. * Array of animations
  109902. */
  109903. animations: Nullable<Array<Animation>>;
  109904. }
  109905. }
  109906. declare module BABYLON {
  109907. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  109908. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109909. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109910. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109911. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109912. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109913. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109914. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109915. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109916. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109917. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109918. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109919. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109920. /**
  109921. * Decorator used to define property that can be serialized as reference to a camera
  109922. * @param sourceName defines the name of the property to decorate
  109923. */
  109924. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109925. /**
  109926. * Class used to help serialization objects
  109927. */
  109928. export class SerializationHelper {
  109929. /** @hidden */
  109930. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  109931. /** @hidden */
  109932. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  109933. /** @hidden */
  109934. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  109935. /** @hidden */
  109936. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  109937. /**
  109938. * Appends the serialized animations from the source animations
  109939. * @param source Source containing the animations
  109940. * @param destination Target to store the animations
  109941. */
  109942. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  109943. /**
  109944. * Static function used to serialized a specific entity
  109945. * @param entity defines the entity to serialize
  109946. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  109947. * @returns a JSON compatible object representing the serialization of the entity
  109948. */
  109949. static Serialize<T>(entity: T, serializationObject?: any): any;
  109950. /**
  109951. * Creates a new entity from a serialization data object
  109952. * @param creationFunction defines a function used to instanciated the new entity
  109953. * @param source defines the source serialization data
  109954. * @param scene defines the hosting scene
  109955. * @param rootUrl defines the root url for resources
  109956. * @returns a new entity
  109957. */
  109958. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  109959. /**
  109960. * Clones an object
  109961. * @param creationFunction defines the function used to instanciate the new object
  109962. * @param source defines the source object
  109963. * @returns the cloned object
  109964. */
  109965. static Clone<T>(creationFunction: () => T, source: T): T;
  109966. /**
  109967. * Instanciates a new object based on a source one (some data will be shared between both object)
  109968. * @param creationFunction defines the function used to instanciate the new object
  109969. * @param source defines the source object
  109970. * @returns the new object
  109971. */
  109972. static Instanciate<T>(creationFunction: () => T, source: T): T;
  109973. }
  109974. }
  109975. declare module BABYLON {
  109976. /**
  109977. * Base class of all the textures in babylon.
  109978. * It groups all the common properties the materials, post process, lights... might need
  109979. * in order to make a correct use of the texture.
  109980. */
  109981. export class BaseTexture implements IAnimatable {
  109982. /**
  109983. * Default anisotropic filtering level for the application.
  109984. * It is set to 4 as a good tradeoff between perf and quality.
  109985. */
  109986. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  109987. /**
  109988. * Gets or sets the unique id of the texture
  109989. */
  109990. uniqueId: number;
  109991. /**
  109992. * Define the name of the texture.
  109993. */
  109994. name: string;
  109995. /**
  109996. * Gets or sets an object used to store user defined information.
  109997. */
  109998. metadata: any;
  109999. /**
  110000. * For internal use only. Please do not use.
  110001. */
  110002. reservedDataStore: any;
  110003. private _hasAlpha;
  110004. /**
  110005. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  110006. */
  110007. set hasAlpha(value: boolean);
  110008. get hasAlpha(): boolean;
  110009. /**
  110010. * Defines if the alpha value should be determined via the rgb values.
  110011. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  110012. */
  110013. getAlphaFromRGB: boolean;
  110014. /**
  110015. * Intensity or strength of the texture.
  110016. * It is commonly used by materials to fine tune the intensity of the texture
  110017. */
  110018. level: number;
  110019. /**
  110020. * Define the UV chanel to use starting from 0 and defaulting to 0.
  110021. * This is part of the texture as textures usually maps to one uv set.
  110022. */
  110023. coordinatesIndex: number;
  110024. private _coordinatesMode;
  110025. /**
  110026. * How a texture is mapped.
  110027. *
  110028. * | Value | Type | Description |
  110029. * | ----- | ----------------------------------- | ----------- |
  110030. * | 0 | EXPLICIT_MODE | |
  110031. * | 1 | SPHERICAL_MODE | |
  110032. * | 2 | PLANAR_MODE | |
  110033. * | 3 | CUBIC_MODE | |
  110034. * | 4 | PROJECTION_MODE | |
  110035. * | 5 | SKYBOX_MODE | |
  110036. * | 6 | INVCUBIC_MODE | |
  110037. * | 7 | EQUIRECTANGULAR_MODE | |
  110038. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  110039. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  110040. */
  110041. set coordinatesMode(value: number);
  110042. get coordinatesMode(): number;
  110043. /**
  110044. * | Value | Type | Description |
  110045. * | ----- | ------------------ | ----------- |
  110046. * | 0 | CLAMP_ADDRESSMODE | |
  110047. * | 1 | WRAP_ADDRESSMODE | |
  110048. * | 2 | MIRROR_ADDRESSMODE | |
  110049. */
  110050. wrapU: number;
  110051. /**
  110052. * | Value | Type | Description |
  110053. * | ----- | ------------------ | ----------- |
  110054. * | 0 | CLAMP_ADDRESSMODE | |
  110055. * | 1 | WRAP_ADDRESSMODE | |
  110056. * | 2 | MIRROR_ADDRESSMODE | |
  110057. */
  110058. wrapV: number;
  110059. /**
  110060. * | Value | Type | Description |
  110061. * | ----- | ------------------ | ----------- |
  110062. * | 0 | CLAMP_ADDRESSMODE | |
  110063. * | 1 | WRAP_ADDRESSMODE | |
  110064. * | 2 | MIRROR_ADDRESSMODE | |
  110065. */
  110066. wrapR: number;
  110067. /**
  110068. * With compliant hardware and browser (supporting anisotropic filtering)
  110069. * this defines the level of anisotropic filtering in the texture.
  110070. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  110071. */
  110072. anisotropicFilteringLevel: number;
  110073. /**
  110074. * Define if the texture is a cube texture or if false a 2d texture.
  110075. */
  110076. get isCube(): boolean;
  110077. set isCube(value: boolean);
  110078. /**
  110079. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  110080. */
  110081. get is3D(): boolean;
  110082. set is3D(value: boolean);
  110083. /**
  110084. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  110085. */
  110086. get is2DArray(): boolean;
  110087. set is2DArray(value: boolean);
  110088. /**
  110089. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  110090. * HDR texture are usually stored in linear space.
  110091. * This only impacts the PBR and Background materials
  110092. */
  110093. gammaSpace: boolean;
  110094. /**
  110095. * Gets or sets whether or not the texture contains RGBD data.
  110096. */
  110097. get isRGBD(): boolean;
  110098. set isRGBD(value: boolean);
  110099. /**
  110100. * Is Z inverted in the texture (useful in a cube texture).
  110101. */
  110102. invertZ: boolean;
  110103. /**
  110104. * Are mip maps generated for this texture or not.
  110105. */
  110106. get noMipmap(): boolean;
  110107. /**
  110108. * @hidden
  110109. */
  110110. lodLevelInAlpha: boolean;
  110111. /**
  110112. * With prefiltered texture, defined the offset used during the prefiltering steps.
  110113. */
  110114. get lodGenerationOffset(): number;
  110115. set lodGenerationOffset(value: number);
  110116. /**
  110117. * With prefiltered texture, defined the scale used during the prefiltering steps.
  110118. */
  110119. get lodGenerationScale(): number;
  110120. set lodGenerationScale(value: number);
  110121. /**
  110122. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  110123. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  110124. * average roughness values.
  110125. */
  110126. get linearSpecularLOD(): boolean;
  110127. set linearSpecularLOD(value: boolean);
  110128. /**
  110129. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  110130. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  110131. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  110132. */
  110133. get irradianceTexture(): Nullable<BaseTexture>;
  110134. set irradianceTexture(value: Nullable<BaseTexture>);
  110135. /**
  110136. * Define if the texture is a render target.
  110137. */
  110138. isRenderTarget: boolean;
  110139. /**
  110140. * Define the unique id of the texture in the scene.
  110141. */
  110142. get uid(): string;
  110143. /** @hidden */
  110144. _prefiltered: boolean;
  110145. /**
  110146. * Return a string representation of the texture.
  110147. * @returns the texture as a string
  110148. */
  110149. toString(): string;
  110150. /**
  110151. * Get the class name of the texture.
  110152. * @returns "BaseTexture"
  110153. */
  110154. getClassName(): string;
  110155. /**
  110156. * Define the list of animation attached to the texture.
  110157. */
  110158. animations: Animation[];
  110159. /**
  110160. * An event triggered when the texture is disposed.
  110161. */
  110162. onDisposeObservable: Observable<BaseTexture>;
  110163. private _onDisposeObserver;
  110164. /**
  110165. * Callback triggered when the texture has been disposed.
  110166. * Kept for back compatibility, you can use the onDisposeObservable instead.
  110167. */
  110168. set onDispose(callback: () => void);
  110169. /**
  110170. * Define the current state of the loading sequence when in delayed load mode.
  110171. */
  110172. delayLoadState: number;
  110173. private _scene;
  110174. private _engine;
  110175. /** @hidden */
  110176. _texture: Nullable<InternalTexture>;
  110177. private _uid;
  110178. /**
  110179. * Define if the texture is preventinga material to render or not.
  110180. * If not and the texture is not ready, the engine will use a default black texture instead.
  110181. */
  110182. get isBlocking(): boolean;
  110183. /**
  110184. * Instantiates a new BaseTexture.
  110185. * Base class of all the textures in babylon.
  110186. * It groups all the common properties the materials, post process, lights... might need
  110187. * in order to make a correct use of the texture.
  110188. * @param sceneOrEngine Define the scene or engine the texture blongs to
  110189. */
  110190. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  110191. /**
  110192. * Get the scene the texture belongs to.
  110193. * @returns the scene or null if undefined
  110194. */
  110195. getScene(): Nullable<Scene>;
  110196. /** @hidden */
  110197. protected _getEngine(): Nullable<ThinEngine>;
  110198. /**
  110199. * Get the texture transform matrix used to offset tile the texture for istance.
  110200. * @returns the transformation matrix
  110201. */
  110202. getTextureMatrix(): Matrix;
  110203. /**
  110204. * Get the texture reflection matrix used to rotate/transform the reflection.
  110205. * @returns the reflection matrix
  110206. */
  110207. getReflectionTextureMatrix(): Matrix;
  110208. /**
  110209. * Get the underlying lower level texture from Babylon.
  110210. * @returns the insternal texture
  110211. */
  110212. getInternalTexture(): Nullable<InternalTexture>;
  110213. /**
  110214. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  110215. * @returns true if ready or not blocking
  110216. */
  110217. isReadyOrNotBlocking(): boolean;
  110218. /**
  110219. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  110220. * @returns true if fully ready
  110221. */
  110222. isReady(): boolean;
  110223. private _cachedSize;
  110224. /**
  110225. * Get the size of the texture.
  110226. * @returns the texture size.
  110227. */
  110228. getSize(): ISize;
  110229. /**
  110230. * Get the base size of the texture.
  110231. * It can be different from the size if the texture has been resized for POT for instance
  110232. * @returns the base size
  110233. */
  110234. getBaseSize(): ISize;
  110235. /**
  110236. * Update the sampling mode of the texture.
  110237. * Default is Trilinear mode.
  110238. *
  110239. * | Value | Type | Description |
  110240. * | ----- | ------------------ | ----------- |
  110241. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  110242. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  110243. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  110244. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  110245. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  110246. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  110247. * | 7 | NEAREST_LINEAR | |
  110248. * | 8 | NEAREST_NEAREST | |
  110249. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  110250. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  110251. * | 11 | LINEAR_LINEAR | |
  110252. * | 12 | LINEAR_NEAREST | |
  110253. *
  110254. * > _mag_: magnification filter (close to the viewer)
  110255. * > _min_: minification filter (far from the viewer)
  110256. * > _mip_: filter used between mip map levels
  110257. *@param samplingMode Define the new sampling mode of the texture
  110258. */
  110259. updateSamplingMode(samplingMode: number): void;
  110260. /**
  110261. * Scales the texture if is `canRescale()`
  110262. * @param ratio the resize factor we want to use to rescale
  110263. */
  110264. scale(ratio: number): void;
  110265. /**
  110266. * Get if the texture can rescale.
  110267. */
  110268. get canRescale(): boolean;
  110269. /** @hidden */
  110270. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  110271. /** @hidden */
  110272. _rebuild(): void;
  110273. /**
  110274. * Triggers the load sequence in delayed load mode.
  110275. */
  110276. delayLoad(): void;
  110277. /**
  110278. * Clones the texture.
  110279. * @returns the cloned texture
  110280. */
  110281. clone(): Nullable<BaseTexture>;
  110282. /**
  110283. * Get the texture underlying type (INT, FLOAT...)
  110284. */
  110285. get textureType(): number;
  110286. /**
  110287. * Get the texture underlying format (RGB, RGBA...)
  110288. */
  110289. get textureFormat(): number;
  110290. /**
  110291. * Indicates that textures need to be re-calculated for all materials
  110292. */
  110293. protected _markAllSubMeshesAsTexturesDirty(): void;
  110294. /**
  110295. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  110296. * This will returns an RGBA array buffer containing either in values (0-255) or
  110297. * float values (0-1) depending of the underlying buffer type.
  110298. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  110299. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  110300. * @param buffer defines a user defined buffer to fill with data (can be null)
  110301. * @returns The Array buffer containing the pixels data.
  110302. */
  110303. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  110304. /**
  110305. * Release and destroy the underlying lower level texture aka internalTexture.
  110306. */
  110307. releaseInternalTexture(): void;
  110308. /** @hidden */
  110309. get _lodTextureHigh(): Nullable<BaseTexture>;
  110310. /** @hidden */
  110311. get _lodTextureMid(): Nullable<BaseTexture>;
  110312. /** @hidden */
  110313. get _lodTextureLow(): Nullable<BaseTexture>;
  110314. /**
  110315. * Dispose the texture and release its associated resources.
  110316. */
  110317. dispose(): void;
  110318. /**
  110319. * Serialize the texture into a JSON representation that can be parsed later on.
  110320. * @returns the JSON representation of the texture
  110321. */
  110322. serialize(): any;
  110323. /**
  110324. * Helper function to be called back once a list of texture contains only ready textures.
  110325. * @param textures Define the list of textures to wait for
  110326. * @param callback Define the callback triggered once the entire list will be ready
  110327. */
  110328. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  110329. private static _isScene;
  110330. }
  110331. }
  110332. declare module BABYLON {
  110333. /**
  110334. * Options to be used when creating an effect.
  110335. */
  110336. export interface IEffectCreationOptions {
  110337. /**
  110338. * Atrributes that will be used in the shader.
  110339. */
  110340. attributes: string[];
  110341. /**
  110342. * Uniform varible names that will be set in the shader.
  110343. */
  110344. uniformsNames: string[];
  110345. /**
  110346. * Uniform buffer variable names that will be set in the shader.
  110347. */
  110348. uniformBuffersNames: string[];
  110349. /**
  110350. * Sampler texture variable names that will be set in the shader.
  110351. */
  110352. samplers: string[];
  110353. /**
  110354. * Define statements that will be set in the shader.
  110355. */
  110356. defines: any;
  110357. /**
  110358. * Possible fallbacks for this effect to improve performance when needed.
  110359. */
  110360. fallbacks: Nullable<IEffectFallbacks>;
  110361. /**
  110362. * Callback that will be called when the shader is compiled.
  110363. */
  110364. onCompiled: Nullable<(effect: Effect) => void>;
  110365. /**
  110366. * Callback that will be called if an error occurs during shader compilation.
  110367. */
  110368. onError: Nullable<(effect: Effect, errors: string) => void>;
  110369. /**
  110370. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  110371. */
  110372. indexParameters?: any;
  110373. /**
  110374. * Max number of lights that can be used in the shader.
  110375. */
  110376. maxSimultaneousLights?: number;
  110377. /**
  110378. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  110379. */
  110380. transformFeedbackVaryings?: Nullable<string[]>;
  110381. /**
  110382. * 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
  110383. */
  110384. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  110385. }
  110386. /**
  110387. * Effect containing vertex and fragment shader that can be executed on an object.
  110388. */
  110389. export class Effect implements IDisposable {
  110390. /**
  110391. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  110392. */
  110393. static ShadersRepository: string;
  110394. /**
  110395. * Enable logging of the shader code when a compilation error occurs
  110396. */
  110397. static LogShaderCodeOnCompilationError: boolean;
  110398. /**
  110399. * Name of the effect.
  110400. */
  110401. name: any;
  110402. /**
  110403. * String container all the define statements that should be set on the shader.
  110404. */
  110405. defines: string;
  110406. /**
  110407. * Callback that will be called when the shader is compiled.
  110408. */
  110409. onCompiled: Nullable<(effect: Effect) => void>;
  110410. /**
  110411. * Callback that will be called if an error occurs during shader compilation.
  110412. */
  110413. onError: Nullable<(effect: Effect, errors: string) => void>;
  110414. /**
  110415. * Callback that will be called when effect is bound.
  110416. */
  110417. onBind: Nullable<(effect: Effect) => void>;
  110418. /**
  110419. * Unique ID of the effect.
  110420. */
  110421. uniqueId: number;
  110422. /**
  110423. * Observable that will be called when the shader is compiled.
  110424. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  110425. */
  110426. onCompileObservable: Observable<Effect>;
  110427. /**
  110428. * Observable that will be called if an error occurs during shader compilation.
  110429. */
  110430. onErrorObservable: Observable<Effect>;
  110431. /** @hidden */
  110432. _onBindObservable: Nullable<Observable<Effect>>;
  110433. /**
  110434. * @hidden
  110435. * Specifies if the effect was previously ready
  110436. */
  110437. _wasPreviouslyReady: boolean;
  110438. /**
  110439. * Observable that will be called when effect is bound.
  110440. */
  110441. get onBindObservable(): Observable<Effect>;
  110442. /** @hidden */
  110443. _bonesComputationForcedToCPU: boolean;
  110444. private static _uniqueIdSeed;
  110445. private _engine;
  110446. private _uniformBuffersNames;
  110447. private _uniformBuffersNamesList;
  110448. private _uniformsNames;
  110449. private _samplerList;
  110450. private _samplers;
  110451. private _isReady;
  110452. private _compilationError;
  110453. private _allFallbacksProcessed;
  110454. private _attributesNames;
  110455. private _attributes;
  110456. private _attributeLocationByName;
  110457. private _uniforms;
  110458. /**
  110459. * Key for the effect.
  110460. * @hidden
  110461. */
  110462. _key: string;
  110463. private _indexParameters;
  110464. private _fallbacks;
  110465. private _vertexSourceCode;
  110466. private _fragmentSourceCode;
  110467. private _vertexSourceCodeOverride;
  110468. private _fragmentSourceCodeOverride;
  110469. private _transformFeedbackVaryings;
  110470. /**
  110471. * Compiled shader to webGL program.
  110472. * @hidden
  110473. */
  110474. _pipelineContext: Nullable<IPipelineContext>;
  110475. private _valueCache;
  110476. private static _baseCache;
  110477. /**
  110478. * Instantiates an effect.
  110479. * An effect can be used to create/manage/execute vertex and fragment shaders.
  110480. * @param baseName Name of the effect.
  110481. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  110482. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  110483. * @param samplers List of sampler variables that will be passed to the shader.
  110484. * @param engine Engine to be used to render the effect
  110485. * @param defines Define statements to be added to the shader.
  110486. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  110487. * @param onCompiled Callback that will be called when the shader is compiled.
  110488. * @param onError Callback that will be called if an error occurs during shader compilation.
  110489. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  110490. */
  110491. 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);
  110492. private _useFinalCode;
  110493. /**
  110494. * Unique key for this effect
  110495. */
  110496. get key(): string;
  110497. /**
  110498. * If the effect has been compiled and prepared.
  110499. * @returns if the effect is compiled and prepared.
  110500. */
  110501. isReady(): boolean;
  110502. private _isReadyInternal;
  110503. /**
  110504. * The engine the effect was initialized with.
  110505. * @returns the engine.
  110506. */
  110507. getEngine(): Engine;
  110508. /**
  110509. * The pipeline context for this effect
  110510. * @returns the associated pipeline context
  110511. */
  110512. getPipelineContext(): Nullable<IPipelineContext>;
  110513. /**
  110514. * The set of names of attribute variables for the shader.
  110515. * @returns An array of attribute names.
  110516. */
  110517. getAttributesNames(): string[];
  110518. /**
  110519. * Returns the attribute at the given index.
  110520. * @param index The index of the attribute.
  110521. * @returns The location of the attribute.
  110522. */
  110523. getAttributeLocation(index: number): number;
  110524. /**
  110525. * Returns the attribute based on the name of the variable.
  110526. * @param name of the attribute to look up.
  110527. * @returns the attribute location.
  110528. */
  110529. getAttributeLocationByName(name: string): number;
  110530. /**
  110531. * The number of attributes.
  110532. * @returns the numnber of attributes.
  110533. */
  110534. getAttributesCount(): number;
  110535. /**
  110536. * Gets the index of a uniform variable.
  110537. * @param uniformName of the uniform to look up.
  110538. * @returns the index.
  110539. */
  110540. getUniformIndex(uniformName: string): number;
  110541. /**
  110542. * Returns the attribute based on the name of the variable.
  110543. * @param uniformName of the uniform to look up.
  110544. * @returns the location of the uniform.
  110545. */
  110546. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  110547. /**
  110548. * Returns an array of sampler variable names
  110549. * @returns The array of sampler variable names.
  110550. */
  110551. getSamplers(): string[];
  110552. /**
  110553. * Returns an array of uniform variable names
  110554. * @returns The array of uniform variable names.
  110555. */
  110556. getUniformNames(): string[];
  110557. /**
  110558. * Returns an array of uniform buffer variable names
  110559. * @returns The array of uniform buffer variable names.
  110560. */
  110561. getUniformBuffersNames(): string[];
  110562. /**
  110563. * Returns the index parameters used to create the effect
  110564. * @returns The index parameters object
  110565. */
  110566. getIndexParameters(): any;
  110567. /**
  110568. * The error from the last compilation.
  110569. * @returns the error string.
  110570. */
  110571. getCompilationError(): string;
  110572. /**
  110573. * Gets a boolean indicating that all fallbacks were used during compilation
  110574. * @returns true if all fallbacks were used
  110575. */
  110576. allFallbacksProcessed(): boolean;
  110577. /**
  110578. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  110579. * @param func The callback to be used.
  110580. */
  110581. executeWhenCompiled(func: (effect: Effect) => void): void;
  110582. private _checkIsReady;
  110583. private _loadShader;
  110584. /**
  110585. * Gets the vertex shader source code of this effect
  110586. */
  110587. get vertexSourceCode(): string;
  110588. /**
  110589. * Gets the fragment shader source code of this effect
  110590. */
  110591. get fragmentSourceCode(): string;
  110592. /**
  110593. * Recompiles the webGL program
  110594. * @param vertexSourceCode The source code for the vertex shader.
  110595. * @param fragmentSourceCode The source code for the fragment shader.
  110596. * @param onCompiled Callback called when completed.
  110597. * @param onError Callback called on error.
  110598. * @hidden
  110599. */
  110600. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  110601. /**
  110602. * Prepares the effect
  110603. * @hidden
  110604. */
  110605. _prepareEffect(): void;
  110606. private _getShaderCodeAndErrorLine;
  110607. private _processCompilationErrors;
  110608. /**
  110609. * Checks if the effect is supported. (Must be called after compilation)
  110610. */
  110611. get isSupported(): boolean;
  110612. /**
  110613. * Binds a texture to the engine to be used as output of the shader.
  110614. * @param channel Name of the output variable.
  110615. * @param texture Texture to bind.
  110616. * @hidden
  110617. */
  110618. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  110619. /**
  110620. * Sets a texture on the engine to be used in the shader.
  110621. * @param channel Name of the sampler variable.
  110622. * @param texture Texture to set.
  110623. */
  110624. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  110625. /**
  110626. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  110627. * @param channel Name of the sampler variable.
  110628. * @param texture Texture to set.
  110629. */
  110630. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  110631. /**
  110632. * Sets an array of textures on the engine to be used in the shader.
  110633. * @param channel Name of the variable.
  110634. * @param textures Textures to set.
  110635. */
  110636. setTextureArray(channel: string, textures: BaseTexture[]): void;
  110637. /**
  110638. * 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)
  110639. * @param channel Name of the sampler variable.
  110640. * @param postProcess Post process to get the input texture from.
  110641. */
  110642. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  110643. /**
  110644. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  110645. * 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)
  110646. * @param channel Name of the sampler variable.
  110647. * @param postProcess Post process to get the output texture from.
  110648. */
  110649. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  110650. /** @hidden */
  110651. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  110652. /** @hidden */
  110653. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  110654. /** @hidden */
  110655. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  110656. /** @hidden */
  110657. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  110658. /**
  110659. * Binds a buffer to a uniform.
  110660. * @param buffer Buffer to bind.
  110661. * @param name Name of the uniform variable to bind to.
  110662. */
  110663. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  110664. /**
  110665. * Binds block to a uniform.
  110666. * @param blockName Name of the block to bind.
  110667. * @param index Index to bind.
  110668. */
  110669. bindUniformBlock(blockName: string, index: number): void;
  110670. /**
  110671. * Sets an interger value on a uniform variable.
  110672. * @param uniformName Name of the variable.
  110673. * @param value Value to be set.
  110674. * @returns this effect.
  110675. */
  110676. setInt(uniformName: string, value: number): Effect;
  110677. /**
  110678. * Sets an int array on a uniform variable.
  110679. * @param uniformName Name of the variable.
  110680. * @param array array to be set.
  110681. * @returns this effect.
  110682. */
  110683. setIntArray(uniformName: string, array: Int32Array): Effect;
  110684. /**
  110685. * 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)
  110686. * @param uniformName Name of the variable.
  110687. * @param array array to be set.
  110688. * @returns this effect.
  110689. */
  110690. setIntArray2(uniformName: string, array: Int32Array): Effect;
  110691. /**
  110692. * 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)
  110693. * @param uniformName Name of the variable.
  110694. * @param array array to be set.
  110695. * @returns this effect.
  110696. */
  110697. setIntArray3(uniformName: string, array: Int32Array): Effect;
  110698. /**
  110699. * 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)
  110700. * @param uniformName Name of the variable.
  110701. * @param array array to be set.
  110702. * @returns this effect.
  110703. */
  110704. setIntArray4(uniformName: string, array: Int32Array): Effect;
  110705. /**
  110706. * Sets an float array on a uniform variable.
  110707. * @param uniformName Name of the variable.
  110708. * @param array array to be set.
  110709. * @returns this effect.
  110710. */
  110711. setFloatArray(uniformName: string, array: Float32Array): Effect;
  110712. /**
  110713. * 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)
  110714. * @param uniformName Name of the variable.
  110715. * @param array array to be set.
  110716. * @returns this effect.
  110717. */
  110718. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  110719. /**
  110720. * 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)
  110721. * @param uniformName Name of the variable.
  110722. * @param array array to be set.
  110723. * @returns this effect.
  110724. */
  110725. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  110726. /**
  110727. * 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)
  110728. * @param uniformName Name of the variable.
  110729. * @param array array to be set.
  110730. * @returns this effect.
  110731. */
  110732. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  110733. /**
  110734. * Sets an array on a uniform variable.
  110735. * @param uniformName Name of the variable.
  110736. * @param array array to be set.
  110737. * @returns this effect.
  110738. */
  110739. setArray(uniformName: string, array: number[]): Effect;
  110740. /**
  110741. * 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)
  110742. * @param uniformName Name of the variable.
  110743. * @param array array to be set.
  110744. * @returns this effect.
  110745. */
  110746. setArray2(uniformName: string, array: number[]): Effect;
  110747. /**
  110748. * 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)
  110749. * @param uniformName Name of the variable.
  110750. * @param array array to be set.
  110751. * @returns this effect.
  110752. */
  110753. setArray3(uniformName: string, array: number[]): Effect;
  110754. /**
  110755. * 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)
  110756. * @param uniformName Name of the variable.
  110757. * @param array array to be set.
  110758. * @returns this effect.
  110759. */
  110760. setArray4(uniformName: string, array: number[]): Effect;
  110761. /**
  110762. * Sets matrices on a uniform variable.
  110763. * @param uniformName Name of the variable.
  110764. * @param matrices matrices to be set.
  110765. * @returns this effect.
  110766. */
  110767. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  110768. /**
  110769. * Sets matrix on a uniform variable.
  110770. * @param uniformName Name of the variable.
  110771. * @param matrix matrix to be set.
  110772. * @returns this effect.
  110773. */
  110774. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  110775. /**
  110776. * 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)
  110777. * @param uniformName Name of the variable.
  110778. * @param matrix matrix to be set.
  110779. * @returns this effect.
  110780. */
  110781. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  110782. /**
  110783. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  110784. * @param uniformName Name of the variable.
  110785. * @param matrix matrix to be set.
  110786. * @returns this effect.
  110787. */
  110788. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  110789. /**
  110790. * Sets a float on a uniform variable.
  110791. * @param uniformName Name of the variable.
  110792. * @param value value to be set.
  110793. * @returns this effect.
  110794. */
  110795. setFloat(uniformName: string, value: number): Effect;
  110796. /**
  110797. * Sets a boolean on a uniform variable.
  110798. * @param uniformName Name of the variable.
  110799. * @param bool value to be set.
  110800. * @returns this effect.
  110801. */
  110802. setBool(uniformName: string, bool: boolean): Effect;
  110803. /**
  110804. * Sets a Vector2 on a uniform variable.
  110805. * @param uniformName Name of the variable.
  110806. * @param vector2 vector2 to be set.
  110807. * @returns this effect.
  110808. */
  110809. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  110810. /**
  110811. * Sets a float2 on a uniform variable.
  110812. * @param uniformName Name of the variable.
  110813. * @param x First float in float2.
  110814. * @param y Second float in float2.
  110815. * @returns this effect.
  110816. */
  110817. setFloat2(uniformName: string, x: number, y: number): Effect;
  110818. /**
  110819. * Sets a Vector3 on a uniform variable.
  110820. * @param uniformName Name of the variable.
  110821. * @param vector3 Value to be set.
  110822. * @returns this effect.
  110823. */
  110824. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  110825. /**
  110826. * Sets a float3 on a uniform variable.
  110827. * @param uniformName Name of the variable.
  110828. * @param x First float in float3.
  110829. * @param y Second float in float3.
  110830. * @param z Third float in float3.
  110831. * @returns this effect.
  110832. */
  110833. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  110834. /**
  110835. * Sets a Vector4 on a uniform variable.
  110836. * @param uniformName Name of the variable.
  110837. * @param vector4 Value to be set.
  110838. * @returns this effect.
  110839. */
  110840. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  110841. /**
  110842. * Sets a float4 on a uniform variable.
  110843. * @param uniformName Name of the variable.
  110844. * @param x First float in float4.
  110845. * @param y Second float in float4.
  110846. * @param z Third float in float4.
  110847. * @param w Fourth float in float4.
  110848. * @returns this effect.
  110849. */
  110850. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  110851. /**
  110852. * Sets a Color3 on a uniform variable.
  110853. * @param uniformName Name of the variable.
  110854. * @param color3 Value to be set.
  110855. * @returns this effect.
  110856. */
  110857. setColor3(uniformName: string, color3: IColor3Like): Effect;
  110858. /**
  110859. * Sets a Color4 on a uniform variable.
  110860. * @param uniformName Name of the variable.
  110861. * @param color3 Value to be set.
  110862. * @param alpha Alpha value to be set.
  110863. * @returns this effect.
  110864. */
  110865. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  110866. /**
  110867. * Sets a Color4 on a uniform variable
  110868. * @param uniformName defines the name of the variable
  110869. * @param color4 defines the value to be set
  110870. * @returns this effect.
  110871. */
  110872. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  110873. /** Release all associated resources */
  110874. dispose(): void;
  110875. /**
  110876. * This function will add a new shader to the shader store
  110877. * @param name the name of the shader
  110878. * @param pixelShader optional pixel shader content
  110879. * @param vertexShader optional vertex shader content
  110880. */
  110881. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  110882. /**
  110883. * Store of each shader (The can be looked up using effect.key)
  110884. */
  110885. static ShadersStore: {
  110886. [key: string]: string;
  110887. };
  110888. /**
  110889. * Store of each included file for a shader (The can be looked up using effect.key)
  110890. */
  110891. static IncludesShadersStore: {
  110892. [key: string]: string;
  110893. };
  110894. /**
  110895. * Resets the cache of effects.
  110896. */
  110897. static ResetCache(): void;
  110898. }
  110899. }
  110900. declare module BABYLON {
  110901. /**
  110902. * Interface used to describe the capabilities of the engine relatively to the current browser
  110903. */
  110904. export interface EngineCapabilities {
  110905. /** Maximum textures units per fragment shader */
  110906. maxTexturesImageUnits: number;
  110907. /** Maximum texture units per vertex shader */
  110908. maxVertexTextureImageUnits: number;
  110909. /** Maximum textures units in the entire pipeline */
  110910. maxCombinedTexturesImageUnits: number;
  110911. /** Maximum texture size */
  110912. maxTextureSize: number;
  110913. /** Maximum texture samples */
  110914. maxSamples?: number;
  110915. /** Maximum cube texture size */
  110916. maxCubemapTextureSize: number;
  110917. /** Maximum render texture size */
  110918. maxRenderTextureSize: number;
  110919. /** Maximum number of vertex attributes */
  110920. maxVertexAttribs: number;
  110921. /** Maximum number of varyings */
  110922. maxVaryingVectors: number;
  110923. /** Maximum number of uniforms per vertex shader */
  110924. maxVertexUniformVectors: number;
  110925. /** Maximum number of uniforms per fragment shader */
  110926. maxFragmentUniformVectors: number;
  110927. /** Defines if standard derivates (dx/dy) are supported */
  110928. standardDerivatives: boolean;
  110929. /** Defines if s3tc texture compression is supported */
  110930. s3tc?: WEBGL_compressed_texture_s3tc;
  110931. /** Defines if pvrtc texture compression is supported */
  110932. pvrtc: any;
  110933. /** Defines if etc1 texture compression is supported */
  110934. etc1: any;
  110935. /** Defines if etc2 texture compression is supported */
  110936. etc2: any;
  110937. /** Defines if astc texture compression is supported */
  110938. astc: any;
  110939. /** Defines if float textures are supported */
  110940. textureFloat: boolean;
  110941. /** Defines if vertex array objects are supported */
  110942. vertexArrayObject: boolean;
  110943. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  110944. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  110945. /** Gets the maximum level of anisotropy supported */
  110946. maxAnisotropy: number;
  110947. /** Defines if instancing is supported */
  110948. instancedArrays: boolean;
  110949. /** Defines if 32 bits indices are supported */
  110950. uintIndices: boolean;
  110951. /** Defines if high precision shaders are supported */
  110952. highPrecisionShaderSupported: boolean;
  110953. /** Defines if depth reading in the fragment shader is supported */
  110954. fragmentDepthSupported: boolean;
  110955. /** Defines if float texture linear filtering is supported*/
  110956. textureFloatLinearFiltering: boolean;
  110957. /** Defines if rendering to float textures is supported */
  110958. textureFloatRender: boolean;
  110959. /** Defines if half float textures are supported*/
  110960. textureHalfFloat: boolean;
  110961. /** Defines if half float texture linear filtering is supported*/
  110962. textureHalfFloatLinearFiltering: boolean;
  110963. /** Defines if rendering to half float textures is supported */
  110964. textureHalfFloatRender: boolean;
  110965. /** Defines if textureLOD shader command is supported */
  110966. textureLOD: boolean;
  110967. /** Defines if draw buffers extension is supported */
  110968. drawBuffersExtension: boolean;
  110969. /** Defines if depth textures are supported */
  110970. depthTextureExtension: boolean;
  110971. /** Defines if float color buffer are supported */
  110972. colorBufferFloat: boolean;
  110973. /** Gets disjoint timer query extension (null if not supported) */
  110974. timerQuery?: EXT_disjoint_timer_query;
  110975. /** Defines if timestamp can be used with timer query */
  110976. canUseTimestampForTimerQuery: boolean;
  110977. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  110978. multiview?: any;
  110979. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  110980. oculusMultiview?: any;
  110981. /** Function used to let the system compiles shaders in background */
  110982. parallelShaderCompile?: {
  110983. COMPLETION_STATUS_KHR: number;
  110984. };
  110985. /** Max number of texture samples for MSAA */
  110986. maxMSAASamples: number;
  110987. /** Defines if the blend min max extension is supported */
  110988. blendMinMax: boolean;
  110989. }
  110990. }
  110991. declare module BABYLON {
  110992. /**
  110993. * @hidden
  110994. **/
  110995. export class DepthCullingState {
  110996. private _isDepthTestDirty;
  110997. private _isDepthMaskDirty;
  110998. private _isDepthFuncDirty;
  110999. private _isCullFaceDirty;
  111000. private _isCullDirty;
  111001. private _isZOffsetDirty;
  111002. private _isFrontFaceDirty;
  111003. private _depthTest;
  111004. private _depthMask;
  111005. private _depthFunc;
  111006. private _cull;
  111007. private _cullFace;
  111008. private _zOffset;
  111009. private _frontFace;
  111010. /**
  111011. * Initializes the state.
  111012. */
  111013. constructor();
  111014. get isDirty(): boolean;
  111015. get zOffset(): number;
  111016. set zOffset(value: number);
  111017. get cullFace(): Nullable<number>;
  111018. set cullFace(value: Nullable<number>);
  111019. get cull(): Nullable<boolean>;
  111020. set cull(value: Nullable<boolean>);
  111021. get depthFunc(): Nullable<number>;
  111022. set depthFunc(value: Nullable<number>);
  111023. get depthMask(): boolean;
  111024. set depthMask(value: boolean);
  111025. get depthTest(): boolean;
  111026. set depthTest(value: boolean);
  111027. get frontFace(): Nullable<number>;
  111028. set frontFace(value: Nullable<number>);
  111029. reset(): void;
  111030. apply(gl: WebGLRenderingContext): void;
  111031. }
  111032. }
  111033. declare module BABYLON {
  111034. /**
  111035. * @hidden
  111036. **/
  111037. export class StencilState {
  111038. /** 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 */
  111039. static readonly ALWAYS: number;
  111040. /** Passed to stencilOperation to specify that stencil value must be kept */
  111041. static readonly KEEP: number;
  111042. /** Passed to stencilOperation to specify that stencil value must be replaced */
  111043. static readonly REPLACE: number;
  111044. private _isStencilTestDirty;
  111045. private _isStencilMaskDirty;
  111046. private _isStencilFuncDirty;
  111047. private _isStencilOpDirty;
  111048. private _stencilTest;
  111049. private _stencilMask;
  111050. private _stencilFunc;
  111051. private _stencilFuncRef;
  111052. private _stencilFuncMask;
  111053. private _stencilOpStencilFail;
  111054. private _stencilOpDepthFail;
  111055. private _stencilOpStencilDepthPass;
  111056. get isDirty(): boolean;
  111057. get stencilFunc(): number;
  111058. set stencilFunc(value: number);
  111059. get stencilFuncRef(): number;
  111060. set stencilFuncRef(value: number);
  111061. get stencilFuncMask(): number;
  111062. set stencilFuncMask(value: number);
  111063. get stencilOpStencilFail(): number;
  111064. set stencilOpStencilFail(value: number);
  111065. get stencilOpDepthFail(): number;
  111066. set stencilOpDepthFail(value: number);
  111067. get stencilOpStencilDepthPass(): number;
  111068. set stencilOpStencilDepthPass(value: number);
  111069. get stencilMask(): number;
  111070. set stencilMask(value: number);
  111071. get stencilTest(): boolean;
  111072. set stencilTest(value: boolean);
  111073. constructor();
  111074. reset(): void;
  111075. apply(gl: WebGLRenderingContext): void;
  111076. }
  111077. }
  111078. declare module BABYLON {
  111079. /**
  111080. * @hidden
  111081. **/
  111082. export class AlphaState {
  111083. private _isAlphaBlendDirty;
  111084. private _isBlendFunctionParametersDirty;
  111085. private _isBlendEquationParametersDirty;
  111086. private _isBlendConstantsDirty;
  111087. private _alphaBlend;
  111088. private _blendFunctionParameters;
  111089. private _blendEquationParameters;
  111090. private _blendConstants;
  111091. /**
  111092. * Initializes the state.
  111093. */
  111094. constructor();
  111095. get isDirty(): boolean;
  111096. get alphaBlend(): boolean;
  111097. set alphaBlend(value: boolean);
  111098. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  111099. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  111100. setAlphaEquationParameters(rgb: number, alpha: number): void;
  111101. reset(): void;
  111102. apply(gl: WebGLRenderingContext): void;
  111103. }
  111104. }
  111105. declare module BABYLON {
  111106. /** @hidden */
  111107. export class WebGL2ShaderProcessor implements IShaderProcessor {
  111108. attributeProcessor(attribute: string): string;
  111109. varyingProcessor(varying: string, isFragment: boolean): string;
  111110. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  111111. }
  111112. }
  111113. declare module BABYLON {
  111114. /**
  111115. * Interface for attribute information associated with buffer instanciation
  111116. */
  111117. export interface InstancingAttributeInfo {
  111118. /**
  111119. * Name of the GLSL attribute
  111120. * if attribute index is not specified, this is used to retrieve the index from the effect
  111121. */
  111122. attributeName: string;
  111123. /**
  111124. * Index/offset of the attribute in the vertex shader
  111125. * if not specified, this will be computes from the name.
  111126. */
  111127. index?: number;
  111128. /**
  111129. * size of the attribute, 1, 2, 3 or 4
  111130. */
  111131. attributeSize: number;
  111132. /**
  111133. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  111134. */
  111135. offset: number;
  111136. /**
  111137. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  111138. * default to 1
  111139. */
  111140. divisor?: number;
  111141. /**
  111142. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  111143. * default is FLOAT
  111144. */
  111145. attributeType?: number;
  111146. /**
  111147. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  111148. */
  111149. normalized?: boolean;
  111150. }
  111151. }
  111152. declare module BABYLON {
  111153. interface ThinEngine {
  111154. /**
  111155. * Update a video texture
  111156. * @param texture defines the texture to update
  111157. * @param video defines the video element to use
  111158. * @param invertY defines if data must be stored with Y axis inverted
  111159. */
  111160. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  111161. }
  111162. }
  111163. declare module BABYLON {
  111164. /**
  111165. * Settings for finer control over video usage
  111166. */
  111167. export interface VideoTextureSettings {
  111168. /**
  111169. * Applies `autoplay` to video, if specified
  111170. */
  111171. autoPlay?: boolean;
  111172. /**
  111173. * Applies `loop` to video, if specified
  111174. */
  111175. loop?: boolean;
  111176. /**
  111177. * Automatically updates internal texture from video at every frame in the render loop
  111178. */
  111179. autoUpdateTexture: boolean;
  111180. /**
  111181. * Image src displayed during the video loading or until the user interacts with the video.
  111182. */
  111183. poster?: string;
  111184. }
  111185. /**
  111186. * If you want to display a video in your scene, this is the special texture for that.
  111187. * This special texture works similar to other textures, with the exception of a few parameters.
  111188. * @see https://doc.babylonjs.com/how_to/video_texture
  111189. */
  111190. export class VideoTexture extends Texture {
  111191. /**
  111192. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  111193. */
  111194. readonly autoUpdateTexture: boolean;
  111195. /**
  111196. * The video instance used by the texture internally
  111197. */
  111198. readonly video: HTMLVideoElement;
  111199. private _onUserActionRequestedObservable;
  111200. /**
  111201. * Event triggerd when a dom action is required by the user to play the video.
  111202. * This happens due to recent changes in browser policies preventing video to auto start.
  111203. */
  111204. get onUserActionRequestedObservable(): Observable<Texture>;
  111205. private _generateMipMaps;
  111206. private _stillImageCaptured;
  111207. private _displayingPosterTexture;
  111208. private _settings;
  111209. private _createInternalTextureOnEvent;
  111210. private _frameId;
  111211. private _currentSrc;
  111212. /**
  111213. * Creates a video texture.
  111214. * If you want to display a video in your scene, this is the special texture for that.
  111215. * This special texture works similar to other textures, with the exception of a few parameters.
  111216. * @see https://doc.babylonjs.com/how_to/video_texture
  111217. * @param name optional name, will detect from video source, if not defined
  111218. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  111219. * @param scene is obviously the current scene.
  111220. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  111221. * @param invertY is false by default but can be used to invert video on Y axis
  111222. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  111223. * @param settings allows finer control over video usage
  111224. */
  111225. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  111226. private _getName;
  111227. private _getVideo;
  111228. private _createInternalTexture;
  111229. private reset;
  111230. /**
  111231. * @hidden Internal method to initiate `update`.
  111232. */
  111233. _rebuild(): void;
  111234. /**
  111235. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  111236. */
  111237. update(): void;
  111238. /**
  111239. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  111240. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  111241. */
  111242. updateTexture(isVisible: boolean): void;
  111243. protected _updateInternalTexture: () => void;
  111244. /**
  111245. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  111246. * @param url New url.
  111247. */
  111248. updateURL(url: string): void;
  111249. /**
  111250. * Clones the texture.
  111251. * @returns the cloned texture
  111252. */
  111253. clone(): VideoTexture;
  111254. /**
  111255. * Dispose the texture and release its associated resources.
  111256. */
  111257. dispose(): void;
  111258. /**
  111259. * Creates a video texture straight from a stream.
  111260. * @param scene Define the scene the texture should be created in
  111261. * @param stream Define the stream the texture should be created from
  111262. * @returns The created video texture as a promise
  111263. */
  111264. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  111265. /**
  111266. * Creates a video texture straight from your WebCam video feed.
  111267. * @param scene Define the scene the texture should be created in
  111268. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  111269. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  111270. * @returns The created video texture as a promise
  111271. */
  111272. static CreateFromWebCamAsync(scene: Scene, constraints: {
  111273. minWidth: number;
  111274. maxWidth: number;
  111275. minHeight: number;
  111276. maxHeight: number;
  111277. deviceId: string;
  111278. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  111279. /**
  111280. * Creates a video texture straight from your WebCam video feed.
  111281. * @param scene Define the scene the texture should be created in
  111282. * @param onReady Define a callback to triggered once the texture will be ready
  111283. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  111284. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  111285. */
  111286. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  111287. minWidth: number;
  111288. maxWidth: number;
  111289. minHeight: number;
  111290. maxHeight: number;
  111291. deviceId: string;
  111292. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  111293. }
  111294. }
  111295. declare module BABYLON {
  111296. /**
  111297. * Defines the interface used by objects working like Scene
  111298. * @hidden
  111299. */
  111300. export interface ISceneLike {
  111301. _addPendingData(data: any): void;
  111302. _removePendingData(data: any): void;
  111303. offlineProvider: IOfflineProvider;
  111304. }
  111305. /** Interface defining initialization parameters for Engine class */
  111306. export interface EngineOptions extends WebGLContextAttributes {
  111307. /**
  111308. * Defines if the engine should no exceed a specified device ratio
  111309. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  111310. */
  111311. limitDeviceRatio?: number;
  111312. /**
  111313. * Defines if webvr should be enabled automatically
  111314. * @see http://doc.babylonjs.com/how_to/webvr_camera
  111315. */
  111316. autoEnableWebVR?: boolean;
  111317. /**
  111318. * Defines if webgl2 should be turned off even if supported
  111319. * @see http://doc.babylonjs.com/features/webgl2
  111320. */
  111321. disableWebGL2Support?: boolean;
  111322. /**
  111323. * Defines if webaudio should be initialized as well
  111324. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111325. */
  111326. audioEngine?: boolean;
  111327. /**
  111328. * Defines if animations should run using a deterministic lock step
  111329. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111330. */
  111331. deterministicLockstep?: boolean;
  111332. /** Defines the maximum steps to use with deterministic lock step mode */
  111333. lockstepMaxSteps?: number;
  111334. /** Defines the seconds between each deterministic lock step */
  111335. timeStep?: number;
  111336. /**
  111337. * Defines that engine should ignore context lost events
  111338. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  111339. */
  111340. doNotHandleContextLost?: boolean;
  111341. /**
  111342. * Defines that engine should ignore modifying touch action attribute and style
  111343. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  111344. */
  111345. doNotHandleTouchAction?: boolean;
  111346. /**
  111347. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  111348. */
  111349. useHighPrecisionFloats?: boolean;
  111350. /**
  111351. * Make the canvas XR Compatible for XR sessions
  111352. */
  111353. xrCompatible?: boolean;
  111354. }
  111355. /**
  111356. * The base engine class (root of all engines)
  111357. */
  111358. export class ThinEngine {
  111359. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  111360. static ExceptionList: ({
  111361. key: string;
  111362. capture: string;
  111363. captureConstraint: number;
  111364. targets: string[];
  111365. } | {
  111366. key: string;
  111367. capture: null;
  111368. captureConstraint: null;
  111369. targets: string[];
  111370. })[];
  111371. /** @hidden */
  111372. static _TextureLoaders: IInternalTextureLoader[];
  111373. /**
  111374. * Returns the current npm package of the sdk
  111375. */
  111376. static get NpmPackage(): string;
  111377. /**
  111378. * Returns the current version of the framework
  111379. */
  111380. static get Version(): string;
  111381. /**
  111382. * Returns a string describing the current engine
  111383. */
  111384. get description(): string;
  111385. /**
  111386. * Gets or sets the epsilon value used by collision engine
  111387. */
  111388. static CollisionsEpsilon: number;
  111389. /**
  111390. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  111391. */
  111392. static get ShadersRepository(): string;
  111393. static set ShadersRepository(value: string);
  111394. /** @hidden */
  111395. _shaderProcessor: IShaderProcessor;
  111396. /**
  111397. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  111398. */
  111399. forcePOTTextures: boolean;
  111400. /**
  111401. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  111402. */
  111403. isFullscreen: boolean;
  111404. /**
  111405. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  111406. */
  111407. cullBackFaces: boolean;
  111408. /**
  111409. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  111410. */
  111411. renderEvenInBackground: boolean;
  111412. /**
  111413. * Gets or sets a boolean indicating that cache can be kept between frames
  111414. */
  111415. preventCacheWipeBetweenFrames: boolean;
  111416. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  111417. validateShaderPrograms: boolean;
  111418. /**
  111419. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  111420. * This can provide greater z depth for distant objects.
  111421. */
  111422. useReverseDepthBuffer: boolean;
  111423. /**
  111424. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  111425. */
  111426. disableUniformBuffers: boolean;
  111427. /** @hidden */
  111428. _uniformBuffers: UniformBuffer[];
  111429. /**
  111430. * Gets a boolean indicating that the engine supports uniform buffers
  111431. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  111432. */
  111433. get supportsUniformBuffers(): boolean;
  111434. /** @hidden */
  111435. _gl: WebGLRenderingContext;
  111436. /** @hidden */
  111437. _webGLVersion: number;
  111438. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  111439. protected _windowIsBackground: boolean;
  111440. protected _creationOptions: EngineOptions;
  111441. protected _highPrecisionShadersAllowed: boolean;
  111442. /** @hidden */
  111443. get _shouldUseHighPrecisionShader(): boolean;
  111444. /**
  111445. * Gets a boolean indicating that only power of 2 textures are supported
  111446. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  111447. */
  111448. get needPOTTextures(): boolean;
  111449. /** @hidden */
  111450. _badOS: boolean;
  111451. /** @hidden */
  111452. _badDesktopOS: boolean;
  111453. private _hardwareScalingLevel;
  111454. /** @hidden */
  111455. _caps: EngineCapabilities;
  111456. private _isStencilEnable;
  111457. private _glVersion;
  111458. private _glRenderer;
  111459. private _glVendor;
  111460. /** @hidden */
  111461. _videoTextureSupported: boolean;
  111462. protected _renderingQueueLaunched: boolean;
  111463. protected _activeRenderLoops: (() => void)[];
  111464. /**
  111465. * Observable signaled when a context lost event is raised
  111466. */
  111467. onContextLostObservable: Observable<ThinEngine>;
  111468. /**
  111469. * Observable signaled when a context restored event is raised
  111470. */
  111471. onContextRestoredObservable: Observable<ThinEngine>;
  111472. private _onContextLost;
  111473. private _onContextRestored;
  111474. protected _contextWasLost: boolean;
  111475. /** @hidden */
  111476. _doNotHandleContextLost: boolean;
  111477. /**
  111478. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  111479. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  111480. */
  111481. get doNotHandleContextLost(): boolean;
  111482. set doNotHandleContextLost(value: boolean);
  111483. /**
  111484. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  111485. */
  111486. disableVertexArrayObjects: boolean;
  111487. /** @hidden */
  111488. protected _colorWrite: boolean;
  111489. /** @hidden */
  111490. protected _colorWriteChanged: boolean;
  111491. /** @hidden */
  111492. protected _depthCullingState: DepthCullingState;
  111493. /** @hidden */
  111494. protected _stencilState: StencilState;
  111495. /** @hidden */
  111496. _alphaState: AlphaState;
  111497. /** @hidden */
  111498. _alphaMode: number;
  111499. /** @hidden */
  111500. _alphaEquation: number;
  111501. /** @hidden */
  111502. _internalTexturesCache: InternalTexture[];
  111503. /** @hidden */
  111504. protected _activeChannel: number;
  111505. private _currentTextureChannel;
  111506. /** @hidden */
  111507. protected _boundTexturesCache: {
  111508. [key: string]: Nullable<InternalTexture>;
  111509. };
  111510. /** @hidden */
  111511. protected _currentEffect: Nullable<Effect>;
  111512. /** @hidden */
  111513. protected _currentProgram: Nullable<WebGLProgram>;
  111514. private _compiledEffects;
  111515. private _vertexAttribArraysEnabled;
  111516. /** @hidden */
  111517. protected _cachedViewport: Nullable<IViewportLike>;
  111518. private _cachedVertexArrayObject;
  111519. /** @hidden */
  111520. protected _cachedVertexBuffers: any;
  111521. /** @hidden */
  111522. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  111523. /** @hidden */
  111524. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  111525. /** @hidden */
  111526. _currentRenderTarget: Nullable<InternalTexture>;
  111527. private _uintIndicesCurrentlySet;
  111528. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  111529. /** @hidden */
  111530. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  111531. /** @hidden */
  111532. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  111533. private _currentBufferPointers;
  111534. private _currentInstanceLocations;
  111535. private _currentInstanceBuffers;
  111536. private _textureUnits;
  111537. /** @hidden */
  111538. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  111539. /** @hidden */
  111540. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  111541. /** @hidden */
  111542. _boundRenderFunction: any;
  111543. private _vaoRecordInProgress;
  111544. private _mustWipeVertexAttributes;
  111545. private _emptyTexture;
  111546. private _emptyCubeTexture;
  111547. private _emptyTexture3D;
  111548. private _emptyTexture2DArray;
  111549. /** @hidden */
  111550. _frameHandler: number;
  111551. private _nextFreeTextureSlots;
  111552. private _maxSimultaneousTextures;
  111553. private _activeRequests;
  111554. /** @hidden */
  111555. _transformTextureUrl: Nullable<(url: string) => string>;
  111556. protected get _supportsHardwareTextureRescaling(): boolean;
  111557. private _framebufferDimensionsObject;
  111558. /**
  111559. * sets the object from which width and height will be taken from when getting render width and height
  111560. * Will fallback to the gl object
  111561. * @param dimensions the framebuffer width and height that will be used.
  111562. */
  111563. set framebufferDimensionsObject(dimensions: Nullable<{
  111564. framebufferWidth: number;
  111565. framebufferHeight: number;
  111566. }>);
  111567. /**
  111568. * Gets the current viewport
  111569. */
  111570. get currentViewport(): Nullable<IViewportLike>;
  111571. /**
  111572. * Gets the default empty texture
  111573. */
  111574. get emptyTexture(): InternalTexture;
  111575. /**
  111576. * Gets the default empty 3D texture
  111577. */
  111578. get emptyTexture3D(): InternalTexture;
  111579. /**
  111580. * Gets the default empty 2D array texture
  111581. */
  111582. get emptyTexture2DArray(): InternalTexture;
  111583. /**
  111584. * Gets the default empty cube texture
  111585. */
  111586. get emptyCubeTexture(): InternalTexture;
  111587. /**
  111588. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  111589. */
  111590. readonly premultipliedAlpha: boolean;
  111591. /**
  111592. * Observable event triggered before each texture is initialized
  111593. */
  111594. onBeforeTextureInitObservable: Observable<Texture>;
  111595. /**
  111596. * Creates a new engine
  111597. * @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
  111598. * @param antialias defines enable antialiasing (default: false)
  111599. * @param options defines further options to be sent to the getContext() function
  111600. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  111601. */
  111602. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  111603. private _rebuildInternalTextures;
  111604. private _rebuildEffects;
  111605. /**
  111606. * Gets a boolean indicating if all created effects are ready
  111607. * @returns true if all effects are ready
  111608. */
  111609. areAllEffectsReady(): boolean;
  111610. protected _rebuildBuffers(): void;
  111611. protected _initGLContext(): void;
  111612. /**
  111613. * Gets version of the current webGL context
  111614. */
  111615. get webGLVersion(): number;
  111616. /**
  111617. * Gets a string idenfifying the name of the class
  111618. * @returns "Engine" string
  111619. */
  111620. getClassName(): string;
  111621. /**
  111622. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  111623. */
  111624. get isStencilEnable(): boolean;
  111625. /** @hidden */
  111626. _prepareWorkingCanvas(): void;
  111627. /**
  111628. * Reset the texture cache to empty state
  111629. */
  111630. resetTextureCache(): void;
  111631. /**
  111632. * Gets an object containing information about the current webGL context
  111633. * @returns an object containing the vender, the renderer and the version of the current webGL context
  111634. */
  111635. getGlInfo(): {
  111636. vendor: string;
  111637. renderer: string;
  111638. version: string;
  111639. };
  111640. /**
  111641. * Defines the hardware scaling level.
  111642. * By default the hardware scaling level is computed from the window device ratio.
  111643. * 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.
  111644. * @param level defines the level to use
  111645. */
  111646. setHardwareScalingLevel(level: number): void;
  111647. /**
  111648. * Gets the current hardware scaling level.
  111649. * By default the hardware scaling level is computed from the window device ratio.
  111650. * 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.
  111651. * @returns a number indicating the current hardware scaling level
  111652. */
  111653. getHardwareScalingLevel(): number;
  111654. /**
  111655. * Gets the list of loaded textures
  111656. * @returns an array containing all loaded textures
  111657. */
  111658. getLoadedTexturesCache(): InternalTexture[];
  111659. /**
  111660. * Gets the object containing all engine capabilities
  111661. * @returns the EngineCapabilities object
  111662. */
  111663. getCaps(): EngineCapabilities;
  111664. /**
  111665. * stop executing a render loop function and remove it from the execution array
  111666. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  111667. */
  111668. stopRenderLoop(renderFunction?: () => void): void;
  111669. /** @hidden */
  111670. _renderLoop(): void;
  111671. /**
  111672. * Gets the HTML canvas attached with the current webGL context
  111673. * @returns a HTML canvas
  111674. */
  111675. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  111676. /**
  111677. * Gets host window
  111678. * @returns the host window object
  111679. */
  111680. getHostWindow(): Nullable<Window>;
  111681. /**
  111682. * Gets the current render width
  111683. * @param useScreen defines if screen size must be used (or the current render target if any)
  111684. * @returns a number defining the current render width
  111685. */
  111686. getRenderWidth(useScreen?: boolean): number;
  111687. /**
  111688. * Gets the current render height
  111689. * @param useScreen defines if screen size must be used (or the current render target if any)
  111690. * @returns a number defining the current render height
  111691. */
  111692. getRenderHeight(useScreen?: boolean): number;
  111693. /**
  111694. * Can be used to override the current requestAnimationFrame requester.
  111695. * @hidden
  111696. */
  111697. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  111698. /**
  111699. * Register and execute a render loop. The engine can have more than one render function
  111700. * @param renderFunction defines the function to continuously execute
  111701. */
  111702. runRenderLoop(renderFunction: () => void): void;
  111703. /**
  111704. * Clear the current render buffer or the current render target (if any is set up)
  111705. * @param color defines the color to use
  111706. * @param backBuffer defines if the back buffer must be cleared
  111707. * @param depth defines if the depth buffer must be cleared
  111708. * @param stencil defines if the stencil buffer must be cleared
  111709. */
  111710. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111711. private _viewportCached;
  111712. /** @hidden */
  111713. _viewport(x: number, y: number, width: number, height: number): void;
  111714. /**
  111715. * Set the WebGL's viewport
  111716. * @param viewport defines the viewport element to be used
  111717. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  111718. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  111719. */
  111720. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  111721. /**
  111722. * Begin a new frame
  111723. */
  111724. beginFrame(): void;
  111725. /**
  111726. * Enf the current frame
  111727. */
  111728. endFrame(): void;
  111729. /**
  111730. * Resize the view according to the canvas' size
  111731. */
  111732. resize(): void;
  111733. /**
  111734. * Force a specific size of the canvas
  111735. * @param width defines the new canvas' width
  111736. * @param height defines the new canvas' height
  111737. */
  111738. setSize(width: number, height: number): void;
  111739. /**
  111740. * Binds the frame buffer to the specified texture.
  111741. * @param texture The texture to render to or null for the default canvas
  111742. * @param faceIndex The face of the texture to render to in case of cube texture
  111743. * @param requiredWidth The width of the target to render to
  111744. * @param requiredHeight The height of the target to render to
  111745. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  111746. * @param lodLevel defines the lod level to bind to the frame buffer
  111747. * @param layer defines the 2d array index to bind to frame buffer to
  111748. */
  111749. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  111750. /** @hidden */
  111751. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  111752. /**
  111753. * Unbind the current render target texture from the webGL context
  111754. * @param texture defines the render target texture to unbind
  111755. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111756. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111757. */
  111758. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111759. /**
  111760. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  111761. */
  111762. flushFramebuffer(): void;
  111763. /**
  111764. * Unbind the current render target and bind the default framebuffer
  111765. */
  111766. restoreDefaultFramebuffer(): void;
  111767. /** @hidden */
  111768. protected _resetVertexBufferBinding(): void;
  111769. /**
  111770. * Creates a vertex buffer
  111771. * @param data the data for the vertex buffer
  111772. * @returns the new WebGL static buffer
  111773. */
  111774. createVertexBuffer(data: DataArray): DataBuffer;
  111775. private _createVertexBuffer;
  111776. /**
  111777. * Creates a dynamic vertex buffer
  111778. * @param data the data for the dynamic vertex buffer
  111779. * @returns the new WebGL dynamic buffer
  111780. */
  111781. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  111782. protected _resetIndexBufferBinding(): void;
  111783. /**
  111784. * Creates a new index buffer
  111785. * @param indices defines the content of the index buffer
  111786. * @param updatable defines if the index buffer must be updatable
  111787. * @returns a new webGL buffer
  111788. */
  111789. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  111790. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  111791. /**
  111792. * Bind a webGL buffer to the webGL context
  111793. * @param buffer defines the buffer to bind
  111794. */
  111795. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  111796. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  111797. private bindBuffer;
  111798. /**
  111799. * update the bound buffer with the given data
  111800. * @param data defines the data to update
  111801. */
  111802. updateArrayBuffer(data: Float32Array): void;
  111803. private _vertexAttribPointer;
  111804. /** @hidden */
  111805. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  111806. private _bindVertexBuffersAttributes;
  111807. /**
  111808. * Records a vertex array object
  111809. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  111810. * @param vertexBuffers defines the list of vertex buffers to store
  111811. * @param indexBuffer defines the index buffer to store
  111812. * @param effect defines the effect to store
  111813. * @returns the new vertex array object
  111814. */
  111815. recordVertexArrayObject(vertexBuffers: {
  111816. [key: string]: VertexBuffer;
  111817. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  111818. /**
  111819. * Bind a specific vertex array object
  111820. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  111821. * @param vertexArrayObject defines the vertex array object to bind
  111822. * @param indexBuffer defines the index buffer to bind
  111823. */
  111824. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  111825. /**
  111826. * Bind webGl buffers directly to the webGL context
  111827. * @param vertexBuffer defines the vertex buffer to bind
  111828. * @param indexBuffer defines the index buffer to bind
  111829. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  111830. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  111831. * @param effect defines the effect associated with the vertex buffer
  111832. */
  111833. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  111834. private _unbindVertexArrayObject;
  111835. /**
  111836. * Bind a list of vertex buffers to the webGL context
  111837. * @param vertexBuffers defines the list of vertex buffers to bind
  111838. * @param indexBuffer defines the index buffer to bind
  111839. * @param effect defines the effect associated with the vertex buffers
  111840. */
  111841. bindBuffers(vertexBuffers: {
  111842. [key: string]: Nullable<VertexBuffer>;
  111843. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  111844. /**
  111845. * Unbind all instance attributes
  111846. */
  111847. unbindInstanceAttributes(): void;
  111848. /**
  111849. * Release and free the memory of a vertex array object
  111850. * @param vao defines the vertex array object to delete
  111851. */
  111852. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  111853. /** @hidden */
  111854. _releaseBuffer(buffer: DataBuffer): boolean;
  111855. protected _deleteBuffer(buffer: DataBuffer): void;
  111856. /**
  111857. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  111858. * @param instancesBuffer defines the webGL buffer to update and bind
  111859. * @param data defines the data to store in the buffer
  111860. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  111861. */
  111862. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  111863. /**
  111864. * Bind the content of a webGL buffer used with instantiation
  111865. * @param instancesBuffer defines the webGL buffer to bind
  111866. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  111867. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  111868. */
  111869. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  111870. /**
  111871. * Disable the instance attribute corresponding to the name in parameter
  111872. * @param name defines the name of the attribute to disable
  111873. */
  111874. disableInstanceAttributeByName(name: string): void;
  111875. /**
  111876. * Disable the instance attribute corresponding to the location in parameter
  111877. * @param attributeLocation defines the attribute location of the attribute to disable
  111878. */
  111879. disableInstanceAttribute(attributeLocation: number): void;
  111880. /**
  111881. * Disable the attribute corresponding to the location in parameter
  111882. * @param attributeLocation defines the attribute location of the attribute to disable
  111883. */
  111884. disableAttributeByIndex(attributeLocation: number): void;
  111885. /**
  111886. * Send a draw order
  111887. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  111888. * @param indexStart defines the starting index
  111889. * @param indexCount defines the number of index to draw
  111890. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111891. */
  111892. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  111893. /**
  111894. * Draw a list of points
  111895. * @param verticesStart defines the index of first vertex to draw
  111896. * @param verticesCount defines the count of vertices to draw
  111897. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111898. */
  111899. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111900. /**
  111901. * Draw a list of unindexed primitives
  111902. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  111903. * @param verticesStart defines the index of first vertex to draw
  111904. * @param verticesCount defines the count of vertices to draw
  111905. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111906. */
  111907. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111908. /**
  111909. * Draw a list of indexed primitives
  111910. * @param fillMode defines the primitive to use
  111911. * @param indexStart defines the starting index
  111912. * @param indexCount defines the number of index to draw
  111913. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111914. */
  111915. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111916. /**
  111917. * Draw a list of unindexed primitives
  111918. * @param fillMode defines the primitive to use
  111919. * @param verticesStart defines the index of first vertex to draw
  111920. * @param verticesCount defines the count of vertices to draw
  111921. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111922. */
  111923. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111924. private _drawMode;
  111925. /** @hidden */
  111926. protected _reportDrawCall(): void;
  111927. /** @hidden */
  111928. _releaseEffect(effect: Effect): void;
  111929. /** @hidden */
  111930. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  111931. /**
  111932. * Create a new effect (used to store vertex/fragment shaders)
  111933. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  111934. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  111935. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  111936. * @param samplers defines an array of string used to represent textures
  111937. * @param defines defines the string containing the defines to use to compile the shaders
  111938. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  111939. * @param onCompiled defines a function to call when the effect creation is successful
  111940. * @param onError defines a function to call when the effect creation has failed
  111941. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  111942. * @returns the new Effect
  111943. */
  111944. 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;
  111945. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  111946. private _compileShader;
  111947. private _compileRawShader;
  111948. /** @hidden */
  111949. _getShaderSource(shader: WebGLShader): Nullable<string>;
  111950. /**
  111951. * Directly creates a webGL program
  111952. * @param pipelineContext defines the pipeline context to attach to
  111953. * @param vertexCode defines the vertex shader code to use
  111954. * @param fragmentCode defines the fragment shader code to use
  111955. * @param context defines the webGL context to use (if not set, the current one will be used)
  111956. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  111957. * @returns the new webGL program
  111958. */
  111959. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  111960. /**
  111961. * Creates a webGL program
  111962. * @param pipelineContext defines the pipeline context to attach to
  111963. * @param vertexCode defines the vertex shader code to use
  111964. * @param fragmentCode defines the fragment shader code to use
  111965. * @param defines defines the string containing the defines to use to compile the shaders
  111966. * @param context defines the webGL context to use (if not set, the current one will be used)
  111967. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  111968. * @returns the new webGL program
  111969. */
  111970. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  111971. /**
  111972. * Creates a new pipeline context
  111973. * @returns the new pipeline
  111974. */
  111975. createPipelineContext(): IPipelineContext;
  111976. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  111977. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  111978. /** @hidden */
  111979. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  111980. /** @hidden */
  111981. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  111982. /** @hidden */
  111983. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  111984. /**
  111985. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  111986. * @param pipelineContext defines the pipeline context to use
  111987. * @param uniformsNames defines the list of uniform names
  111988. * @returns an array of webGL uniform locations
  111989. */
  111990. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  111991. /**
  111992. * Gets the lsit of active attributes for a given webGL program
  111993. * @param pipelineContext defines the pipeline context to use
  111994. * @param attributesNames defines the list of attribute names to get
  111995. * @returns an array of indices indicating the offset of each attribute
  111996. */
  111997. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111998. /**
  111999. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  112000. * @param effect defines the effect to activate
  112001. */
  112002. enableEffect(effect: Nullable<Effect>): void;
  112003. /**
  112004. * Set the value of an uniform to a number (int)
  112005. * @param uniform defines the webGL uniform location where to store the value
  112006. * @param value defines the int number to store
  112007. */
  112008. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  112009. /**
  112010. * Set the value of an uniform to an array of int32
  112011. * @param uniform defines the webGL uniform location where to store the value
  112012. * @param array defines the array of int32 to store
  112013. */
  112014. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112015. /**
  112016. * Set the value of an uniform to an array of int32 (stored as vec2)
  112017. * @param uniform defines the webGL uniform location where to store the value
  112018. * @param array defines the array of int32 to store
  112019. */
  112020. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112021. /**
  112022. * Set the value of an uniform to an array of int32 (stored as vec3)
  112023. * @param uniform defines the webGL uniform location where to store the value
  112024. * @param array defines the array of int32 to store
  112025. */
  112026. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112027. /**
  112028. * Set the value of an uniform to an array of int32 (stored as vec4)
  112029. * @param uniform defines the webGL uniform location where to store the value
  112030. * @param array defines the array of int32 to store
  112031. */
  112032. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112033. /**
  112034. * Set the value of an uniform to an array of number
  112035. * @param uniform defines the webGL uniform location where to store the value
  112036. * @param array defines the array of number to store
  112037. */
  112038. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112039. /**
  112040. * Set the value of an uniform to an array of number (stored as vec2)
  112041. * @param uniform defines the webGL uniform location where to store the value
  112042. * @param array defines the array of number to store
  112043. */
  112044. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112045. /**
  112046. * Set the value of an uniform to an array of number (stored as vec3)
  112047. * @param uniform defines the webGL uniform location where to store the value
  112048. * @param array defines the array of number to store
  112049. */
  112050. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112051. /**
  112052. * Set the value of an uniform to an array of number (stored as vec4)
  112053. * @param uniform defines the webGL uniform location where to store the value
  112054. * @param array defines the array of number to store
  112055. */
  112056. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112057. /**
  112058. * Set the value of an uniform to an array of float32 (stored as matrices)
  112059. * @param uniform defines the webGL uniform location where to store the value
  112060. * @param matrices defines the array of float32 to store
  112061. */
  112062. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  112063. /**
  112064. * Set the value of an uniform to a matrix (3x3)
  112065. * @param uniform defines the webGL uniform location where to store the value
  112066. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  112067. */
  112068. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  112069. /**
  112070. * Set the value of an uniform to a matrix (2x2)
  112071. * @param uniform defines the webGL uniform location where to store the value
  112072. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  112073. */
  112074. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  112075. /**
  112076. * Set the value of an uniform to a number (float)
  112077. * @param uniform defines the webGL uniform location where to store the value
  112078. * @param value defines the float number to store
  112079. */
  112080. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  112081. /**
  112082. * Set the value of an uniform to a vec2
  112083. * @param uniform defines the webGL uniform location where to store the value
  112084. * @param x defines the 1st component of the value
  112085. * @param y defines the 2nd component of the value
  112086. */
  112087. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  112088. /**
  112089. * Set the value of an uniform to a vec3
  112090. * @param uniform defines the webGL uniform location where to store the value
  112091. * @param x defines the 1st component of the value
  112092. * @param y defines the 2nd component of the value
  112093. * @param z defines the 3rd component of the value
  112094. */
  112095. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  112096. /**
  112097. * Set the value of an uniform to a vec4
  112098. * @param uniform defines the webGL uniform location where to store the value
  112099. * @param x defines the 1st component of the value
  112100. * @param y defines the 2nd component of the value
  112101. * @param z defines the 3rd component of the value
  112102. * @param w defines the 4th component of the value
  112103. */
  112104. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  112105. /**
  112106. * Apply all cached states (depth, culling, stencil and alpha)
  112107. */
  112108. applyStates(): void;
  112109. /**
  112110. * Enable or disable color writing
  112111. * @param enable defines the state to set
  112112. */
  112113. setColorWrite(enable: boolean): void;
  112114. /**
  112115. * Gets a boolean indicating if color writing is enabled
  112116. * @returns the current color writing state
  112117. */
  112118. getColorWrite(): boolean;
  112119. /**
  112120. * Gets the depth culling state manager
  112121. */
  112122. get depthCullingState(): DepthCullingState;
  112123. /**
  112124. * Gets the alpha state manager
  112125. */
  112126. get alphaState(): AlphaState;
  112127. /**
  112128. * Gets the stencil state manager
  112129. */
  112130. get stencilState(): StencilState;
  112131. /**
  112132. * Clears the list of texture accessible through engine.
  112133. * This can help preventing texture load conflict due to name collision.
  112134. */
  112135. clearInternalTexturesCache(): void;
  112136. /**
  112137. * Force the entire cache to be cleared
  112138. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  112139. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  112140. */
  112141. wipeCaches(bruteForce?: boolean): void;
  112142. /** @hidden */
  112143. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  112144. min: number;
  112145. mag: number;
  112146. };
  112147. /** @hidden */
  112148. _createTexture(): WebGLTexture;
  112149. /**
  112150. * Usually called from Texture.ts.
  112151. * Passed information to create a WebGLTexture
  112152. * @param url defines a value which contains one of the following:
  112153. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112154. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112155. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112156. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112157. * @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)
  112158. * @param scene needed for loading to the correct scene
  112159. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  112160. * @param onLoad optional callback to be called upon successful completion
  112161. * @param onError optional callback to be called upon failure
  112162. * @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
  112163. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112164. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112165. * @param forcedExtension defines the extension to use to pick the right loader
  112166. * @param mimeType defines an optional mime type
  112167. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112168. */
  112169. 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;
  112170. /**
  112171. * Loads an image as an HTMLImageElement.
  112172. * @param input url string, ArrayBuffer, or Blob to load
  112173. * @param onLoad callback called when the image successfully loads
  112174. * @param onError callback called when the image fails to load
  112175. * @param offlineProvider offline provider for caching
  112176. * @param mimeType optional mime type
  112177. * @returns the HTMLImageElement of the loaded image
  112178. * @hidden
  112179. */
  112180. 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>;
  112181. /**
  112182. * @hidden
  112183. */
  112184. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  112185. private _unpackFlipYCached;
  112186. /**
  112187. * In case you are sharing the context with other applications, it might
  112188. * be interested to not cache the unpack flip y state to ensure a consistent
  112189. * value would be set.
  112190. */
  112191. enableUnpackFlipYCached: boolean;
  112192. /** @hidden */
  112193. _unpackFlipY(value: boolean): void;
  112194. /** @hidden */
  112195. _getUnpackAlignement(): number;
  112196. private _getTextureTarget;
  112197. /**
  112198. * Update the sampling mode of a given texture
  112199. * @param samplingMode defines the required sampling mode
  112200. * @param texture defines the texture to update
  112201. * @param generateMipMaps defines whether to generate mipmaps for the texture
  112202. */
  112203. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  112204. /**
  112205. * Update the sampling mode of a given texture
  112206. * @param texture defines the texture to update
  112207. * @param wrapU defines the texture wrap mode of the u coordinates
  112208. * @param wrapV defines the texture wrap mode of the v coordinates
  112209. * @param wrapR defines the texture wrap mode of the r coordinates
  112210. */
  112211. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  112212. /** @hidden */
  112213. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  112214. width: number;
  112215. height: number;
  112216. layers?: number;
  112217. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  112218. /** @hidden */
  112219. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112220. /** @hidden */
  112221. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  112222. /**
  112223. * Update a portion of an internal texture
  112224. * @param texture defines the texture to update
  112225. * @param imageData defines the data to store into the texture
  112226. * @param xOffset defines the x coordinates of the update rectangle
  112227. * @param yOffset defines the y coordinates of the update rectangle
  112228. * @param width defines the width of the update rectangle
  112229. * @param height defines the height of the update rectangle
  112230. * @param faceIndex defines the face index if texture is a cube (0 by default)
  112231. * @param lod defines the lod level to update (0 by default)
  112232. */
  112233. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  112234. /** @hidden */
  112235. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112236. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  112237. private _prepareWebGLTexture;
  112238. /** @hidden */
  112239. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  112240. private _getDepthStencilBuffer;
  112241. /** @hidden */
  112242. _releaseFramebufferObjects(texture: InternalTexture): void;
  112243. /** @hidden */
  112244. _releaseTexture(texture: InternalTexture): void;
  112245. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  112246. protected _setProgram(program: WebGLProgram): void;
  112247. protected _boundUniforms: {
  112248. [key: number]: WebGLUniformLocation;
  112249. };
  112250. /**
  112251. * Binds an effect to the webGL context
  112252. * @param effect defines the effect to bind
  112253. */
  112254. bindSamplers(effect: Effect): void;
  112255. private _activateCurrentTexture;
  112256. /** @hidden */
  112257. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  112258. /** @hidden */
  112259. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  112260. /**
  112261. * Unbind all textures from the webGL context
  112262. */
  112263. unbindAllTextures(): void;
  112264. /**
  112265. * Sets a texture to the according uniform.
  112266. * @param channel The texture channel
  112267. * @param uniform The uniform to set
  112268. * @param texture The texture to apply
  112269. */
  112270. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  112271. private _bindSamplerUniformToChannel;
  112272. private _getTextureWrapMode;
  112273. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  112274. /**
  112275. * Sets an array of texture to the webGL context
  112276. * @param channel defines the channel where the texture array must be set
  112277. * @param uniform defines the associated uniform location
  112278. * @param textures defines the array of textures to bind
  112279. */
  112280. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  112281. /** @hidden */
  112282. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  112283. private _setTextureParameterFloat;
  112284. private _setTextureParameterInteger;
  112285. /**
  112286. * Unbind all vertex attributes from the webGL context
  112287. */
  112288. unbindAllAttributes(): void;
  112289. /**
  112290. * 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
  112291. */
  112292. releaseEffects(): void;
  112293. /**
  112294. * Dispose and release all associated resources
  112295. */
  112296. dispose(): void;
  112297. /**
  112298. * Attach a new callback raised when context lost event is fired
  112299. * @param callback defines the callback to call
  112300. */
  112301. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  112302. /**
  112303. * Attach a new callback raised when context restored event is fired
  112304. * @param callback defines the callback to call
  112305. */
  112306. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  112307. /**
  112308. * Get the current error code of the webGL context
  112309. * @returns the error code
  112310. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  112311. */
  112312. getError(): number;
  112313. private _canRenderToFloatFramebuffer;
  112314. private _canRenderToHalfFloatFramebuffer;
  112315. private _canRenderToFramebuffer;
  112316. /** @hidden */
  112317. _getWebGLTextureType(type: number): number;
  112318. /** @hidden */
  112319. _getInternalFormat(format: number): number;
  112320. /** @hidden */
  112321. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  112322. /** @hidden */
  112323. _getRGBAMultiSampleBufferFormat(type: number): number;
  112324. /** @hidden */
  112325. _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;
  112326. /**
  112327. * Loads a file from a url
  112328. * @param url url to load
  112329. * @param onSuccess callback called when the file successfully loads
  112330. * @param onProgress callback called while file is loading (if the server supports this mode)
  112331. * @param offlineProvider defines the offline provider for caching
  112332. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  112333. * @param onError callback called when the file fails to load
  112334. * @returns a file request object
  112335. * @hidden
  112336. */
  112337. 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;
  112338. /**
  112339. * Reads pixels from the current frame buffer. Please note that this function can be slow
  112340. * @param x defines the x coordinate of the rectangle where pixels must be read
  112341. * @param y defines the y coordinate of the rectangle where pixels must be read
  112342. * @param width defines the width of the rectangle where pixels must be read
  112343. * @param height defines the height of the rectangle where pixels must be read
  112344. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  112345. * @returns a Uint8Array containing RGBA colors
  112346. */
  112347. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  112348. private static _isSupported;
  112349. /**
  112350. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  112351. * @returns true if the engine can be created
  112352. * @ignorenaming
  112353. */
  112354. static isSupported(): boolean;
  112355. /**
  112356. * Find the next highest power of two.
  112357. * @param x Number to start search from.
  112358. * @return Next highest power of two.
  112359. */
  112360. static CeilingPOT(x: number): number;
  112361. /**
  112362. * Find the next lowest power of two.
  112363. * @param x Number to start search from.
  112364. * @return Next lowest power of two.
  112365. */
  112366. static FloorPOT(x: number): number;
  112367. /**
  112368. * Find the nearest power of two.
  112369. * @param x Number to start search from.
  112370. * @return Next nearest power of two.
  112371. */
  112372. static NearestPOT(x: number): number;
  112373. /**
  112374. * Get the closest exponent of two
  112375. * @param value defines the value to approximate
  112376. * @param max defines the maximum value to return
  112377. * @param mode defines how to define the closest value
  112378. * @returns closest exponent of two of the given value
  112379. */
  112380. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  112381. /**
  112382. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  112383. * @param func - the function to be called
  112384. * @param requester - the object that will request the next frame. Falls back to window.
  112385. * @returns frame number
  112386. */
  112387. static QueueNewFrame(func: () => void, requester?: any): number;
  112388. /**
  112389. * Gets host document
  112390. * @returns the host document object
  112391. */
  112392. getHostDocument(): Nullable<Document>;
  112393. }
  112394. }
  112395. declare module BABYLON {
  112396. /**
  112397. * Class representing spherical harmonics coefficients to the 3rd degree
  112398. */
  112399. export class SphericalHarmonics {
  112400. /**
  112401. * Defines whether or not the harmonics have been prescaled for rendering.
  112402. */
  112403. preScaled: boolean;
  112404. /**
  112405. * The l0,0 coefficients of the spherical harmonics
  112406. */
  112407. l00: Vector3;
  112408. /**
  112409. * The l1,-1 coefficients of the spherical harmonics
  112410. */
  112411. l1_1: Vector3;
  112412. /**
  112413. * The l1,0 coefficients of the spherical harmonics
  112414. */
  112415. l10: Vector3;
  112416. /**
  112417. * The l1,1 coefficients of the spherical harmonics
  112418. */
  112419. l11: Vector3;
  112420. /**
  112421. * The l2,-2 coefficients of the spherical harmonics
  112422. */
  112423. l2_2: Vector3;
  112424. /**
  112425. * The l2,-1 coefficients of the spherical harmonics
  112426. */
  112427. l2_1: Vector3;
  112428. /**
  112429. * The l2,0 coefficients of the spherical harmonics
  112430. */
  112431. l20: Vector3;
  112432. /**
  112433. * The l2,1 coefficients of the spherical harmonics
  112434. */
  112435. l21: Vector3;
  112436. /**
  112437. * The l2,2 coefficients of the spherical harmonics
  112438. */
  112439. l22: Vector3;
  112440. /**
  112441. * Adds a light to the spherical harmonics
  112442. * @param direction the direction of the light
  112443. * @param color the color of the light
  112444. * @param deltaSolidAngle the delta solid angle of the light
  112445. */
  112446. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  112447. /**
  112448. * Scales the spherical harmonics by the given amount
  112449. * @param scale the amount to scale
  112450. */
  112451. scaleInPlace(scale: number): void;
  112452. /**
  112453. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  112454. *
  112455. * ```
  112456. * E_lm = A_l * L_lm
  112457. * ```
  112458. *
  112459. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  112460. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  112461. * the scaling factors are given in equation 9.
  112462. */
  112463. convertIncidentRadianceToIrradiance(): void;
  112464. /**
  112465. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  112466. *
  112467. * ```
  112468. * L = (1/pi) * E * rho
  112469. * ```
  112470. *
  112471. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  112472. */
  112473. convertIrradianceToLambertianRadiance(): void;
  112474. /**
  112475. * Integrates the reconstruction coefficients directly in to the SH preventing further
  112476. * required operations at run time.
  112477. *
  112478. * This is simply done by scaling back the SH with Ylm constants parameter.
  112479. * The trigonometric part being applied by the shader at run time.
  112480. */
  112481. preScaleForRendering(): void;
  112482. /**
  112483. * Constructs a spherical harmonics from an array.
  112484. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  112485. * @returns the spherical harmonics
  112486. */
  112487. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  112488. /**
  112489. * Gets the spherical harmonics from polynomial
  112490. * @param polynomial the spherical polynomial
  112491. * @returns the spherical harmonics
  112492. */
  112493. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  112494. }
  112495. /**
  112496. * Class representing spherical polynomial coefficients to the 3rd degree
  112497. */
  112498. export class SphericalPolynomial {
  112499. private _harmonics;
  112500. /**
  112501. * The spherical harmonics used to create the polynomials.
  112502. */
  112503. get preScaledHarmonics(): SphericalHarmonics;
  112504. /**
  112505. * The x coefficients of the spherical polynomial
  112506. */
  112507. x: Vector3;
  112508. /**
  112509. * The y coefficients of the spherical polynomial
  112510. */
  112511. y: Vector3;
  112512. /**
  112513. * The z coefficients of the spherical polynomial
  112514. */
  112515. z: Vector3;
  112516. /**
  112517. * The xx coefficients of the spherical polynomial
  112518. */
  112519. xx: Vector3;
  112520. /**
  112521. * The yy coefficients of the spherical polynomial
  112522. */
  112523. yy: Vector3;
  112524. /**
  112525. * The zz coefficients of the spherical polynomial
  112526. */
  112527. zz: Vector3;
  112528. /**
  112529. * The xy coefficients of the spherical polynomial
  112530. */
  112531. xy: Vector3;
  112532. /**
  112533. * The yz coefficients of the spherical polynomial
  112534. */
  112535. yz: Vector3;
  112536. /**
  112537. * The zx coefficients of the spherical polynomial
  112538. */
  112539. zx: Vector3;
  112540. /**
  112541. * Adds an ambient color to the spherical polynomial
  112542. * @param color the color to add
  112543. */
  112544. addAmbient(color: Color3): void;
  112545. /**
  112546. * Scales the spherical polynomial by the given amount
  112547. * @param scale the amount to scale
  112548. */
  112549. scaleInPlace(scale: number): void;
  112550. /**
  112551. * Gets the spherical polynomial from harmonics
  112552. * @param harmonics the spherical harmonics
  112553. * @returns the spherical polynomial
  112554. */
  112555. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  112556. /**
  112557. * Constructs a spherical polynomial from an array.
  112558. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  112559. * @returns the spherical polynomial
  112560. */
  112561. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  112562. }
  112563. }
  112564. declare module BABYLON {
  112565. /**
  112566. * Defines the source of the internal texture
  112567. */
  112568. export enum InternalTextureSource {
  112569. /**
  112570. * The source of the texture data is unknown
  112571. */
  112572. Unknown = 0,
  112573. /**
  112574. * Texture data comes from an URL
  112575. */
  112576. Url = 1,
  112577. /**
  112578. * Texture data is only used for temporary storage
  112579. */
  112580. Temp = 2,
  112581. /**
  112582. * Texture data comes from raw data (ArrayBuffer)
  112583. */
  112584. Raw = 3,
  112585. /**
  112586. * Texture content is dynamic (video or dynamic texture)
  112587. */
  112588. Dynamic = 4,
  112589. /**
  112590. * Texture content is generated by rendering to it
  112591. */
  112592. RenderTarget = 5,
  112593. /**
  112594. * Texture content is part of a multi render target process
  112595. */
  112596. MultiRenderTarget = 6,
  112597. /**
  112598. * Texture data comes from a cube data file
  112599. */
  112600. Cube = 7,
  112601. /**
  112602. * Texture data comes from a raw cube data
  112603. */
  112604. CubeRaw = 8,
  112605. /**
  112606. * Texture data come from a prefiltered cube data file
  112607. */
  112608. CubePrefiltered = 9,
  112609. /**
  112610. * Texture content is raw 3D data
  112611. */
  112612. Raw3D = 10,
  112613. /**
  112614. * Texture content is raw 2D array data
  112615. */
  112616. Raw2DArray = 11,
  112617. /**
  112618. * Texture content is a depth texture
  112619. */
  112620. Depth = 12,
  112621. /**
  112622. * Texture data comes from a raw cube data encoded with RGBD
  112623. */
  112624. CubeRawRGBD = 13
  112625. }
  112626. /**
  112627. * Class used to store data associated with WebGL texture data for the engine
  112628. * This class should not be used directly
  112629. */
  112630. export class InternalTexture {
  112631. /** @hidden */
  112632. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  112633. /**
  112634. * Defines if the texture is ready
  112635. */
  112636. isReady: boolean;
  112637. /**
  112638. * Defines if the texture is a cube texture
  112639. */
  112640. isCube: boolean;
  112641. /**
  112642. * Defines if the texture contains 3D data
  112643. */
  112644. is3D: boolean;
  112645. /**
  112646. * Defines if the texture contains 2D array data
  112647. */
  112648. is2DArray: boolean;
  112649. /**
  112650. * Defines if the texture contains multiview data
  112651. */
  112652. isMultiview: boolean;
  112653. /**
  112654. * Gets the URL used to load this texture
  112655. */
  112656. url: string;
  112657. /**
  112658. * Gets the sampling mode of the texture
  112659. */
  112660. samplingMode: number;
  112661. /**
  112662. * Gets a boolean indicating if the texture needs mipmaps generation
  112663. */
  112664. generateMipMaps: boolean;
  112665. /**
  112666. * Gets the number of samples used by the texture (WebGL2+ only)
  112667. */
  112668. samples: number;
  112669. /**
  112670. * Gets the type of the texture (int, float...)
  112671. */
  112672. type: number;
  112673. /**
  112674. * Gets the format of the texture (RGB, RGBA...)
  112675. */
  112676. format: number;
  112677. /**
  112678. * Observable called when the texture is loaded
  112679. */
  112680. onLoadedObservable: Observable<InternalTexture>;
  112681. /**
  112682. * Gets the width of the texture
  112683. */
  112684. width: number;
  112685. /**
  112686. * Gets the height of the texture
  112687. */
  112688. height: number;
  112689. /**
  112690. * Gets the depth of the texture
  112691. */
  112692. depth: number;
  112693. /**
  112694. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  112695. */
  112696. baseWidth: number;
  112697. /**
  112698. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  112699. */
  112700. baseHeight: number;
  112701. /**
  112702. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  112703. */
  112704. baseDepth: number;
  112705. /**
  112706. * Gets a boolean indicating if the texture is inverted on Y axis
  112707. */
  112708. invertY: boolean;
  112709. /** @hidden */
  112710. _invertVScale: boolean;
  112711. /** @hidden */
  112712. _associatedChannel: number;
  112713. /** @hidden */
  112714. _source: InternalTextureSource;
  112715. /** @hidden */
  112716. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  112717. /** @hidden */
  112718. _bufferView: Nullable<ArrayBufferView>;
  112719. /** @hidden */
  112720. _bufferViewArray: Nullable<ArrayBufferView[]>;
  112721. /** @hidden */
  112722. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  112723. /** @hidden */
  112724. _size: number;
  112725. /** @hidden */
  112726. _extension: string;
  112727. /** @hidden */
  112728. _files: Nullable<string[]>;
  112729. /** @hidden */
  112730. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  112731. /** @hidden */
  112732. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  112733. /** @hidden */
  112734. _framebuffer: Nullable<WebGLFramebuffer>;
  112735. /** @hidden */
  112736. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  112737. /** @hidden */
  112738. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  112739. /** @hidden */
  112740. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  112741. /** @hidden */
  112742. _attachments: Nullable<number[]>;
  112743. /** @hidden */
  112744. _cachedCoordinatesMode: Nullable<number>;
  112745. /** @hidden */
  112746. _cachedWrapU: Nullable<number>;
  112747. /** @hidden */
  112748. _cachedWrapV: Nullable<number>;
  112749. /** @hidden */
  112750. _cachedWrapR: Nullable<number>;
  112751. /** @hidden */
  112752. _cachedAnisotropicFilteringLevel: Nullable<number>;
  112753. /** @hidden */
  112754. _isDisabled: boolean;
  112755. /** @hidden */
  112756. _compression: Nullable<string>;
  112757. /** @hidden */
  112758. _generateStencilBuffer: boolean;
  112759. /** @hidden */
  112760. _generateDepthBuffer: boolean;
  112761. /** @hidden */
  112762. _comparisonFunction: number;
  112763. /** @hidden */
  112764. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  112765. /** @hidden */
  112766. _lodGenerationScale: number;
  112767. /** @hidden */
  112768. _lodGenerationOffset: number;
  112769. /** @hidden */
  112770. _depthStencilTexture: Nullable<InternalTexture>;
  112771. /** @hidden */
  112772. _colorTextureArray: Nullable<WebGLTexture>;
  112773. /** @hidden */
  112774. _depthStencilTextureArray: Nullable<WebGLTexture>;
  112775. /** @hidden */
  112776. _lodTextureHigh: Nullable<BaseTexture>;
  112777. /** @hidden */
  112778. _lodTextureMid: Nullable<BaseTexture>;
  112779. /** @hidden */
  112780. _lodTextureLow: Nullable<BaseTexture>;
  112781. /** @hidden */
  112782. _isRGBD: boolean;
  112783. /** @hidden */
  112784. _linearSpecularLOD: boolean;
  112785. /** @hidden */
  112786. _irradianceTexture: Nullable<BaseTexture>;
  112787. /** @hidden */
  112788. _webGLTexture: Nullable<WebGLTexture>;
  112789. /** @hidden */
  112790. _references: number;
  112791. private _engine;
  112792. /**
  112793. * Gets the Engine the texture belongs to.
  112794. * @returns The babylon engine
  112795. */
  112796. getEngine(): ThinEngine;
  112797. /**
  112798. * Gets the data source type of the texture
  112799. */
  112800. get source(): InternalTextureSource;
  112801. /**
  112802. * Creates a new InternalTexture
  112803. * @param engine defines the engine to use
  112804. * @param source defines the type of data that will be used
  112805. * @param delayAllocation if the texture allocation should be delayed (default: false)
  112806. */
  112807. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  112808. /**
  112809. * Increments the number of references (ie. the number of Texture that point to it)
  112810. */
  112811. incrementReferences(): void;
  112812. /**
  112813. * Change the size of the texture (not the size of the content)
  112814. * @param width defines the new width
  112815. * @param height defines the new height
  112816. * @param depth defines the new depth (1 by default)
  112817. */
  112818. updateSize(width: int, height: int, depth?: int): void;
  112819. /** @hidden */
  112820. _rebuild(): void;
  112821. /** @hidden */
  112822. _swapAndDie(target: InternalTexture): void;
  112823. /**
  112824. * Dispose the current allocated resources
  112825. */
  112826. dispose(): void;
  112827. }
  112828. }
  112829. declare module BABYLON {
  112830. /**
  112831. * Class used to work with sound analyzer using fast fourier transform (FFT)
  112832. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112833. */
  112834. export class Analyser {
  112835. /**
  112836. * Gets or sets the smoothing
  112837. * @ignorenaming
  112838. */
  112839. SMOOTHING: number;
  112840. /**
  112841. * Gets or sets the FFT table size
  112842. * @ignorenaming
  112843. */
  112844. FFT_SIZE: number;
  112845. /**
  112846. * Gets or sets the bar graph amplitude
  112847. * @ignorenaming
  112848. */
  112849. BARGRAPHAMPLITUDE: number;
  112850. /**
  112851. * Gets or sets the position of the debug canvas
  112852. * @ignorenaming
  112853. */
  112854. DEBUGCANVASPOS: {
  112855. x: number;
  112856. y: number;
  112857. };
  112858. /**
  112859. * Gets or sets the debug canvas size
  112860. * @ignorenaming
  112861. */
  112862. DEBUGCANVASSIZE: {
  112863. width: number;
  112864. height: number;
  112865. };
  112866. private _byteFreqs;
  112867. private _byteTime;
  112868. private _floatFreqs;
  112869. private _webAudioAnalyser;
  112870. private _debugCanvas;
  112871. private _debugCanvasContext;
  112872. private _scene;
  112873. private _registerFunc;
  112874. private _audioEngine;
  112875. /**
  112876. * Creates a new analyser
  112877. * @param scene defines hosting scene
  112878. */
  112879. constructor(scene: Scene);
  112880. /**
  112881. * Get the number of data values you will have to play with for the visualization
  112882. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  112883. * @returns a number
  112884. */
  112885. getFrequencyBinCount(): number;
  112886. /**
  112887. * Gets the current frequency data as a byte array
  112888. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  112889. * @returns a Uint8Array
  112890. */
  112891. getByteFrequencyData(): Uint8Array;
  112892. /**
  112893. * Gets the current waveform as a byte array
  112894. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  112895. * @returns a Uint8Array
  112896. */
  112897. getByteTimeDomainData(): Uint8Array;
  112898. /**
  112899. * Gets the current frequency data as a float array
  112900. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  112901. * @returns a Float32Array
  112902. */
  112903. getFloatFrequencyData(): Float32Array;
  112904. /**
  112905. * Renders the debug canvas
  112906. */
  112907. drawDebugCanvas(): void;
  112908. /**
  112909. * Stops rendering the debug canvas and removes it
  112910. */
  112911. stopDebugCanvas(): void;
  112912. /**
  112913. * Connects two audio nodes
  112914. * @param inputAudioNode defines first node to connect
  112915. * @param outputAudioNode defines second node to connect
  112916. */
  112917. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  112918. /**
  112919. * Releases all associated resources
  112920. */
  112921. dispose(): void;
  112922. }
  112923. }
  112924. declare module BABYLON {
  112925. /**
  112926. * This represents an audio engine and it is responsible
  112927. * to play, synchronize and analyse sounds throughout the application.
  112928. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112929. */
  112930. export interface IAudioEngine extends IDisposable {
  112931. /**
  112932. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  112933. */
  112934. readonly canUseWebAudio: boolean;
  112935. /**
  112936. * Gets the current AudioContext if available.
  112937. */
  112938. readonly audioContext: Nullable<AudioContext>;
  112939. /**
  112940. * The master gain node defines the global audio volume of your audio engine.
  112941. */
  112942. readonly masterGain: GainNode;
  112943. /**
  112944. * Gets whether or not mp3 are supported by your browser.
  112945. */
  112946. readonly isMP3supported: boolean;
  112947. /**
  112948. * Gets whether or not ogg are supported by your browser.
  112949. */
  112950. readonly isOGGsupported: boolean;
  112951. /**
  112952. * Defines if Babylon should emit a warning if WebAudio is not supported.
  112953. * @ignoreNaming
  112954. */
  112955. WarnedWebAudioUnsupported: boolean;
  112956. /**
  112957. * Defines if the audio engine relies on a custom unlocked button.
  112958. * In this case, the embedded button will not be displayed.
  112959. */
  112960. useCustomUnlockedButton: boolean;
  112961. /**
  112962. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  112963. */
  112964. readonly unlocked: boolean;
  112965. /**
  112966. * Event raised when audio has been unlocked on the browser.
  112967. */
  112968. onAudioUnlockedObservable: Observable<AudioEngine>;
  112969. /**
  112970. * Event raised when audio has been locked on the browser.
  112971. */
  112972. onAudioLockedObservable: Observable<AudioEngine>;
  112973. /**
  112974. * Flags the audio engine in Locked state.
  112975. * This happens due to new browser policies preventing audio to autoplay.
  112976. */
  112977. lock(): void;
  112978. /**
  112979. * Unlocks the audio engine once a user action has been done on the dom.
  112980. * This is helpful to resume play once browser policies have been satisfied.
  112981. */
  112982. unlock(): void;
  112983. /**
  112984. * Gets the global volume sets on the master gain.
  112985. * @returns the global volume if set or -1 otherwise
  112986. */
  112987. getGlobalVolume(): number;
  112988. /**
  112989. * Sets the global volume of your experience (sets on the master gain).
  112990. * @param newVolume Defines the new global volume of the application
  112991. */
  112992. setGlobalVolume(newVolume: number): void;
  112993. /**
  112994. * Connect the audio engine to an audio analyser allowing some amazing
  112995. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  112996. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  112997. * @param analyser The analyser to connect to the engine
  112998. */
  112999. connectToAnalyser(analyser: Analyser): void;
  113000. }
  113001. /**
  113002. * This represents the default audio engine used in babylon.
  113003. * It is responsible to play, synchronize and analyse sounds throughout the application.
  113004. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113005. */
  113006. export class AudioEngine implements IAudioEngine {
  113007. private _audioContext;
  113008. private _audioContextInitialized;
  113009. private _muteButton;
  113010. private _hostElement;
  113011. /**
  113012. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  113013. */
  113014. canUseWebAudio: boolean;
  113015. /**
  113016. * The master gain node defines the global audio volume of your audio engine.
  113017. */
  113018. masterGain: GainNode;
  113019. /**
  113020. * Defines if Babylon should emit a warning if WebAudio is not supported.
  113021. * @ignoreNaming
  113022. */
  113023. WarnedWebAudioUnsupported: boolean;
  113024. /**
  113025. * Gets whether or not mp3 are supported by your browser.
  113026. */
  113027. isMP3supported: boolean;
  113028. /**
  113029. * Gets whether or not ogg are supported by your browser.
  113030. */
  113031. isOGGsupported: boolean;
  113032. /**
  113033. * Gets whether audio has been unlocked on the device.
  113034. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  113035. * a user interaction has happened.
  113036. */
  113037. unlocked: boolean;
  113038. /**
  113039. * Defines if the audio engine relies on a custom unlocked button.
  113040. * In this case, the embedded button will not be displayed.
  113041. */
  113042. useCustomUnlockedButton: boolean;
  113043. /**
  113044. * Event raised when audio has been unlocked on the browser.
  113045. */
  113046. onAudioUnlockedObservable: Observable<AudioEngine>;
  113047. /**
  113048. * Event raised when audio has been locked on the browser.
  113049. */
  113050. onAudioLockedObservable: Observable<AudioEngine>;
  113051. /**
  113052. * Gets the current AudioContext if available.
  113053. */
  113054. get audioContext(): Nullable<AudioContext>;
  113055. private _connectedAnalyser;
  113056. /**
  113057. * Instantiates a new audio engine.
  113058. *
  113059. * There should be only one per page as some browsers restrict the number
  113060. * of audio contexts you can create.
  113061. * @param hostElement defines the host element where to display the mute icon if necessary
  113062. */
  113063. constructor(hostElement?: Nullable<HTMLElement>);
  113064. /**
  113065. * Flags the audio engine in Locked state.
  113066. * This happens due to new browser policies preventing audio to autoplay.
  113067. */
  113068. lock(): void;
  113069. /**
  113070. * Unlocks the audio engine once a user action has been done on the dom.
  113071. * This is helpful to resume play once browser policies have been satisfied.
  113072. */
  113073. unlock(): void;
  113074. private _resumeAudioContext;
  113075. private _initializeAudioContext;
  113076. private _tryToRun;
  113077. private _triggerRunningState;
  113078. private _triggerSuspendedState;
  113079. private _displayMuteButton;
  113080. private _moveButtonToTopLeft;
  113081. private _onResize;
  113082. private _hideMuteButton;
  113083. /**
  113084. * Destroy and release the resources associated with the audio ccontext.
  113085. */
  113086. dispose(): void;
  113087. /**
  113088. * Gets the global volume sets on the master gain.
  113089. * @returns the global volume if set or -1 otherwise
  113090. */
  113091. getGlobalVolume(): number;
  113092. /**
  113093. * Sets the global volume of your experience (sets on the master gain).
  113094. * @param newVolume Defines the new global volume of the application
  113095. */
  113096. setGlobalVolume(newVolume: number): void;
  113097. /**
  113098. * Connect the audio engine to an audio analyser allowing some amazing
  113099. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  113100. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  113101. * @param analyser The analyser to connect to the engine
  113102. */
  113103. connectToAnalyser(analyser: Analyser): void;
  113104. }
  113105. }
  113106. declare module BABYLON {
  113107. /**
  113108. * Interface used to present a loading screen while loading a scene
  113109. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113110. */
  113111. export interface ILoadingScreen {
  113112. /**
  113113. * Function called to display the loading screen
  113114. */
  113115. displayLoadingUI: () => void;
  113116. /**
  113117. * Function called to hide the loading screen
  113118. */
  113119. hideLoadingUI: () => void;
  113120. /**
  113121. * Gets or sets the color to use for the background
  113122. */
  113123. loadingUIBackgroundColor: string;
  113124. /**
  113125. * Gets or sets the text to display while loading
  113126. */
  113127. loadingUIText: string;
  113128. }
  113129. /**
  113130. * Class used for the default loading screen
  113131. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113132. */
  113133. export class DefaultLoadingScreen implements ILoadingScreen {
  113134. private _renderingCanvas;
  113135. private _loadingText;
  113136. private _loadingDivBackgroundColor;
  113137. private _loadingDiv;
  113138. private _loadingTextDiv;
  113139. /** Gets or sets the logo url to use for the default loading screen */
  113140. static DefaultLogoUrl: string;
  113141. /** Gets or sets the spinner url to use for the default loading screen */
  113142. static DefaultSpinnerUrl: string;
  113143. /**
  113144. * Creates a new default loading screen
  113145. * @param _renderingCanvas defines the canvas used to render the scene
  113146. * @param _loadingText defines the default text to display
  113147. * @param _loadingDivBackgroundColor defines the default background color
  113148. */
  113149. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  113150. /**
  113151. * Function called to display the loading screen
  113152. */
  113153. displayLoadingUI(): void;
  113154. /**
  113155. * Function called to hide the loading screen
  113156. */
  113157. hideLoadingUI(): void;
  113158. /**
  113159. * Gets or sets the text to display while loading
  113160. */
  113161. set loadingUIText(text: string);
  113162. get loadingUIText(): string;
  113163. /**
  113164. * Gets or sets the color to use for the background
  113165. */
  113166. get loadingUIBackgroundColor(): string;
  113167. set loadingUIBackgroundColor(color: string);
  113168. private _resizeLoadingUI;
  113169. }
  113170. }
  113171. declare module BABYLON {
  113172. /**
  113173. * Interface for any object that can request an animation frame
  113174. */
  113175. export interface ICustomAnimationFrameRequester {
  113176. /**
  113177. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  113178. */
  113179. renderFunction?: Function;
  113180. /**
  113181. * Called to request the next frame to render to
  113182. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  113183. */
  113184. requestAnimationFrame: Function;
  113185. /**
  113186. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  113187. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  113188. */
  113189. requestID?: number;
  113190. }
  113191. }
  113192. declare module BABYLON {
  113193. /**
  113194. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  113195. */
  113196. export class PerformanceMonitor {
  113197. private _enabled;
  113198. private _rollingFrameTime;
  113199. private _lastFrameTimeMs;
  113200. /**
  113201. * constructor
  113202. * @param frameSampleSize The number of samples required to saturate the sliding window
  113203. */
  113204. constructor(frameSampleSize?: number);
  113205. /**
  113206. * Samples current frame
  113207. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  113208. */
  113209. sampleFrame(timeMs?: number): void;
  113210. /**
  113211. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  113212. */
  113213. get averageFrameTime(): number;
  113214. /**
  113215. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  113216. */
  113217. get averageFrameTimeVariance(): number;
  113218. /**
  113219. * Returns the frame time of the most recent frame
  113220. */
  113221. get instantaneousFrameTime(): number;
  113222. /**
  113223. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  113224. */
  113225. get averageFPS(): number;
  113226. /**
  113227. * Returns the average framerate in frames per second using the most recent frame time
  113228. */
  113229. get instantaneousFPS(): number;
  113230. /**
  113231. * Returns true if enough samples have been taken to completely fill the sliding window
  113232. */
  113233. get isSaturated(): boolean;
  113234. /**
  113235. * Enables contributions to the sliding window sample set
  113236. */
  113237. enable(): void;
  113238. /**
  113239. * Disables contributions to the sliding window sample set
  113240. * Samples will not be interpolated over the disabled period
  113241. */
  113242. disable(): void;
  113243. /**
  113244. * Returns true if sampling is enabled
  113245. */
  113246. get isEnabled(): boolean;
  113247. /**
  113248. * Resets performance monitor
  113249. */
  113250. reset(): void;
  113251. }
  113252. /**
  113253. * RollingAverage
  113254. *
  113255. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  113256. */
  113257. export class RollingAverage {
  113258. /**
  113259. * Current average
  113260. */
  113261. average: number;
  113262. /**
  113263. * Current variance
  113264. */
  113265. variance: number;
  113266. protected _samples: Array<number>;
  113267. protected _sampleCount: number;
  113268. protected _pos: number;
  113269. protected _m2: number;
  113270. /**
  113271. * constructor
  113272. * @param length The number of samples required to saturate the sliding window
  113273. */
  113274. constructor(length: number);
  113275. /**
  113276. * Adds a sample to the sample set
  113277. * @param v The sample value
  113278. */
  113279. add(v: number): void;
  113280. /**
  113281. * Returns previously added values or null if outside of history or outside the sliding window domain
  113282. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  113283. * @return Value previously recorded with add() or null if outside of range
  113284. */
  113285. history(i: number): number;
  113286. /**
  113287. * Returns true if enough samples have been taken to completely fill the sliding window
  113288. * @return true if sample-set saturated
  113289. */
  113290. isSaturated(): boolean;
  113291. /**
  113292. * Resets the rolling average (equivalent to 0 samples taken so far)
  113293. */
  113294. reset(): void;
  113295. /**
  113296. * Wraps a value around the sample range boundaries
  113297. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  113298. * @return Wrapped position in sample range
  113299. */
  113300. protected _wrapPosition(i: number): number;
  113301. }
  113302. }
  113303. declare module BABYLON {
  113304. /**
  113305. * This class is used to track a performance counter which is number based.
  113306. * The user has access to many properties which give statistics of different nature.
  113307. *
  113308. * The implementer can track two kinds of Performance Counter: time and count.
  113309. * 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.
  113310. * 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.
  113311. */
  113312. export class PerfCounter {
  113313. /**
  113314. * Gets or sets a global boolean to turn on and off all the counters
  113315. */
  113316. static Enabled: boolean;
  113317. /**
  113318. * Returns the smallest value ever
  113319. */
  113320. get min(): number;
  113321. /**
  113322. * Returns the biggest value ever
  113323. */
  113324. get max(): number;
  113325. /**
  113326. * Returns the average value since the performance counter is running
  113327. */
  113328. get average(): number;
  113329. /**
  113330. * Returns the average value of the last second the counter was monitored
  113331. */
  113332. get lastSecAverage(): number;
  113333. /**
  113334. * Returns the current value
  113335. */
  113336. get current(): number;
  113337. /**
  113338. * Gets the accumulated total
  113339. */
  113340. get total(): number;
  113341. /**
  113342. * Gets the total value count
  113343. */
  113344. get count(): number;
  113345. /**
  113346. * Creates a new counter
  113347. */
  113348. constructor();
  113349. /**
  113350. * Call this method to start monitoring a new frame.
  113351. * 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.
  113352. */
  113353. fetchNewFrame(): void;
  113354. /**
  113355. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  113356. * @param newCount the count value to add to the monitored count
  113357. * @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.
  113358. */
  113359. addCount(newCount: number, fetchResult: boolean): void;
  113360. /**
  113361. * Start monitoring this performance counter
  113362. */
  113363. beginMonitoring(): void;
  113364. /**
  113365. * Compute the time lapsed since the previous beginMonitoring() call.
  113366. * @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
  113367. */
  113368. endMonitoring(newFrame?: boolean): void;
  113369. private _fetchResult;
  113370. private _startMonitoringTime;
  113371. private _min;
  113372. private _max;
  113373. private _average;
  113374. private _current;
  113375. private _totalValueCount;
  113376. private _totalAccumulated;
  113377. private _lastSecAverage;
  113378. private _lastSecAccumulated;
  113379. private _lastSecTime;
  113380. private _lastSecValueCount;
  113381. }
  113382. }
  113383. declare module BABYLON {
  113384. interface ThinEngine {
  113385. /**
  113386. * Sets alpha constants used by some alpha blending modes
  113387. * @param r defines the red component
  113388. * @param g defines the green component
  113389. * @param b defines the blue component
  113390. * @param a defines the alpha component
  113391. */
  113392. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  113393. /**
  113394. * Sets the current alpha mode
  113395. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  113396. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  113397. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113398. */
  113399. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  113400. /**
  113401. * Gets the current alpha mode
  113402. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113403. * @returns the current alpha mode
  113404. */
  113405. getAlphaMode(): number;
  113406. /**
  113407. * Sets the current alpha equation
  113408. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  113409. */
  113410. setAlphaEquation(equation: number): void;
  113411. /**
  113412. * Gets the current alpha equation.
  113413. * @returns the current alpha equation
  113414. */
  113415. getAlphaEquation(): number;
  113416. }
  113417. }
  113418. declare module BABYLON {
  113419. interface ThinEngine {
  113420. /** @hidden */
  113421. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  113422. }
  113423. }
  113424. declare module BABYLON {
  113425. /**
  113426. * Defines the interface used by display changed events
  113427. */
  113428. export interface IDisplayChangedEventArgs {
  113429. /** Gets the vrDisplay object (if any) */
  113430. vrDisplay: Nullable<any>;
  113431. /** Gets a boolean indicating if webVR is supported */
  113432. vrSupported: boolean;
  113433. }
  113434. /**
  113435. * Defines the interface used by objects containing a viewport (like a camera)
  113436. */
  113437. interface IViewportOwnerLike {
  113438. /**
  113439. * Gets or sets the viewport
  113440. */
  113441. viewport: IViewportLike;
  113442. }
  113443. /**
  113444. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  113445. */
  113446. export class Engine extends ThinEngine {
  113447. /** Defines that alpha blending is disabled */
  113448. static readonly ALPHA_DISABLE: number;
  113449. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  113450. static readonly ALPHA_ADD: number;
  113451. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  113452. static readonly ALPHA_COMBINE: number;
  113453. /** Defines that alpha blending to DEST - SRC * DEST */
  113454. static readonly ALPHA_SUBTRACT: number;
  113455. /** Defines that alpha blending to SRC * DEST */
  113456. static readonly ALPHA_MULTIPLY: number;
  113457. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  113458. static readonly ALPHA_MAXIMIZED: number;
  113459. /** Defines that alpha blending to SRC + DEST */
  113460. static readonly ALPHA_ONEONE: number;
  113461. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  113462. static readonly ALPHA_PREMULTIPLIED: number;
  113463. /**
  113464. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  113465. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  113466. */
  113467. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  113468. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  113469. static readonly ALPHA_INTERPOLATE: number;
  113470. /**
  113471. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  113472. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  113473. */
  113474. static readonly ALPHA_SCREENMODE: number;
  113475. /** Defines that the ressource is not delayed*/
  113476. static readonly DELAYLOADSTATE_NONE: number;
  113477. /** Defines that the ressource was successfully delay loaded */
  113478. static readonly DELAYLOADSTATE_LOADED: number;
  113479. /** Defines that the ressource is currently delay loading */
  113480. static readonly DELAYLOADSTATE_LOADING: number;
  113481. /** Defines that the ressource is delayed and has not started loading */
  113482. static readonly DELAYLOADSTATE_NOTLOADED: number;
  113483. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  113484. static readonly NEVER: number;
  113485. /** 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 */
  113486. static readonly ALWAYS: number;
  113487. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  113488. static readonly LESS: number;
  113489. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  113490. static readonly EQUAL: number;
  113491. /** 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 */
  113492. static readonly LEQUAL: number;
  113493. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  113494. static readonly GREATER: number;
  113495. /** 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 */
  113496. static readonly GEQUAL: number;
  113497. /** 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 */
  113498. static readonly NOTEQUAL: number;
  113499. /** Passed to stencilOperation to specify that stencil value must be kept */
  113500. static readonly KEEP: number;
  113501. /** Passed to stencilOperation to specify that stencil value must be replaced */
  113502. static readonly REPLACE: number;
  113503. /** Passed to stencilOperation to specify that stencil value must be incremented */
  113504. static readonly INCR: number;
  113505. /** Passed to stencilOperation to specify that stencil value must be decremented */
  113506. static readonly DECR: number;
  113507. /** Passed to stencilOperation to specify that stencil value must be inverted */
  113508. static readonly INVERT: number;
  113509. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  113510. static readonly INCR_WRAP: number;
  113511. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  113512. static readonly DECR_WRAP: number;
  113513. /** Texture is not repeating outside of 0..1 UVs */
  113514. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  113515. /** Texture is repeating outside of 0..1 UVs */
  113516. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  113517. /** Texture is repeating and mirrored */
  113518. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  113519. /** ALPHA */
  113520. static readonly TEXTUREFORMAT_ALPHA: number;
  113521. /** LUMINANCE */
  113522. static readonly TEXTUREFORMAT_LUMINANCE: number;
  113523. /** LUMINANCE_ALPHA */
  113524. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  113525. /** RGB */
  113526. static readonly TEXTUREFORMAT_RGB: number;
  113527. /** RGBA */
  113528. static readonly TEXTUREFORMAT_RGBA: number;
  113529. /** RED */
  113530. static readonly TEXTUREFORMAT_RED: number;
  113531. /** RED (2nd reference) */
  113532. static readonly TEXTUREFORMAT_R: number;
  113533. /** RG */
  113534. static readonly TEXTUREFORMAT_RG: number;
  113535. /** RED_INTEGER */
  113536. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  113537. /** RED_INTEGER (2nd reference) */
  113538. static readonly TEXTUREFORMAT_R_INTEGER: number;
  113539. /** RG_INTEGER */
  113540. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  113541. /** RGB_INTEGER */
  113542. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  113543. /** RGBA_INTEGER */
  113544. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  113545. /** UNSIGNED_BYTE */
  113546. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  113547. /** UNSIGNED_BYTE (2nd reference) */
  113548. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  113549. /** FLOAT */
  113550. static readonly TEXTURETYPE_FLOAT: number;
  113551. /** HALF_FLOAT */
  113552. static readonly TEXTURETYPE_HALF_FLOAT: number;
  113553. /** BYTE */
  113554. static readonly TEXTURETYPE_BYTE: number;
  113555. /** SHORT */
  113556. static readonly TEXTURETYPE_SHORT: number;
  113557. /** UNSIGNED_SHORT */
  113558. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  113559. /** INT */
  113560. static readonly TEXTURETYPE_INT: number;
  113561. /** UNSIGNED_INT */
  113562. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  113563. /** UNSIGNED_SHORT_4_4_4_4 */
  113564. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  113565. /** UNSIGNED_SHORT_5_5_5_1 */
  113566. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  113567. /** UNSIGNED_SHORT_5_6_5 */
  113568. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  113569. /** UNSIGNED_INT_2_10_10_10_REV */
  113570. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  113571. /** UNSIGNED_INT_24_8 */
  113572. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  113573. /** UNSIGNED_INT_10F_11F_11F_REV */
  113574. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  113575. /** UNSIGNED_INT_5_9_9_9_REV */
  113576. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  113577. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  113578. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  113579. /** nearest is mag = nearest and min = nearest and mip = linear */
  113580. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  113581. /** Bilinear is mag = linear and min = linear and mip = nearest */
  113582. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  113583. /** Trilinear is mag = linear and min = linear and mip = linear */
  113584. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  113585. /** nearest is mag = nearest and min = nearest and mip = linear */
  113586. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  113587. /** Bilinear is mag = linear and min = linear and mip = nearest */
  113588. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  113589. /** Trilinear is mag = linear and min = linear and mip = linear */
  113590. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  113591. /** mag = nearest and min = nearest and mip = nearest */
  113592. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  113593. /** mag = nearest and min = linear and mip = nearest */
  113594. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  113595. /** mag = nearest and min = linear and mip = linear */
  113596. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  113597. /** mag = nearest and min = linear and mip = none */
  113598. static readonly TEXTURE_NEAREST_LINEAR: number;
  113599. /** mag = nearest and min = nearest and mip = none */
  113600. static readonly TEXTURE_NEAREST_NEAREST: number;
  113601. /** mag = linear and min = nearest and mip = nearest */
  113602. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  113603. /** mag = linear and min = nearest and mip = linear */
  113604. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  113605. /** mag = linear and min = linear and mip = none */
  113606. static readonly TEXTURE_LINEAR_LINEAR: number;
  113607. /** mag = linear and min = nearest and mip = none */
  113608. static readonly TEXTURE_LINEAR_NEAREST: number;
  113609. /** Explicit coordinates mode */
  113610. static readonly TEXTURE_EXPLICIT_MODE: number;
  113611. /** Spherical coordinates mode */
  113612. static readonly TEXTURE_SPHERICAL_MODE: number;
  113613. /** Planar coordinates mode */
  113614. static readonly TEXTURE_PLANAR_MODE: number;
  113615. /** Cubic coordinates mode */
  113616. static readonly TEXTURE_CUBIC_MODE: number;
  113617. /** Projection coordinates mode */
  113618. static readonly TEXTURE_PROJECTION_MODE: number;
  113619. /** Skybox coordinates mode */
  113620. static readonly TEXTURE_SKYBOX_MODE: number;
  113621. /** Inverse Cubic coordinates mode */
  113622. static readonly TEXTURE_INVCUBIC_MODE: number;
  113623. /** Equirectangular coordinates mode */
  113624. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  113625. /** Equirectangular Fixed coordinates mode */
  113626. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  113627. /** Equirectangular Fixed Mirrored coordinates mode */
  113628. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  113629. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  113630. static readonly SCALEMODE_FLOOR: number;
  113631. /** Defines that texture rescaling will look for the nearest power of 2 size */
  113632. static readonly SCALEMODE_NEAREST: number;
  113633. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  113634. static readonly SCALEMODE_CEILING: number;
  113635. /**
  113636. * Returns the current npm package of the sdk
  113637. */
  113638. static get NpmPackage(): string;
  113639. /**
  113640. * Returns the current version of the framework
  113641. */
  113642. static get Version(): string;
  113643. /** Gets the list of created engines */
  113644. static get Instances(): Engine[];
  113645. /**
  113646. * Gets the latest created engine
  113647. */
  113648. static get LastCreatedEngine(): Nullable<Engine>;
  113649. /**
  113650. * Gets the latest created scene
  113651. */
  113652. static get LastCreatedScene(): Nullable<Scene>;
  113653. /**
  113654. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  113655. * @param flag defines which part of the materials must be marked as dirty
  113656. * @param predicate defines a predicate used to filter which materials should be affected
  113657. */
  113658. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  113659. /**
  113660. * Method called to create the default loading screen.
  113661. * This can be overriden in your own app.
  113662. * @param canvas The rendering canvas element
  113663. * @returns The loading screen
  113664. */
  113665. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  113666. /**
  113667. * Method called to create the default rescale post process on each engine.
  113668. */
  113669. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  113670. /**
  113671. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  113672. **/
  113673. enableOfflineSupport: boolean;
  113674. /**
  113675. * 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)
  113676. **/
  113677. disableManifestCheck: boolean;
  113678. /**
  113679. * Gets the list of created scenes
  113680. */
  113681. scenes: Scene[];
  113682. /**
  113683. * Event raised when a new scene is created
  113684. */
  113685. onNewSceneAddedObservable: Observable<Scene>;
  113686. /**
  113687. * Gets the list of created postprocesses
  113688. */
  113689. postProcesses: PostProcess[];
  113690. /**
  113691. * Gets a boolean indicating if the pointer is currently locked
  113692. */
  113693. isPointerLock: boolean;
  113694. /**
  113695. * Observable event triggered each time the rendering canvas is resized
  113696. */
  113697. onResizeObservable: Observable<Engine>;
  113698. /**
  113699. * Observable event triggered each time the canvas loses focus
  113700. */
  113701. onCanvasBlurObservable: Observable<Engine>;
  113702. /**
  113703. * Observable event triggered each time the canvas gains focus
  113704. */
  113705. onCanvasFocusObservable: Observable<Engine>;
  113706. /**
  113707. * Observable event triggered each time the canvas receives pointerout event
  113708. */
  113709. onCanvasPointerOutObservable: Observable<PointerEvent>;
  113710. /**
  113711. * Observable raised when the engine begins a new frame
  113712. */
  113713. onBeginFrameObservable: Observable<Engine>;
  113714. /**
  113715. * If set, will be used to request the next animation frame for the render loop
  113716. */
  113717. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  113718. /**
  113719. * Observable raised when the engine ends the current frame
  113720. */
  113721. onEndFrameObservable: Observable<Engine>;
  113722. /**
  113723. * Observable raised when the engine is about to compile a shader
  113724. */
  113725. onBeforeShaderCompilationObservable: Observable<Engine>;
  113726. /**
  113727. * Observable raised when the engine has jsut compiled a shader
  113728. */
  113729. onAfterShaderCompilationObservable: Observable<Engine>;
  113730. /**
  113731. * Gets the audio engine
  113732. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113733. * @ignorenaming
  113734. */
  113735. static audioEngine: IAudioEngine;
  113736. /**
  113737. * Default AudioEngine factory responsible of creating the Audio Engine.
  113738. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  113739. */
  113740. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  113741. /**
  113742. * Default offline support factory responsible of creating a tool used to store data locally.
  113743. * By default, this will create a Database object if the workload has been embedded.
  113744. */
  113745. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  113746. private _loadingScreen;
  113747. private _pointerLockRequested;
  113748. private _rescalePostProcess;
  113749. private _deterministicLockstep;
  113750. private _lockstepMaxSteps;
  113751. private _timeStep;
  113752. protected get _supportsHardwareTextureRescaling(): boolean;
  113753. private _fps;
  113754. private _deltaTime;
  113755. /** @hidden */
  113756. _drawCalls: PerfCounter;
  113757. /** 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 */
  113758. canvasTabIndex: number;
  113759. /**
  113760. * Turn this value on if you want to pause FPS computation when in background
  113761. */
  113762. disablePerformanceMonitorInBackground: boolean;
  113763. private _performanceMonitor;
  113764. /**
  113765. * Gets the performance monitor attached to this engine
  113766. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  113767. */
  113768. get performanceMonitor(): PerformanceMonitor;
  113769. private _onFocus;
  113770. private _onBlur;
  113771. private _onCanvasPointerOut;
  113772. private _onCanvasBlur;
  113773. private _onCanvasFocus;
  113774. private _onFullscreenChange;
  113775. private _onPointerLockChange;
  113776. /**
  113777. * Gets the HTML element used to attach event listeners
  113778. * @returns a HTML element
  113779. */
  113780. getInputElement(): Nullable<HTMLElement>;
  113781. /**
  113782. * Creates a new engine
  113783. * @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
  113784. * @param antialias defines enable antialiasing (default: false)
  113785. * @param options defines further options to be sent to the getContext() function
  113786. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  113787. */
  113788. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  113789. /**
  113790. * Gets current aspect ratio
  113791. * @param viewportOwner defines the camera to use to get the aspect ratio
  113792. * @param useScreen defines if screen size must be used (or the current render target if any)
  113793. * @returns a number defining the aspect ratio
  113794. */
  113795. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  113796. /**
  113797. * Gets current screen aspect ratio
  113798. * @returns a number defining the aspect ratio
  113799. */
  113800. getScreenAspectRatio(): number;
  113801. /**
  113802. * Gets the client rect of the HTML canvas attached with the current webGL context
  113803. * @returns a client rectanglee
  113804. */
  113805. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  113806. /**
  113807. * Gets the client rect of the HTML element used for events
  113808. * @returns a client rectanglee
  113809. */
  113810. getInputElementClientRect(): Nullable<ClientRect>;
  113811. /**
  113812. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  113813. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113814. * @returns true if engine is in deterministic lock step mode
  113815. */
  113816. isDeterministicLockStep(): boolean;
  113817. /**
  113818. * Gets the max steps when engine is running in deterministic lock step
  113819. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113820. * @returns the max steps
  113821. */
  113822. getLockstepMaxSteps(): number;
  113823. /**
  113824. * Returns the time in ms between steps when using deterministic lock step.
  113825. * @returns time step in (ms)
  113826. */
  113827. getTimeStep(): number;
  113828. /**
  113829. * Force the mipmap generation for the given render target texture
  113830. * @param texture defines the render target texture to use
  113831. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  113832. */
  113833. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  113834. /** States */
  113835. /**
  113836. * Set various states to the webGL context
  113837. * @param culling defines backface culling state
  113838. * @param zOffset defines the value to apply to zOffset (0 by default)
  113839. * @param force defines if states must be applied even if cache is up to date
  113840. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  113841. */
  113842. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  113843. /**
  113844. * Set the z offset to apply to current rendering
  113845. * @param value defines the offset to apply
  113846. */
  113847. setZOffset(value: number): void;
  113848. /**
  113849. * Gets the current value of the zOffset
  113850. * @returns the current zOffset state
  113851. */
  113852. getZOffset(): number;
  113853. /**
  113854. * Enable or disable depth buffering
  113855. * @param enable defines the state to set
  113856. */
  113857. setDepthBuffer(enable: boolean): void;
  113858. /**
  113859. * Gets a boolean indicating if depth writing is enabled
  113860. * @returns the current depth writing state
  113861. */
  113862. getDepthWrite(): boolean;
  113863. /**
  113864. * Enable or disable depth writing
  113865. * @param enable defines the state to set
  113866. */
  113867. setDepthWrite(enable: boolean): void;
  113868. /**
  113869. * Gets a boolean indicating if stencil buffer is enabled
  113870. * @returns the current stencil buffer state
  113871. */
  113872. getStencilBuffer(): boolean;
  113873. /**
  113874. * Enable or disable the stencil buffer
  113875. * @param enable defines if the stencil buffer must be enabled or disabled
  113876. */
  113877. setStencilBuffer(enable: boolean): void;
  113878. /**
  113879. * Gets the current stencil mask
  113880. * @returns a number defining the new stencil mask to use
  113881. */
  113882. getStencilMask(): number;
  113883. /**
  113884. * Sets the current stencil mask
  113885. * @param mask defines the new stencil mask to use
  113886. */
  113887. setStencilMask(mask: number): void;
  113888. /**
  113889. * Gets the current stencil function
  113890. * @returns a number defining the stencil function to use
  113891. */
  113892. getStencilFunction(): number;
  113893. /**
  113894. * Gets the current stencil reference value
  113895. * @returns a number defining the stencil reference value to use
  113896. */
  113897. getStencilFunctionReference(): number;
  113898. /**
  113899. * Gets the current stencil mask
  113900. * @returns a number defining the stencil mask to use
  113901. */
  113902. getStencilFunctionMask(): number;
  113903. /**
  113904. * Sets the current stencil function
  113905. * @param stencilFunc defines the new stencil function to use
  113906. */
  113907. setStencilFunction(stencilFunc: number): void;
  113908. /**
  113909. * Sets the current stencil reference
  113910. * @param reference defines the new stencil reference to use
  113911. */
  113912. setStencilFunctionReference(reference: number): void;
  113913. /**
  113914. * Sets the current stencil mask
  113915. * @param mask defines the new stencil mask to use
  113916. */
  113917. setStencilFunctionMask(mask: number): void;
  113918. /**
  113919. * Gets the current stencil operation when stencil fails
  113920. * @returns a number defining stencil operation to use when stencil fails
  113921. */
  113922. getStencilOperationFail(): number;
  113923. /**
  113924. * Gets the current stencil operation when depth fails
  113925. * @returns a number defining stencil operation to use when depth fails
  113926. */
  113927. getStencilOperationDepthFail(): number;
  113928. /**
  113929. * Gets the current stencil operation when stencil passes
  113930. * @returns a number defining stencil operation to use when stencil passes
  113931. */
  113932. getStencilOperationPass(): number;
  113933. /**
  113934. * Sets the stencil operation to use when stencil fails
  113935. * @param operation defines the stencil operation to use when stencil fails
  113936. */
  113937. setStencilOperationFail(operation: number): void;
  113938. /**
  113939. * Sets the stencil operation to use when depth fails
  113940. * @param operation defines the stencil operation to use when depth fails
  113941. */
  113942. setStencilOperationDepthFail(operation: number): void;
  113943. /**
  113944. * Sets the stencil operation to use when stencil passes
  113945. * @param operation defines the stencil operation to use when stencil passes
  113946. */
  113947. setStencilOperationPass(operation: number): void;
  113948. /**
  113949. * Sets a boolean indicating if the dithering state is enabled or disabled
  113950. * @param value defines the dithering state
  113951. */
  113952. setDitheringState(value: boolean): void;
  113953. /**
  113954. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  113955. * @param value defines the rasterizer state
  113956. */
  113957. setRasterizerState(value: boolean): void;
  113958. /**
  113959. * Gets the current depth function
  113960. * @returns a number defining the depth function
  113961. */
  113962. getDepthFunction(): Nullable<number>;
  113963. /**
  113964. * Sets the current depth function
  113965. * @param depthFunc defines the function to use
  113966. */
  113967. setDepthFunction(depthFunc: number): void;
  113968. /**
  113969. * Sets the current depth function to GREATER
  113970. */
  113971. setDepthFunctionToGreater(): void;
  113972. /**
  113973. * Sets the current depth function to GEQUAL
  113974. */
  113975. setDepthFunctionToGreaterOrEqual(): void;
  113976. /**
  113977. * Sets the current depth function to LESS
  113978. */
  113979. setDepthFunctionToLess(): void;
  113980. /**
  113981. * Sets the current depth function to LEQUAL
  113982. */
  113983. setDepthFunctionToLessOrEqual(): void;
  113984. private _cachedStencilBuffer;
  113985. private _cachedStencilFunction;
  113986. private _cachedStencilMask;
  113987. private _cachedStencilOperationPass;
  113988. private _cachedStencilOperationFail;
  113989. private _cachedStencilOperationDepthFail;
  113990. private _cachedStencilReference;
  113991. /**
  113992. * Caches the the state of the stencil buffer
  113993. */
  113994. cacheStencilState(): void;
  113995. /**
  113996. * Restores the state of the stencil buffer
  113997. */
  113998. restoreStencilState(): void;
  113999. /**
  114000. * Directly set the WebGL Viewport
  114001. * @param x defines the x coordinate of the viewport (in screen space)
  114002. * @param y defines the y coordinate of the viewport (in screen space)
  114003. * @param width defines the width of the viewport (in screen space)
  114004. * @param height defines the height of the viewport (in screen space)
  114005. * @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
  114006. */
  114007. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  114008. /**
  114009. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  114010. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  114011. * @param y defines the y-coordinate of the corner of the clear rectangle
  114012. * @param width defines the width of the clear rectangle
  114013. * @param height defines the height of the clear rectangle
  114014. * @param clearColor defines the clear color
  114015. */
  114016. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  114017. /**
  114018. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  114019. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  114020. * @param y defines the y-coordinate of the corner of the clear rectangle
  114021. * @param width defines the width of the clear rectangle
  114022. * @param height defines the height of the clear rectangle
  114023. */
  114024. enableScissor(x: number, y: number, width: number, height: number): void;
  114025. /**
  114026. * Disable previously set scissor test rectangle
  114027. */
  114028. disableScissor(): void;
  114029. protected _reportDrawCall(): void;
  114030. /**
  114031. * Initializes a webVR display and starts listening to display change events
  114032. * The onVRDisplayChangedObservable will be notified upon these changes
  114033. * @returns The onVRDisplayChangedObservable
  114034. */
  114035. initWebVR(): Observable<IDisplayChangedEventArgs>;
  114036. /** @hidden */
  114037. _prepareVRComponent(): void;
  114038. /** @hidden */
  114039. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  114040. /** @hidden */
  114041. _submitVRFrame(): void;
  114042. /**
  114043. * Call this function to leave webVR mode
  114044. * Will do nothing if webVR is not supported or if there is no webVR device
  114045. * @see http://doc.babylonjs.com/how_to/webvr_camera
  114046. */
  114047. disableVR(): void;
  114048. /**
  114049. * Gets a boolean indicating that the system is in VR mode and is presenting
  114050. * @returns true if VR mode is engaged
  114051. */
  114052. isVRPresenting(): boolean;
  114053. /** @hidden */
  114054. _requestVRFrame(): void;
  114055. /** @hidden */
  114056. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  114057. /**
  114058. * Gets the source code of the vertex shader associated with a specific webGL program
  114059. * @param program defines the program to use
  114060. * @returns a string containing the source code of the vertex shader associated with the program
  114061. */
  114062. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  114063. /**
  114064. * Gets the source code of the fragment shader associated with a specific webGL program
  114065. * @param program defines the program to use
  114066. * @returns a string containing the source code of the fragment shader associated with the program
  114067. */
  114068. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  114069. /**
  114070. * Sets a depth stencil texture from a render target to the according uniform.
  114071. * @param channel The texture channel
  114072. * @param uniform The uniform to set
  114073. * @param texture The render target texture containing the depth stencil texture to apply
  114074. */
  114075. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  114076. /**
  114077. * Sets a texture to the webGL context from a postprocess
  114078. * @param channel defines the channel to use
  114079. * @param postProcess defines the source postprocess
  114080. */
  114081. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  114082. /**
  114083. * Binds the output of the passed in post process to the texture channel specified
  114084. * @param channel The channel the texture should be bound to
  114085. * @param postProcess The post process which's output should be bound
  114086. */
  114087. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  114088. protected _rebuildBuffers(): void;
  114089. /** @hidden */
  114090. _renderFrame(): void;
  114091. _renderLoop(): void;
  114092. /** @hidden */
  114093. _renderViews(): boolean;
  114094. /**
  114095. * Toggle full screen mode
  114096. * @param requestPointerLock defines if a pointer lock should be requested from the user
  114097. */
  114098. switchFullscreen(requestPointerLock: boolean): void;
  114099. /**
  114100. * Enters full screen mode
  114101. * @param requestPointerLock defines if a pointer lock should be requested from the user
  114102. */
  114103. enterFullscreen(requestPointerLock: boolean): void;
  114104. /**
  114105. * Exits full screen mode
  114106. */
  114107. exitFullscreen(): void;
  114108. /**
  114109. * Enters Pointerlock mode
  114110. */
  114111. enterPointerlock(): void;
  114112. /**
  114113. * Exits Pointerlock mode
  114114. */
  114115. exitPointerlock(): void;
  114116. /**
  114117. * Begin a new frame
  114118. */
  114119. beginFrame(): void;
  114120. /**
  114121. * Enf the current frame
  114122. */
  114123. endFrame(): void;
  114124. resize(): void;
  114125. /**
  114126. * Force a specific size of the canvas
  114127. * @param width defines the new canvas' width
  114128. * @param height defines the new canvas' height
  114129. */
  114130. setSize(width: number, height: number): void;
  114131. /**
  114132. * Updates a dynamic vertex buffer.
  114133. * @param vertexBuffer the vertex buffer to update
  114134. * @param data the data used to update the vertex buffer
  114135. * @param byteOffset the byte offset of the data
  114136. * @param byteLength the byte length of the data
  114137. */
  114138. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  114139. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  114140. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114141. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114142. _releaseTexture(texture: InternalTexture): void;
  114143. /**
  114144. * @hidden
  114145. * Rescales a texture
  114146. * @param source input texutre
  114147. * @param destination destination texture
  114148. * @param scene scene to use to render the resize
  114149. * @param internalFormat format to use when resizing
  114150. * @param onComplete callback to be called when resize has completed
  114151. */
  114152. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  114153. /**
  114154. * Gets the current framerate
  114155. * @returns a number representing the framerate
  114156. */
  114157. getFps(): number;
  114158. /**
  114159. * Gets the time spent between current and previous frame
  114160. * @returns a number representing the delta time in ms
  114161. */
  114162. getDeltaTime(): number;
  114163. private _measureFps;
  114164. /** @hidden */
  114165. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  114166. /**
  114167. * Update a dynamic index buffer
  114168. * @param indexBuffer defines the target index buffer
  114169. * @param indices defines the data to update
  114170. * @param offset defines the offset in the target index buffer where update should start
  114171. */
  114172. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  114173. /**
  114174. * Updates the sample count of a render target texture
  114175. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  114176. * @param texture defines the texture to update
  114177. * @param samples defines the sample count to set
  114178. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  114179. */
  114180. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  114181. /**
  114182. * Updates a depth texture Comparison Mode and Function.
  114183. * If the comparison Function is equal to 0, the mode will be set to none.
  114184. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  114185. * @param texture The texture to set the comparison function for
  114186. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  114187. */
  114188. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  114189. /**
  114190. * Creates a webGL buffer to use with instanciation
  114191. * @param capacity defines the size of the buffer
  114192. * @returns the webGL buffer
  114193. */
  114194. createInstancesBuffer(capacity: number): DataBuffer;
  114195. /**
  114196. * Delete a webGL buffer used with instanciation
  114197. * @param buffer defines the webGL buffer to delete
  114198. */
  114199. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  114200. private _clientWaitAsync;
  114201. /** @hidden */
  114202. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  114203. dispose(): void;
  114204. private _disableTouchAction;
  114205. /**
  114206. * Display the loading screen
  114207. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114208. */
  114209. displayLoadingUI(): void;
  114210. /**
  114211. * Hide the loading screen
  114212. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114213. */
  114214. hideLoadingUI(): void;
  114215. /**
  114216. * Gets the current loading screen object
  114217. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114218. */
  114219. get loadingScreen(): ILoadingScreen;
  114220. /**
  114221. * Sets the current loading screen object
  114222. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114223. */
  114224. set loadingScreen(loadingScreen: ILoadingScreen);
  114225. /**
  114226. * Sets the current loading screen text
  114227. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114228. */
  114229. set loadingUIText(text: string);
  114230. /**
  114231. * Sets the current loading screen background color
  114232. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114233. */
  114234. set loadingUIBackgroundColor(color: string);
  114235. /** Pointerlock and fullscreen */
  114236. /**
  114237. * Ask the browser to promote the current element to pointerlock mode
  114238. * @param element defines the DOM element to promote
  114239. */
  114240. static _RequestPointerlock(element: HTMLElement): void;
  114241. /**
  114242. * Asks the browser to exit pointerlock mode
  114243. */
  114244. static _ExitPointerlock(): void;
  114245. /**
  114246. * Ask the browser to promote the current element to fullscreen rendering mode
  114247. * @param element defines the DOM element to promote
  114248. */
  114249. static _RequestFullscreen(element: HTMLElement): void;
  114250. /**
  114251. * Asks the browser to exit fullscreen mode
  114252. */
  114253. static _ExitFullscreen(): void;
  114254. }
  114255. }
  114256. declare module BABYLON {
  114257. /**
  114258. * The engine store class is responsible to hold all the instances of Engine and Scene created
  114259. * during the life time of the application.
  114260. */
  114261. export class EngineStore {
  114262. /** Gets the list of created engines */
  114263. static Instances: Engine[];
  114264. /** @hidden */
  114265. static _LastCreatedScene: Nullable<Scene>;
  114266. /**
  114267. * Gets the latest created engine
  114268. */
  114269. static get LastCreatedEngine(): Nullable<Engine>;
  114270. /**
  114271. * Gets the latest created scene
  114272. */
  114273. static get LastCreatedScene(): Nullable<Scene>;
  114274. /**
  114275. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  114276. * @ignorenaming
  114277. */
  114278. static UseFallbackTexture: boolean;
  114279. /**
  114280. * Texture content used if a texture cannot loaded
  114281. * @ignorenaming
  114282. */
  114283. static FallbackTexture: string;
  114284. }
  114285. }
  114286. declare module BABYLON {
  114287. /**
  114288. * Helper class that provides a small promise polyfill
  114289. */
  114290. export class PromisePolyfill {
  114291. /**
  114292. * Static function used to check if the polyfill is required
  114293. * If this is the case then the function will inject the polyfill to window.Promise
  114294. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  114295. */
  114296. static Apply(force?: boolean): void;
  114297. }
  114298. }
  114299. declare module BABYLON {
  114300. /**
  114301. * Interface for screenshot methods with describe argument called `size` as object with options
  114302. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  114303. */
  114304. export interface IScreenshotSize {
  114305. /**
  114306. * number in pixels for canvas height
  114307. */
  114308. height?: number;
  114309. /**
  114310. * multiplier allowing render at a higher or lower resolution
  114311. * If value is defined then height and width will be ignored and taken from camera
  114312. */
  114313. precision?: number;
  114314. /**
  114315. * number in pixels for canvas width
  114316. */
  114317. width?: number;
  114318. }
  114319. }
  114320. declare module BABYLON {
  114321. interface IColor4Like {
  114322. r: float;
  114323. g: float;
  114324. b: float;
  114325. a: float;
  114326. }
  114327. /**
  114328. * Class containing a set of static utilities functions
  114329. */
  114330. export class Tools {
  114331. /**
  114332. * Gets or sets the base URL to use to load assets
  114333. */
  114334. static get BaseUrl(): string;
  114335. static set BaseUrl(value: string);
  114336. /**
  114337. * Enable/Disable Custom HTTP Request Headers globally.
  114338. * default = false
  114339. * @see CustomRequestHeaders
  114340. */
  114341. static UseCustomRequestHeaders: boolean;
  114342. /**
  114343. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  114344. * i.e. when loading files, where the server/service expects an Authorization header
  114345. */
  114346. static CustomRequestHeaders: {
  114347. [key: string]: string;
  114348. };
  114349. /**
  114350. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  114351. */
  114352. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  114353. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  114354. /**
  114355. * Default behaviour for cors in the application.
  114356. * It can be a string if the expected behavior is identical in the entire app.
  114357. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  114358. */
  114359. static get CorsBehavior(): string | ((url: string | string[]) => string);
  114360. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  114361. /**
  114362. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  114363. * @ignorenaming
  114364. */
  114365. static get UseFallbackTexture(): boolean;
  114366. static set UseFallbackTexture(value: boolean);
  114367. /**
  114368. * Use this object to register external classes like custom textures or material
  114369. * to allow the laoders to instantiate them
  114370. */
  114371. static get RegisteredExternalClasses(): {
  114372. [key: string]: Object;
  114373. };
  114374. static set RegisteredExternalClasses(classes: {
  114375. [key: string]: Object;
  114376. });
  114377. /**
  114378. * Texture content used if a texture cannot loaded
  114379. * @ignorenaming
  114380. */
  114381. static get fallbackTexture(): string;
  114382. static set fallbackTexture(value: string);
  114383. /**
  114384. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  114385. * @param u defines the coordinate on X axis
  114386. * @param v defines the coordinate on Y axis
  114387. * @param width defines the width of the source data
  114388. * @param height defines the height of the source data
  114389. * @param pixels defines the source byte array
  114390. * @param color defines the output color
  114391. */
  114392. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  114393. /**
  114394. * Interpolates between a and b via alpha
  114395. * @param a The lower value (returned when alpha = 0)
  114396. * @param b The upper value (returned when alpha = 1)
  114397. * @param alpha The interpolation-factor
  114398. * @return The mixed value
  114399. */
  114400. static Mix(a: number, b: number, alpha: number): number;
  114401. /**
  114402. * Tries to instantiate a new object from a given class name
  114403. * @param className defines the class name to instantiate
  114404. * @returns the new object or null if the system was not able to do the instantiation
  114405. */
  114406. static Instantiate(className: string): any;
  114407. /**
  114408. * Provides a slice function that will work even on IE
  114409. * @param data defines the array to slice
  114410. * @param start defines the start of the data (optional)
  114411. * @param end defines the end of the data (optional)
  114412. * @returns the new sliced array
  114413. */
  114414. static Slice<T>(data: T, start?: number, end?: number): T;
  114415. /**
  114416. * Polyfill for setImmediate
  114417. * @param action defines the action to execute after the current execution block
  114418. */
  114419. static SetImmediate(action: () => void): void;
  114420. /**
  114421. * Function indicating if a number is an exponent of 2
  114422. * @param value defines the value to test
  114423. * @returns true if the value is an exponent of 2
  114424. */
  114425. static IsExponentOfTwo(value: number): boolean;
  114426. private static _tmpFloatArray;
  114427. /**
  114428. * Returns the nearest 32-bit single precision float representation of a Number
  114429. * @param value A Number. If the parameter is of a different type, it will get converted
  114430. * to a number or to NaN if it cannot be converted
  114431. * @returns number
  114432. */
  114433. static FloatRound(value: number): number;
  114434. /**
  114435. * Extracts the filename from a path
  114436. * @param path defines the path to use
  114437. * @returns the filename
  114438. */
  114439. static GetFilename(path: string): string;
  114440. /**
  114441. * Extracts the "folder" part of a path (everything before the filename).
  114442. * @param uri The URI to extract the info from
  114443. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  114444. * @returns The "folder" part of the path
  114445. */
  114446. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  114447. /**
  114448. * Extracts text content from a DOM element hierarchy
  114449. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  114450. */
  114451. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  114452. /**
  114453. * Convert an angle in radians to degrees
  114454. * @param angle defines the angle to convert
  114455. * @returns the angle in degrees
  114456. */
  114457. static ToDegrees(angle: number): number;
  114458. /**
  114459. * Convert an angle in degrees to radians
  114460. * @param angle defines the angle to convert
  114461. * @returns the angle in radians
  114462. */
  114463. static ToRadians(angle: number): number;
  114464. /**
  114465. * Returns an array if obj is not an array
  114466. * @param obj defines the object to evaluate as an array
  114467. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  114468. * @returns either obj directly if obj is an array or a new array containing obj
  114469. */
  114470. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  114471. /**
  114472. * Gets the pointer prefix to use
  114473. * @param engine defines the engine we are finding the prefix for
  114474. * @returns "pointer" if touch is enabled. Else returns "mouse"
  114475. */
  114476. static GetPointerPrefix(engine: Engine): string;
  114477. /**
  114478. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  114479. * @param url define the url we are trying
  114480. * @param element define the dom element where to configure the cors policy
  114481. */
  114482. static SetCorsBehavior(url: string | string[], element: {
  114483. crossOrigin: string | null;
  114484. }): void;
  114485. /**
  114486. * Removes unwanted characters from an url
  114487. * @param url defines the url to clean
  114488. * @returns the cleaned url
  114489. */
  114490. static CleanUrl(url: string): string;
  114491. /**
  114492. * Gets or sets a function used to pre-process url before using them to load assets
  114493. */
  114494. static get PreprocessUrl(): (url: string) => string;
  114495. static set PreprocessUrl(processor: (url: string) => string);
  114496. /**
  114497. * Loads an image as an HTMLImageElement.
  114498. * @param input url string, ArrayBuffer, or Blob to load
  114499. * @param onLoad callback called when the image successfully loads
  114500. * @param onError callback called when the image fails to load
  114501. * @param offlineProvider offline provider for caching
  114502. * @param mimeType optional mime type
  114503. * @returns the HTMLImageElement of the loaded image
  114504. */
  114505. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  114506. /**
  114507. * Loads a file from a url
  114508. * @param url url string, ArrayBuffer, or Blob to load
  114509. * @param onSuccess callback called when the file successfully loads
  114510. * @param onProgress callback called while file is loading (if the server supports this mode)
  114511. * @param offlineProvider defines the offline provider for caching
  114512. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  114513. * @param onError callback called when the file fails to load
  114514. * @returns a file request object
  114515. */
  114516. 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;
  114517. /**
  114518. * Loads a file from a url
  114519. * @param url the file url to load
  114520. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  114521. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  114522. */
  114523. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  114524. /**
  114525. * Load a script (identified by an url). When the url returns, the
  114526. * content of this file is added into a new script element, attached to the DOM (body element)
  114527. * @param scriptUrl defines the url of the script to laod
  114528. * @param onSuccess defines the callback called when the script is loaded
  114529. * @param onError defines the callback to call if an error occurs
  114530. * @param scriptId defines the id of the script element
  114531. */
  114532. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  114533. /**
  114534. * Load an asynchronous script (identified by an url). When the url returns, the
  114535. * content of this file is added into a new script element, attached to the DOM (body element)
  114536. * @param scriptUrl defines the url of the script to laod
  114537. * @param scriptId defines the id of the script element
  114538. * @returns a promise request object
  114539. */
  114540. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  114541. /**
  114542. * Loads a file from a blob
  114543. * @param fileToLoad defines the blob to use
  114544. * @param callback defines the callback to call when data is loaded
  114545. * @param progressCallback defines the callback to call during loading process
  114546. * @returns a file request object
  114547. */
  114548. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  114549. /**
  114550. * Reads a file from a File object
  114551. * @param file defines the file to load
  114552. * @param onSuccess defines the callback to call when data is loaded
  114553. * @param onProgress defines the callback to call during loading process
  114554. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  114555. * @param onError defines the callback to call when an error occurs
  114556. * @returns a file request object
  114557. */
  114558. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  114559. /**
  114560. * Creates a data url from a given string content
  114561. * @param content defines the content to convert
  114562. * @returns the new data url link
  114563. */
  114564. static FileAsURL(content: string): string;
  114565. /**
  114566. * Format the given number to a specific decimal format
  114567. * @param value defines the number to format
  114568. * @param decimals defines the number of decimals to use
  114569. * @returns the formatted string
  114570. */
  114571. static Format(value: number, decimals?: number): string;
  114572. /**
  114573. * Tries to copy an object by duplicating every property
  114574. * @param source defines the source object
  114575. * @param destination defines the target object
  114576. * @param doNotCopyList defines a list of properties to avoid
  114577. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  114578. */
  114579. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  114580. /**
  114581. * Gets a boolean indicating if the given object has no own property
  114582. * @param obj defines the object to test
  114583. * @returns true if object has no own property
  114584. */
  114585. static IsEmpty(obj: any): boolean;
  114586. /**
  114587. * Function used to register events at window level
  114588. * @param windowElement defines the Window object to use
  114589. * @param events defines the events to register
  114590. */
  114591. static RegisterTopRootEvents(windowElement: Window, events: {
  114592. name: string;
  114593. handler: Nullable<(e: FocusEvent) => any>;
  114594. }[]): void;
  114595. /**
  114596. * Function used to unregister events from window level
  114597. * @param windowElement defines the Window object to use
  114598. * @param events defines the events to unregister
  114599. */
  114600. static UnregisterTopRootEvents(windowElement: Window, events: {
  114601. name: string;
  114602. handler: Nullable<(e: FocusEvent) => any>;
  114603. }[]): void;
  114604. /**
  114605. * @ignore
  114606. */
  114607. static _ScreenshotCanvas: HTMLCanvasElement;
  114608. /**
  114609. * Dumps the current bound framebuffer
  114610. * @param width defines the rendering width
  114611. * @param height defines the rendering height
  114612. * @param engine defines the hosting engine
  114613. * @param successCallback defines the callback triggered once the data are available
  114614. * @param mimeType defines the mime type of the result
  114615. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  114616. */
  114617. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  114618. /**
  114619. * Converts the canvas data to blob.
  114620. * This acts as a polyfill for browsers not supporting the to blob function.
  114621. * @param canvas Defines the canvas to extract the data from
  114622. * @param successCallback Defines the callback triggered once the data are available
  114623. * @param mimeType Defines the mime type of the result
  114624. */
  114625. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  114626. /**
  114627. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  114628. * @param successCallback defines the callback triggered once the data are available
  114629. * @param mimeType defines the mime type of the result
  114630. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  114631. */
  114632. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  114633. /**
  114634. * Downloads a blob in the browser
  114635. * @param blob defines the blob to download
  114636. * @param fileName defines the name of the downloaded file
  114637. */
  114638. static Download(blob: Blob, fileName: string): void;
  114639. /**
  114640. * Captures a screenshot of the current rendering
  114641. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114642. * @param engine defines the rendering engine
  114643. * @param camera defines the source camera
  114644. * @param size This parameter can be set to a single number or to an object with the
  114645. * following (optional) properties: precision, width, height. If a single number is passed,
  114646. * it will be used for both width and height. If an object is passed, the screenshot size
  114647. * will be derived from the parameters. The precision property is a multiplier allowing
  114648. * rendering at a higher or lower resolution
  114649. * @param successCallback defines the callback receives a single parameter which contains the
  114650. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  114651. * src parameter of an <img> to display it
  114652. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  114653. * Check your browser for supported MIME types
  114654. */
  114655. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  114656. /**
  114657. * Captures a screenshot of the current rendering
  114658. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114659. * @param engine defines the rendering engine
  114660. * @param camera defines the source camera
  114661. * @param size This parameter can be set to a single number or to an object with the
  114662. * following (optional) properties: precision, width, height. If a single number is passed,
  114663. * it will be used for both width and height. If an object is passed, the screenshot size
  114664. * will be derived from the parameters. The precision property is a multiplier allowing
  114665. * rendering at a higher or lower resolution
  114666. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  114667. * Check your browser for supported MIME types
  114668. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  114669. * to the src parameter of an <img> to display it
  114670. */
  114671. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  114672. /**
  114673. * Generates an image screenshot from the specified camera.
  114674. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114675. * @param engine The engine to use for rendering
  114676. * @param camera The camera to use for rendering
  114677. * @param size This parameter can be set to a single number or to an object with the
  114678. * following (optional) properties: precision, width, height. If a single number is passed,
  114679. * it will be used for both width and height. If an object is passed, the screenshot size
  114680. * will be derived from the parameters. The precision property is a multiplier allowing
  114681. * rendering at a higher or lower resolution
  114682. * @param successCallback The callback receives a single parameter which contains the
  114683. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  114684. * src parameter of an <img> to display it
  114685. * @param mimeType The MIME type of the screenshot image (default: image/png).
  114686. * Check your browser for supported MIME types
  114687. * @param samples Texture samples (default: 1)
  114688. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  114689. * @param fileName A name for for the downloaded file.
  114690. */
  114691. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  114692. /**
  114693. * Generates an image screenshot from the specified camera.
  114694. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114695. * @param engine The engine to use for rendering
  114696. * @param camera The camera to use for rendering
  114697. * @param size This parameter can be set to a single number or to an object with the
  114698. * following (optional) properties: precision, width, height. If a single number is passed,
  114699. * it will be used for both width and height. If an object is passed, the screenshot size
  114700. * will be derived from the parameters. The precision property is a multiplier allowing
  114701. * rendering at a higher or lower resolution
  114702. * @param mimeType The MIME type of the screenshot image (default: image/png).
  114703. * Check your browser for supported MIME types
  114704. * @param samples Texture samples (default: 1)
  114705. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  114706. * @param fileName A name for for the downloaded file.
  114707. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  114708. * to the src parameter of an <img> to display it
  114709. */
  114710. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  114711. /**
  114712. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  114713. * Be aware Math.random() could cause collisions, but:
  114714. * "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"
  114715. * @returns a pseudo random id
  114716. */
  114717. static RandomId(): string;
  114718. /**
  114719. * Test if the given uri is a base64 string
  114720. * @param uri The uri to test
  114721. * @return True if the uri is a base64 string or false otherwise
  114722. */
  114723. static IsBase64(uri: string): boolean;
  114724. /**
  114725. * Decode the given base64 uri.
  114726. * @param uri The uri to decode
  114727. * @return The decoded base64 data.
  114728. */
  114729. static DecodeBase64(uri: string): ArrayBuffer;
  114730. /**
  114731. * Gets the absolute url.
  114732. * @param url the input url
  114733. * @return the absolute url
  114734. */
  114735. static GetAbsoluteUrl(url: string): string;
  114736. /**
  114737. * No log
  114738. */
  114739. static readonly NoneLogLevel: number;
  114740. /**
  114741. * Only message logs
  114742. */
  114743. static readonly MessageLogLevel: number;
  114744. /**
  114745. * Only warning logs
  114746. */
  114747. static readonly WarningLogLevel: number;
  114748. /**
  114749. * Only error logs
  114750. */
  114751. static readonly ErrorLogLevel: number;
  114752. /**
  114753. * All logs
  114754. */
  114755. static readonly AllLogLevel: number;
  114756. /**
  114757. * Gets a value indicating the number of loading errors
  114758. * @ignorenaming
  114759. */
  114760. static get errorsCount(): number;
  114761. /**
  114762. * Callback called when a new log is added
  114763. */
  114764. static OnNewCacheEntry: (entry: string) => void;
  114765. /**
  114766. * Log a message to the console
  114767. * @param message defines the message to log
  114768. */
  114769. static Log(message: string): void;
  114770. /**
  114771. * Write a warning message to the console
  114772. * @param message defines the message to log
  114773. */
  114774. static Warn(message: string): void;
  114775. /**
  114776. * Write an error message to the console
  114777. * @param message defines the message to log
  114778. */
  114779. static Error(message: string): void;
  114780. /**
  114781. * Gets current log cache (list of logs)
  114782. */
  114783. static get LogCache(): string;
  114784. /**
  114785. * Clears the log cache
  114786. */
  114787. static ClearLogCache(): void;
  114788. /**
  114789. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  114790. */
  114791. static set LogLevels(level: number);
  114792. /**
  114793. * Checks if the window object exists
  114794. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  114795. */
  114796. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  114797. /**
  114798. * No performance log
  114799. */
  114800. static readonly PerformanceNoneLogLevel: number;
  114801. /**
  114802. * Use user marks to log performance
  114803. */
  114804. static readonly PerformanceUserMarkLogLevel: number;
  114805. /**
  114806. * Log performance to the console
  114807. */
  114808. static readonly PerformanceConsoleLogLevel: number;
  114809. private static _performance;
  114810. /**
  114811. * Sets the current performance log level
  114812. */
  114813. static set PerformanceLogLevel(level: number);
  114814. private static _StartPerformanceCounterDisabled;
  114815. private static _EndPerformanceCounterDisabled;
  114816. private static _StartUserMark;
  114817. private static _EndUserMark;
  114818. private static _StartPerformanceConsole;
  114819. private static _EndPerformanceConsole;
  114820. /**
  114821. * Starts a performance counter
  114822. */
  114823. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  114824. /**
  114825. * Ends a specific performance coutner
  114826. */
  114827. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  114828. /**
  114829. * Gets either window.performance.now() if supported or Date.now() else
  114830. */
  114831. static get Now(): number;
  114832. /**
  114833. * This method will return the name of the class used to create the instance of the given object.
  114834. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  114835. * @param object the object to get the class name from
  114836. * @param isType defines if the object is actually a type
  114837. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  114838. */
  114839. static GetClassName(object: any, isType?: boolean): string;
  114840. /**
  114841. * Gets the first element of an array satisfying a given predicate
  114842. * @param array defines the array to browse
  114843. * @param predicate defines the predicate to use
  114844. * @returns null if not found or the element
  114845. */
  114846. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  114847. /**
  114848. * This method will return the name of the full name of the class, including its owning module (if any).
  114849. * 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).
  114850. * @param object the object to get the class name from
  114851. * @param isType defines if the object is actually a type
  114852. * @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.
  114853. * @ignorenaming
  114854. */
  114855. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  114856. /**
  114857. * Returns a promise that resolves after the given amount of time.
  114858. * @param delay Number of milliseconds to delay
  114859. * @returns Promise that resolves after the given amount of time
  114860. */
  114861. static DelayAsync(delay: number): Promise<void>;
  114862. /**
  114863. * Utility function to detect if the current user agent is Safari
  114864. * @returns whether or not the current user agent is safari
  114865. */
  114866. static IsSafari(): boolean;
  114867. }
  114868. /**
  114869. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  114870. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  114871. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  114872. * @param name The name of the class, case should be preserved
  114873. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  114874. */
  114875. export function className(name: string, module?: string): (target: Object) => void;
  114876. /**
  114877. * An implementation of a loop for asynchronous functions.
  114878. */
  114879. export class AsyncLoop {
  114880. /**
  114881. * Defines the number of iterations for the loop
  114882. */
  114883. iterations: number;
  114884. /**
  114885. * Defines the current index of the loop.
  114886. */
  114887. index: number;
  114888. private _done;
  114889. private _fn;
  114890. private _successCallback;
  114891. /**
  114892. * Constructor.
  114893. * @param iterations the number of iterations.
  114894. * @param func the function to run each iteration
  114895. * @param successCallback the callback that will be called upon succesful execution
  114896. * @param offset starting offset.
  114897. */
  114898. constructor(
  114899. /**
  114900. * Defines the number of iterations for the loop
  114901. */
  114902. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  114903. /**
  114904. * Execute the next iteration. Must be called after the last iteration was finished.
  114905. */
  114906. executeNext(): void;
  114907. /**
  114908. * Break the loop and run the success callback.
  114909. */
  114910. breakLoop(): void;
  114911. /**
  114912. * Create and run an async loop.
  114913. * @param iterations the number of iterations.
  114914. * @param fn the function to run each iteration
  114915. * @param successCallback the callback that will be called upon succesful execution
  114916. * @param offset starting offset.
  114917. * @returns the created async loop object
  114918. */
  114919. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  114920. /**
  114921. * A for-loop that will run a given number of iterations synchronous and the rest async.
  114922. * @param iterations total number of iterations
  114923. * @param syncedIterations number of synchronous iterations in each async iteration.
  114924. * @param fn the function to call each iteration.
  114925. * @param callback a success call back that will be called when iterating stops.
  114926. * @param breakFunction a break condition (optional)
  114927. * @param timeout timeout settings for the setTimeout function. default - 0.
  114928. * @returns the created async loop object
  114929. */
  114930. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  114931. }
  114932. }
  114933. declare module BABYLON {
  114934. /**
  114935. * This class implement a typical dictionary using a string as key and the generic type T as value.
  114936. * The underlying implementation relies on an associative array to ensure the best performances.
  114937. * The value can be anything including 'null' but except 'undefined'
  114938. */
  114939. export class StringDictionary<T> {
  114940. /**
  114941. * This will clear this dictionary and copy the content from the 'source' one.
  114942. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  114943. * @param source the dictionary to take the content from and copy to this dictionary
  114944. */
  114945. copyFrom(source: StringDictionary<T>): void;
  114946. /**
  114947. * Get a value based from its key
  114948. * @param key the given key to get the matching value from
  114949. * @return the value if found, otherwise undefined is returned
  114950. */
  114951. get(key: string): T | undefined;
  114952. /**
  114953. * Get a value from its key or add it if it doesn't exist.
  114954. * This method will ensure you that a given key/data will be present in the dictionary.
  114955. * @param key the given key to get the matching value from
  114956. * @param factory the factory that will create the value if the key is not present in the dictionary.
  114957. * The factory will only be invoked if there's no data for the given key.
  114958. * @return the value corresponding to the key.
  114959. */
  114960. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  114961. /**
  114962. * Get a value from its key if present in the dictionary otherwise add it
  114963. * @param key the key to get the value from
  114964. * @param val if there's no such key/value pair in the dictionary add it with this value
  114965. * @return the value corresponding to the key
  114966. */
  114967. getOrAdd(key: string, val: T): T;
  114968. /**
  114969. * Check if there's a given key in the dictionary
  114970. * @param key the key to check for
  114971. * @return true if the key is present, false otherwise
  114972. */
  114973. contains(key: string): boolean;
  114974. /**
  114975. * Add a new key and its corresponding value
  114976. * @param key the key to add
  114977. * @param value the value corresponding to the key
  114978. * @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
  114979. */
  114980. add(key: string, value: T): boolean;
  114981. /**
  114982. * Update a specific value associated to a key
  114983. * @param key defines the key to use
  114984. * @param value defines the value to store
  114985. * @returns true if the value was updated (or false if the key was not found)
  114986. */
  114987. set(key: string, value: T): boolean;
  114988. /**
  114989. * Get the element of the given key and remove it from the dictionary
  114990. * @param key defines the key to search
  114991. * @returns the value associated with the key or null if not found
  114992. */
  114993. getAndRemove(key: string): Nullable<T>;
  114994. /**
  114995. * Remove a key/value from the dictionary.
  114996. * @param key the key to remove
  114997. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  114998. */
  114999. remove(key: string): boolean;
  115000. /**
  115001. * Clear the whole content of the dictionary
  115002. */
  115003. clear(): void;
  115004. /**
  115005. * Gets the current count
  115006. */
  115007. get count(): number;
  115008. /**
  115009. * Execute a callback on each key/val of the dictionary.
  115010. * Note that you can remove any element in this dictionary in the callback implementation
  115011. * @param callback the callback to execute on a given key/value pair
  115012. */
  115013. forEach(callback: (key: string, val: T) => void): void;
  115014. /**
  115015. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  115016. * If the callback returns null or undefined the method will iterate to the next key/value pair
  115017. * Note that you can remove any element in this dictionary in the callback implementation
  115018. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  115019. * @returns the first item
  115020. */
  115021. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  115022. private _count;
  115023. private _data;
  115024. }
  115025. }
  115026. declare module BABYLON {
  115027. /** @hidden */
  115028. export interface ICollisionCoordinator {
  115029. createCollider(): Collider;
  115030. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  115031. init(scene: Scene): void;
  115032. }
  115033. /** @hidden */
  115034. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  115035. private _scene;
  115036. private _scaledPosition;
  115037. private _scaledVelocity;
  115038. private _finalPosition;
  115039. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  115040. createCollider(): Collider;
  115041. init(scene: Scene): void;
  115042. private _collideWithWorld;
  115043. }
  115044. }
  115045. declare module BABYLON {
  115046. /**
  115047. * Class used to manage all inputs for the scene.
  115048. */
  115049. export class InputManager {
  115050. /** The distance in pixel that you have to move to prevent some events */
  115051. static DragMovementThreshold: number;
  115052. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  115053. static LongPressDelay: number;
  115054. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  115055. static DoubleClickDelay: number;
  115056. /** If you need to check double click without raising a single click at first click, enable this flag */
  115057. static ExclusiveDoubleClickMode: boolean;
  115058. private _wheelEventName;
  115059. private _onPointerMove;
  115060. private _onPointerDown;
  115061. private _onPointerUp;
  115062. private _initClickEvent;
  115063. private _initActionManager;
  115064. private _delayedSimpleClick;
  115065. private _delayedSimpleClickTimeout;
  115066. private _previousDelayedSimpleClickTimeout;
  115067. private _meshPickProceed;
  115068. private _previousButtonPressed;
  115069. private _currentPickResult;
  115070. private _previousPickResult;
  115071. private _totalPointersPressed;
  115072. private _doubleClickOccured;
  115073. private _pointerOverMesh;
  115074. private _pickedDownMesh;
  115075. private _pickedUpMesh;
  115076. private _pointerX;
  115077. private _pointerY;
  115078. private _unTranslatedPointerX;
  115079. private _unTranslatedPointerY;
  115080. private _startingPointerPosition;
  115081. private _previousStartingPointerPosition;
  115082. private _startingPointerTime;
  115083. private _previousStartingPointerTime;
  115084. private _pointerCaptures;
  115085. private _onKeyDown;
  115086. private _onKeyUp;
  115087. private _onCanvasFocusObserver;
  115088. private _onCanvasBlurObserver;
  115089. private _scene;
  115090. /**
  115091. * Creates a new InputManager
  115092. * @param scene defines the hosting scene
  115093. */
  115094. constructor(scene: Scene);
  115095. /**
  115096. * Gets the mesh that is currently under the pointer
  115097. */
  115098. get meshUnderPointer(): Nullable<AbstractMesh>;
  115099. /**
  115100. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  115101. */
  115102. get unTranslatedPointer(): Vector2;
  115103. /**
  115104. * Gets or sets the current on-screen X position of the pointer
  115105. */
  115106. get pointerX(): number;
  115107. set pointerX(value: number);
  115108. /**
  115109. * Gets or sets the current on-screen Y position of the pointer
  115110. */
  115111. get pointerY(): number;
  115112. set pointerY(value: number);
  115113. private _updatePointerPosition;
  115114. private _processPointerMove;
  115115. private _setRayOnPointerInfo;
  115116. private _checkPrePointerObservable;
  115117. /**
  115118. * Use this method to simulate a pointer move on a mesh
  115119. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115120. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115121. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115122. */
  115123. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  115124. /**
  115125. * Use this method to simulate a pointer down on a mesh
  115126. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115127. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115128. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115129. */
  115130. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  115131. private _processPointerDown;
  115132. /** @hidden */
  115133. _isPointerSwiping(): boolean;
  115134. /**
  115135. * Use this method to simulate a pointer up on a mesh
  115136. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115137. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115138. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115139. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  115140. */
  115141. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  115142. private _processPointerUp;
  115143. /**
  115144. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  115145. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  115146. * @returns true if the pointer was captured
  115147. */
  115148. isPointerCaptured(pointerId?: number): boolean;
  115149. /**
  115150. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  115151. * @param attachUp defines if you want to attach events to pointerup
  115152. * @param attachDown defines if you want to attach events to pointerdown
  115153. * @param attachMove defines if you want to attach events to pointermove
  115154. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  115155. */
  115156. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  115157. /**
  115158. * Detaches all event handlers
  115159. */
  115160. detachControl(): void;
  115161. /**
  115162. * Force the value of meshUnderPointer
  115163. * @param mesh defines the mesh to use
  115164. */
  115165. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  115166. /**
  115167. * Gets the mesh under the pointer
  115168. * @returns a Mesh or null if no mesh is under the pointer
  115169. */
  115170. getPointerOverMesh(): Nullable<AbstractMesh>;
  115171. }
  115172. }
  115173. declare module BABYLON {
  115174. /**
  115175. * This class defines the direct association between an animation and a target
  115176. */
  115177. export class TargetedAnimation {
  115178. /**
  115179. * Animation to perform
  115180. */
  115181. animation: Animation;
  115182. /**
  115183. * Target to animate
  115184. */
  115185. target: any;
  115186. /**
  115187. * Returns the string "TargetedAnimation"
  115188. * @returns "TargetedAnimation"
  115189. */
  115190. getClassName(): string;
  115191. /**
  115192. * Serialize the object
  115193. * @returns the JSON object representing the current entity
  115194. */
  115195. serialize(): any;
  115196. }
  115197. /**
  115198. * Use this class to create coordinated animations on multiple targets
  115199. */
  115200. export class AnimationGroup implements IDisposable {
  115201. /** The name of the animation group */
  115202. name: string;
  115203. private _scene;
  115204. private _targetedAnimations;
  115205. private _animatables;
  115206. private _from;
  115207. private _to;
  115208. private _isStarted;
  115209. private _isPaused;
  115210. private _speedRatio;
  115211. private _loopAnimation;
  115212. private _isAdditive;
  115213. /**
  115214. * Gets or sets the unique id of the node
  115215. */
  115216. uniqueId: number;
  115217. /**
  115218. * This observable will notify when one animation have ended
  115219. */
  115220. onAnimationEndObservable: Observable<TargetedAnimation>;
  115221. /**
  115222. * Observer raised when one animation loops
  115223. */
  115224. onAnimationLoopObservable: Observable<TargetedAnimation>;
  115225. /**
  115226. * Observer raised when all animations have looped
  115227. */
  115228. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  115229. /**
  115230. * This observable will notify when all animations have ended.
  115231. */
  115232. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  115233. /**
  115234. * This observable will notify when all animations have paused.
  115235. */
  115236. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  115237. /**
  115238. * This observable will notify when all animations are playing.
  115239. */
  115240. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  115241. /**
  115242. * Gets the first frame
  115243. */
  115244. get from(): number;
  115245. /**
  115246. * Gets the last frame
  115247. */
  115248. get to(): number;
  115249. /**
  115250. * Define if the animations are started
  115251. */
  115252. get isStarted(): boolean;
  115253. /**
  115254. * Gets a value indicating that the current group is playing
  115255. */
  115256. get isPlaying(): boolean;
  115257. /**
  115258. * Gets or sets the speed ratio to use for all animations
  115259. */
  115260. get speedRatio(): number;
  115261. /**
  115262. * Gets or sets the speed ratio to use for all animations
  115263. */
  115264. set speedRatio(value: number);
  115265. /**
  115266. * Gets or sets if all animations should loop or not
  115267. */
  115268. get loopAnimation(): boolean;
  115269. set loopAnimation(value: boolean);
  115270. /**
  115271. * Gets or sets if all animations should be evaluated additively
  115272. */
  115273. get isAdditive(): boolean;
  115274. set isAdditive(value: boolean);
  115275. /**
  115276. * Gets the targeted animations for this animation group
  115277. */
  115278. get targetedAnimations(): Array<TargetedAnimation>;
  115279. /**
  115280. * returning the list of animatables controlled by this animation group.
  115281. */
  115282. get animatables(): Array<Animatable>;
  115283. /**
  115284. * Gets the list of target animations
  115285. */
  115286. get children(): TargetedAnimation[];
  115287. /**
  115288. * Instantiates a new Animation Group.
  115289. * This helps managing several animations at once.
  115290. * @see http://doc.babylonjs.com/how_to/group
  115291. * @param name Defines the name of the group
  115292. * @param scene Defines the scene the group belongs to
  115293. */
  115294. constructor(
  115295. /** The name of the animation group */
  115296. name: string, scene?: Nullable<Scene>);
  115297. /**
  115298. * Add an animation (with its target) in the group
  115299. * @param animation defines the animation we want to add
  115300. * @param target defines the target of the animation
  115301. * @returns the TargetedAnimation object
  115302. */
  115303. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  115304. /**
  115305. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  115306. * It can add constant keys at begin or end
  115307. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  115308. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  115309. * @returns the animation group
  115310. */
  115311. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  115312. private _animationLoopCount;
  115313. private _animationLoopFlags;
  115314. private _processLoop;
  115315. /**
  115316. * Start all animations on given targets
  115317. * @param loop defines if animations must loop
  115318. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  115319. * @param from defines the from key (optional)
  115320. * @param to defines the to key (optional)
  115321. * @param isAdditive defines the additive state for the resulting animatables (optional)
  115322. * @returns the current animation group
  115323. */
  115324. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  115325. /**
  115326. * Pause all animations
  115327. * @returns the animation group
  115328. */
  115329. pause(): AnimationGroup;
  115330. /**
  115331. * Play all animations to initial state
  115332. * This function will start() the animations if they were not started or will restart() them if they were paused
  115333. * @param loop defines if animations must loop
  115334. * @returns the animation group
  115335. */
  115336. play(loop?: boolean): AnimationGroup;
  115337. /**
  115338. * Reset all animations to initial state
  115339. * @returns the animation group
  115340. */
  115341. reset(): AnimationGroup;
  115342. /**
  115343. * Restart animations from key 0
  115344. * @returns the animation group
  115345. */
  115346. restart(): AnimationGroup;
  115347. /**
  115348. * Stop all animations
  115349. * @returns the animation group
  115350. */
  115351. stop(): AnimationGroup;
  115352. /**
  115353. * Set animation weight for all animatables
  115354. * @param weight defines the weight to use
  115355. * @return the animationGroup
  115356. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  115357. */
  115358. setWeightForAllAnimatables(weight: number): AnimationGroup;
  115359. /**
  115360. * Synchronize and normalize all animatables with a source animatable
  115361. * @param root defines the root animatable to synchronize with
  115362. * @return the animationGroup
  115363. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  115364. */
  115365. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  115366. /**
  115367. * Goes to a specific frame in this animation group
  115368. * @param frame the frame number to go to
  115369. * @return the animationGroup
  115370. */
  115371. goToFrame(frame: number): AnimationGroup;
  115372. /**
  115373. * Dispose all associated resources
  115374. */
  115375. dispose(): void;
  115376. private _checkAnimationGroupEnded;
  115377. /**
  115378. * Clone the current animation group and returns a copy
  115379. * @param newName defines the name of the new group
  115380. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  115381. * @returns the new aniamtion group
  115382. */
  115383. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  115384. /**
  115385. * Serializes the animationGroup to an object
  115386. * @returns Serialized object
  115387. */
  115388. serialize(): any;
  115389. /**
  115390. * Returns a new AnimationGroup object parsed from the source provided.
  115391. * @param parsedAnimationGroup defines the source
  115392. * @param scene defines the scene that will receive the animationGroup
  115393. * @returns a new AnimationGroup
  115394. */
  115395. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  115396. /**
  115397. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  115398. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  115399. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  115400. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  115401. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  115402. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  115403. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  115404. */
  115405. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  115406. /**
  115407. * Returns the string "AnimationGroup"
  115408. * @returns "AnimationGroup"
  115409. */
  115410. getClassName(): string;
  115411. /**
  115412. * Creates a detailled string about the object
  115413. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  115414. * @returns a string representing the object
  115415. */
  115416. toString(fullDetails?: boolean): string;
  115417. }
  115418. }
  115419. declare module BABYLON {
  115420. /**
  115421. * Define an interface for all classes that will hold resources
  115422. */
  115423. export interface IDisposable {
  115424. /**
  115425. * Releases all held resources
  115426. */
  115427. dispose(): void;
  115428. }
  115429. /** Interface defining initialization parameters for Scene class */
  115430. export interface SceneOptions {
  115431. /**
  115432. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  115433. * It will improve performance when the number of geometries becomes important.
  115434. */
  115435. useGeometryUniqueIdsMap?: boolean;
  115436. /**
  115437. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  115438. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  115439. */
  115440. useMaterialMeshMap?: boolean;
  115441. /**
  115442. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  115443. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  115444. */
  115445. useClonedMeshMap?: boolean;
  115446. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  115447. virtual?: boolean;
  115448. }
  115449. /**
  115450. * Represents a scene to be rendered by the engine.
  115451. * @see http://doc.babylonjs.com/features/scene
  115452. */
  115453. export class Scene extends AbstractScene implements IAnimatable {
  115454. /** The fog is deactivated */
  115455. static readonly FOGMODE_NONE: number;
  115456. /** The fog density is following an exponential function */
  115457. static readonly FOGMODE_EXP: number;
  115458. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  115459. static readonly FOGMODE_EXP2: number;
  115460. /** The fog density is following a linear function. */
  115461. static readonly FOGMODE_LINEAR: number;
  115462. /**
  115463. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  115464. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115465. */
  115466. static MinDeltaTime: number;
  115467. /**
  115468. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  115469. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115470. */
  115471. static MaxDeltaTime: number;
  115472. /**
  115473. * Factory used to create the default material.
  115474. * @param name The name of the material to create
  115475. * @param scene The scene to create the material for
  115476. * @returns The default material
  115477. */
  115478. static DefaultMaterialFactory(scene: Scene): Material;
  115479. /**
  115480. * Factory used to create the a collision coordinator.
  115481. * @returns The collision coordinator
  115482. */
  115483. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  115484. /** @hidden */
  115485. _inputManager: InputManager;
  115486. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  115487. cameraToUseForPointers: Nullable<Camera>;
  115488. /** @hidden */
  115489. readonly _isScene: boolean;
  115490. /** @hidden */
  115491. _blockEntityCollection: boolean;
  115492. /**
  115493. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  115494. */
  115495. autoClear: boolean;
  115496. /**
  115497. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  115498. */
  115499. autoClearDepthAndStencil: boolean;
  115500. /**
  115501. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  115502. */
  115503. clearColor: Color4;
  115504. /**
  115505. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  115506. */
  115507. ambientColor: Color3;
  115508. /**
  115509. * This is use to store the default BRDF lookup for PBR materials in your scene.
  115510. * It should only be one of the following (if not the default embedded one):
  115511. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  115512. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  115513. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  115514. * The material properties need to be setup according to the type of texture in use.
  115515. */
  115516. environmentBRDFTexture: BaseTexture;
  115517. /** @hidden */
  115518. protected _environmentTexture: Nullable<BaseTexture>;
  115519. /**
  115520. * Texture used in all pbr material as the reflection texture.
  115521. * As in the majority of the scene they are the same (exception for multi room and so on),
  115522. * this is easier to reference from here than from all the materials.
  115523. */
  115524. get environmentTexture(): Nullable<BaseTexture>;
  115525. /**
  115526. * Texture used in all pbr material as the reflection texture.
  115527. * As in the majority of the scene they are the same (exception for multi room and so on),
  115528. * this is easier to set here than in all the materials.
  115529. */
  115530. set environmentTexture(value: Nullable<BaseTexture>);
  115531. /** @hidden */
  115532. protected _environmentIntensity: number;
  115533. /**
  115534. * Intensity of the environment in all pbr material.
  115535. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  115536. * As in the majority of the scene they are the same (exception for multi room and so on),
  115537. * this is easier to reference from here than from all the materials.
  115538. */
  115539. get environmentIntensity(): number;
  115540. /**
  115541. * Intensity of the environment in all pbr material.
  115542. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  115543. * As in the majority of the scene they are the same (exception for multi room and so on),
  115544. * this is easier to set here than in all the materials.
  115545. */
  115546. set environmentIntensity(value: number);
  115547. /** @hidden */
  115548. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115549. /**
  115550. * Default image processing configuration used either in the rendering
  115551. * Forward main pass or through the imageProcessingPostProcess if present.
  115552. * As in the majority of the scene they are the same (exception for multi camera),
  115553. * this is easier to reference from here than from all the materials and post process.
  115554. *
  115555. * No setter as we it is a shared configuration, you can set the values instead.
  115556. */
  115557. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115558. private _forceWireframe;
  115559. /**
  115560. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  115561. */
  115562. set forceWireframe(value: boolean);
  115563. get forceWireframe(): boolean;
  115564. private _skipFrustumClipping;
  115565. /**
  115566. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  115567. */
  115568. set skipFrustumClipping(value: boolean);
  115569. get skipFrustumClipping(): boolean;
  115570. private _forcePointsCloud;
  115571. /**
  115572. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  115573. */
  115574. set forcePointsCloud(value: boolean);
  115575. get forcePointsCloud(): boolean;
  115576. /**
  115577. * Gets or sets the active clipplane 1
  115578. */
  115579. clipPlane: Nullable<Plane>;
  115580. /**
  115581. * Gets or sets the active clipplane 2
  115582. */
  115583. clipPlane2: Nullable<Plane>;
  115584. /**
  115585. * Gets or sets the active clipplane 3
  115586. */
  115587. clipPlane3: Nullable<Plane>;
  115588. /**
  115589. * Gets or sets the active clipplane 4
  115590. */
  115591. clipPlane4: Nullable<Plane>;
  115592. /**
  115593. * Gets or sets the active clipplane 5
  115594. */
  115595. clipPlane5: Nullable<Plane>;
  115596. /**
  115597. * Gets or sets the active clipplane 6
  115598. */
  115599. clipPlane6: Nullable<Plane>;
  115600. /**
  115601. * Gets or sets a boolean indicating if animations are enabled
  115602. */
  115603. animationsEnabled: boolean;
  115604. private _animationPropertiesOverride;
  115605. /**
  115606. * Gets or sets the animation properties override
  115607. */
  115608. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  115609. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  115610. /**
  115611. * Gets or sets a boolean indicating if a constant deltatime has to be used
  115612. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  115613. */
  115614. useConstantAnimationDeltaTime: boolean;
  115615. /**
  115616. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  115617. * Please note that it requires to run a ray cast through the scene on every frame
  115618. */
  115619. constantlyUpdateMeshUnderPointer: boolean;
  115620. /**
  115621. * Defines the HTML cursor to use when hovering over interactive elements
  115622. */
  115623. hoverCursor: string;
  115624. /**
  115625. * Defines the HTML default cursor to use (empty by default)
  115626. */
  115627. defaultCursor: string;
  115628. /**
  115629. * Defines whether cursors are handled by the scene.
  115630. */
  115631. doNotHandleCursors: boolean;
  115632. /**
  115633. * This is used to call preventDefault() on pointer down
  115634. * in order to block unwanted artifacts like system double clicks
  115635. */
  115636. preventDefaultOnPointerDown: boolean;
  115637. /**
  115638. * This is used to call preventDefault() on pointer up
  115639. * in order to block unwanted artifacts like system double clicks
  115640. */
  115641. preventDefaultOnPointerUp: boolean;
  115642. /**
  115643. * Gets or sets user defined metadata
  115644. */
  115645. metadata: any;
  115646. /**
  115647. * For internal use only. Please do not use.
  115648. */
  115649. reservedDataStore: any;
  115650. /**
  115651. * Gets the name of the plugin used to load this scene (null by default)
  115652. */
  115653. loadingPluginName: string;
  115654. /**
  115655. * Use this array to add regular expressions used to disable offline support for specific urls
  115656. */
  115657. disableOfflineSupportExceptionRules: RegExp[];
  115658. /**
  115659. * An event triggered when the scene is disposed.
  115660. */
  115661. onDisposeObservable: Observable<Scene>;
  115662. private _onDisposeObserver;
  115663. /** Sets a function to be executed when this scene is disposed. */
  115664. set onDispose(callback: () => void);
  115665. /**
  115666. * An event triggered before rendering the scene (right after animations and physics)
  115667. */
  115668. onBeforeRenderObservable: Observable<Scene>;
  115669. private _onBeforeRenderObserver;
  115670. /** Sets a function to be executed before rendering this scene */
  115671. set beforeRender(callback: Nullable<() => void>);
  115672. /**
  115673. * An event triggered after rendering the scene
  115674. */
  115675. onAfterRenderObservable: Observable<Scene>;
  115676. /**
  115677. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  115678. */
  115679. onAfterRenderCameraObservable: Observable<Camera>;
  115680. private _onAfterRenderObserver;
  115681. /** Sets a function to be executed after rendering this scene */
  115682. set afterRender(callback: Nullable<() => void>);
  115683. /**
  115684. * An event triggered before animating the scene
  115685. */
  115686. onBeforeAnimationsObservable: Observable<Scene>;
  115687. /**
  115688. * An event triggered after animations processing
  115689. */
  115690. onAfterAnimationsObservable: Observable<Scene>;
  115691. /**
  115692. * An event triggered before draw calls are ready to be sent
  115693. */
  115694. onBeforeDrawPhaseObservable: Observable<Scene>;
  115695. /**
  115696. * An event triggered after draw calls have been sent
  115697. */
  115698. onAfterDrawPhaseObservable: Observable<Scene>;
  115699. /**
  115700. * An event triggered when the scene is ready
  115701. */
  115702. onReadyObservable: Observable<Scene>;
  115703. /**
  115704. * An event triggered before rendering a camera
  115705. */
  115706. onBeforeCameraRenderObservable: Observable<Camera>;
  115707. private _onBeforeCameraRenderObserver;
  115708. /** Sets a function to be executed before rendering a camera*/
  115709. set beforeCameraRender(callback: () => void);
  115710. /**
  115711. * An event triggered after rendering a camera
  115712. */
  115713. onAfterCameraRenderObservable: Observable<Camera>;
  115714. private _onAfterCameraRenderObserver;
  115715. /** Sets a function to be executed after rendering a camera*/
  115716. set afterCameraRender(callback: () => void);
  115717. /**
  115718. * An event triggered when active meshes evaluation is about to start
  115719. */
  115720. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  115721. /**
  115722. * An event triggered when active meshes evaluation is done
  115723. */
  115724. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  115725. /**
  115726. * An event triggered when particles rendering is about to start
  115727. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  115728. */
  115729. onBeforeParticlesRenderingObservable: Observable<Scene>;
  115730. /**
  115731. * An event triggered when particles rendering is done
  115732. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  115733. */
  115734. onAfterParticlesRenderingObservable: Observable<Scene>;
  115735. /**
  115736. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  115737. */
  115738. onDataLoadedObservable: Observable<Scene>;
  115739. /**
  115740. * An event triggered when a camera is created
  115741. */
  115742. onNewCameraAddedObservable: Observable<Camera>;
  115743. /**
  115744. * An event triggered when a camera is removed
  115745. */
  115746. onCameraRemovedObservable: Observable<Camera>;
  115747. /**
  115748. * An event triggered when a light is created
  115749. */
  115750. onNewLightAddedObservable: Observable<Light>;
  115751. /**
  115752. * An event triggered when a light is removed
  115753. */
  115754. onLightRemovedObservable: Observable<Light>;
  115755. /**
  115756. * An event triggered when a geometry is created
  115757. */
  115758. onNewGeometryAddedObservable: Observable<Geometry>;
  115759. /**
  115760. * An event triggered when a geometry is removed
  115761. */
  115762. onGeometryRemovedObservable: Observable<Geometry>;
  115763. /**
  115764. * An event triggered when a transform node is created
  115765. */
  115766. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  115767. /**
  115768. * An event triggered when a transform node is removed
  115769. */
  115770. onTransformNodeRemovedObservable: Observable<TransformNode>;
  115771. /**
  115772. * An event triggered when a mesh is created
  115773. */
  115774. onNewMeshAddedObservable: Observable<AbstractMesh>;
  115775. /**
  115776. * An event triggered when a mesh is removed
  115777. */
  115778. onMeshRemovedObservable: Observable<AbstractMesh>;
  115779. /**
  115780. * An event triggered when a skeleton is created
  115781. */
  115782. onNewSkeletonAddedObservable: Observable<Skeleton>;
  115783. /**
  115784. * An event triggered when a skeleton is removed
  115785. */
  115786. onSkeletonRemovedObservable: Observable<Skeleton>;
  115787. /**
  115788. * An event triggered when a material is created
  115789. */
  115790. onNewMaterialAddedObservable: Observable<Material>;
  115791. /**
  115792. * An event triggered when a material is removed
  115793. */
  115794. onMaterialRemovedObservable: Observable<Material>;
  115795. /**
  115796. * An event triggered when a texture is created
  115797. */
  115798. onNewTextureAddedObservable: Observable<BaseTexture>;
  115799. /**
  115800. * An event triggered when a texture is removed
  115801. */
  115802. onTextureRemovedObservable: Observable<BaseTexture>;
  115803. /**
  115804. * An event triggered when render targets are about to be rendered
  115805. * Can happen multiple times per frame.
  115806. */
  115807. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  115808. /**
  115809. * An event triggered when render targets were rendered.
  115810. * Can happen multiple times per frame.
  115811. */
  115812. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  115813. /**
  115814. * An event triggered before calculating deterministic simulation step
  115815. */
  115816. onBeforeStepObservable: Observable<Scene>;
  115817. /**
  115818. * An event triggered after calculating deterministic simulation step
  115819. */
  115820. onAfterStepObservable: Observable<Scene>;
  115821. /**
  115822. * An event triggered when the activeCamera property is updated
  115823. */
  115824. onActiveCameraChanged: Observable<Scene>;
  115825. /**
  115826. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  115827. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  115828. * 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)
  115829. */
  115830. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  115831. /**
  115832. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  115833. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  115834. * 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)
  115835. */
  115836. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  115837. /**
  115838. * This Observable will when a mesh has been imported into the scene.
  115839. */
  115840. onMeshImportedObservable: Observable<AbstractMesh>;
  115841. /**
  115842. * This Observable will when an animation file has been imported into the scene.
  115843. */
  115844. onAnimationFileImportedObservable: Observable<Scene>;
  115845. /**
  115846. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  115847. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  115848. */
  115849. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  115850. /** @hidden */
  115851. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  115852. /**
  115853. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  115854. */
  115855. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  115856. /**
  115857. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  115858. */
  115859. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  115860. /**
  115861. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  115862. */
  115863. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  115864. /** Callback called when a pointer move is detected */
  115865. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  115866. /** Callback called when a pointer down is detected */
  115867. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  115868. /** Callback called when a pointer up is detected */
  115869. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  115870. /** Callback called when a pointer pick is detected */
  115871. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  115872. /**
  115873. * 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).
  115874. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  115875. */
  115876. onPrePointerObservable: Observable<PointerInfoPre>;
  115877. /**
  115878. * Observable event triggered each time an input event is received from the rendering canvas
  115879. */
  115880. onPointerObservable: Observable<PointerInfo>;
  115881. /**
  115882. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  115883. */
  115884. get unTranslatedPointer(): Vector2;
  115885. /**
  115886. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  115887. */
  115888. static get DragMovementThreshold(): number;
  115889. static set DragMovementThreshold(value: number);
  115890. /**
  115891. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  115892. */
  115893. static get LongPressDelay(): number;
  115894. static set LongPressDelay(value: number);
  115895. /**
  115896. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  115897. */
  115898. static get DoubleClickDelay(): number;
  115899. static set DoubleClickDelay(value: number);
  115900. /** If you need to check double click without raising a single click at first click, enable this flag */
  115901. static get ExclusiveDoubleClickMode(): boolean;
  115902. static set ExclusiveDoubleClickMode(value: boolean);
  115903. /** @hidden */
  115904. _mirroredCameraPosition: Nullable<Vector3>;
  115905. /**
  115906. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  115907. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  115908. */
  115909. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  115910. /**
  115911. * Observable event triggered each time an keyboard event is received from the hosting window
  115912. */
  115913. onKeyboardObservable: Observable<KeyboardInfo>;
  115914. private _useRightHandedSystem;
  115915. /**
  115916. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  115917. */
  115918. set useRightHandedSystem(value: boolean);
  115919. get useRightHandedSystem(): boolean;
  115920. private _timeAccumulator;
  115921. private _currentStepId;
  115922. private _currentInternalStep;
  115923. /**
  115924. * Sets the step Id used by deterministic lock step
  115925. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115926. * @param newStepId defines the step Id
  115927. */
  115928. setStepId(newStepId: number): void;
  115929. /**
  115930. * Gets the step Id used by deterministic lock step
  115931. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115932. * @returns the step Id
  115933. */
  115934. getStepId(): number;
  115935. /**
  115936. * Gets the internal step used by deterministic lock step
  115937. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115938. * @returns the internal step
  115939. */
  115940. getInternalStep(): number;
  115941. private _fogEnabled;
  115942. /**
  115943. * Gets or sets a boolean indicating if fog is enabled on this scene
  115944. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115945. * (Default is true)
  115946. */
  115947. set fogEnabled(value: boolean);
  115948. get fogEnabled(): boolean;
  115949. private _fogMode;
  115950. /**
  115951. * Gets or sets the fog mode to use
  115952. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115953. * | mode | value |
  115954. * | --- | --- |
  115955. * | FOGMODE_NONE | 0 |
  115956. * | FOGMODE_EXP | 1 |
  115957. * | FOGMODE_EXP2 | 2 |
  115958. * | FOGMODE_LINEAR | 3 |
  115959. */
  115960. set fogMode(value: number);
  115961. get fogMode(): number;
  115962. /**
  115963. * Gets or sets the fog color to use
  115964. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115965. * (Default is Color3(0.2, 0.2, 0.3))
  115966. */
  115967. fogColor: Color3;
  115968. /**
  115969. * Gets or sets the fog density to use
  115970. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115971. * (Default is 0.1)
  115972. */
  115973. fogDensity: number;
  115974. /**
  115975. * Gets or sets the fog start distance to use
  115976. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115977. * (Default is 0)
  115978. */
  115979. fogStart: number;
  115980. /**
  115981. * Gets or sets the fog end distance to use
  115982. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115983. * (Default is 1000)
  115984. */
  115985. fogEnd: number;
  115986. private _shadowsEnabled;
  115987. /**
  115988. * Gets or sets a boolean indicating if shadows are enabled on this scene
  115989. */
  115990. set shadowsEnabled(value: boolean);
  115991. get shadowsEnabled(): boolean;
  115992. private _lightsEnabled;
  115993. /**
  115994. * Gets or sets a boolean indicating if lights are enabled on this scene
  115995. */
  115996. set lightsEnabled(value: boolean);
  115997. get lightsEnabled(): boolean;
  115998. /** All of the active cameras added to this scene. */
  115999. activeCameras: Camera[];
  116000. /** @hidden */
  116001. _activeCamera: Nullable<Camera>;
  116002. /** Gets or sets the current active camera */
  116003. get activeCamera(): Nullable<Camera>;
  116004. set activeCamera(value: Nullable<Camera>);
  116005. private _defaultMaterial;
  116006. /** The default material used on meshes when no material is affected */
  116007. get defaultMaterial(): Material;
  116008. /** The default material used on meshes when no material is affected */
  116009. set defaultMaterial(value: Material);
  116010. private _texturesEnabled;
  116011. /**
  116012. * Gets or sets a boolean indicating if textures are enabled on this scene
  116013. */
  116014. set texturesEnabled(value: boolean);
  116015. get texturesEnabled(): boolean;
  116016. /**
  116017. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  116018. */
  116019. physicsEnabled: boolean;
  116020. /**
  116021. * Gets or sets a boolean indicating if particles are enabled on this scene
  116022. */
  116023. particlesEnabled: boolean;
  116024. /**
  116025. * Gets or sets a boolean indicating if sprites are enabled on this scene
  116026. */
  116027. spritesEnabled: boolean;
  116028. private _skeletonsEnabled;
  116029. /**
  116030. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  116031. */
  116032. set skeletonsEnabled(value: boolean);
  116033. get skeletonsEnabled(): boolean;
  116034. /**
  116035. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  116036. */
  116037. lensFlaresEnabled: boolean;
  116038. /**
  116039. * Gets or sets a boolean indicating if collisions are enabled on this scene
  116040. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116041. */
  116042. collisionsEnabled: boolean;
  116043. private _collisionCoordinator;
  116044. /** @hidden */
  116045. get collisionCoordinator(): ICollisionCoordinator;
  116046. /**
  116047. * Defines the gravity applied to this scene (used only for collisions)
  116048. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116049. */
  116050. gravity: Vector3;
  116051. /**
  116052. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  116053. */
  116054. postProcessesEnabled: boolean;
  116055. /**
  116056. * The list of postprocesses added to the scene
  116057. */
  116058. postProcesses: PostProcess[];
  116059. /**
  116060. * Gets the current postprocess manager
  116061. */
  116062. postProcessManager: PostProcessManager;
  116063. /**
  116064. * Gets or sets a boolean indicating if render targets are enabled on this scene
  116065. */
  116066. renderTargetsEnabled: boolean;
  116067. /**
  116068. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  116069. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  116070. */
  116071. dumpNextRenderTargets: boolean;
  116072. /**
  116073. * The list of user defined render targets added to the scene
  116074. */
  116075. customRenderTargets: RenderTargetTexture[];
  116076. /**
  116077. * Defines if texture loading must be delayed
  116078. * If true, textures will only be loaded when they need to be rendered
  116079. */
  116080. useDelayedTextureLoading: boolean;
  116081. /**
  116082. * Gets the list of meshes imported to the scene through SceneLoader
  116083. */
  116084. importedMeshesFiles: String[];
  116085. /**
  116086. * Gets or sets a boolean indicating if probes are enabled on this scene
  116087. */
  116088. probesEnabled: boolean;
  116089. /**
  116090. * Gets or sets the current offline provider to use to store scene data
  116091. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  116092. */
  116093. offlineProvider: IOfflineProvider;
  116094. /**
  116095. * Gets or sets the action manager associated with the scene
  116096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  116097. */
  116098. actionManager: AbstractActionManager;
  116099. private _meshesForIntersections;
  116100. /**
  116101. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  116102. */
  116103. proceduralTexturesEnabled: boolean;
  116104. private _engine;
  116105. private _totalVertices;
  116106. /** @hidden */
  116107. _activeIndices: PerfCounter;
  116108. /** @hidden */
  116109. _activeParticles: PerfCounter;
  116110. /** @hidden */
  116111. _activeBones: PerfCounter;
  116112. private _animationRatio;
  116113. /** @hidden */
  116114. _animationTimeLast: number;
  116115. /** @hidden */
  116116. _animationTime: number;
  116117. /**
  116118. * Gets or sets a general scale for animation speed
  116119. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  116120. */
  116121. animationTimeScale: number;
  116122. /** @hidden */
  116123. _cachedMaterial: Nullable<Material>;
  116124. /** @hidden */
  116125. _cachedEffect: Nullable<Effect>;
  116126. /** @hidden */
  116127. _cachedVisibility: Nullable<number>;
  116128. private _renderId;
  116129. private _frameId;
  116130. private _executeWhenReadyTimeoutId;
  116131. private _intermediateRendering;
  116132. private _viewUpdateFlag;
  116133. private _projectionUpdateFlag;
  116134. /** @hidden */
  116135. _toBeDisposed: Nullable<IDisposable>[];
  116136. private _activeRequests;
  116137. /** @hidden */
  116138. _pendingData: any[];
  116139. private _isDisposed;
  116140. /**
  116141. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  116142. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  116143. */
  116144. dispatchAllSubMeshesOfActiveMeshes: boolean;
  116145. private _activeMeshes;
  116146. private _processedMaterials;
  116147. private _renderTargets;
  116148. /** @hidden */
  116149. _activeParticleSystems: SmartArray<IParticleSystem>;
  116150. private _activeSkeletons;
  116151. private _softwareSkinnedMeshes;
  116152. private _renderingManager;
  116153. /** @hidden */
  116154. _activeAnimatables: Animatable[];
  116155. private _transformMatrix;
  116156. private _sceneUbo;
  116157. /** @hidden */
  116158. _viewMatrix: Matrix;
  116159. private _projectionMatrix;
  116160. /** @hidden */
  116161. _forcedViewPosition: Nullable<Vector3>;
  116162. /** @hidden */
  116163. _frustumPlanes: Plane[];
  116164. /**
  116165. * Gets the list of frustum planes (built from the active camera)
  116166. */
  116167. get frustumPlanes(): Plane[];
  116168. /**
  116169. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  116170. * This is useful if there are more lights that the maximum simulteanous authorized
  116171. */
  116172. requireLightSorting: boolean;
  116173. /** @hidden */
  116174. readonly useMaterialMeshMap: boolean;
  116175. /** @hidden */
  116176. readonly useClonedMeshMap: boolean;
  116177. private _externalData;
  116178. private _uid;
  116179. /**
  116180. * @hidden
  116181. * Backing store of defined scene components.
  116182. */
  116183. _components: ISceneComponent[];
  116184. /**
  116185. * @hidden
  116186. * Backing store of defined scene components.
  116187. */
  116188. _serializableComponents: ISceneSerializableComponent[];
  116189. /**
  116190. * List of components to register on the next registration step.
  116191. */
  116192. private _transientComponents;
  116193. /**
  116194. * Registers the transient components if needed.
  116195. */
  116196. private _registerTransientComponents;
  116197. /**
  116198. * @hidden
  116199. * Add a component to the scene.
  116200. * Note that the ccomponent could be registered on th next frame if this is called after
  116201. * the register component stage.
  116202. * @param component Defines the component to add to the scene
  116203. */
  116204. _addComponent(component: ISceneComponent): void;
  116205. /**
  116206. * @hidden
  116207. * Gets a component from the scene.
  116208. * @param name defines the name of the component to retrieve
  116209. * @returns the component or null if not present
  116210. */
  116211. _getComponent(name: string): Nullable<ISceneComponent>;
  116212. /**
  116213. * @hidden
  116214. * Defines the actions happening before camera updates.
  116215. */
  116216. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  116217. /**
  116218. * @hidden
  116219. * Defines the actions happening before clear the canvas.
  116220. */
  116221. _beforeClearStage: Stage<SimpleStageAction>;
  116222. /**
  116223. * @hidden
  116224. * Defines the actions when collecting render targets for the frame.
  116225. */
  116226. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  116227. /**
  116228. * @hidden
  116229. * Defines the actions happening for one camera in the frame.
  116230. */
  116231. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  116232. /**
  116233. * @hidden
  116234. * Defines the actions happening during the per mesh ready checks.
  116235. */
  116236. _isReadyForMeshStage: Stage<MeshStageAction>;
  116237. /**
  116238. * @hidden
  116239. * Defines the actions happening before evaluate active mesh checks.
  116240. */
  116241. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  116242. /**
  116243. * @hidden
  116244. * Defines the actions happening during the evaluate sub mesh checks.
  116245. */
  116246. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  116247. /**
  116248. * @hidden
  116249. * Defines the actions happening during the active mesh stage.
  116250. */
  116251. _activeMeshStage: Stage<ActiveMeshStageAction>;
  116252. /**
  116253. * @hidden
  116254. * Defines the actions happening during the per camera render target step.
  116255. */
  116256. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  116257. /**
  116258. * @hidden
  116259. * Defines the actions happening just before the active camera is drawing.
  116260. */
  116261. _beforeCameraDrawStage: Stage<CameraStageAction>;
  116262. /**
  116263. * @hidden
  116264. * Defines the actions happening just before a render target is drawing.
  116265. */
  116266. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  116267. /**
  116268. * @hidden
  116269. * Defines the actions happening just before a rendering group is drawing.
  116270. */
  116271. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  116272. /**
  116273. * @hidden
  116274. * Defines the actions happening just before a mesh is drawing.
  116275. */
  116276. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  116277. /**
  116278. * @hidden
  116279. * Defines the actions happening just after a mesh has been drawn.
  116280. */
  116281. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  116282. /**
  116283. * @hidden
  116284. * Defines the actions happening just after a rendering group has been drawn.
  116285. */
  116286. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  116287. /**
  116288. * @hidden
  116289. * Defines the actions happening just after the active camera has been drawn.
  116290. */
  116291. _afterCameraDrawStage: Stage<CameraStageAction>;
  116292. /**
  116293. * @hidden
  116294. * Defines the actions happening just after a render target has been drawn.
  116295. */
  116296. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  116297. /**
  116298. * @hidden
  116299. * Defines the actions happening just after rendering all cameras and computing intersections.
  116300. */
  116301. _afterRenderStage: Stage<SimpleStageAction>;
  116302. /**
  116303. * @hidden
  116304. * Defines the actions happening when a pointer move event happens.
  116305. */
  116306. _pointerMoveStage: Stage<PointerMoveStageAction>;
  116307. /**
  116308. * @hidden
  116309. * Defines the actions happening when a pointer down event happens.
  116310. */
  116311. _pointerDownStage: Stage<PointerUpDownStageAction>;
  116312. /**
  116313. * @hidden
  116314. * Defines the actions happening when a pointer up event happens.
  116315. */
  116316. _pointerUpStage: Stage<PointerUpDownStageAction>;
  116317. /**
  116318. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  116319. */
  116320. private geometriesByUniqueId;
  116321. /**
  116322. * Creates a new Scene
  116323. * @param engine defines the engine to use to render this scene
  116324. * @param options defines the scene options
  116325. */
  116326. constructor(engine: Engine, options?: SceneOptions);
  116327. /**
  116328. * Gets a string idenfifying the name of the class
  116329. * @returns "Scene" string
  116330. */
  116331. getClassName(): string;
  116332. private _defaultMeshCandidates;
  116333. /**
  116334. * @hidden
  116335. */
  116336. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  116337. private _defaultSubMeshCandidates;
  116338. /**
  116339. * @hidden
  116340. */
  116341. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  116342. /**
  116343. * Sets the default candidate providers for the scene.
  116344. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  116345. * and getCollidingSubMeshCandidates to their default function
  116346. */
  116347. setDefaultCandidateProviders(): void;
  116348. /**
  116349. * Gets the mesh that is currently under the pointer
  116350. */
  116351. get meshUnderPointer(): Nullable<AbstractMesh>;
  116352. /**
  116353. * Gets or sets the current on-screen X position of the pointer
  116354. */
  116355. get pointerX(): number;
  116356. set pointerX(value: number);
  116357. /**
  116358. * Gets or sets the current on-screen Y position of the pointer
  116359. */
  116360. get pointerY(): number;
  116361. set pointerY(value: number);
  116362. /**
  116363. * Gets the cached material (ie. the latest rendered one)
  116364. * @returns the cached material
  116365. */
  116366. getCachedMaterial(): Nullable<Material>;
  116367. /**
  116368. * Gets the cached effect (ie. the latest rendered one)
  116369. * @returns the cached effect
  116370. */
  116371. getCachedEffect(): Nullable<Effect>;
  116372. /**
  116373. * Gets the cached visibility state (ie. the latest rendered one)
  116374. * @returns the cached visibility state
  116375. */
  116376. getCachedVisibility(): Nullable<number>;
  116377. /**
  116378. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  116379. * @param material defines the current material
  116380. * @param effect defines the current effect
  116381. * @param visibility defines the current visibility state
  116382. * @returns true if one parameter is not cached
  116383. */
  116384. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  116385. /**
  116386. * Gets the engine associated with the scene
  116387. * @returns an Engine
  116388. */
  116389. getEngine(): Engine;
  116390. /**
  116391. * Gets the total number of vertices rendered per frame
  116392. * @returns the total number of vertices rendered per frame
  116393. */
  116394. getTotalVertices(): number;
  116395. /**
  116396. * Gets the performance counter for total vertices
  116397. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116398. */
  116399. get totalVerticesPerfCounter(): PerfCounter;
  116400. /**
  116401. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  116402. * @returns the total number of active indices rendered per frame
  116403. */
  116404. getActiveIndices(): number;
  116405. /**
  116406. * Gets the performance counter for active indices
  116407. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116408. */
  116409. get totalActiveIndicesPerfCounter(): PerfCounter;
  116410. /**
  116411. * Gets the total number of active particles rendered per frame
  116412. * @returns the total number of active particles rendered per frame
  116413. */
  116414. getActiveParticles(): number;
  116415. /**
  116416. * Gets the performance counter for active particles
  116417. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116418. */
  116419. get activeParticlesPerfCounter(): PerfCounter;
  116420. /**
  116421. * Gets the total number of active bones rendered per frame
  116422. * @returns the total number of active bones rendered per frame
  116423. */
  116424. getActiveBones(): number;
  116425. /**
  116426. * Gets the performance counter for active bones
  116427. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116428. */
  116429. get activeBonesPerfCounter(): PerfCounter;
  116430. /**
  116431. * Gets the array of active meshes
  116432. * @returns an array of AbstractMesh
  116433. */
  116434. getActiveMeshes(): SmartArray<AbstractMesh>;
  116435. /**
  116436. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  116437. * @returns a number
  116438. */
  116439. getAnimationRatio(): number;
  116440. /**
  116441. * Gets an unique Id for the current render phase
  116442. * @returns a number
  116443. */
  116444. getRenderId(): number;
  116445. /**
  116446. * Gets an unique Id for the current frame
  116447. * @returns a number
  116448. */
  116449. getFrameId(): number;
  116450. /** Call this function if you want to manually increment the render Id*/
  116451. incrementRenderId(): void;
  116452. private _createUbo;
  116453. /**
  116454. * Use this method to simulate a pointer move on a mesh
  116455. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116456. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116457. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116458. * @returns the current scene
  116459. */
  116460. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  116461. /**
  116462. * Use this method to simulate a pointer down on a mesh
  116463. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116464. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116465. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116466. * @returns the current scene
  116467. */
  116468. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  116469. /**
  116470. * Use this method to simulate a pointer up on a mesh
  116471. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116472. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116473. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116474. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  116475. * @returns the current scene
  116476. */
  116477. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  116478. /**
  116479. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  116480. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  116481. * @returns true if the pointer was captured
  116482. */
  116483. isPointerCaptured(pointerId?: number): boolean;
  116484. /**
  116485. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  116486. * @param attachUp defines if you want to attach events to pointerup
  116487. * @param attachDown defines if you want to attach events to pointerdown
  116488. * @param attachMove defines if you want to attach events to pointermove
  116489. */
  116490. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  116491. /** Detaches all event handlers*/
  116492. detachControl(): void;
  116493. /**
  116494. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  116495. * Delay loaded resources are not taking in account
  116496. * @return true if all required resources are ready
  116497. */
  116498. isReady(): boolean;
  116499. /** Resets all cached information relative to material (including effect and visibility) */
  116500. resetCachedMaterial(): void;
  116501. /**
  116502. * Registers a function to be called before every frame render
  116503. * @param func defines the function to register
  116504. */
  116505. registerBeforeRender(func: () => void): void;
  116506. /**
  116507. * Unregisters a function called before every frame render
  116508. * @param func defines the function to unregister
  116509. */
  116510. unregisterBeforeRender(func: () => void): void;
  116511. /**
  116512. * Registers a function to be called after every frame render
  116513. * @param func defines the function to register
  116514. */
  116515. registerAfterRender(func: () => void): void;
  116516. /**
  116517. * Unregisters a function called after every frame render
  116518. * @param func defines the function to unregister
  116519. */
  116520. unregisterAfterRender(func: () => void): void;
  116521. private _executeOnceBeforeRender;
  116522. /**
  116523. * The provided function will run before render once and will be disposed afterwards.
  116524. * A timeout delay can be provided so that the function will be executed in N ms.
  116525. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  116526. * @param func The function to be executed.
  116527. * @param timeout optional delay in ms
  116528. */
  116529. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  116530. /** @hidden */
  116531. _addPendingData(data: any): void;
  116532. /** @hidden */
  116533. _removePendingData(data: any): void;
  116534. /**
  116535. * Returns the number of items waiting to be loaded
  116536. * @returns the number of items waiting to be loaded
  116537. */
  116538. getWaitingItemsCount(): number;
  116539. /**
  116540. * Returns a boolean indicating if the scene is still loading data
  116541. */
  116542. get isLoading(): boolean;
  116543. /**
  116544. * Registers a function to be executed when the scene is ready
  116545. * @param {Function} func - the function to be executed
  116546. */
  116547. executeWhenReady(func: () => void): void;
  116548. /**
  116549. * Returns a promise that resolves when the scene is ready
  116550. * @returns A promise that resolves when the scene is ready
  116551. */
  116552. whenReadyAsync(): Promise<void>;
  116553. /** @hidden */
  116554. _checkIsReady(): void;
  116555. /**
  116556. * Gets all animatable attached to the scene
  116557. */
  116558. get animatables(): Animatable[];
  116559. /**
  116560. * Resets the last animation time frame.
  116561. * Useful to override when animations start running when loading a scene for the first time.
  116562. */
  116563. resetLastAnimationTimeFrame(): void;
  116564. /**
  116565. * Gets the current view matrix
  116566. * @returns a Matrix
  116567. */
  116568. getViewMatrix(): Matrix;
  116569. /**
  116570. * Gets the current projection matrix
  116571. * @returns a Matrix
  116572. */
  116573. getProjectionMatrix(): Matrix;
  116574. /**
  116575. * Gets the current transform matrix
  116576. * @returns a Matrix made of View * Projection
  116577. */
  116578. getTransformMatrix(): Matrix;
  116579. /**
  116580. * Sets the current transform matrix
  116581. * @param viewL defines the View matrix to use
  116582. * @param projectionL defines the Projection matrix to use
  116583. * @param viewR defines the right View matrix to use (if provided)
  116584. * @param projectionR defines the right Projection matrix to use (if provided)
  116585. */
  116586. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  116587. /**
  116588. * Gets the uniform buffer used to store scene data
  116589. * @returns a UniformBuffer
  116590. */
  116591. getSceneUniformBuffer(): UniformBuffer;
  116592. /**
  116593. * Gets an unique (relatively to the current scene) Id
  116594. * @returns an unique number for the scene
  116595. */
  116596. getUniqueId(): number;
  116597. /**
  116598. * Add a mesh to the list of scene's meshes
  116599. * @param newMesh defines the mesh to add
  116600. * @param recursive if all child meshes should also be added to the scene
  116601. */
  116602. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  116603. /**
  116604. * Remove a mesh for the list of scene's meshes
  116605. * @param toRemove defines the mesh to remove
  116606. * @param recursive if all child meshes should also be removed from the scene
  116607. * @returns the index where the mesh was in the mesh list
  116608. */
  116609. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  116610. /**
  116611. * Add a transform node to the list of scene's transform nodes
  116612. * @param newTransformNode defines the transform node to add
  116613. */
  116614. addTransformNode(newTransformNode: TransformNode): void;
  116615. /**
  116616. * Remove a transform node for the list of scene's transform nodes
  116617. * @param toRemove defines the transform node to remove
  116618. * @returns the index where the transform node was in the transform node list
  116619. */
  116620. removeTransformNode(toRemove: TransformNode): number;
  116621. /**
  116622. * Remove a skeleton for the list of scene's skeletons
  116623. * @param toRemove defines the skeleton to remove
  116624. * @returns the index where the skeleton was in the skeleton list
  116625. */
  116626. removeSkeleton(toRemove: Skeleton): number;
  116627. /**
  116628. * Remove a morph target for the list of scene's morph targets
  116629. * @param toRemove defines the morph target to remove
  116630. * @returns the index where the morph target was in the morph target list
  116631. */
  116632. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  116633. /**
  116634. * Remove a light for the list of scene's lights
  116635. * @param toRemove defines the light to remove
  116636. * @returns the index where the light was in the light list
  116637. */
  116638. removeLight(toRemove: Light): number;
  116639. /**
  116640. * Remove a camera for the list of scene's cameras
  116641. * @param toRemove defines the camera to remove
  116642. * @returns the index where the camera was in the camera list
  116643. */
  116644. removeCamera(toRemove: Camera): number;
  116645. /**
  116646. * Remove a particle system for the list of scene's particle systems
  116647. * @param toRemove defines the particle system to remove
  116648. * @returns the index where the particle system was in the particle system list
  116649. */
  116650. removeParticleSystem(toRemove: IParticleSystem): number;
  116651. /**
  116652. * Remove a animation for the list of scene's animations
  116653. * @param toRemove defines the animation to remove
  116654. * @returns the index where the animation was in the animation list
  116655. */
  116656. removeAnimation(toRemove: Animation): number;
  116657. /**
  116658. * Will stop the animation of the given target
  116659. * @param target - the target
  116660. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  116661. * @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)
  116662. */
  116663. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  116664. /**
  116665. * Removes the given animation group from this scene.
  116666. * @param toRemove The animation group to remove
  116667. * @returns The index of the removed animation group
  116668. */
  116669. removeAnimationGroup(toRemove: AnimationGroup): number;
  116670. /**
  116671. * Removes the given multi-material from this scene.
  116672. * @param toRemove The multi-material to remove
  116673. * @returns The index of the removed multi-material
  116674. */
  116675. removeMultiMaterial(toRemove: MultiMaterial): number;
  116676. /**
  116677. * Removes the given material from this scene.
  116678. * @param toRemove The material to remove
  116679. * @returns The index of the removed material
  116680. */
  116681. removeMaterial(toRemove: Material): number;
  116682. /**
  116683. * Removes the given action manager from this scene.
  116684. * @param toRemove The action manager to remove
  116685. * @returns The index of the removed action manager
  116686. */
  116687. removeActionManager(toRemove: AbstractActionManager): number;
  116688. /**
  116689. * Removes the given texture from this scene.
  116690. * @param toRemove The texture to remove
  116691. * @returns The index of the removed texture
  116692. */
  116693. removeTexture(toRemove: BaseTexture): number;
  116694. /**
  116695. * Adds the given light to this scene
  116696. * @param newLight The light to add
  116697. */
  116698. addLight(newLight: Light): void;
  116699. /**
  116700. * Sorts the list list based on light priorities
  116701. */
  116702. sortLightsByPriority(): void;
  116703. /**
  116704. * Adds the given camera to this scene
  116705. * @param newCamera The camera to add
  116706. */
  116707. addCamera(newCamera: Camera): void;
  116708. /**
  116709. * Adds the given skeleton to this scene
  116710. * @param newSkeleton The skeleton to add
  116711. */
  116712. addSkeleton(newSkeleton: Skeleton): void;
  116713. /**
  116714. * Adds the given particle system to this scene
  116715. * @param newParticleSystem The particle system to add
  116716. */
  116717. addParticleSystem(newParticleSystem: IParticleSystem): void;
  116718. /**
  116719. * Adds the given animation to this scene
  116720. * @param newAnimation The animation to add
  116721. */
  116722. addAnimation(newAnimation: Animation): void;
  116723. /**
  116724. * Adds the given animation group to this scene.
  116725. * @param newAnimationGroup The animation group to add
  116726. */
  116727. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  116728. /**
  116729. * Adds the given multi-material to this scene
  116730. * @param newMultiMaterial The multi-material to add
  116731. */
  116732. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  116733. /**
  116734. * Adds the given material to this scene
  116735. * @param newMaterial The material to add
  116736. */
  116737. addMaterial(newMaterial: Material): void;
  116738. /**
  116739. * Adds the given morph target to this scene
  116740. * @param newMorphTargetManager The morph target to add
  116741. */
  116742. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  116743. /**
  116744. * Adds the given geometry to this scene
  116745. * @param newGeometry The geometry to add
  116746. */
  116747. addGeometry(newGeometry: Geometry): void;
  116748. /**
  116749. * Adds the given action manager to this scene
  116750. * @param newActionManager The action manager to add
  116751. */
  116752. addActionManager(newActionManager: AbstractActionManager): void;
  116753. /**
  116754. * Adds the given texture to this scene.
  116755. * @param newTexture The texture to add
  116756. */
  116757. addTexture(newTexture: BaseTexture): void;
  116758. /**
  116759. * Switch active camera
  116760. * @param newCamera defines the new active camera
  116761. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  116762. */
  116763. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  116764. /**
  116765. * sets the active camera of the scene using its ID
  116766. * @param id defines the camera's ID
  116767. * @return the new active camera or null if none found.
  116768. */
  116769. setActiveCameraByID(id: string): Nullable<Camera>;
  116770. /**
  116771. * sets the active camera of the scene using its name
  116772. * @param name defines the camera's name
  116773. * @returns the new active camera or null if none found.
  116774. */
  116775. setActiveCameraByName(name: string): Nullable<Camera>;
  116776. /**
  116777. * get an animation group using its name
  116778. * @param name defines the material's name
  116779. * @return the animation group or null if none found.
  116780. */
  116781. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  116782. /**
  116783. * Get a material using its unique id
  116784. * @param uniqueId defines the material's unique id
  116785. * @return the material or null if none found.
  116786. */
  116787. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  116788. /**
  116789. * get a material using its id
  116790. * @param id defines the material's ID
  116791. * @return the material or null if none found.
  116792. */
  116793. getMaterialByID(id: string): Nullable<Material>;
  116794. /**
  116795. * Gets a the last added material using a given id
  116796. * @param id defines the material's ID
  116797. * @return the last material with the given id or null if none found.
  116798. */
  116799. getLastMaterialByID(id: string): Nullable<Material>;
  116800. /**
  116801. * Gets a material using its name
  116802. * @param name defines the material's name
  116803. * @return the material or null if none found.
  116804. */
  116805. getMaterialByName(name: string): Nullable<Material>;
  116806. /**
  116807. * Get a texture using its unique id
  116808. * @param uniqueId defines the texture's unique id
  116809. * @return the texture or null if none found.
  116810. */
  116811. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  116812. /**
  116813. * Gets a camera using its id
  116814. * @param id defines the id to look for
  116815. * @returns the camera or null if not found
  116816. */
  116817. getCameraByID(id: string): Nullable<Camera>;
  116818. /**
  116819. * Gets a camera using its unique id
  116820. * @param uniqueId defines the unique id to look for
  116821. * @returns the camera or null if not found
  116822. */
  116823. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  116824. /**
  116825. * Gets a camera using its name
  116826. * @param name defines the camera's name
  116827. * @return the camera or null if none found.
  116828. */
  116829. getCameraByName(name: string): Nullable<Camera>;
  116830. /**
  116831. * Gets a bone using its id
  116832. * @param id defines the bone's id
  116833. * @return the bone or null if not found
  116834. */
  116835. getBoneByID(id: string): Nullable<Bone>;
  116836. /**
  116837. * Gets a bone using its id
  116838. * @param name defines the bone's name
  116839. * @return the bone or null if not found
  116840. */
  116841. getBoneByName(name: string): Nullable<Bone>;
  116842. /**
  116843. * Gets a light node using its name
  116844. * @param name defines the the light's name
  116845. * @return the light or null if none found.
  116846. */
  116847. getLightByName(name: string): Nullable<Light>;
  116848. /**
  116849. * Gets a light node using its id
  116850. * @param id defines the light's id
  116851. * @return the light or null if none found.
  116852. */
  116853. getLightByID(id: string): Nullable<Light>;
  116854. /**
  116855. * Gets a light node using its scene-generated unique ID
  116856. * @param uniqueId defines the light's unique id
  116857. * @return the light or null if none found.
  116858. */
  116859. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  116860. /**
  116861. * Gets a particle system by id
  116862. * @param id defines the particle system id
  116863. * @return the corresponding system or null if none found
  116864. */
  116865. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  116866. /**
  116867. * Gets a geometry using its ID
  116868. * @param id defines the geometry's id
  116869. * @return the geometry or null if none found.
  116870. */
  116871. getGeometryByID(id: string): Nullable<Geometry>;
  116872. private _getGeometryByUniqueID;
  116873. /**
  116874. * Add a new geometry to this scene
  116875. * @param geometry defines the geometry to be added to the scene.
  116876. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  116877. * @return a boolean defining if the geometry was added or not
  116878. */
  116879. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  116880. /**
  116881. * Removes an existing geometry
  116882. * @param geometry defines the geometry to be removed from the scene
  116883. * @return a boolean defining if the geometry was removed or not
  116884. */
  116885. removeGeometry(geometry: Geometry): boolean;
  116886. /**
  116887. * Gets the list of geometries attached to the scene
  116888. * @returns an array of Geometry
  116889. */
  116890. getGeometries(): Geometry[];
  116891. /**
  116892. * Gets the first added mesh found of a given ID
  116893. * @param id defines the id to search for
  116894. * @return the mesh found or null if not found at all
  116895. */
  116896. getMeshByID(id: string): Nullable<AbstractMesh>;
  116897. /**
  116898. * Gets a list of meshes using their id
  116899. * @param id defines the id to search for
  116900. * @returns a list of meshes
  116901. */
  116902. getMeshesByID(id: string): Array<AbstractMesh>;
  116903. /**
  116904. * Gets the first added transform node found of a given ID
  116905. * @param id defines the id to search for
  116906. * @return the found transform node or null if not found at all.
  116907. */
  116908. getTransformNodeByID(id: string): Nullable<TransformNode>;
  116909. /**
  116910. * Gets a transform node with its auto-generated unique id
  116911. * @param uniqueId efines the unique id to search for
  116912. * @return the found transform node or null if not found at all.
  116913. */
  116914. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  116915. /**
  116916. * Gets a list of transform nodes using their id
  116917. * @param id defines the id to search for
  116918. * @returns a list of transform nodes
  116919. */
  116920. getTransformNodesByID(id: string): Array<TransformNode>;
  116921. /**
  116922. * Gets a mesh with its auto-generated unique id
  116923. * @param uniqueId defines the unique id to search for
  116924. * @return the found mesh or null if not found at all.
  116925. */
  116926. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  116927. /**
  116928. * Gets a the last added mesh using a given id
  116929. * @param id defines the id to search for
  116930. * @return the found mesh or null if not found at all.
  116931. */
  116932. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  116933. /**
  116934. * Gets a the last added node (Mesh, Camera, Light) using a given id
  116935. * @param id defines the id to search for
  116936. * @return the found node or null if not found at all
  116937. */
  116938. getLastEntryByID(id: string): Nullable<Node>;
  116939. /**
  116940. * Gets a node (Mesh, Camera, Light) using a given id
  116941. * @param id defines the id to search for
  116942. * @return the found node or null if not found at all
  116943. */
  116944. getNodeByID(id: string): Nullable<Node>;
  116945. /**
  116946. * Gets a node (Mesh, Camera, Light) using a given name
  116947. * @param name defines the name to search for
  116948. * @return the found node or null if not found at all.
  116949. */
  116950. getNodeByName(name: string): Nullable<Node>;
  116951. /**
  116952. * Gets a mesh using a given name
  116953. * @param name defines the name to search for
  116954. * @return the found mesh or null if not found at all.
  116955. */
  116956. getMeshByName(name: string): Nullable<AbstractMesh>;
  116957. /**
  116958. * Gets a transform node using a given name
  116959. * @param name defines the name to search for
  116960. * @return the found transform node or null if not found at all.
  116961. */
  116962. getTransformNodeByName(name: string): Nullable<TransformNode>;
  116963. /**
  116964. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  116965. * @param id defines the id to search for
  116966. * @return the found skeleton or null if not found at all.
  116967. */
  116968. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  116969. /**
  116970. * Gets a skeleton using a given auto generated unique id
  116971. * @param uniqueId defines the unique id to search for
  116972. * @return the found skeleton or null if not found at all.
  116973. */
  116974. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  116975. /**
  116976. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  116977. * @param id defines the id to search for
  116978. * @return the found skeleton or null if not found at all.
  116979. */
  116980. getSkeletonById(id: string): Nullable<Skeleton>;
  116981. /**
  116982. * Gets a skeleton using a given name
  116983. * @param name defines the name to search for
  116984. * @return the found skeleton or null if not found at all.
  116985. */
  116986. getSkeletonByName(name: string): Nullable<Skeleton>;
  116987. /**
  116988. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  116989. * @param id defines the id to search for
  116990. * @return the found morph target manager or null if not found at all.
  116991. */
  116992. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  116993. /**
  116994. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  116995. * @param id defines the id to search for
  116996. * @return the found morph target or null if not found at all.
  116997. */
  116998. getMorphTargetById(id: string): Nullable<MorphTarget>;
  116999. /**
  117000. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  117001. * @param name defines the name to search for
  117002. * @return the found morph target or null if not found at all.
  117003. */
  117004. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  117005. /**
  117006. * Gets a boolean indicating if the given mesh is active
  117007. * @param mesh defines the mesh to look for
  117008. * @returns true if the mesh is in the active list
  117009. */
  117010. isActiveMesh(mesh: AbstractMesh): boolean;
  117011. /**
  117012. * Return a unique id as a string which can serve as an identifier for the scene
  117013. */
  117014. get uid(): string;
  117015. /**
  117016. * Add an externaly attached data from its key.
  117017. * This method call will fail and return false, if such key already exists.
  117018. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  117019. * @param key the unique key that identifies the data
  117020. * @param data the data object to associate to the key for this Engine instance
  117021. * @return true if no such key were already present and the data was added successfully, false otherwise
  117022. */
  117023. addExternalData<T>(key: string, data: T): boolean;
  117024. /**
  117025. * Get an externaly attached data from its key
  117026. * @param key the unique key that identifies the data
  117027. * @return the associated data, if present (can be null), or undefined if not present
  117028. */
  117029. getExternalData<T>(key: string): Nullable<T>;
  117030. /**
  117031. * Get an externaly attached data from its key, create it using a factory if it's not already present
  117032. * @param key the unique key that identifies the data
  117033. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  117034. * @return the associated data, can be null if the factory returned null.
  117035. */
  117036. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  117037. /**
  117038. * Remove an externaly attached data from the Engine instance
  117039. * @param key the unique key that identifies the data
  117040. * @return true if the data was successfully removed, false if it doesn't exist
  117041. */
  117042. removeExternalData(key: string): boolean;
  117043. private _evaluateSubMesh;
  117044. /**
  117045. * Clear the processed materials smart array preventing retention point in material dispose.
  117046. */
  117047. freeProcessedMaterials(): void;
  117048. private _preventFreeActiveMeshesAndRenderingGroups;
  117049. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  117050. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  117051. * when disposing several meshes in a row or a hierarchy of meshes.
  117052. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  117053. */
  117054. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  117055. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  117056. /**
  117057. * Clear the active meshes smart array preventing retention point in mesh dispose.
  117058. */
  117059. freeActiveMeshes(): void;
  117060. /**
  117061. * Clear the info related to rendering groups preventing retention points during dispose.
  117062. */
  117063. freeRenderingGroups(): void;
  117064. /** @hidden */
  117065. _isInIntermediateRendering(): boolean;
  117066. /**
  117067. * Lambda returning the list of potentially active meshes.
  117068. */
  117069. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  117070. /**
  117071. * Lambda returning the list of potentially active sub meshes.
  117072. */
  117073. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  117074. /**
  117075. * Lambda returning the list of potentially intersecting sub meshes.
  117076. */
  117077. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  117078. /**
  117079. * Lambda returning the list of potentially colliding sub meshes.
  117080. */
  117081. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  117082. private _activeMeshesFrozen;
  117083. private _skipEvaluateActiveMeshesCompletely;
  117084. /**
  117085. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  117086. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  117087. * @returns the current scene
  117088. */
  117089. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  117090. /**
  117091. * Use this function to restart evaluating active meshes on every frame
  117092. * @returns the current scene
  117093. */
  117094. unfreezeActiveMeshes(): Scene;
  117095. private _evaluateActiveMeshes;
  117096. private _activeMesh;
  117097. /**
  117098. * Update the transform matrix to update from the current active camera
  117099. * @param force defines a boolean used to force the update even if cache is up to date
  117100. */
  117101. updateTransformMatrix(force?: boolean): void;
  117102. private _bindFrameBuffer;
  117103. /** @hidden */
  117104. _allowPostProcessClearColor: boolean;
  117105. /** @hidden */
  117106. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  117107. private _processSubCameras;
  117108. private _checkIntersections;
  117109. /** @hidden */
  117110. _advancePhysicsEngineStep(step: number): void;
  117111. /**
  117112. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  117113. */
  117114. getDeterministicFrameTime: () => number;
  117115. /** @hidden */
  117116. _animate(): void;
  117117. /** Execute all animations (for a frame) */
  117118. animate(): void;
  117119. /**
  117120. * Render the scene
  117121. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  117122. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  117123. */
  117124. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  117125. /**
  117126. * Freeze all materials
  117127. * A frozen material will not be updatable but should be faster to render
  117128. */
  117129. freezeMaterials(): void;
  117130. /**
  117131. * Unfreeze all materials
  117132. * A frozen material will not be updatable but should be faster to render
  117133. */
  117134. unfreezeMaterials(): void;
  117135. /**
  117136. * Releases all held ressources
  117137. */
  117138. dispose(): void;
  117139. /**
  117140. * Gets if the scene is already disposed
  117141. */
  117142. get isDisposed(): boolean;
  117143. /**
  117144. * Call this function to reduce memory footprint of the scene.
  117145. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  117146. */
  117147. clearCachedVertexData(): void;
  117148. /**
  117149. * This function will remove the local cached buffer data from texture.
  117150. * It will save memory but will prevent the texture from being rebuilt
  117151. */
  117152. cleanCachedTextureBuffer(): void;
  117153. /**
  117154. * Get the world extend vectors with an optional filter
  117155. *
  117156. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  117157. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  117158. */
  117159. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  117160. min: Vector3;
  117161. max: Vector3;
  117162. };
  117163. /**
  117164. * Creates a ray that can be used to pick in the scene
  117165. * @param x defines the x coordinate of the origin (on-screen)
  117166. * @param y defines the y coordinate of the origin (on-screen)
  117167. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  117168. * @param camera defines the camera to use for the picking
  117169. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  117170. * @returns a Ray
  117171. */
  117172. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  117173. /**
  117174. * Creates a ray that can be used to pick in the scene
  117175. * @param x defines the x coordinate of the origin (on-screen)
  117176. * @param y defines the y coordinate of the origin (on-screen)
  117177. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  117178. * @param result defines the ray where to store the picking ray
  117179. * @param camera defines the camera to use for the picking
  117180. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  117181. * @returns the current scene
  117182. */
  117183. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  117184. /**
  117185. * Creates a ray that can be used to pick in the scene
  117186. * @param x defines the x coordinate of the origin (on-screen)
  117187. * @param y defines the y coordinate of the origin (on-screen)
  117188. * @param camera defines the camera to use for the picking
  117189. * @returns a Ray
  117190. */
  117191. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  117192. /**
  117193. * Creates a ray that can be used to pick in the scene
  117194. * @param x defines the x coordinate of the origin (on-screen)
  117195. * @param y defines the y coordinate of the origin (on-screen)
  117196. * @param result defines the ray where to store the picking ray
  117197. * @param camera defines the camera to use for the picking
  117198. * @returns the current scene
  117199. */
  117200. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  117201. /** Launch a ray to try to pick a mesh in the scene
  117202. * @param x position on screen
  117203. * @param y position on screen
  117204. * @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
  117205. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117206. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117207. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117208. * @returns a PickingInfo
  117209. */
  117210. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  117211. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  117212. * @param x position on screen
  117213. * @param y position on screen
  117214. * @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
  117215. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117216. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117217. * @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)
  117218. */
  117219. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  117220. /** Use the given ray to pick a mesh in the scene
  117221. * @param ray The ray to use to pick meshes
  117222. * @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
  117223. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117224. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117225. * @returns a PickingInfo
  117226. */
  117227. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  117228. /**
  117229. * Launch a ray to try to pick a mesh in the scene
  117230. * @param x X position on screen
  117231. * @param y Y position on screen
  117232. * @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
  117233. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117234. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117235. * @returns an array of PickingInfo
  117236. */
  117237. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  117238. /**
  117239. * Launch a ray to try to pick a mesh in the scene
  117240. * @param ray Ray to use
  117241. * @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
  117242. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117243. * @returns an array of PickingInfo
  117244. */
  117245. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  117246. /**
  117247. * Force the value of meshUnderPointer
  117248. * @param mesh defines the mesh to use
  117249. */
  117250. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  117251. /**
  117252. * Gets the mesh under the pointer
  117253. * @returns a Mesh or null if no mesh is under the pointer
  117254. */
  117255. getPointerOverMesh(): Nullable<AbstractMesh>;
  117256. /** @hidden */
  117257. _rebuildGeometries(): void;
  117258. /** @hidden */
  117259. _rebuildTextures(): void;
  117260. private _getByTags;
  117261. /**
  117262. * Get a list of meshes by tags
  117263. * @param tagsQuery defines the tags query to use
  117264. * @param forEach defines a predicate used to filter results
  117265. * @returns an array of Mesh
  117266. */
  117267. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  117268. /**
  117269. * Get a list of cameras by tags
  117270. * @param tagsQuery defines the tags query to use
  117271. * @param forEach defines a predicate used to filter results
  117272. * @returns an array of Camera
  117273. */
  117274. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  117275. /**
  117276. * Get a list of lights by tags
  117277. * @param tagsQuery defines the tags query to use
  117278. * @param forEach defines a predicate used to filter results
  117279. * @returns an array of Light
  117280. */
  117281. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  117282. /**
  117283. * Get a list of materials by tags
  117284. * @param tagsQuery defines the tags query to use
  117285. * @param forEach defines a predicate used to filter results
  117286. * @returns an array of Material
  117287. */
  117288. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  117289. /**
  117290. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  117291. * This allowed control for front to back rendering or reversly depending of the special needs.
  117292. *
  117293. * @param renderingGroupId The rendering group id corresponding to its index
  117294. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  117295. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  117296. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  117297. */
  117298. 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;
  117299. /**
  117300. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  117301. *
  117302. * @param renderingGroupId The rendering group id corresponding to its index
  117303. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  117304. * @param depth Automatically clears depth between groups if true and autoClear is true.
  117305. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  117306. */
  117307. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  117308. /**
  117309. * Gets the current auto clear configuration for one rendering group of the rendering
  117310. * manager.
  117311. * @param index the rendering group index to get the information for
  117312. * @returns The auto clear setup for the requested rendering group
  117313. */
  117314. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  117315. private _blockMaterialDirtyMechanism;
  117316. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  117317. get blockMaterialDirtyMechanism(): boolean;
  117318. set blockMaterialDirtyMechanism(value: boolean);
  117319. /**
  117320. * Will flag all materials as dirty to trigger new shader compilation
  117321. * @param flag defines the flag used to specify which material part must be marked as dirty
  117322. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  117323. */
  117324. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  117325. /** @hidden */
  117326. _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;
  117327. /** @hidden */
  117328. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117329. /** @hidden */
  117330. _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;
  117331. /** @hidden */
  117332. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  117333. /** @hidden */
  117334. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  117335. /** @hidden */
  117336. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117337. }
  117338. }
  117339. declare module BABYLON {
  117340. /**
  117341. * Set of assets to keep when moving a scene into an asset container.
  117342. */
  117343. export class KeepAssets extends AbstractScene {
  117344. }
  117345. /**
  117346. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  117347. */
  117348. export class InstantiatedEntries {
  117349. /**
  117350. * List of new root nodes (eg. nodes with no parent)
  117351. */
  117352. rootNodes: TransformNode[];
  117353. /**
  117354. * List of new skeletons
  117355. */
  117356. skeletons: Skeleton[];
  117357. /**
  117358. * List of new animation groups
  117359. */
  117360. animationGroups: AnimationGroup[];
  117361. }
  117362. /**
  117363. * Container with a set of assets that can be added or removed from a scene.
  117364. */
  117365. export class AssetContainer extends AbstractScene {
  117366. private _wasAddedToScene;
  117367. /**
  117368. * The scene the AssetContainer belongs to.
  117369. */
  117370. scene: Scene;
  117371. /**
  117372. * Instantiates an AssetContainer.
  117373. * @param scene The scene the AssetContainer belongs to.
  117374. */
  117375. constructor(scene: Scene);
  117376. /**
  117377. * Instantiate or clone all meshes and add the new ones to the scene.
  117378. * Skeletons and animation groups will all be cloned
  117379. * @param nameFunction defines an optional function used to get new names for clones
  117380. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  117381. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  117382. */
  117383. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  117384. /**
  117385. * Adds all the assets from the container to the scene.
  117386. */
  117387. addAllToScene(): void;
  117388. /**
  117389. * Removes all the assets in the container from the scene
  117390. */
  117391. removeAllFromScene(): void;
  117392. /**
  117393. * Disposes all the assets in the container
  117394. */
  117395. dispose(): void;
  117396. private _moveAssets;
  117397. /**
  117398. * Removes all the assets contained in the scene and adds them to the container.
  117399. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  117400. */
  117401. moveAllFromScene(keepAssets?: KeepAssets): void;
  117402. /**
  117403. * 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.
  117404. * @returns the root mesh
  117405. */
  117406. createRootMesh(): Mesh;
  117407. /**
  117408. * Merge animations (direct and animation groups) from this asset container into a scene
  117409. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117410. * @param animatables set of animatables to retarget to a node from the scene
  117411. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  117412. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  117413. */
  117414. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  117415. }
  117416. }
  117417. declare module BABYLON {
  117418. /**
  117419. * Defines how the parser contract is defined.
  117420. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  117421. */
  117422. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  117423. /**
  117424. * Defines how the individual parser contract is defined.
  117425. * These parser can parse an individual asset
  117426. */
  117427. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  117428. /**
  117429. * Base class of the scene acting as a container for the different elements composing a scene.
  117430. * This class is dynamically extended by the different components of the scene increasing
  117431. * flexibility and reducing coupling
  117432. */
  117433. export abstract class AbstractScene {
  117434. /**
  117435. * Stores the list of available parsers in the application.
  117436. */
  117437. private static _BabylonFileParsers;
  117438. /**
  117439. * Stores the list of available individual parsers in the application.
  117440. */
  117441. private static _IndividualBabylonFileParsers;
  117442. /**
  117443. * Adds a parser in the list of available ones
  117444. * @param name Defines the name of the parser
  117445. * @param parser Defines the parser to add
  117446. */
  117447. static AddParser(name: string, parser: BabylonFileParser): void;
  117448. /**
  117449. * Gets a general parser from the list of avaialble ones
  117450. * @param name Defines the name of the parser
  117451. * @returns the requested parser or null
  117452. */
  117453. static GetParser(name: string): Nullable<BabylonFileParser>;
  117454. /**
  117455. * Adds n individual parser in the list of available ones
  117456. * @param name Defines the name of the parser
  117457. * @param parser Defines the parser to add
  117458. */
  117459. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  117460. /**
  117461. * Gets an individual parser from the list of avaialble ones
  117462. * @param name Defines the name of the parser
  117463. * @returns the requested parser or null
  117464. */
  117465. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  117466. /**
  117467. * Parser json data and populate both a scene and its associated container object
  117468. * @param jsonData Defines the data to parse
  117469. * @param scene Defines the scene to parse the data for
  117470. * @param container Defines the container attached to the parsing sequence
  117471. * @param rootUrl Defines the root url of the data
  117472. */
  117473. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  117474. /**
  117475. * Gets the list of root nodes (ie. nodes with no parent)
  117476. */
  117477. rootNodes: Node[];
  117478. /** All of the cameras added to this scene
  117479. * @see http://doc.babylonjs.com/babylon101/cameras
  117480. */
  117481. cameras: Camera[];
  117482. /**
  117483. * All of the lights added to this scene
  117484. * @see http://doc.babylonjs.com/babylon101/lights
  117485. */
  117486. lights: Light[];
  117487. /**
  117488. * All of the (abstract) meshes added to this scene
  117489. */
  117490. meshes: AbstractMesh[];
  117491. /**
  117492. * The list of skeletons added to the scene
  117493. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  117494. */
  117495. skeletons: Skeleton[];
  117496. /**
  117497. * All of the particle systems added to this scene
  117498. * @see http://doc.babylonjs.com/babylon101/particles
  117499. */
  117500. particleSystems: IParticleSystem[];
  117501. /**
  117502. * Gets a list of Animations associated with the scene
  117503. */
  117504. animations: Animation[];
  117505. /**
  117506. * All of the animation groups added to this scene
  117507. * @see http://doc.babylonjs.com/how_to/group
  117508. */
  117509. animationGroups: AnimationGroup[];
  117510. /**
  117511. * All of the multi-materials added to this scene
  117512. * @see http://doc.babylonjs.com/how_to/multi_materials
  117513. */
  117514. multiMaterials: MultiMaterial[];
  117515. /**
  117516. * All of the materials added to this scene
  117517. * In the context of a Scene, it is not supposed to be modified manually.
  117518. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  117519. * Note also that the order of the Material within the array is not significant and might change.
  117520. * @see http://doc.babylonjs.com/babylon101/materials
  117521. */
  117522. materials: Material[];
  117523. /**
  117524. * The list of morph target managers added to the scene
  117525. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  117526. */
  117527. morphTargetManagers: MorphTargetManager[];
  117528. /**
  117529. * The list of geometries used in the scene.
  117530. */
  117531. geometries: Geometry[];
  117532. /**
  117533. * All of the tranform nodes added to this scene
  117534. * In the context of a Scene, it is not supposed to be modified manually.
  117535. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  117536. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  117537. * @see http://doc.babylonjs.com/how_to/transformnode
  117538. */
  117539. transformNodes: TransformNode[];
  117540. /**
  117541. * ActionManagers available on the scene.
  117542. */
  117543. actionManagers: AbstractActionManager[];
  117544. /**
  117545. * Textures to keep.
  117546. */
  117547. textures: BaseTexture[];
  117548. /**
  117549. * Environment texture for the scene
  117550. */
  117551. environmentTexture: Nullable<BaseTexture>;
  117552. /**
  117553. * @returns all meshes, lights, cameras, transformNodes and bones
  117554. */
  117555. getNodes(): Array<Node>;
  117556. }
  117557. }
  117558. declare module BABYLON {
  117559. /**
  117560. * Interface used to define options for Sound class
  117561. */
  117562. export interface ISoundOptions {
  117563. /**
  117564. * Does the sound autoplay once loaded.
  117565. */
  117566. autoplay?: boolean;
  117567. /**
  117568. * Does the sound loop after it finishes playing once.
  117569. */
  117570. loop?: boolean;
  117571. /**
  117572. * Sound's volume
  117573. */
  117574. volume?: number;
  117575. /**
  117576. * Is it a spatial sound?
  117577. */
  117578. spatialSound?: boolean;
  117579. /**
  117580. * Maximum distance to hear that sound
  117581. */
  117582. maxDistance?: number;
  117583. /**
  117584. * Uses user defined attenuation function
  117585. */
  117586. useCustomAttenuation?: boolean;
  117587. /**
  117588. * Define the roll off factor of spatial sounds.
  117589. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117590. */
  117591. rolloffFactor?: number;
  117592. /**
  117593. * Define the reference distance the sound should be heard perfectly.
  117594. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117595. */
  117596. refDistance?: number;
  117597. /**
  117598. * Define the distance attenuation model the sound will follow.
  117599. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117600. */
  117601. distanceModel?: string;
  117602. /**
  117603. * Defines the playback speed (1 by default)
  117604. */
  117605. playbackRate?: number;
  117606. /**
  117607. * Defines if the sound is from a streaming source
  117608. */
  117609. streaming?: boolean;
  117610. /**
  117611. * Defines an optional length (in seconds) inside the sound file
  117612. */
  117613. length?: number;
  117614. /**
  117615. * Defines an optional offset (in seconds) inside the sound file
  117616. */
  117617. offset?: number;
  117618. /**
  117619. * If true, URLs will not be required to state the audio file codec to use.
  117620. */
  117621. skipCodecCheck?: boolean;
  117622. }
  117623. /**
  117624. * Defines a sound that can be played in the application.
  117625. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  117626. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  117627. */
  117628. export class Sound {
  117629. /**
  117630. * The name of the sound in the scene.
  117631. */
  117632. name: string;
  117633. /**
  117634. * Does the sound autoplay once loaded.
  117635. */
  117636. autoplay: boolean;
  117637. /**
  117638. * Does the sound loop after it finishes playing once.
  117639. */
  117640. loop: boolean;
  117641. /**
  117642. * Does the sound use a custom attenuation curve to simulate the falloff
  117643. * happening when the source gets further away from the camera.
  117644. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  117645. */
  117646. useCustomAttenuation: boolean;
  117647. /**
  117648. * The sound track id this sound belongs to.
  117649. */
  117650. soundTrackId: number;
  117651. /**
  117652. * Is this sound currently played.
  117653. */
  117654. isPlaying: boolean;
  117655. /**
  117656. * Is this sound currently paused.
  117657. */
  117658. isPaused: boolean;
  117659. /**
  117660. * Does this sound enables spatial sound.
  117661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117662. */
  117663. spatialSound: boolean;
  117664. /**
  117665. * Define the reference distance the sound should be heard perfectly.
  117666. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117667. */
  117668. refDistance: number;
  117669. /**
  117670. * Define the roll off factor of spatial sounds.
  117671. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117672. */
  117673. rolloffFactor: number;
  117674. /**
  117675. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  117676. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117677. */
  117678. maxDistance: number;
  117679. /**
  117680. * Define the distance attenuation model the sound will follow.
  117681. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117682. */
  117683. distanceModel: string;
  117684. /**
  117685. * @hidden
  117686. * Back Compat
  117687. **/
  117688. onended: () => any;
  117689. /**
  117690. * Gets or sets an object used to store user defined information for the sound.
  117691. */
  117692. metadata: any;
  117693. /**
  117694. * Observable event when the current playing sound finishes.
  117695. */
  117696. onEndedObservable: Observable<Sound>;
  117697. private _panningModel;
  117698. private _playbackRate;
  117699. private _streaming;
  117700. private _startTime;
  117701. private _startOffset;
  117702. private _position;
  117703. /** @hidden */
  117704. _positionInEmitterSpace: boolean;
  117705. private _localDirection;
  117706. private _volume;
  117707. private _isReadyToPlay;
  117708. private _isDirectional;
  117709. private _readyToPlayCallback;
  117710. private _audioBuffer;
  117711. private _soundSource;
  117712. private _streamingSource;
  117713. private _soundPanner;
  117714. private _soundGain;
  117715. private _inputAudioNode;
  117716. private _outputAudioNode;
  117717. private _coneInnerAngle;
  117718. private _coneOuterAngle;
  117719. private _coneOuterGain;
  117720. private _scene;
  117721. private _connectedTransformNode;
  117722. private _customAttenuationFunction;
  117723. private _registerFunc;
  117724. private _isOutputConnected;
  117725. private _htmlAudioElement;
  117726. private _urlType;
  117727. private _length?;
  117728. private _offset?;
  117729. /** @hidden */
  117730. static _SceneComponentInitialization: (scene: Scene) => void;
  117731. /**
  117732. * Create a sound and attach it to a scene
  117733. * @param name Name of your sound
  117734. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  117735. * @param scene defines the scene the sound belongs to
  117736. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  117737. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  117738. */
  117739. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  117740. /**
  117741. * Release the sound and its associated resources
  117742. */
  117743. dispose(): void;
  117744. /**
  117745. * Gets if the sounds is ready to be played or not.
  117746. * @returns true if ready, otherwise false
  117747. */
  117748. isReady(): boolean;
  117749. private _soundLoaded;
  117750. /**
  117751. * Sets the data of the sound from an audiobuffer
  117752. * @param audioBuffer The audioBuffer containing the data
  117753. */
  117754. setAudioBuffer(audioBuffer: AudioBuffer): void;
  117755. /**
  117756. * Updates the current sounds options such as maxdistance, loop...
  117757. * @param options A JSON object containing values named as the object properties
  117758. */
  117759. updateOptions(options: ISoundOptions): void;
  117760. private _createSpatialParameters;
  117761. private _updateSpatialParameters;
  117762. /**
  117763. * Switch the panning model to HRTF:
  117764. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  117765. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117766. */
  117767. switchPanningModelToHRTF(): void;
  117768. /**
  117769. * Switch the panning model to Equal Power:
  117770. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  117771. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117772. */
  117773. switchPanningModelToEqualPower(): void;
  117774. private _switchPanningModel;
  117775. /**
  117776. * Connect this sound to a sound track audio node like gain...
  117777. * @param soundTrackAudioNode the sound track audio node to connect to
  117778. */
  117779. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  117780. /**
  117781. * Transform this sound into a directional source
  117782. * @param coneInnerAngle Size of the inner cone in degree
  117783. * @param coneOuterAngle Size of the outer cone in degree
  117784. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  117785. */
  117786. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  117787. /**
  117788. * Gets or sets the inner angle for the directional cone.
  117789. */
  117790. get directionalConeInnerAngle(): number;
  117791. /**
  117792. * Gets or sets the inner angle for the directional cone.
  117793. */
  117794. set directionalConeInnerAngle(value: number);
  117795. /**
  117796. * Gets or sets the outer angle for the directional cone.
  117797. */
  117798. get directionalConeOuterAngle(): number;
  117799. /**
  117800. * Gets or sets the outer angle for the directional cone.
  117801. */
  117802. set directionalConeOuterAngle(value: number);
  117803. /**
  117804. * Sets the position of the emitter if spatial sound is enabled
  117805. * @param newPosition Defines the new posisiton
  117806. */
  117807. setPosition(newPosition: Vector3): void;
  117808. /**
  117809. * Sets the local direction of the emitter if spatial sound is enabled
  117810. * @param newLocalDirection Defines the new local direction
  117811. */
  117812. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  117813. private _updateDirection;
  117814. /** @hidden */
  117815. updateDistanceFromListener(): void;
  117816. /**
  117817. * Sets a new custom attenuation function for the sound.
  117818. * @param callback Defines the function used for the attenuation
  117819. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  117820. */
  117821. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  117822. /**
  117823. * Play the sound
  117824. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  117825. * @param offset (optional) Start the sound at a specific time in seconds
  117826. * @param length (optional) Sound duration (in seconds)
  117827. */
  117828. play(time?: number, offset?: number, length?: number): void;
  117829. private _onended;
  117830. /**
  117831. * Stop the sound
  117832. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  117833. */
  117834. stop(time?: number): void;
  117835. /**
  117836. * Put the sound in pause
  117837. */
  117838. pause(): void;
  117839. /**
  117840. * Sets a dedicated volume for this sounds
  117841. * @param newVolume Define the new volume of the sound
  117842. * @param time Define time for gradual change to new volume
  117843. */
  117844. setVolume(newVolume: number, time?: number): void;
  117845. /**
  117846. * Set the sound play back rate
  117847. * @param newPlaybackRate Define the playback rate the sound should be played at
  117848. */
  117849. setPlaybackRate(newPlaybackRate: number): void;
  117850. /**
  117851. * Gets the volume of the sound.
  117852. * @returns the volume of the sound
  117853. */
  117854. getVolume(): number;
  117855. /**
  117856. * Attach the sound to a dedicated mesh
  117857. * @param transformNode The transform node to connect the sound with
  117858. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  117859. */
  117860. attachToMesh(transformNode: TransformNode): void;
  117861. /**
  117862. * Detach the sound from the previously attached mesh
  117863. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  117864. */
  117865. detachFromMesh(): void;
  117866. private _onRegisterAfterWorldMatrixUpdate;
  117867. /**
  117868. * Clone the current sound in the scene.
  117869. * @returns the new sound clone
  117870. */
  117871. clone(): Nullable<Sound>;
  117872. /**
  117873. * Gets the current underlying audio buffer containing the data
  117874. * @returns the audio buffer
  117875. */
  117876. getAudioBuffer(): Nullable<AudioBuffer>;
  117877. /**
  117878. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  117879. * @returns the source node
  117880. */
  117881. getSoundSource(): Nullable<AudioBufferSourceNode>;
  117882. /**
  117883. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  117884. * @returns the gain node
  117885. */
  117886. getSoundGain(): Nullable<GainNode>;
  117887. /**
  117888. * Serializes the Sound in a JSON representation
  117889. * @returns the JSON representation of the sound
  117890. */
  117891. serialize(): any;
  117892. /**
  117893. * Parse a JSON representation of a sound to innstantiate in a given scene
  117894. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  117895. * @param scene Define the scene the new parsed sound should be created in
  117896. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  117897. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  117898. * @returns the newly parsed sound
  117899. */
  117900. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  117901. }
  117902. }
  117903. declare module BABYLON {
  117904. /**
  117905. * This defines an action helpful to play a defined sound on a triggered action.
  117906. */
  117907. export class PlaySoundAction extends Action {
  117908. private _sound;
  117909. /**
  117910. * Instantiate the action
  117911. * @param triggerOptions defines the trigger options
  117912. * @param sound defines the sound to play
  117913. * @param condition defines the trigger related conditions
  117914. */
  117915. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  117916. /** @hidden */
  117917. _prepare(): void;
  117918. /**
  117919. * Execute the action and play the sound.
  117920. */
  117921. execute(): void;
  117922. /**
  117923. * Serializes the actions and its related information.
  117924. * @param parent defines the object to serialize in
  117925. * @returns the serialized object
  117926. */
  117927. serialize(parent: any): any;
  117928. }
  117929. /**
  117930. * This defines an action helpful to stop a defined sound on a triggered action.
  117931. */
  117932. export class StopSoundAction extends Action {
  117933. private _sound;
  117934. /**
  117935. * Instantiate the action
  117936. * @param triggerOptions defines the trigger options
  117937. * @param sound defines the sound to stop
  117938. * @param condition defines the trigger related conditions
  117939. */
  117940. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  117941. /** @hidden */
  117942. _prepare(): void;
  117943. /**
  117944. * Execute the action and stop the sound.
  117945. */
  117946. execute(): void;
  117947. /**
  117948. * Serializes the actions and its related information.
  117949. * @param parent defines the object to serialize in
  117950. * @returns the serialized object
  117951. */
  117952. serialize(parent: any): any;
  117953. }
  117954. }
  117955. declare module BABYLON {
  117956. /**
  117957. * This defines an action responsible to change the value of a property
  117958. * by interpolating between its current value and the newly set one once triggered.
  117959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  117960. */
  117961. export class InterpolateValueAction extends Action {
  117962. /**
  117963. * Defines the path of the property where the value should be interpolated
  117964. */
  117965. propertyPath: string;
  117966. /**
  117967. * Defines the target value at the end of the interpolation.
  117968. */
  117969. value: any;
  117970. /**
  117971. * Defines the time it will take for the property to interpolate to the value.
  117972. */
  117973. duration: number;
  117974. /**
  117975. * Defines if the other scene animations should be stopped when the action has been triggered
  117976. */
  117977. stopOtherAnimations?: boolean;
  117978. /**
  117979. * Defines a callback raised once the interpolation animation has been done.
  117980. */
  117981. onInterpolationDone?: () => void;
  117982. /**
  117983. * Observable triggered once the interpolation animation has been done.
  117984. */
  117985. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  117986. private _target;
  117987. private _effectiveTarget;
  117988. private _property;
  117989. /**
  117990. * Instantiate the action
  117991. * @param triggerOptions defines the trigger options
  117992. * @param target defines the object containing the value to interpolate
  117993. * @param propertyPath defines the path to the property in the target object
  117994. * @param value defines the target value at the end of the interpolation
  117995. * @param duration deines the time it will take for the property to interpolate to the value.
  117996. * @param condition defines the trigger related conditions
  117997. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  117998. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  117999. */
  118000. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  118001. /** @hidden */
  118002. _prepare(): void;
  118003. /**
  118004. * Execute the action starts the value interpolation.
  118005. */
  118006. execute(): void;
  118007. /**
  118008. * Serializes the actions and its related information.
  118009. * @param parent defines the object to serialize in
  118010. * @returns the serialized object
  118011. */
  118012. serialize(parent: any): any;
  118013. }
  118014. }
  118015. declare module BABYLON {
  118016. /**
  118017. * Options allowed during the creation of a sound track.
  118018. */
  118019. export interface ISoundTrackOptions {
  118020. /**
  118021. * The volume the sound track should take during creation
  118022. */
  118023. volume?: number;
  118024. /**
  118025. * Define if the sound track is the main sound track of the scene
  118026. */
  118027. mainTrack?: boolean;
  118028. }
  118029. /**
  118030. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  118031. * It will be also used in a future release to apply effects on a specific track.
  118032. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  118033. */
  118034. export class SoundTrack {
  118035. /**
  118036. * The unique identifier of the sound track in the scene.
  118037. */
  118038. id: number;
  118039. /**
  118040. * The list of sounds included in the sound track.
  118041. */
  118042. soundCollection: Array<Sound>;
  118043. private _outputAudioNode;
  118044. private _scene;
  118045. private _connectedAnalyser;
  118046. private _options;
  118047. private _isInitialized;
  118048. /**
  118049. * Creates a new sound track.
  118050. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  118051. * @param scene Define the scene the sound track belongs to
  118052. * @param options
  118053. */
  118054. constructor(scene: Scene, options?: ISoundTrackOptions);
  118055. private _initializeSoundTrackAudioGraph;
  118056. /**
  118057. * Release the sound track and its associated resources
  118058. */
  118059. dispose(): void;
  118060. /**
  118061. * Adds a sound to this sound track
  118062. * @param sound define the cound to add
  118063. * @ignoreNaming
  118064. */
  118065. AddSound(sound: Sound): void;
  118066. /**
  118067. * Removes a sound to this sound track
  118068. * @param sound define the cound to remove
  118069. * @ignoreNaming
  118070. */
  118071. RemoveSound(sound: Sound): void;
  118072. /**
  118073. * Set a global volume for the full sound track.
  118074. * @param newVolume Define the new volume of the sound track
  118075. */
  118076. setVolume(newVolume: number): void;
  118077. /**
  118078. * Switch the panning model to HRTF:
  118079. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  118080. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118081. */
  118082. switchPanningModelToHRTF(): void;
  118083. /**
  118084. * Switch the panning model to Equal Power:
  118085. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  118086. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118087. */
  118088. switchPanningModelToEqualPower(): void;
  118089. /**
  118090. * Connect the sound track to an audio analyser allowing some amazing
  118091. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  118092. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  118093. * @param analyser The analyser to connect to the engine
  118094. */
  118095. connectToAnalyser(analyser: Analyser): void;
  118096. }
  118097. }
  118098. declare module BABYLON {
  118099. interface AbstractScene {
  118100. /**
  118101. * The list of sounds used in the scene.
  118102. */
  118103. sounds: Nullable<Array<Sound>>;
  118104. }
  118105. interface Scene {
  118106. /**
  118107. * @hidden
  118108. * Backing field
  118109. */
  118110. _mainSoundTrack: SoundTrack;
  118111. /**
  118112. * The main sound track played by the scene.
  118113. * It cotains your primary collection of sounds.
  118114. */
  118115. mainSoundTrack: SoundTrack;
  118116. /**
  118117. * The list of sound tracks added to the scene
  118118. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118119. */
  118120. soundTracks: Nullable<Array<SoundTrack>>;
  118121. /**
  118122. * Gets a sound using a given name
  118123. * @param name defines the name to search for
  118124. * @return the found sound or null if not found at all.
  118125. */
  118126. getSoundByName(name: string): Nullable<Sound>;
  118127. /**
  118128. * Gets or sets if audio support is enabled
  118129. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118130. */
  118131. audioEnabled: boolean;
  118132. /**
  118133. * Gets or sets if audio will be output to headphones
  118134. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118135. */
  118136. headphone: boolean;
  118137. /**
  118138. * Gets or sets custom audio listener position provider
  118139. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118140. */
  118141. audioListenerPositionProvider: Nullable<() => Vector3>;
  118142. /**
  118143. * Gets or sets a refresh rate when using 3D audio positioning
  118144. */
  118145. audioPositioningRefreshRate: number;
  118146. }
  118147. /**
  118148. * Defines the sound scene component responsible to manage any sounds
  118149. * in a given scene.
  118150. */
  118151. export class AudioSceneComponent implements ISceneSerializableComponent {
  118152. /**
  118153. * The component name helpfull to identify the component in the list of scene components.
  118154. */
  118155. readonly name: string;
  118156. /**
  118157. * The scene the component belongs to.
  118158. */
  118159. scene: Scene;
  118160. private _audioEnabled;
  118161. /**
  118162. * Gets whether audio is enabled or not.
  118163. * Please use related enable/disable method to switch state.
  118164. */
  118165. get audioEnabled(): boolean;
  118166. private _headphone;
  118167. /**
  118168. * Gets whether audio is outputing to headphone or not.
  118169. * Please use the according Switch methods to change output.
  118170. */
  118171. get headphone(): boolean;
  118172. /**
  118173. * Gets or sets a refresh rate when using 3D audio positioning
  118174. */
  118175. audioPositioningRefreshRate: number;
  118176. private _audioListenerPositionProvider;
  118177. /**
  118178. * Gets the current audio listener position provider
  118179. */
  118180. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  118181. /**
  118182. * Sets a custom listener position for all sounds in the scene
  118183. * By default, this is the position of the first active camera
  118184. */
  118185. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  118186. /**
  118187. * Creates a new instance of the component for the given scene
  118188. * @param scene Defines the scene to register the component in
  118189. */
  118190. constructor(scene: Scene);
  118191. /**
  118192. * Registers the component in a given scene
  118193. */
  118194. register(): void;
  118195. /**
  118196. * Rebuilds the elements related to this component in case of
  118197. * context lost for instance.
  118198. */
  118199. rebuild(): void;
  118200. /**
  118201. * Serializes the component data to the specified json object
  118202. * @param serializationObject The object to serialize to
  118203. */
  118204. serialize(serializationObject: any): void;
  118205. /**
  118206. * Adds all the elements from the container to the scene
  118207. * @param container the container holding the elements
  118208. */
  118209. addFromContainer(container: AbstractScene): void;
  118210. /**
  118211. * Removes all the elements in the container from the scene
  118212. * @param container contains the elements to remove
  118213. * @param dispose if the removed element should be disposed (default: false)
  118214. */
  118215. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118216. /**
  118217. * Disposes the component and the associated ressources.
  118218. */
  118219. dispose(): void;
  118220. /**
  118221. * Disables audio in the associated scene.
  118222. */
  118223. disableAudio(): void;
  118224. /**
  118225. * Enables audio in the associated scene.
  118226. */
  118227. enableAudio(): void;
  118228. /**
  118229. * Switch audio to headphone output.
  118230. */
  118231. switchAudioModeForHeadphones(): void;
  118232. /**
  118233. * Switch audio to normal speakers.
  118234. */
  118235. switchAudioModeForNormalSpeakers(): void;
  118236. private _cachedCameraDirection;
  118237. private _cachedCameraPosition;
  118238. private _lastCheck;
  118239. private _afterRender;
  118240. }
  118241. }
  118242. declare module BABYLON {
  118243. /**
  118244. * Wraps one or more Sound objects and selects one with random weight for playback.
  118245. */
  118246. export class WeightedSound {
  118247. /** When true a Sound will be selected and played when the current playing Sound completes. */
  118248. loop: boolean;
  118249. private _coneInnerAngle;
  118250. private _coneOuterAngle;
  118251. private _volume;
  118252. /** A Sound is currently playing. */
  118253. isPlaying: boolean;
  118254. /** A Sound is currently paused. */
  118255. isPaused: boolean;
  118256. private _sounds;
  118257. private _weights;
  118258. private _currentIndex?;
  118259. /**
  118260. * Creates a new WeightedSound from the list of sounds given.
  118261. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  118262. * @param sounds Array of Sounds that will be selected from.
  118263. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  118264. */
  118265. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  118266. /**
  118267. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  118268. */
  118269. get directionalConeInnerAngle(): number;
  118270. /**
  118271. * The size of cone in degress for a directional sound in which there will be no attenuation.
  118272. */
  118273. set directionalConeInnerAngle(value: number);
  118274. /**
  118275. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  118276. * Listener angles between innerAngle and outerAngle will falloff linearly.
  118277. */
  118278. get directionalConeOuterAngle(): number;
  118279. /**
  118280. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  118281. * Listener angles between innerAngle and outerAngle will falloff linearly.
  118282. */
  118283. set directionalConeOuterAngle(value: number);
  118284. /**
  118285. * Playback volume.
  118286. */
  118287. get volume(): number;
  118288. /**
  118289. * Playback volume.
  118290. */
  118291. set volume(value: number);
  118292. private _onended;
  118293. /**
  118294. * Suspend playback
  118295. */
  118296. pause(): void;
  118297. /**
  118298. * Stop playback
  118299. */
  118300. stop(): void;
  118301. /**
  118302. * Start playback.
  118303. * @param startOffset Position the clip head at a specific time in seconds.
  118304. */
  118305. play(startOffset?: number): void;
  118306. }
  118307. }
  118308. declare module BABYLON {
  118309. /**
  118310. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  118311. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  118312. */
  118313. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  118314. /**
  118315. * Gets the name of the behavior.
  118316. */
  118317. get name(): string;
  118318. /**
  118319. * The easing function used by animations
  118320. */
  118321. static EasingFunction: BackEase;
  118322. /**
  118323. * The easing mode used by animations
  118324. */
  118325. static EasingMode: number;
  118326. /**
  118327. * The duration of the animation, in milliseconds
  118328. */
  118329. transitionDuration: number;
  118330. /**
  118331. * Length of the distance animated by the transition when lower radius is reached
  118332. */
  118333. lowerRadiusTransitionRange: number;
  118334. /**
  118335. * Length of the distance animated by the transition when upper radius is reached
  118336. */
  118337. upperRadiusTransitionRange: number;
  118338. private _autoTransitionRange;
  118339. /**
  118340. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  118341. */
  118342. get autoTransitionRange(): boolean;
  118343. /**
  118344. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  118345. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  118346. */
  118347. set autoTransitionRange(value: boolean);
  118348. private _attachedCamera;
  118349. private _onAfterCheckInputsObserver;
  118350. private _onMeshTargetChangedObserver;
  118351. /**
  118352. * Initializes the behavior.
  118353. */
  118354. init(): void;
  118355. /**
  118356. * Attaches the behavior to its arc rotate camera.
  118357. * @param camera Defines the camera to attach the behavior to
  118358. */
  118359. attach(camera: ArcRotateCamera): void;
  118360. /**
  118361. * Detaches the behavior from its current arc rotate camera.
  118362. */
  118363. detach(): void;
  118364. private _radiusIsAnimating;
  118365. private _radiusBounceTransition;
  118366. private _animatables;
  118367. private _cachedWheelPrecision;
  118368. /**
  118369. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  118370. * @param radiusLimit The limit to check against.
  118371. * @return Bool to indicate if at limit.
  118372. */
  118373. private _isRadiusAtLimit;
  118374. /**
  118375. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  118376. * @param radiusDelta The delta by which to animate to. Can be negative.
  118377. */
  118378. private _applyBoundRadiusAnimation;
  118379. /**
  118380. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  118381. */
  118382. protected _clearAnimationLocks(): void;
  118383. /**
  118384. * Stops and removes all animations that have been applied to the camera
  118385. */
  118386. stopAllAnimations(): void;
  118387. }
  118388. }
  118389. declare module BABYLON {
  118390. /**
  118391. * 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.
  118392. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  118393. */
  118394. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  118395. /**
  118396. * Gets the name of the behavior.
  118397. */
  118398. get name(): string;
  118399. private _mode;
  118400. private _radiusScale;
  118401. private _positionScale;
  118402. private _defaultElevation;
  118403. private _elevationReturnTime;
  118404. private _elevationReturnWaitTime;
  118405. private _zoomStopsAnimation;
  118406. private _framingTime;
  118407. /**
  118408. * The easing function used by animations
  118409. */
  118410. static EasingFunction: ExponentialEase;
  118411. /**
  118412. * The easing mode used by animations
  118413. */
  118414. static EasingMode: number;
  118415. /**
  118416. * Sets the current mode used by the behavior
  118417. */
  118418. set mode(mode: number);
  118419. /**
  118420. * Gets current mode used by the behavior.
  118421. */
  118422. get mode(): number;
  118423. /**
  118424. * Sets the scale applied to the radius (1 by default)
  118425. */
  118426. set radiusScale(radius: number);
  118427. /**
  118428. * Gets the scale applied to the radius
  118429. */
  118430. get radiusScale(): number;
  118431. /**
  118432. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  118433. */
  118434. set positionScale(scale: number);
  118435. /**
  118436. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  118437. */
  118438. get positionScale(): number;
  118439. /**
  118440. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  118441. * behaviour is triggered, in radians.
  118442. */
  118443. set defaultElevation(elevation: number);
  118444. /**
  118445. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  118446. * behaviour is triggered, in radians.
  118447. */
  118448. get defaultElevation(): number;
  118449. /**
  118450. * Sets the time (in milliseconds) taken to return to the default beta position.
  118451. * Negative value indicates camera should not return to default.
  118452. */
  118453. set elevationReturnTime(speed: number);
  118454. /**
  118455. * Gets the time (in milliseconds) taken to return to the default beta position.
  118456. * Negative value indicates camera should not return to default.
  118457. */
  118458. get elevationReturnTime(): number;
  118459. /**
  118460. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  118461. */
  118462. set elevationReturnWaitTime(time: number);
  118463. /**
  118464. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  118465. */
  118466. get elevationReturnWaitTime(): number;
  118467. /**
  118468. * Sets the flag that indicates if user zooming should stop animation.
  118469. */
  118470. set zoomStopsAnimation(flag: boolean);
  118471. /**
  118472. * Gets the flag that indicates if user zooming should stop animation.
  118473. */
  118474. get zoomStopsAnimation(): boolean;
  118475. /**
  118476. * Sets the transition time when framing the mesh, in milliseconds
  118477. */
  118478. set framingTime(time: number);
  118479. /**
  118480. * Gets the transition time when framing the mesh, in milliseconds
  118481. */
  118482. get framingTime(): number;
  118483. /**
  118484. * Define if the behavior should automatically change the configured
  118485. * camera limits and sensibilities.
  118486. */
  118487. autoCorrectCameraLimitsAndSensibility: boolean;
  118488. private _onPrePointerObservableObserver;
  118489. private _onAfterCheckInputsObserver;
  118490. private _onMeshTargetChangedObserver;
  118491. private _attachedCamera;
  118492. private _isPointerDown;
  118493. private _lastInteractionTime;
  118494. /**
  118495. * Initializes the behavior.
  118496. */
  118497. init(): void;
  118498. /**
  118499. * Attaches the behavior to its arc rotate camera.
  118500. * @param camera Defines the camera to attach the behavior to
  118501. */
  118502. attach(camera: ArcRotateCamera): void;
  118503. /**
  118504. * Detaches the behavior from its current arc rotate camera.
  118505. */
  118506. detach(): void;
  118507. private _animatables;
  118508. private _betaIsAnimating;
  118509. private _betaTransition;
  118510. private _radiusTransition;
  118511. private _vectorTransition;
  118512. /**
  118513. * Targets the given mesh and updates zoom level accordingly.
  118514. * @param mesh The mesh to target.
  118515. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118516. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118517. */
  118518. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118519. /**
  118520. * Targets the given mesh with its children and updates zoom level accordingly.
  118521. * @param mesh The mesh to target.
  118522. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118523. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118524. */
  118525. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118526. /**
  118527. * Targets the given meshes with their children and updates zoom level accordingly.
  118528. * @param meshes The mesh to target.
  118529. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118530. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118531. */
  118532. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118533. /**
  118534. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  118535. * @param minimumWorld Determines the smaller position of the bounding box extend
  118536. * @param maximumWorld Determines the bigger position of the bounding box extend
  118537. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118538. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118539. */
  118540. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118541. /**
  118542. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  118543. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  118544. * frustum width.
  118545. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  118546. * to fully enclose the mesh in the viewing frustum.
  118547. */
  118548. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  118549. /**
  118550. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  118551. * is automatically returned to its default position (expected to be above ground plane).
  118552. */
  118553. private _maintainCameraAboveGround;
  118554. /**
  118555. * Returns the frustum slope based on the canvas ratio and camera FOV
  118556. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  118557. */
  118558. private _getFrustumSlope;
  118559. /**
  118560. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  118561. */
  118562. private _clearAnimationLocks;
  118563. /**
  118564. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  118565. */
  118566. private _applyUserInteraction;
  118567. /**
  118568. * Stops and removes all animations that have been applied to the camera
  118569. */
  118570. stopAllAnimations(): void;
  118571. /**
  118572. * Gets a value indicating if the user is moving the camera
  118573. */
  118574. get isUserIsMoving(): boolean;
  118575. /**
  118576. * The camera can move all the way towards the mesh.
  118577. */
  118578. static IgnoreBoundsSizeMode: number;
  118579. /**
  118580. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  118581. */
  118582. static FitFrustumSidesMode: number;
  118583. }
  118584. }
  118585. declare module BABYLON {
  118586. /**
  118587. * Base class for Camera Pointer Inputs.
  118588. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  118589. * for example usage.
  118590. */
  118591. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  118592. /**
  118593. * Defines the camera the input is attached to.
  118594. */
  118595. abstract camera: Camera;
  118596. /**
  118597. * Whether keyboard modifier keys are pressed at time of last mouse event.
  118598. */
  118599. protected _altKey: boolean;
  118600. protected _ctrlKey: boolean;
  118601. protected _metaKey: boolean;
  118602. protected _shiftKey: boolean;
  118603. /**
  118604. * Which mouse buttons were pressed at time of last mouse event.
  118605. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  118606. */
  118607. protected _buttonsPressed: number;
  118608. /**
  118609. * Defines the buttons associated with the input to handle camera move.
  118610. */
  118611. buttons: number[];
  118612. /**
  118613. * Attach the input controls to a specific dom element to get the input from.
  118614. * @param element Defines the element the controls should be listened from
  118615. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118616. */
  118617. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  118618. /**
  118619. * Detach the current controls from the specified dom element.
  118620. * @param element Defines the element to stop listening the inputs from
  118621. */
  118622. detachControl(element: Nullable<HTMLElement>): void;
  118623. /**
  118624. * Gets the class name of the current input.
  118625. * @returns the class name
  118626. */
  118627. getClassName(): string;
  118628. /**
  118629. * Get the friendly name associated with the input class.
  118630. * @returns the input friendly name
  118631. */
  118632. getSimpleName(): string;
  118633. /**
  118634. * Called on pointer POINTERDOUBLETAP event.
  118635. * Override this method to provide functionality on POINTERDOUBLETAP event.
  118636. */
  118637. protected onDoubleTap(type: string): void;
  118638. /**
  118639. * Called on pointer POINTERMOVE event if only a single touch is active.
  118640. * Override this method to provide functionality.
  118641. */
  118642. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  118643. /**
  118644. * Called on pointer POINTERMOVE event if multiple touches are active.
  118645. * Override this method to provide functionality.
  118646. */
  118647. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  118648. /**
  118649. * Called on JS contextmenu event.
  118650. * Override this method to provide functionality.
  118651. */
  118652. protected onContextMenu(evt: PointerEvent): void;
  118653. /**
  118654. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  118655. * press.
  118656. * Override this method to provide functionality.
  118657. */
  118658. protected onButtonDown(evt: PointerEvent): void;
  118659. /**
  118660. * Called each time a new POINTERUP event occurs. Ie, for each button
  118661. * release.
  118662. * Override this method to provide functionality.
  118663. */
  118664. protected onButtonUp(evt: PointerEvent): void;
  118665. /**
  118666. * Called when window becomes inactive.
  118667. * Override this method to provide functionality.
  118668. */
  118669. protected onLostFocus(): void;
  118670. private _pointerInput;
  118671. private _observer;
  118672. private _onLostFocus;
  118673. private pointA;
  118674. private pointB;
  118675. }
  118676. }
  118677. declare module BABYLON {
  118678. /**
  118679. * Manage the pointers inputs to control an arc rotate camera.
  118680. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  118681. */
  118682. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  118683. /**
  118684. * Defines the camera the input is attached to.
  118685. */
  118686. camera: ArcRotateCamera;
  118687. /**
  118688. * Gets the class name of the current input.
  118689. * @returns the class name
  118690. */
  118691. getClassName(): string;
  118692. /**
  118693. * Defines the buttons associated with the input to handle camera move.
  118694. */
  118695. buttons: number[];
  118696. /**
  118697. * Defines the pointer angular sensibility along the X axis or how fast is
  118698. * the camera rotating.
  118699. */
  118700. angularSensibilityX: number;
  118701. /**
  118702. * Defines the pointer angular sensibility along the Y axis or how fast is
  118703. * the camera rotating.
  118704. */
  118705. angularSensibilityY: number;
  118706. /**
  118707. * Defines the pointer pinch precision or how fast is the camera zooming.
  118708. */
  118709. pinchPrecision: number;
  118710. /**
  118711. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  118712. * from 0.
  118713. * It defines the percentage of current camera.radius to use as delta when
  118714. * pinch zoom is used.
  118715. */
  118716. pinchDeltaPercentage: number;
  118717. /**
  118718. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  118719. * that any object in the plane at the camera's target point will scale
  118720. * perfectly with finger motion.
  118721. * Overrides pinchDeltaPercentage and pinchPrecision.
  118722. */
  118723. useNaturalPinchZoom: boolean;
  118724. /**
  118725. * Defines the pointer panning sensibility or how fast is the camera moving.
  118726. */
  118727. panningSensibility: number;
  118728. /**
  118729. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  118730. */
  118731. multiTouchPanning: boolean;
  118732. /**
  118733. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  118734. * zoom (pinch) through multitouch.
  118735. */
  118736. multiTouchPanAndZoom: boolean;
  118737. /**
  118738. * Revers pinch action direction.
  118739. */
  118740. pinchInwards: boolean;
  118741. private _isPanClick;
  118742. private _twoFingerActivityCount;
  118743. private _isPinching;
  118744. /**
  118745. * Called on pointer POINTERMOVE event if only a single touch is active.
  118746. */
  118747. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  118748. /**
  118749. * Called on pointer POINTERDOUBLETAP event.
  118750. */
  118751. protected onDoubleTap(type: string): void;
  118752. /**
  118753. * Called on pointer POINTERMOVE event if multiple touches are active.
  118754. */
  118755. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  118756. /**
  118757. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  118758. * press.
  118759. */
  118760. protected onButtonDown(evt: PointerEvent): void;
  118761. /**
  118762. * Called each time a new POINTERUP event occurs. Ie, for each button
  118763. * release.
  118764. */
  118765. protected onButtonUp(evt: PointerEvent): void;
  118766. /**
  118767. * Called when window becomes inactive.
  118768. */
  118769. protected onLostFocus(): void;
  118770. }
  118771. }
  118772. declare module BABYLON {
  118773. /**
  118774. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  118775. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  118776. */
  118777. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  118778. /**
  118779. * Defines the camera the input is attached to.
  118780. */
  118781. camera: ArcRotateCamera;
  118782. /**
  118783. * Defines the list of key codes associated with the up action (increase alpha)
  118784. */
  118785. keysUp: number[];
  118786. /**
  118787. * Defines the list of key codes associated with the down action (decrease alpha)
  118788. */
  118789. keysDown: number[];
  118790. /**
  118791. * Defines the list of key codes associated with the left action (increase beta)
  118792. */
  118793. keysLeft: number[];
  118794. /**
  118795. * Defines the list of key codes associated with the right action (decrease beta)
  118796. */
  118797. keysRight: number[];
  118798. /**
  118799. * Defines the list of key codes associated with the reset action.
  118800. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  118801. */
  118802. keysReset: number[];
  118803. /**
  118804. * Defines the panning sensibility of the inputs.
  118805. * (How fast is the camera panning)
  118806. */
  118807. panningSensibility: number;
  118808. /**
  118809. * Defines the zooming sensibility of the inputs.
  118810. * (How fast is the camera zooming)
  118811. */
  118812. zoomingSensibility: number;
  118813. /**
  118814. * Defines whether maintaining the alt key down switch the movement mode from
  118815. * orientation to zoom.
  118816. */
  118817. useAltToZoom: boolean;
  118818. /**
  118819. * Rotation speed of the camera
  118820. */
  118821. angularSpeed: number;
  118822. private _keys;
  118823. private _ctrlPressed;
  118824. private _altPressed;
  118825. private _onCanvasBlurObserver;
  118826. private _onKeyboardObserver;
  118827. private _engine;
  118828. private _scene;
  118829. /**
  118830. * Attach the input controls to a specific dom element to get the input from.
  118831. * @param element Defines the element the controls should be listened from
  118832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118833. */
  118834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  118835. /**
  118836. * Detach the current controls from the specified dom element.
  118837. * @param element Defines the element to stop listening the inputs from
  118838. */
  118839. detachControl(element: Nullable<HTMLElement>): void;
  118840. /**
  118841. * Update the current camera state depending on the inputs that have been used this frame.
  118842. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  118843. */
  118844. checkInputs(): void;
  118845. /**
  118846. * Gets the class name of the current intput.
  118847. * @returns the class name
  118848. */
  118849. getClassName(): string;
  118850. /**
  118851. * Get the friendly name associated with the input class.
  118852. * @returns the input friendly name
  118853. */
  118854. getSimpleName(): string;
  118855. }
  118856. }
  118857. declare module BABYLON {
  118858. /**
  118859. * Manage the mouse wheel inputs to control an arc rotate camera.
  118860. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  118861. */
  118862. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  118863. /**
  118864. * Defines the camera the input is attached to.
  118865. */
  118866. camera: ArcRotateCamera;
  118867. /**
  118868. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  118869. */
  118870. wheelPrecision: number;
  118871. /**
  118872. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  118873. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  118874. */
  118875. wheelDeltaPercentage: number;
  118876. private _wheel;
  118877. private _observer;
  118878. private computeDeltaFromMouseWheelLegacyEvent;
  118879. /**
  118880. * Attach the input controls to a specific dom element to get the input from.
  118881. * @param element Defines the element the controls should be listened from
  118882. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118883. */
  118884. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  118885. /**
  118886. * Detach the current controls from the specified dom element.
  118887. * @param element Defines the element to stop listening the inputs from
  118888. */
  118889. detachControl(element: Nullable<HTMLElement>): void;
  118890. /**
  118891. * Gets the class name of the current intput.
  118892. * @returns the class name
  118893. */
  118894. getClassName(): string;
  118895. /**
  118896. * Get the friendly name associated with the input class.
  118897. * @returns the input friendly name
  118898. */
  118899. getSimpleName(): string;
  118900. }
  118901. }
  118902. declare module BABYLON {
  118903. /**
  118904. * Default Inputs manager for the ArcRotateCamera.
  118905. * It groups all the default supported inputs for ease of use.
  118906. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  118907. */
  118908. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  118909. /**
  118910. * Instantiates a new ArcRotateCameraInputsManager.
  118911. * @param camera Defines the camera the inputs belong to
  118912. */
  118913. constructor(camera: ArcRotateCamera);
  118914. /**
  118915. * Add mouse wheel input support to the input manager.
  118916. * @returns the current input manager
  118917. */
  118918. addMouseWheel(): ArcRotateCameraInputsManager;
  118919. /**
  118920. * Add pointers input support to the input manager.
  118921. * @returns the current input manager
  118922. */
  118923. addPointers(): ArcRotateCameraInputsManager;
  118924. /**
  118925. * Add keyboard input support to the input manager.
  118926. * @returns the current input manager
  118927. */
  118928. addKeyboard(): ArcRotateCameraInputsManager;
  118929. }
  118930. }
  118931. declare module BABYLON {
  118932. /**
  118933. * This represents an orbital type of camera.
  118934. *
  118935. * 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.
  118936. * 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.
  118937. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  118938. */
  118939. export class ArcRotateCamera extends TargetCamera {
  118940. /**
  118941. * Defines the rotation angle of the camera along the longitudinal axis.
  118942. */
  118943. alpha: number;
  118944. /**
  118945. * Defines the rotation angle of the camera along the latitudinal axis.
  118946. */
  118947. beta: number;
  118948. /**
  118949. * Defines the radius of the camera from it s target point.
  118950. */
  118951. radius: number;
  118952. protected _target: Vector3;
  118953. protected _targetHost: Nullable<AbstractMesh>;
  118954. /**
  118955. * Defines the target point of the camera.
  118956. * The camera looks towards it form the radius distance.
  118957. */
  118958. get target(): Vector3;
  118959. set target(value: Vector3);
  118960. /**
  118961. * Define the current local position of the camera in the scene
  118962. */
  118963. get position(): Vector3;
  118964. set position(newPosition: Vector3);
  118965. protected _upVector: Vector3;
  118966. protected _upToYMatrix: Matrix;
  118967. protected _YToUpMatrix: Matrix;
  118968. /**
  118969. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  118970. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  118971. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  118972. */
  118973. set upVector(vec: Vector3);
  118974. get upVector(): Vector3;
  118975. /**
  118976. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  118977. */
  118978. setMatUp(): void;
  118979. /**
  118980. * Current inertia value on the longitudinal axis.
  118981. * The bigger this number the longer it will take for the camera to stop.
  118982. */
  118983. inertialAlphaOffset: number;
  118984. /**
  118985. * Current inertia value on the latitudinal axis.
  118986. * The bigger this number the longer it will take for the camera to stop.
  118987. */
  118988. inertialBetaOffset: number;
  118989. /**
  118990. * Current inertia value on the radius axis.
  118991. * The bigger this number the longer it will take for the camera to stop.
  118992. */
  118993. inertialRadiusOffset: number;
  118994. /**
  118995. * Minimum allowed angle on the longitudinal axis.
  118996. * This can help limiting how the Camera is able to move in the scene.
  118997. */
  118998. lowerAlphaLimit: Nullable<number>;
  118999. /**
  119000. * Maximum allowed angle on the longitudinal axis.
  119001. * This can help limiting how the Camera is able to move in the scene.
  119002. */
  119003. upperAlphaLimit: Nullable<number>;
  119004. /**
  119005. * Minimum allowed angle on the latitudinal axis.
  119006. * This can help limiting how the Camera is able to move in the scene.
  119007. */
  119008. lowerBetaLimit: number;
  119009. /**
  119010. * Maximum allowed angle on the latitudinal axis.
  119011. * This can help limiting how the Camera is able to move in the scene.
  119012. */
  119013. upperBetaLimit: number;
  119014. /**
  119015. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  119016. * This can help limiting how the Camera is able to move in the scene.
  119017. */
  119018. lowerRadiusLimit: Nullable<number>;
  119019. /**
  119020. * Maximum allowed distance of the camera to the target (The camera can not get further).
  119021. * This can help limiting how the Camera is able to move in the scene.
  119022. */
  119023. upperRadiusLimit: Nullable<number>;
  119024. /**
  119025. * Defines the current inertia value used during panning of the camera along the X axis.
  119026. */
  119027. inertialPanningX: number;
  119028. /**
  119029. * Defines the current inertia value used during panning of the camera along the Y axis.
  119030. */
  119031. inertialPanningY: number;
  119032. /**
  119033. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  119034. * Basically if your fingers moves away from more than this distance you will be considered
  119035. * in pinch mode.
  119036. */
  119037. pinchToPanMaxDistance: number;
  119038. /**
  119039. * Defines the maximum distance the camera can pan.
  119040. * This could help keeping the cammera always in your scene.
  119041. */
  119042. panningDistanceLimit: Nullable<number>;
  119043. /**
  119044. * Defines the target of the camera before paning.
  119045. */
  119046. panningOriginTarget: Vector3;
  119047. /**
  119048. * Defines the value of the inertia used during panning.
  119049. * 0 would mean stop inertia and one would mean no decelleration at all.
  119050. */
  119051. panningInertia: number;
  119052. /**
  119053. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  119054. */
  119055. get angularSensibilityX(): number;
  119056. set angularSensibilityX(value: number);
  119057. /**
  119058. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  119059. */
  119060. get angularSensibilityY(): number;
  119061. set angularSensibilityY(value: number);
  119062. /**
  119063. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  119064. */
  119065. get pinchPrecision(): number;
  119066. set pinchPrecision(value: number);
  119067. /**
  119068. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  119069. * It will be used instead of pinchDeltaPrecision if different from 0.
  119070. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  119071. */
  119072. get pinchDeltaPercentage(): number;
  119073. set pinchDeltaPercentage(value: number);
  119074. /**
  119075. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  119076. * and pinch delta percentage.
  119077. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  119078. * that any object in the plane at the camera's target point will scale
  119079. * perfectly with finger motion.
  119080. */
  119081. get useNaturalPinchZoom(): boolean;
  119082. set useNaturalPinchZoom(value: boolean);
  119083. /**
  119084. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  119085. */
  119086. get panningSensibility(): number;
  119087. set panningSensibility(value: number);
  119088. /**
  119089. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  119090. */
  119091. get keysUp(): number[];
  119092. set keysUp(value: number[]);
  119093. /**
  119094. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  119095. */
  119096. get keysDown(): number[];
  119097. set keysDown(value: number[]);
  119098. /**
  119099. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  119100. */
  119101. get keysLeft(): number[];
  119102. set keysLeft(value: number[]);
  119103. /**
  119104. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  119105. */
  119106. get keysRight(): number[];
  119107. set keysRight(value: number[]);
  119108. /**
  119109. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  119110. */
  119111. get wheelPrecision(): number;
  119112. set wheelPrecision(value: number);
  119113. /**
  119114. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  119115. * It will be used instead of pinchDeltaPrecision if different from 0.
  119116. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  119117. */
  119118. get wheelDeltaPercentage(): number;
  119119. set wheelDeltaPercentage(value: number);
  119120. /**
  119121. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  119122. */
  119123. zoomOnFactor: number;
  119124. /**
  119125. * Defines a screen offset for the camera position.
  119126. */
  119127. targetScreenOffset: Vector2;
  119128. /**
  119129. * Allows the camera to be completely reversed.
  119130. * If false the camera can not arrive upside down.
  119131. */
  119132. allowUpsideDown: boolean;
  119133. /**
  119134. * Define if double tap/click is used to restore the previously saved state of the camera.
  119135. */
  119136. useInputToRestoreState: boolean;
  119137. /** @hidden */
  119138. _viewMatrix: Matrix;
  119139. /** @hidden */
  119140. _useCtrlForPanning: boolean;
  119141. /** @hidden */
  119142. _panningMouseButton: number;
  119143. /**
  119144. * Defines the input associated to the camera.
  119145. */
  119146. inputs: ArcRotateCameraInputsManager;
  119147. /** @hidden */
  119148. _reset: () => void;
  119149. /**
  119150. * Defines the allowed panning axis.
  119151. */
  119152. panningAxis: Vector3;
  119153. protected _localDirection: Vector3;
  119154. protected _transformedDirection: Vector3;
  119155. private _bouncingBehavior;
  119156. /**
  119157. * Gets the bouncing behavior of the camera if it has been enabled.
  119158. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119159. */
  119160. get bouncingBehavior(): Nullable<BouncingBehavior>;
  119161. /**
  119162. * Defines if the bouncing behavior of the camera is enabled on the camera.
  119163. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119164. */
  119165. get useBouncingBehavior(): boolean;
  119166. set useBouncingBehavior(value: boolean);
  119167. private _framingBehavior;
  119168. /**
  119169. * Gets the framing behavior of the camera if it has been enabled.
  119170. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119171. */
  119172. get framingBehavior(): Nullable<FramingBehavior>;
  119173. /**
  119174. * Defines if the framing behavior of the camera is enabled on the camera.
  119175. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119176. */
  119177. get useFramingBehavior(): boolean;
  119178. set useFramingBehavior(value: boolean);
  119179. private _autoRotationBehavior;
  119180. /**
  119181. * Gets the auto rotation behavior of the camera if it has been enabled.
  119182. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119183. */
  119184. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  119185. /**
  119186. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  119187. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119188. */
  119189. get useAutoRotationBehavior(): boolean;
  119190. set useAutoRotationBehavior(value: boolean);
  119191. /**
  119192. * Observable triggered when the mesh target has been changed on the camera.
  119193. */
  119194. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  119195. /**
  119196. * Event raised when the camera is colliding with a mesh.
  119197. */
  119198. onCollide: (collidedMesh: AbstractMesh) => void;
  119199. /**
  119200. * Defines whether the camera should check collision with the objects oh the scene.
  119201. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  119202. */
  119203. checkCollisions: boolean;
  119204. /**
  119205. * Defines the collision radius of the camera.
  119206. * This simulates a sphere around the camera.
  119207. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  119208. */
  119209. collisionRadius: Vector3;
  119210. protected _collider: Collider;
  119211. protected _previousPosition: Vector3;
  119212. protected _collisionVelocity: Vector3;
  119213. protected _newPosition: Vector3;
  119214. protected _previousAlpha: number;
  119215. protected _previousBeta: number;
  119216. protected _previousRadius: number;
  119217. protected _collisionTriggered: boolean;
  119218. protected _targetBoundingCenter: Nullable<Vector3>;
  119219. private _computationVector;
  119220. /**
  119221. * Instantiates a new ArcRotateCamera in a given scene
  119222. * @param name Defines the name of the camera
  119223. * @param alpha Defines the camera rotation along the logitudinal axis
  119224. * @param beta Defines the camera rotation along the latitudinal axis
  119225. * @param radius Defines the camera distance from its target
  119226. * @param target Defines the camera target
  119227. * @param scene Defines the scene the camera belongs to
  119228. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  119229. */
  119230. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  119231. /** @hidden */
  119232. _initCache(): void;
  119233. /** @hidden */
  119234. _updateCache(ignoreParentClass?: boolean): void;
  119235. protected _getTargetPosition(): Vector3;
  119236. private _storedAlpha;
  119237. private _storedBeta;
  119238. private _storedRadius;
  119239. private _storedTarget;
  119240. private _storedTargetScreenOffset;
  119241. /**
  119242. * Stores the current state of the camera (alpha, beta, radius and target)
  119243. * @returns the camera itself
  119244. */
  119245. storeState(): Camera;
  119246. /**
  119247. * @hidden
  119248. * Restored camera state. You must call storeState() first
  119249. */
  119250. _restoreStateValues(): boolean;
  119251. /** @hidden */
  119252. _isSynchronizedViewMatrix(): boolean;
  119253. /**
  119254. * Attached controls to the current camera.
  119255. * @param element Defines the element the controls should be listened from
  119256. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119257. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  119258. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  119259. */
  119260. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  119261. /**
  119262. * Detach the current controls from the camera.
  119263. * The camera will stop reacting to inputs.
  119264. * @param element Defines the element to stop listening the inputs from
  119265. */
  119266. detachControl(element: HTMLElement): void;
  119267. /** @hidden */
  119268. _checkInputs(): void;
  119269. protected _checkLimits(): void;
  119270. /**
  119271. * Rebuilds angles (alpha, beta) and radius from the give position and target
  119272. */
  119273. rebuildAnglesAndRadius(): void;
  119274. /**
  119275. * Use a position to define the current camera related information like alpha, beta and radius
  119276. * @param position Defines the position to set the camera at
  119277. */
  119278. setPosition(position: Vector3): void;
  119279. /**
  119280. * Defines the target the camera should look at.
  119281. * This will automatically adapt alpha beta and radius to fit within the new target.
  119282. * @param target Defines the new target as a Vector or a mesh
  119283. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  119284. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  119285. */
  119286. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  119287. /** @hidden */
  119288. _getViewMatrix(): Matrix;
  119289. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  119290. /**
  119291. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  119292. * @param meshes Defines the mesh to zoom on
  119293. * @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)
  119294. */
  119295. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  119296. /**
  119297. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  119298. * The target will be changed but the radius
  119299. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  119300. * @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)
  119301. */
  119302. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  119303. min: Vector3;
  119304. max: Vector3;
  119305. distance: number;
  119306. }, doNotUpdateMaxZ?: boolean): void;
  119307. /**
  119308. * @override
  119309. * Override Camera.createRigCamera
  119310. */
  119311. createRigCamera(name: string, cameraIndex: number): Camera;
  119312. /**
  119313. * @hidden
  119314. * @override
  119315. * Override Camera._updateRigCameras
  119316. */
  119317. _updateRigCameras(): void;
  119318. /**
  119319. * Destroy the camera and release the current resources hold by it.
  119320. */
  119321. dispose(): void;
  119322. /**
  119323. * Gets the current object class name.
  119324. * @return the class name
  119325. */
  119326. getClassName(): string;
  119327. }
  119328. }
  119329. declare module BABYLON {
  119330. /**
  119331. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  119332. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119333. */
  119334. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  119335. /**
  119336. * Gets the name of the behavior.
  119337. */
  119338. get name(): string;
  119339. private _zoomStopsAnimation;
  119340. private _idleRotationSpeed;
  119341. private _idleRotationWaitTime;
  119342. private _idleRotationSpinupTime;
  119343. /**
  119344. * Sets the flag that indicates if user zooming should stop animation.
  119345. */
  119346. set zoomStopsAnimation(flag: boolean);
  119347. /**
  119348. * Gets the flag that indicates if user zooming should stop animation.
  119349. */
  119350. get zoomStopsAnimation(): boolean;
  119351. /**
  119352. * Sets the default speed at which the camera rotates around the model.
  119353. */
  119354. set idleRotationSpeed(speed: number);
  119355. /**
  119356. * Gets the default speed at which the camera rotates around the model.
  119357. */
  119358. get idleRotationSpeed(): number;
  119359. /**
  119360. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  119361. */
  119362. set idleRotationWaitTime(time: number);
  119363. /**
  119364. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  119365. */
  119366. get idleRotationWaitTime(): number;
  119367. /**
  119368. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  119369. */
  119370. set idleRotationSpinupTime(time: number);
  119371. /**
  119372. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  119373. */
  119374. get idleRotationSpinupTime(): number;
  119375. /**
  119376. * Gets a value indicating if the camera is currently rotating because of this behavior
  119377. */
  119378. get rotationInProgress(): boolean;
  119379. private _onPrePointerObservableObserver;
  119380. private _onAfterCheckInputsObserver;
  119381. private _attachedCamera;
  119382. private _isPointerDown;
  119383. private _lastFrameTime;
  119384. private _lastInteractionTime;
  119385. private _cameraRotationSpeed;
  119386. /**
  119387. * Initializes the behavior.
  119388. */
  119389. init(): void;
  119390. /**
  119391. * Attaches the behavior to its arc rotate camera.
  119392. * @param camera Defines the camera to attach the behavior to
  119393. */
  119394. attach(camera: ArcRotateCamera): void;
  119395. /**
  119396. * Detaches the behavior from its current arc rotate camera.
  119397. */
  119398. detach(): void;
  119399. /**
  119400. * Returns true if user is scrolling.
  119401. * @return true if user is scrolling.
  119402. */
  119403. private _userIsZooming;
  119404. private _lastFrameRadius;
  119405. private _shouldAnimationStopForInteraction;
  119406. /**
  119407. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  119408. */
  119409. private _applyUserInteraction;
  119410. private _userIsMoving;
  119411. }
  119412. }
  119413. declare module BABYLON {
  119414. /**
  119415. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  119416. */
  119417. export class AttachToBoxBehavior implements Behavior<Mesh> {
  119418. private ui;
  119419. /**
  119420. * The name of the behavior
  119421. */
  119422. name: string;
  119423. /**
  119424. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  119425. */
  119426. distanceAwayFromFace: number;
  119427. /**
  119428. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  119429. */
  119430. distanceAwayFromBottomOfFace: number;
  119431. private _faceVectors;
  119432. private _target;
  119433. private _scene;
  119434. private _onRenderObserver;
  119435. private _tmpMatrix;
  119436. private _tmpVector;
  119437. /**
  119438. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  119439. * @param ui The transform node that should be attched to the mesh
  119440. */
  119441. constructor(ui: TransformNode);
  119442. /**
  119443. * Initializes the behavior
  119444. */
  119445. init(): void;
  119446. private _closestFace;
  119447. private _zeroVector;
  119448. private _lookAtTmpMatrix;
  119449. private _lookAtToRef;
  119450. /**
  119451. * Attaches the AttachToBoxBehavior to the passed in mesh
  119452. * @param target The mesh that the specified node will be attached to
  119453. */
  119454. attach(target: Mesh): void;
  119455. /**
  119456. * Detaches the behavior from the mesh
  119457. */
  119458. detach(): void;
  119459. }
  119460. }
  119461. declare module BABYLON {
  119462. /**
  119463. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  119464. */
  119465. export class FadeInOutBehavior implements Behavior<Mesh> {
  119466. /**
  119467. * Time in milliseconds to delay before fading in (Default: 0)
  119468. */
  119469. delay: number;
  119470. /**
  119471. * Time in milliseconds for the mesh to fade in (Default: 300)
  119472. */
  119473. fadeInTime: number;
  119474. private _millisecondsPerFrame;
  119475. private _hovered;
  119476. private _hoverValue;
  119477. private _ownerNode;
  119478. /**
  119479. * Instatiates the FadeInOutBehavior
  119480. */
  119481. constructor();
  119482. /**
  119483. * The name of the behavior
  119484. */
  119485. get name(): string;
  119486. /**
  119487. * Initializes the behavior
  119488. */
  119489. init(): void;
  119490. /**
  119491. * Attaches the fade behavior on the passed in mesh
  119492. * @param ownerNode The mesh that will be faded in/out once attached
  119493. */
  119494. attach(ownerNode: Mesh): void;
  119495. /**
  119496. * Detaches the behavior from the mesh
  119497. */
  119498. detach(): void;
  119499. /**
  119500. * Triggers the mesh to begin fading in or out
  119501. * @param value if the object should fade in or out (true to fade in)
  119502. */
  119503. fadeIn(value: boolean): void;
  119504. private _update;
  119505. private _setAllVisibility;
  119506. }
  119507. }
  119508. declare module BABYLON {
  119509. /**
  119510. * Class containing a set of static utilities functions for managing Pivots
  119511. * @hidden
  119512. */
  119513. export class PivotTools {
  119514. private static _PivotCached;
  119515. private static _OldPivotPoint;
  119516. private static _PivotTranslation;
  119517. private static _PivotTmpVector;
  119518. /** @hidden */
  119519. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  119520. /** @hidden */
  119521. static _RestorePivotPoint(mesh: AbstractMesh): void;
  119522. }
  119523. }
  119524. declare module BABYLON {
  119525. /**
  119526. * Class containing static functions to help procedurally build meshes
  119527. */
  119528. export class PlaneBuilder {
  119529. /**
  119530. * Creates a plane mesh
  119531. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  119532. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  119533. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  119534. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119535. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119537. * @param name defines the name of the mesh
  119538. * @param options defines the options used to create the mesh
  119539. * @param scene defines the hosting scene
  119540. * @returns the plane mesh
  119541. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  119542. */
  119543. static CreatePlane(name: string, options: {
  119544. size?: number;
  119545. width?: number;
  119546. height?: number;
  119547. sideOrientation?: number;
  119548. frontUVs?: Vector4;
  119549. backUVs?: Vector4;
  119550. updatable?: boolean;
  119551. sourcePlane?: Plane;
  119552. }, scene?: Nullable<Scene>): Mesh;
  119553. }
  119554. }
  119555. declare module BABYLON {
  119556. /**
  119557. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  119558. */
  119559. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  119560. private static _AnyMouseID;
  119561. /**
  119562. * Abstract mesh the behavior is set on
  119563. */
  119564. attachedNode: AbstractMesh;
  119565. private _dragPlane;
  119566. private _scene;
  119567. private _pointerObserver;
  119568. private _beforeRenderObserver;
  119569. private static _planeScene;
  119570. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  119571. /**
  119572. * 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)
  119573. */
  119574. maxDragAngle: number;
  119575. /**
  119576. * @hidden
  119577. */
  119578. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  119579. /**
  119580. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  119581. */
  119582. currentDraggingPointerID: number;
  119583. /**
  119584. * The last position where the pointer hit the drag plane in world space
  119585. */
  119586. lastDragPosition: Vector3;
  119587. /**
  119588. * If the behavior is currently in a dragging state
  119589. */
  119590. dragging: boolean;
  119591. /**
  119592. * 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)
  119593. */
  119594. dragDeltaRatio: number;
  119595. /**
  119596. * If the drag plane orientation should be updated during the dragging (Default: true)
  119597. */
  119598. updateDragPlane: boolean;
  119599. private _debugMode;
  119600. private _moving;
  119601. /**
  119602. * Fires each time the attached mesh is dragged with the pointer
  119603. * * delta between last drag position and current drag position in world space
  119604. * * dragDistance along the drag axis
  119605. * * dragPlaneNormal normal of the current drag plane used during the drag
  119606. * * dragPlanePoint in world space where the drag intersects the drag plane
  119607. */
  119608. onDragObservable: Observable<{
  119609. delta: Vector3;
  119610. dragPlanePoint: Vector3;
  119611. dragPlaneNormal: Vector3;
  119612. dragDistance: number;
  119613. pointerId: number;
  119614. }>;
  119615. /**
  119616. * Fires each time a drag begins (eg. mouse down on mesh)
  119617. */
  119618. onDragStartObservable: Observable<{
  119619. dragPlanePoint: Vector3;
  119620. pointerId: number;
  119621. }>;
  119622. /**
  119623. * Fires each time a drag ends (eg. mouse release after drag)
  119624. */
  119625. onDragEndObservable: Observable<{
  119626. dragPlanePoint: Vector3;
  119627. pointerId: number;
  119628. }>;
  119629. /**
  119630. * If the attached mesh should be moved when dragged
  119631. */
  119632. moveAttached: boolean;
  119633. /**
  119634. * If the drag behavior will react to drag events (Default: true)
  119635. */
  119636. enabled: boolean;
  119637. /**
  119638. * If pointer events should start and release the drag (Default: true)
  119639. */
  119640. startAndReleaseDragOnPointerEvents: boolean;
  119641. /**
  119642. * If camera controls should be detached during the drag
  119643. */
  119644. detachCameraControls: boolean;
  119645. /**
  119646. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  119647. */
  119648. useObjectOrientationForDragging: boolean;
  119649. private _options;
  119650. /**
  119651. * Gets the options used by the behavior
  119652. */
  119653. get options(): {
  119654. dragAxis?: Vector3;
  119655. dragPlaneNormal?: Vector3;
  119656. };
  119657. /**
  119658. * Sets the options used by the behavior
  119659. */
  119660. set options(options: {
  119661. dragAxis?: Vector3;
  119662. dragPlaneNormal?: Vector3;
  119663. });
  119664. /**
  119665. * Creates a pointer drag behavior that can be attached to a mesh
  119666. * @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)
  119667. */
  119668. constructor(options?: {
  119669. dragAxis?: Vector3;
  119670. dragPlaneNormal?: Vector3;
  119671. });
  119672. /**
  119673. * Predicate to determine if it is valid to move the object to a new position when it is moved
  119674. */
  119675. validateDrag: (targetPosition: Vector3) => boolean;
  119676. /**
  119677. * The name of the behavior
  119678. */
  119679. get name(): string;
  119680. /**
  119681. * Initializes the behavior
  119682. */
  119683. init(): void;
  119684. private _tmpVector;
  119685. private _alternatePickedPoint;
  119686. private _worldDragAxis;
  119687. private _targetPosition;
  119688. private _attachedElement;
  119689. /**
  119690. * Attaches the drag behavior the passed in mesh
  119691. * @param ownerNode The mesh that will be dragged around once attached
  119692. * @param predicate Predicate to use for pick filtering
  119693. */
  119694. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  119695. /**
  119696. * Force relase the drag action by code.
  119697. */
  119698. releaseDrag(): void;
  119699. private _startDragRay;
  119700. private _lastPointerRay;
  119701. /**
  119702. * Simulates the start of a pointer drag event on the behavior
  119703. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  119704. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  119705. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  119706. */
  119707. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  119708. private _startDrag;
  119709. private _dragDelta;
  119710. private _moveDrag;
  119711. private _pickWithRayOnDragPlane;
  119712. private _pointA;
  119713. private _pointB;
  119714. private _pointC;
  119715. private _lineA;
  119716. private _lineB;
  119717. private _localAxis;
  119718. private _lookAt;
  119719. private _updateDragPlanePosition;
  119720. /**
  119721. * Detaches the behavior from the mesh
  119722. */
  119723. detach(): void;
  119724. }
  119725. }
  119726. declare module BABYLON {
  119727. /**
  119728. * A behavior that when attached to a mesh will allow the mesh to be scaled
  119729. */
  119730. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  119731. private _dragBehaviorA;
  119732. private _dragBehaviorB;
  119733. private _startDistance;
  119734. private _initialScale;
  119735. private _targetScale;
  119736. private _ownerNode;
  119737. private _sceneRenderObserver;
  119738. /**
  119739. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  119740. */
  119741. constructor();
  119742. /**
  119743. * The name of the behavior
  119744. */
  119745. get name(): string;
  119746. /**
  119747. * Initializes the behavior
  119748. */
  119749. init(): void;
  119750. private _getCurrentDistance;
  119751. /**
  119752. * Attaches the scale behavior the passed in mesh
  119753. * @param ownerNode The mesh that will be scaled around once attached
  119754. */
  119755. attach(ownerNode: Mesh): void;
  119756. /**
  119757. * Detaches the behavior from the mesh
  119758. */
  119759. detach(): void;
  119760. }
  119761. }
  119762. declare module BABYLON {
  119763. /**
  119764. * 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
  119765. */
  119766. export class SixDofDragBehavior implements Behavior<Mesh> {
  119767. private static _virtualScene;
  119768. private _ownerNode;
  119769. private _sceneRenderObserver;
  119770. private _scene;
  119771. private _targetPosition;
  119772. private _virtualOriginMesh;
  119773. private _virtualDragMesh;
  119774. private _pointerObserver;
  119775. private _moving;
  119776. private _startingOrientation;
  119777. private _attachedElement;
  119778. /**
  119779. * 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)
  119780. */
  119781. private zDragFactor;
  119782. /**
  119783. * If the object should rotate to face the drag origin
  119784. */
  119785. rotateDraggedObject: boolean;
  119786. /**
  119787. * If the behavior is currently in a dragging state
  119788. */
  119789. dragging: boolean;
  119790. /**
  119791. * 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)
  119792. */
  119793. dragDeltaRatio: number;
  119794. /**
  119795. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  119796. */
  119797. currentDraggingPointerID: number;
  119798. /**
  119799. * If camera controls should be detached during the drag
  119800. */
  119801. detachCameraControls: boolean;
  119802. /**
  119803. * Fires each time a drag starts
  119804. */
  119805. onDragStartObservable: Observable<{}>;
  119806. /**
  119807. * Fires each time a drag ends (eg. mouse release after drag)
  119808. */
  119809. onDragEndObservable: Observable<{}>;
  119810. /**
  119811. * 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
  119812. */
  119813. constructor();
  119814. /**
  119815. * The name of the behavior
  119816. */
  119817. get name(): string;
  119818. /**
  119819. * Initializes the behavior
  119820. */
  119821. init(): void;
  119822. /**
  119823. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  119824. */
  119825. private get _pointerCamera();
  119826. /**
  119827. * Attaches the scale behavior the passed in mesh
  119828. * @param ownerNode The mesh that will be scaled around once attached
  119829. */
  119830. attach(ownerNode: Mesh): void;
  119831. /**
  119832. * Detaches the behavior from the mesh
  119833. */
  119834. detach(): void;
  119835. }
  119836. }
  119837. declare module BABYLON {
  119838. /**
  119839. * Class used to apply inverse kinematics to bones
  119840. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  119841. */
  119842. export class BoneIKController {
  119843. private static _tmpVecs;
  119844. private static _tmpQuat;
  119845. private static _tmpMats;
  119846. /**
  119847. * Gets or sets the target mesh
  119848. */
  119849. targetMesh: AbstractMesh;
  119850. /** Gets or sets the mesh used as pole */
  119851. poleTargetMesh: AbstractMesh;
  119852. /**
  119853. * Gets or sets the bone used as pole
  119854. */
  119855. poleTargetBone: Nullable<Bone>;
  119856. /**
  119857. * Gets or sets the target position
  119858. */
  119859. targetPosition: Vector3;
  119860. /**
  119861. * Gets or sets the pole target position
  119862. */
  119863. poleTargetPosition: Vector3;
  119864. /**
  119865. * Gets or sets the pole target local offset
  119866. */
  119867. poleTargetLocalOffset: Vector3;
  119868. /**
  119869. * Gets or sets the pole angle
  119870. */
  119871. poleAngle: number;
  119872. /**
  119873. * Gets or sets the mesh associated with the controller
  119874. */
  119875. mesh: AbstractMesh;
  119876. /**
  119877. * 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)
  119878. */
  119879. slerpAmount: number;
  119880. private _bone1Quat;
  119881. private _bone1Mat;
  119882. private _bone2Ang;
  119883. private _bone1;
  119884. private _bone2;
  119885. private _bone1Length;
  119886. private _bone2Length;
  119887. private _maxAngle;
  119888. private _maxReach;
  119889. private _rightHandedSystem;
  119890. private _bendAxis;
  119891. private _slerping;
  119892. private _adjustRoll;
  119893. /**
  119894. * Gets or sets maximum allowed angle
  119895. */
  119896. get maxAngle(): number;
  119897. set maxAngle(value: number);
  119898. /**
  119899. * Creates a new BoneIKController
  119900. * @param mesh defines the mesh to control
  119901. * @param bone defines the bone to control
  119902. * @param options defines options to set up the controller
  119903. */
  119904. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  119905. targetMesh?: AbstractMesh;
  119906. poleTargetMesh?: AbstractMesh;
  119907. poleTargetBone?: Bone;
  119908. poleTargetLocalOffset?: Vector3;
  119909. poleAngle?: number;
  119910. bendAxis?: Vector3;
  119911. maxAngle?: number;
  119912. slerpAmount?: number;
  119913. });
  119914. private _setMaxAngle;
  119915. /**
  119916. * Force the controller to update the bones
  119917. */
  119918. update(): void;
  119919. }
  119920. }
  119921. declare module BABYLON {
  119922. /**
  119923. * Class used to make a bone look toward a point in space
  119924. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  119925. */
  119926. export class BoneLookController {
  119927. private static _tmpVecs;
  119928. private static _tmpQuat;
  119929. private static _tmpMats;
  119930. /**
  119931. * The target Vector3 that the bone will look at
  119932. */
  119933. target: Vector3;
  119934. /**
  119935. * The mesh that the bone is attached to
  119936. */
  119937. mesh: AbstractMesh;
  119938. /**
  119939. * The bone that will be looking to the target
  119940. */
  119941. bone: Bone;
  119942. /**
  119943. * The up axis of the coordinate system that is used when the bone is rotated
  119944. */
  119945. upAxis: Vector3;
  119946. /**
  119947. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  119948. */
  119949. upAxisSpace: Space;
  119950. /**
  119951. * Used to make an adjustment to the yaw of the bone
  119952. */
  119953. adjustYaw: number;
  119954. /**
  119955. * Used to make an adjustment to the pitch of the bone
  119956. */
  119957. adjustPitch: number;
  119958. /**
  119959. * Used to make an adjustment to the roll of the bone
  119960. */
  119961. adjustRoll: number;
  119962. /**
  119963. * 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)
  119964. */
  119965. slerpAmount: number;
  119966. private _minYaw;
  119967. private _maxYaw;
  119968. private _minPitch;
  119969. private _maxPitch;
  119970. private _minYawSin;
  119971. private _minYawCos;
  119972. private _maxYawSin;
  119973. private _maxYawCos;
  119974. private _midYawConstraint;
  119975. private _minPitchTan;
  119976. private _maxPitchTan;
  119977. private _boneQuat;
  119978. private _slerping;
  119979. private _transformYawPitch;
  119980. private _transformYawPitchInv;
  119981. private _firstFrameSkipped;
  119982. private _yawRange;
  119983. private _fowardAxis;
  119984. /**
  119985. * Gets or sets the minimum yaw angle that the bone can look to
  119986. */
  119987. get minYaw(): number;
  119988. set minYaw(value: number);
  119989. /**
  119990. * Gets or sets the maximum yaw angle that the bone can look to
  119991. */
  119992. get maxYaw(): number;
  119993. set maxYaw(value: number);
  119994. /**
  119995. * Gets or sets the minimum pitch angle that the bone can look to
  119996. */
  119997. get minPitch(): number;
  119998. set minPitch(value: number);
  119999. /**
  120000. * Gets or sets the maximum pitch angle that the bone can look to
  120001. */
  120002. get maxPitch(): number;
  120003. set maxPitch(value: number);
  120004. /**
  120005. * Create a BoneLookController
  120006. * @param mesh the mesh that the bone belongs to
  120007. * @param bone the bone that will be looking to the target
  120008. * @param target the target Vector3 to look at
  120009. * @param options optional settings:
  120010. * * maxYaw: the maximum angle the bone will yaw to
  120011. * * minYaw: the minimum angle the bone will yaw to
  120012. * * maxPitch: the maximum angle the bone will pitch to
  120013. * * minPitch: the minimum angle the bone will yaw to
  120014. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  120015. * * upAxis: the up axis of the coordinate system
  120016. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  120017. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  120018. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  120019. * * adjustYaw: used to make an adjustment to the yaw of the bone
  120020. * * adjustPitch: used to make an adjustment to the pitch of the bone
  120021. * * adjustRoll: used to make an adjustment to the roll of the bone
  120022. **/
  120023. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  120024. maxYaw?: number;
  120025. minYaw?: number;
  120026. maxPitch?: number;
  120027. minPitch?: number;
  120028. slerpAmount?: number;
  120029. upAxis?: Vector3;
  120030. upAxisSpace?: Space;
  120031. yawAxis?: Vector3;
  120032. pitchAxis?: Vector3;
  120033. adjustYaw?: number;
  120034. adjustPitch?: number;
  120035. adjustRoll?: number;
  120036. });
  120037. /**
  120038. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  120039. */
  120040. update(): void;
  120041. private _getAngleDiff;
  120042. private _getAngleBetween;
  120043. private _isAngleBetween;
  120044. }
  120045. }
  120046. declare module BABYLON {
  120047. /**
  120048. * Manage the gamepad inputs to control an arc rotate camera.
  120049. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120050. */
  120051. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  120052. /**
  120053. * Defines the camera the input is attached to.
  120054. */
  120055. camera: ArcRotateCamera;
  120056. /**
  120057. * Defines the gamepad the input is gathering event from.
  120058. */
  120059. gamepad: Nullable<Gamepad>;
  120060. /**
  120061. * Defines the gamepad rotation sensiblity.
  120062. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  120063. */
  120064. gamepadRotationSensibility: number;
  120065. /**
  120066. * Defines the gamepad move sensiblity.
  120067. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  120068. */
  120069. gamepadMoveSensibility: number;
  120070. private _yAxisScale;
  120071. /**
  120072. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  120073. */
  120074. get invertYAxis(): boolean;
  120075. set invertYAxis(value: boolean);
  120076. private _onGamepadConnectedObserver;
  120077. private _onGamepadDisconnectedObserver;
  120078. /**
  120079. * Attach the input controls to a specific dom element to get the input from.
  120080. * @param element Defines the element the controls should be listened from
  120081. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120082. */
  120083. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120084. /**
  120085. * Detach the current controls from the specified dom element.
  120086. * @param element Defines the element to stop listening the inputs from
  120087. */
  120088. detachControl(element: Nullable<HTMLElement>): void;
  120089. /**
  120090. * Update the current camera state depending on the inputs that have been used this frame.
  120091. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120092. */
  120093. checkInputs(): void;
  120094. /**
  120095. * Gets the class name of the current intput.
  120096. * @returns the class name
  120097. */
  120098. getClassName(): string;
  120099. /**
  120100. * Get the friendly name associated with the input class.
  120101. * @returns the input friendly name
  120102. */
  120103. getSimpleName(): string;
  120104. }
  120105. }
  120106. declare module BABYLON {
  120107. interface ArcRotateCameraInputsManager {
  120108. /**
  120109. * Add orientation input support to the input manager.
  120110. * @returns the current input manager
  120111. */
  120112. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  120113. }
  120114. /**
  120115. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  120116. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120117. */
  120118. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  120119. /**
  120120. * Defines the camera the input is attached to.
  120121. */
  120122. camera: ArcRotateCamera;
  120123. /**
  120124. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  120125. */
  120126. alphaCorrection: number;
  120127. /**
  120128. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  120129. */
  120130. gammaCorrection: number;
  120131. private _alpha;
  120132. private _gamma;
  120133. private _dirty;
  120134. private _deviceOrientationHandler;
  120135. /**
  120136. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  120137. */
  120138. constructor();
  120139. /**
  120140. * Attach the input controls to a specific dom element to get the input from.
  120141. * @param element Defines the element the controls should be listened from
  120142. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120143. */
  120144. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120145. /** @hidden */
  120146. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  120147. /**
  120148. * Update the current camera state depending on the inputs that have been used this frame.
  120149. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120150. */
  120151. checkInputs(): void;
  120152. /**
  120153. * Detach the current controls from the specified dom element.
  120154. * @param element Defines the element to stop listening the inputs from
  120155. */
  120156. detachControl(element: Nullable<HTMLElement>): void;
  120157. /**
  120158. * Gets the class name of the current intput.
  120159. * @returns the class name
  120160. */
  120161. getClassName(): string;
  120162. /**
  120163. * Get the friendly name associated with the input class.
  120164. * @returns the input friendly name
  120165. */
  120166. getSimpleName(): string;
  120167. }
  120168. }
  120169. declare module BABYLON {
  120170. /**
  120171. * Listen to mouse events to control the camera.
  120172. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120173. */
  120174. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  120175. /**
  120176. * Defines the camera the input is attached to.
  120177. */
  120178. camera: FlyCamera;
  120179. /**
  120180. * Defines if touch is enabled. (Default is true.)
  120181. */
  120182. touchEnabled: boolean;
  120183. /**
  120184. * Defines the buttons associated with the input to handle camera rotation.
  120185. */
  120186. buttons: number[];
  120187. /**
  120188. * Assign buttons for Yaw control.
  120189. */
  120190. buttonsYaw: number[];
  120191. /**
  120192. * Assign buttons for Pitch control.
  120193. */
  120194. buttonsPitch: number[];
  120195. /**
  120196. * Assign buttons for Roll control.
  120197. */
  120198. buttonsRoll: number[];
  120199. /**
  120200. * Detect if any button is being pressed while mouse is moved.
  120201. * -1 = Mouse locked.
  120202. * 0 = Left button.
  120203. * 1 = Middle Button.
  120204. * 2 = Right Button.
  120205. */
  120206. activeButton: number;
  120207. /**
  120208. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  120209. * Higher values reduce its sensitivity.
  120210. */
  120211. angularSensibility: number;
  120212. private _mousemoveCallback;
  120213. private _observer;
  120214. private _rollObserver;
  120215. private previousPosition;
  120216. private noPreventDefault;
  120217. private element;
  120218. /**
  120219. * Listen to mouse events to control the camera.
  120220. * @param touchEnabled Define if touch is enabled. (Default is true.)
  120221. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120222. */
  120223. constructor(touchEnabled?: boolean);
  120224. /**
  120225. * Attach the mouse control to the HTML DOM element.
  120226. * @param element Defines the element that listens to the input events.
  120227. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  120228. */
  120229. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120230. /**
  120231. * Detach the current controls from the specified dom element.
  120232. * @param element Defines the element to stop listening the inputs from
  120233. */
  120234. detachControl(element: Nullable<HTMLElement>): void;
  120235. /**
  120236. * Gets the class name of the current input.
  120237. * @returns the class name.
  120238. */
  120239. getClassName(): string;
  120240. /**
  120241. * Get the friendly name associated with the input class.
  120242. * @returns the input's friendly name.
  120243. */
  120244. getSimpleName(): string;
  120245. private _pointerInput;
  120246. private _onMouseMove;
  120247. /**
  120248. * Rotate camera by mouse offset.
  120249. */
  120250. private rotateCamera;
  120251. }
  120252. }
  120253. declare module BABYLON {
  120254. /**
  120255. * Default Inputs manager for the FlyCamera.
  120256. * It groups all the default supported inputs for ease of use.
  120257. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120258. */
  120259. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  120260. /**
  120261. * Instantiates a new FlyCameraInputsManager.
  120262. * @param camera Defines the camera the inputs belong to.
  120263. */
  120264. constructor(camera: FlyCamera);
  120265. /**
  120266. * Add keyboard input support to the input manager.
  120267. * @returns the new FlyCameraKeyboardMoveInput().
  120268. */
  120269. addKeyboard(): FlyCameraInputsManager;
  120270. /**
  120271. * Add mouse input support to the input manager.
  120272. * @param touchEnabled Enable touch screen support.
  120273. * @returns the new FlyCameraMouseInput().
  120274. */
  120275. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  120276. }
  120277. }
  120278. declare module BABYLON {
  120279. /**
  120280. * This is a flying camera, designed for 3D movement and rotation in all directions,
  120281. * such as in a 3D Space Shooter or a Flight Simulator.
  120282. */
  120283. export class FlyCamera extends TargetCamera {
  120284. /**
  120285. * Define the collision ellipsoid of the camera.
  120286. * This is helpful for simulating a camera body, like a player's body.
  120287. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  120288. */
  120289. ellipsoid: Vector3;
  120290. /**
  120291. * Define an offset for the position of the ellipsoid around the camera.
  120292. * This can be helpful if the camera is attached away from the player's body center,
  120293. * such as at its head.
  120294. */
  120295. ellipsoidOffset: Vector3;
  120296. /**
  120297. * Enable or disable collisions of the camera with the rest of the scene objects.
  120298. */
  120299. checkCollisions: boolean;
  120300. /**
  120301. * Enable or disable gravity on the camera.
  120302. */
  120303. applyGravity: boolean;
  120304. /**
  120305. * Define the current direction the camera is moving to.
  120306. */
  120307. cameraDirection: Vector3;
  120308. /**
  120309. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  120310. * This overrides and empties cameraRotation.
  120311. */
  120312. rotationQuaternion: Quaternion;
  120313. /**
  120314. * Track Roll to maintain the wanted Rolling when looking around.
  120315. */
  120316. _trackRoll: number;
  120317. /**
  120318. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  120319. */
  120320. rollCorrect: number;
  120321. /**
  120322. * Mimic a banked turn, Rolling the camera when Yawing.
  120323. * It's recommended to use rollCorrect = 10 for faster banking correction.
  120324. */
  120325. bankedTurn: boolean;
  120326. /**
  120327. * Limit in radians for how much Roll banking will add. (Default: 90°)
  120328. */
  120329. bankedTurnLimit: number;
  120330. /**
  120331. * Value of 0 disables the banked Roll.
  120332. * Value of 1 is equal to the Yaw angle in radians.
  120333. */
  120334. bankedTurnMultiplier: number;
  120335. /**
  120336. * The inputs manager loads all the input sources, such as keyboard and mouse.
  120337. */
  120338. inputs: FlyCameraInputsManager;
  120339. /**
  120340. * Gets the input sensibility for mouse input.
  120341. * Higher values reduce sensitivity.
  120342. */
  120343. get angularSensibility(): number;
  120344. /**
  120345. * Sets the input sensibility for a mouse input.
  120346. * Higher values reduce sensitivity.
  120347. */
  120348. set angularSensibility(value: number);
  120349. /**
  120350. * Get the keys for camera movement forward.
  120351. */
  120352. get keysForward(): number[];
  120353. /**
  120354. * Set the keys for camera movement forward.
  120355. */
  120356. set keysForward(value: number[]);
  120357. /**
  120358. * Get the keys for camera movement backward.
  120359. */
  120360. get keysBackward(): number[];
  120361. set keysBackward(value: number[]);
  120362. /**
  120363. * Get the keys for camera movement up.
  120364. */
  120365. get keysUp(): number[];
  120366. /**
  120367. * Set the keys for camera movement up.
  120368. */
  120369. set keysUp(value: number[]);
  120370. /**
  120371. * Get the keys for camera movement down.
  120372. */
  120373. get keysDown(): number[];
  120374. /**
  120375. * Set the keys for camera movement down.
  120376. */
  120377. set keysDown(value: number[]);
  120378. /**
  120379. * Get the keys for camera movement left.
  120380. */
  120381. get keysLeft(): number[];
  120382. /**
  120383. * Set the keys for camera movement left.
  120384. */
  120385. set keysLeft(value: number[]);
  120386. /**
  120387. * Set the keys for camera movement right.
  120388. */
  120389. get keysRight(): number[];
  120390. /**
  120391. * Set the keys for camera movement right.
  120392. */
  120393. set keysRight(value: number[]);
  120394. /**
  120395. * Event raised when the camera collides with a mesh in the scene.
  120396. */
  120397. onCollide: (collidedMesh: AbstractMesh) => void;
  120398. private _collider;
  120399. private _needMoveForGravity;
  120400. private _oldPosition;
  120401. private _diffPosition;
  120402. private _newPosition;
  120403. /** @hidden */
  120404. _localDirection: Vector3;
  120405. /** @hidden */
  120406. _transformedDirection: Vector3;
  120407. /**
  120408. * Instantiates a FlyCamera.
  120409. * This is a flying camera, designed for 3D movement and rotation in all directions,
  120410. * such as in a 3D Space Shooter or a Flight Simulator.
  120411. * @param name Define the name of the camera in the scene.
  120412. * @param position Define the starting position of the camera in the scene.
  120413. * @param scene Define the scene the camera belongs to.
  120414. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  120415. */
  120416. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  120417. /**
  120418. * Attach a control to the HTML DOM element.
  120419. * @param element Defines the element that listens to the input events.
  120420. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  120421. */
  120422. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120423. /**
  120424. * Detach a control from the HTML DOM element.
  120425. * The camera will stop reacting to that input.
  120426. * @param element Defines the element that listens to the input events.
  120427. */
  120428. detachControl(element: HTMLElement): void;
  120429. private _collisionMask;
  120430. /**
  120431. * Get the mask that the camera ignores in collision events.
  120432. */
  120433. get collisionMask(): number;
  120434. /**
  120435. * Set the mask that the camera ignores in collision events.
  120436. */
  120437. set collisionMask(mask: number);
  120438. /** @hidden */
  120439. _collideWithWorld(displacement: Vector3): void;
  120440. /** @hidden */
  120441. private _onCollisionPositionChange;
  120442. /** @hidden */
  120443. _checkInputs(): void;
  120444. /** @hidden */
  120445. _decideIfNeedsToMove(): boolean;
  120446. /** @hidden */
  120447. _updatePosition(): void;
  120448. /**
  120449. * Restore the Roll to its target value at the rate specified.
  120450. * @param rate - Higher means slower restoring.
  120451. * @hidden
  120452. */
  120453. restoreRoll(rate: number): void;
  120454. /**
  120455. * Destroy the camera and release the current resources held by it.
  120456. */
  120457. dispose(): void;
  120458. /**
  120459. * Get the current object class name.
  120460. * @returns the class name.
  120461. */
  120462. getClassName(): string;
  120463. }
  120464. }
  120465. declare module BABYLON {
  120466. /**
  120467. * Listen to keyboard events to control the camera.
  120468. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120469. */
  120470. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  120471. /**
  120472. * Defines the camera the input is attached to.
  120473. */
  120474. camera: FlyCamera;
  120475. /**
  120476. * The list of keyboard keys used to control the forward move of the camera.
  120477. */
  120478. keysForward: number[];
  120479. /**
  120480. * The list of keyboard keys used to control the backward move of the camera.
  120481. */
  120482. keysBackward: number[];
  120483. /**
  120484. * The list of keyboard keys used to control the forward move of the camera.
  120485. */
  120486. keysUp: number[];
  120487. /**
  120488. * The list of keyboard keys used to control the backward move of the camera.
  120489. */
  120490. keysDown: number[];
  120491. /**
  120492. * The list of keyboard keys used to control the right strafe move of the camera.
  120493. */
  120494. keysRight: number[];
  120495. /**
  120496. * The list of keyboard keys used to control the left strafe move of the camera.
  120497. */
  120498. keysLeft: number[];
  120499. private _keys;
  120500. private _onCanvasBlurObserver;
  120501. private _onKeyboardObserver;
  120502. private _engine;
  120503. private _scene;
  120504. /**
  120505. * Attach the input controls to a specific dom element to get the input from.
  120506. * @param element Defines the element the controls should be listened from
  120507. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120508. */
  120509. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120510. /**
  120511. * Detach the current controls from the specified dom element.
  120512. * @param element Defines the element to stop listening the inputs from
  120513. */
  120514. detachControl(element: Nullable<HTMLElement>): void;
  120515. /**
  120516. * Gets the class name of the current intput.
  120517. * @returns the class name
  120518. */
  120519. getClassName(): string;
  120520. /** @hidden */
  120521. _onLostFocus(e: FocusEvent): void;
  120522. /**
  120523. * Get the friendly name associated with the input class.
  120524. * @returns the input friendly name
  120525. */
  120526. getSimpleName(): string;
  120527. /**
  120528. * Update the current camera state depending on the inputs that have been used this frame.
  120529. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120530. */
  120531. checkInputs(): void;
  120532. }
  120533. }
  120534. declare module BABYLON {
  120535. /**
  120536. * Manage the mouse wheel inputs to control a follow camera.
  120537. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120538. */
  120539. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  120540. /**
  120541. * Defines the camera the input is attached to.
  120542. */
  120543. camera: FollowCamera;
  120544. /**
  120545. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  120546. */
  120547. axisControlRadius: boolean;
  120548. /**
  120549. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  120550. */
  120551. axisControlHeight: boolean;
  120552. /**
  120553. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  120554. */
  120555. axisControlRotation: boolean;
  120556. /**
  120557. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  120558. * relation to mouseWheel events.
  120559. */
  120560. wheelPrecision: number;
  120561. /**
  120562. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  120563. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  120564. */
  120565. wheelDeltaPercentage: number;
  120566. private _wheel;
  120567. private _observer;
  120568. /**
  120569. * Attach the input controls to a specific dom element to get the input from.
  120570. * @param element Defines the element the controls should be listened from
  120571. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120572. */
  120573. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120574. /**
  120575. * Detach the current controls from the specified dom element.
  120576. * @param element Defines the element to stop listening the inputs from
  120577. */
  120578. detachControl(element: Nullable<HTMLElement>): void;
  120579. /**
  120580. * Gets the class name of the current intput.
  120581. * @returns the class name
  120582. */
  120583. getClassName(): string;
  120584. /**
  120585. * Get the friendly name associated with the input class.
  120586. * @returns the input friendly name
  120587. */
  120588. getSimpleName(): string;
  120589. }
  120590. }
  120591. declare module BABYLON {
  120592. /**
  120593. * Manage the pointers inputs to control an follow camera.
  120594. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120595. */
  120596. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  120597. /**
  120598. * Defines the camera the input is attached to.
  120599. */
  120600. camera: FollowCamera;
  120601. /**
  120602. * Gets the class name of the current input.
  120603. * @returns the class name
  120604. */
  120605. getClassName(): string;
  120606. /**
  120607. * Defines the pointer angular sensibility along the X axis or how fast is
  120608. * the camera rotating.
  120609. * A negative number will reverse the axis direction.
  120610. */
  120611. angularSensibilityX: number;
  120612. /**
  120613. * Defines the pointer angular sensibility along the Y axis or how fast is
  120614. * the camera rotating.
  120615. * A negative number will reverse the axis direction.
  120616. */
  120617. angularSensibilityY: number;
  120618. /**
  120619. * Defines the pointer pinch precision or how fast is the camera zooming.
  120620. * A negative number will reverse the axis direction.
  120621. */
  120622. pinchPrecision: number;
  120623. /**
  120624. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  120625. * from 0.
  120626. * It defines the percentage of current camera.radius to use as delta when
  120627. * pinch zoom is used.
  120628. */
  120629. pinchDeltaPercentage: number;
  120630. /**
  120631. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  120632. */
  120633. axisXControlRadius: boolean;
  120634. /**
  120635. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  120636. */
  120637. axisXControlHeight: boolean;
  120638. /**
  120639. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  120640. */
  120641. axisXControlRotation: boolean;
  120642. /**
  120643. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  120644. */
  120645. axisYControlRadius: boolean;
  120646. /**
  120647. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  120648. */
  120649. axisYControlHeight: boolean;
  120650. /**
  120651. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  120652. */
  120653. axisYControlRotation: boolean;
  120654. /**
  120655. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  120656. */
  120657. axisPinchControlRadius: boolean;
  120658. /**
  120659. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  120660. */
  120661. axisPinchControlHeight: boolean;
  120662. /**
  120663. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  120664. */
  120665. axisPinchControlRotation: boolean;
  120666. /**
  120667. * Log error messages if basic misconfiguration has occurred.
  120668. */
  120669. warningEnable: boolean;
  120670. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  120671. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  120672. private _warningCounter;
  120673. private _warning;
  120674. }
  120675. }
  120676. declare module BABYLON {
  120677. /**
  120678. * Default Inputs manager for the FollowCamera.
  120679. * It groups all the default supported inputs for ease of use.
  120680. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120681. */
  120682. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  120683. /**
  120684. * Instantiates a new FollowCameraInputsManager.
  120685. * @param camera Defines the camera the inputs belong to
  120686. */
  120687. constructor(camera: FollowCamera);
  120688. /**
  120689. * Add keyboard input support to the input manager.
  120690. * @returns the current input manager
  120691. */
  120692. addKeyboard(): FollowCameraInputsManager;
  120693. /**
  120694. * Add mouse wheel input support to the input manager.
  120695. * @returns the current input manager
  120696. */
  120697. addMouseWheel(): FollowCameraInputsManager;
  120698. /**
  120699. * Add pointers input support to the input manager.
  120700. * @returns the current input manager
  120701. */
  120702. addPointers(): FollowCameraInputsManager;
  120703. /**
  120704. * Add orientation input support to the input manager.
  120705. * @returns the current input manager
  120706. */
  120707. addVRDeviceOrientation(): FollowCameraInputsManager;
  120708. }
  120709. }
  120710. declare module BABYLON {
  120711. /**
  120712. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  120713. * an arc rotate version arcFollowCamera are available.
  120714. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  120715. */
  120716. export class FollowCamera extends TargetCamera {
  120717. /**
  120718. * Distance the follow camera should follow an object at
  120719. */
  120720. radius: number;
  120721. /**
  120722. * Minimum allowed distance of the camera to the axis of rotation
  120723. * (The camera can not get closer).
  120724. * This can help limiting how the Camera is able to move in the scene.
  120725. */
  120726. lowerRadiusLimit: Nullable<number>;
  120727. /**
  120728. * Maximum allowed distance of the camera to the axis of rotation
  120729. * (The camera can not get further).
  120730. * This can help limiting how the Camera is able to move in the scene.
  120731. */
  120732. upperRadiusLimit: Nullable<number>;
  120733. /**
  120734. * Define a rotation offset between the camera and the object it follows
  120735. */
  120736. rotationOffset: number;
  120737. /**
  120738. * Minimum allowed angle to camera position relative to target object.
  120739. * This can help limiting how the Camera is able to move in the scene.
  120740. */
  120741. lowerRotationOffsetLimit: Nullable<number>;
  120742. /**
  120743. * Maximum allowed angle to camera position relative to target object.
  120744. * This can help limiting how the Camera is able to move in the scene.
  120745. */
  120746. upperRotationOffsetLimit: Nullable<number>;
  120747. /**
  120748. * Define a height offset between the camera and the object it follows.
  120749. * It can help following an object from the top (like a car chaing a plane)
  120750. */
  120751. heightOffset: number;
  120752. /**
  120753. * Minimum allowed height of camera position relative to target object.
  120754. * This can help limiting how the Camera is able to move in the scene.
  120755. */
  120756. lowerHeightOffsetLimit: Nullable<number>;
  120757. /**
  120758. * Maximum allowed height of camera position relative to target object.
  120759. * This can help limiting how the Camera is able to move in the scene.
  120760. */
  120761. upperHeightOffsetLimit: Nullable<number>;
  120762. /**
  120763. * Define how fast the camera can accelerate to follow it s target.
  120764. */
  120765. cameraAcceleration: number;
  120766. /**
  120767. * Define the speed limit of the camera following an object.
  120768. */
  120769. maxCameraSpeed: number;
  120770. /**
  120771. * Define the target of the camera.
  120772. */
  120773. lockedTarget: Nullable<AbstractMesh>;
  120774. /**
  120775. * Defines the input associated with the camera.
  120776. */
  120777. inputs: FollowCameraInputsManager;
  120778. /**
  120779. * Instantiates the follow camera.
  120780. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  120781. * @param name Define the name of the camera in the scene
  120782. * @param position Define the position of the camera
  120783. * @param scene Define the scene the camera belong to
  120784. * @param lockedTarget Define the target of the camera
  120785. */
  120786. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  120787. private _follow;
  120788. /**
  120789. * Attached controls to the current camera.
  120790. * @param element Defines the element the controls should be listened from
  120791. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120792. */
  120793. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120794. /**
  120795. * Detach the current controls from the camera.
  120796. * The camera will stop reacting to inputs.
  120797. * @param element Defines the element to stop listening the inputs from
  120798. */
  120799. detachControl(element: HTMLElement): void;
  120800. /** @hidden */
  120801. _checkInputs(): void;
  120802. private _checkLimits;
  120803. /**
  120804. * Gets the camera class name.
  120805. * @returns the class name
  120806. */
  120807. getClassName(): string;
  120808. }
  120809. /**
  120810. * Arc Rotate version of the follow camera.
  120811. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  120812. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  120813. */
  120814. export class ArcFollowCamera extends TargetCamera {
  120815. /** The longitudinal angle of the camera */
  120816. alpha: number;
  120817. /** The latitudinal angle of the camera */
  120818. beta: number;
  120819. /** The radius of the camera from its target */
  120820. radius: number;
  120821. /** Define the camera target (the messh it should follow) */
  120822. target: Nullable<AbstractMesh>;
  120823. private _cartesianCoordinates;
  120824. /**
  120825. * Instantiates a new ArcFollowCamera
  120826. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  120827. * @param name Define the name of the camera
  120828. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  120829. * @param beta Define the rotation angle of the camera around the elevation axis
  120830. * @param radius Define the radius of the camera from its target point
  120831. * @param target Define the target of the camera
  120832. * @param scene Define the scene the camera belongs to
  120833. */
  120834. constructor(name: string,
  120835. /** The longitudinal angle of the camera */
  120836. alpha: number,
  120837. /** The latitudinal angle of the camera */
  120838. beta: number,
  120839. /** The radius of the camera from its target */
  120840. radius: number,
  120841. /** Define the camera target (the messh it should follow) */
  120842. target: Nullable<AbstractMesh>, scene: Scene);
  120843. private _follow;
  120844. /** @hidden */
  120845. _checkInputs(): void;
  120846. /**
  120847. * Returns the class name of the object.
  120848. * It is mostly used internally for serialization purposes.
  120849. */
  120850. getClassName(): string;
  120851. }
  120852. }
  120853. declare module BABYLON {
  120854. /**
  120855. * Manage the keyboard inputs to control the movement of a follow camera.
  120856. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120857. */
  120858. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  120859. /**
  120860. * Defines the camera the input is attached to.
  120861. */
  120862. camera: FollowCamera;
  120863. /**
  120864. * Defines the list of key codes associated with the up action (increase heightOffset)
  120865. */
  120866. keysHeightOffsetIncr: number[];
  120867. /**
  120868. * Defines the list of key codes associated with the down action (decrease heightOffset)
  120869. */
  120870. keysHeightOffsetDecr: number[];
  120871. /**
  120872. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  120873. */
  120874. keysHeightOffsetModifierAlt: boolean;
  120875. /**
  120876. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  120877. */
  120878. keysHeightOffsetModifierCtrl: boolean;
  120879. /**
  120880. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  120881. */
  120882. keysHeightOffsetModifierShift: boolean;
  120883. /**
  120884. * Defines the list of key codes associated with the left action (increase rotationOffset)
  120885. */
  120886. keysRotationOffsetIncr: number[];
  120887. /**
  120888. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  120889. */
  120890. keysRotationOffsetDecr: number[];
  120891. /**
  120892. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  120893. */
  120894. keysRotationOffsetModifierAlt: boolean;
  120895. /**
  120896. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  120897. */
  120898. keysRotationOffsetModifierCtrl: boolean;
  120899. /**
  120900. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  120901. */
  120902. keysRotationOffsetModifierShift: boolean;
  120903. /**
  120904. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  120905. */
  120906. keysRadiusIncr: number[];
  120907. /**
  120908. * Defines the list of key codes associated with the zoom-out action (increase radius)
  120909. */
  120910. keysRadiusDecr: number[];
  120911. /**
  120912. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  120913. */
  120914. keysRadiusModifierAlt: boolean;
  120915. /**
  120916. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  120917. */
  120918. keysRadiusModifierCtrl: boolean;
  120919. /**
  120920. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  120921. */
  120922. keysRadiusModifierShift: boolean;
  120923. /**
  120924. * Defines the rate of change of heightOffset.
  120925. */
  120926. heightSensibility: number;
  120927. /**
  120928. * Defines the rate of change of rotationOffset.
  120929. */
  120930. rotationSensibility: number;
  120931. /**
  120932. * Defines the rate of change of radius.
  120933. */
  120934. radiusSensibility: number;
  120935. private _keys;
  120936. private _ctrlPressed;
  120937. private _altPressed;
  120938. private _shiftPressed;
  120939. private _onCanvasBlurObserver;
  120940. private _onKeyboardObserver;
  120941. private _engine;
  120942. private _scene;
  120943. /**
  120944. * Attach the input controls to a specific dom element to get the input from.
  120945. * @param element Defines the element the controls should be listened from
  120946. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120947. */
  120948. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120949. /**
  120950. * Detach the current controls from the specified dom element.
  120951. * @param element Defines the element to stop listening the inputs from
  120952. */
  120953. detachControl(element: Nullable<HTMLElement>): void;
  120954. /**
  120955. * Update the current camera state depending on the inputs that have been used this frame.
  120956. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120957. */
  120958. checkInputs(): 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 friendly name
  120967. */
  120968. getSimpleName(): string;
  120969. /**
  120970. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  120971. * allow modification of the heightOffset value.
  120972. */
  120973. private _modifierHeightOffset;
  120974. /**
  120975. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  120976. * allow modification of the rotationOffset value.
  120977. */
  120978. private _modifierRotationOffset;
  120979. /**
  120980. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  120981. * allow modification of the radius value.
  120982. */
  120983. private _modifierRadius;
  120984. }
  120985. }
  120986. declare module BABYLON {
  120987. interface FreeCameraInputsManager {
  120988. /**
  120989. * @hidden
  120990. */
  120991. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  120992. /**
  120993. * Add orientation input support to the input manager.
  120994. * @returns the current input manager
  120995. */
  120996. addDeviceOrientation(): FreeCameraInputsManager;
  120997. }
  120998. /**
  120999. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  121000. * Screen rotation is taken into account.
  121001. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121002. */
  121003. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  121004. private _camera;
  121005. private _screenOrientationAngle;
  121006. private _constantTranform;
  121007. private _screenQuaternion;
  121008. private _alpha;
  121009. private _beta;
  121010. private _gamma;
  121011. /**
  121012. * Can be used to detect if a device orientation sensor is available on a device
  121013. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  121014. * @returns a promise that will resolve on orientation change
  121015. */
  121016. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  121017. /**
  121018. * @hidden
  121019. */
  121020. _onDeviceOrientationChangedObservable: Observable<void>;
  121021. /**
  121022. * Instantiates a new input
  121023. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121024. */
  121025. constructor();
  121026. /**
  121027. * Define the camera controlled by the input.
  121028. */
  121029. get camera(): FreeCamera;
  121030. set camera(camera: FreeCamera);
  121031. /**
  121032. * Attach the input controls to a specific dom element to get the input from.
  121033. * @param element Defines the element the controls should be listened from
  121034. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121035. */
  121036. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121037. private _orientationChanged;
  121038. private _deviceOrientation;
  121039. /**
  121040. * Detach the current controls from the specified dom element.
  121041. * @param element Defines the element to stop listening the inputs from
  121042. */
  121043. detachControl(element: Nullable<HTMLElement>): void;
  121044. /**
  121045. * Update the current camera state depending on the inputs that have been used this frame.
  121046. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121047. */
  121048. checkInputs(): void;
  121049. /**
  121050. * Gets the class name of the current intput.
  121051. * @returns the class name
  121052. */
  121053. getClassName(): string;
  121054. /**
  121055. * Get the friendly name associated with the input class.
  121056. * @returns the input friendly name
  121057. */
  121058. getSimpleName(): string;
  121059. }
  121060. }
  121061. declare module BABYLON {
  121062. /**
  121063. * Manage the gamepad inputs to control a free camera.
  121064. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121065. */
  121066. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  121067. /**
  121068. * Define the camera the input is attached to.
  121069. */
  121070. camera: FreeCamera;
  121071. /**
  121072. * Define the Gamepad controlling the input
  121073. */
  121074. gamepad: Nullable<Gamepad>;
  121075. /**
  121076. * Defines the gamepad rotation sensiblity.
  121077. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  121078. */
  121079. gamepadAngularSensibility: number;
  121080. /**
  121081. * Defines the gamepad move sensiblity.
  121082. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  121083. */
  121084. gamepadMoveSensibility: number;
  121085. private _yAxisScale;
  121086. /**
  121087. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  121088. */
  121089. get invertYAxis(): boolean;
  121090. set invertYAxis(value: boolean);
  121091. private _onGamepadConnectedObserver;
  121092. private _onGamepadDisconnectedObserver;
  121093. private _cameraTransform;
  121094. private _deltaTransform;
  121095. private _vector3;
  121096. private _vector2;
  121097. /**
  121098. * Attach the input controls to a specific dom element to get the input from.
  121099. * @param element Defines the element the controls should be listened from
  121100. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121101. */
  121102. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121103. /**
  121104. * Detach the current controls from the specified dom element.
  121105. * @param element Defines the element to stop listening the inputs from
  121106. */
  121107. detachControl(element: Nullable<HTMLElement>): void;
  121108. /**
  121109. * Update the current camera state depending on the inputs that have been used this frame.
  121110. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121111. */
  121112. checkInputs(): void;
  121113. /**
  121114. * Gets the class name of the current intput.
  121115. * @returns the class name
  121116. */
  121117. getClassName(): string;
  121118. /**
  121119. * Get the friendly name associated with the input class.
  121120. * @returns the input friendly name
  121121. */
  121122. getSimpleName(): string;
  121123. }
  121124. }
  121125. declare module BABYLON {
  121126. /**
  121127. * Defines the potential axis of a Joystick
  121128. */
  121129. export enum JoystickAxis {
  121130. /** X axis */
  121131. X = 0,
  121132. /** Y axis */
  121133. Y = 1,
  121134. /** Z axis */
  121135. Z = 2
  121136. }
  121137. /**
  121138. * Class used to define virtual joystick (used in touch mode)
  121139. */
  121140. export class VirtualJoystick {
  121141. /**
  121142. * Gets or sets a boolean indicating that left and right values must be inverted
  121143. */
  121144. reverseLeftRight: boolean;
  121145. /**
  121146. * Gets or sets a boolean indicating that up and down values must be inverted
  121147. */
  121148. reverseUpDown: boolean;
  121149. /**
  121150. * Gets the offset value for the position (ie. the change of the position value)
  121151. */
  121152. deltaPosition: Vector3;
  121153. /**
  121154. * Gets a boolean indicating if the virtual joystick was pressed
  121155. */
  121156. pressed: boolean;
  121157. /**
  121158. * Canvas the virtual joystick will render onto, default z-index of this is 5
  121159. */
  121160. static Canvas: Nullable<HTMLCanvasElement>;
  121161. private static _globalJoystickIndex;
  121162. private static vjCanvasContext;
  121163. private static vjCanvasWidth;
  121164. private static vjCanvasHeight;
  121165. private static halfWidth;
  121166. private _action;
  121167. private _axisTargetedByLeftAndRight;
  121168. private _axisTargetedByUpAndDown;
  121169. private _joystickSensibility;
  121170. private _inversedSensibility;
  121171. private _joystickPointerID;
  121172. private _joystickColor;
  121173. private _joystickPointerPos;
  121174. private _joystickPreviousPointerPos;
  121175. private _joystickPointerStartPos;
  121176. private _deltaJoystickVector;
  121177. private _leftJoystick;
  121178. private _touches;
  121179. private _onPointerDownHandlerRef;
  121180. private _onPointerMoveHandlerRef;
  121181. private _onPointerUpHandlerRef;
  121182. private _onResize;
  121183. /**
  121184. * Creates a new virtual joystick
  121185. * @param leftJoystick defines that the joystick is for left hand (false by default)
  121186. */
  121187. constructor(leftJoystick?: boolean);
  121188. /**
  121189. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  121190. * @param newJoystickSensibility defines the new sensibility
  121191. */
  121192. setJoystickSensibility(newJoystickSensibility: number): void;
  121193. private _onPointerDown;
  121194. private _onPointerMove;
  121195. private _onPointerUp;
  121196. /**
  121197. * Change the color of the virtual joystick
  121198. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  121199. */
  121200. setJoystickColor(newColor: string): void;
  121201. /**
  121202. * Defines a callback to call when the joystick is touched
  121203. * @param action defines the callback
  121204. */
  121205. setActionOnTouch(action: () => any): void;
  121206. /**
  121207. * Defines which axis you'd like to control for left & right
  121208. * @param axis defines the axis to use
  121209. */
  121210. setAxisForLeftRight(axis: JoystickAxis): void;
  121211. /**
  121212. * Defines which axis you'd like to control for up & down
  121213. * @param axis defines the axis to use
  121214. */
  121215. setAxisForUpDown(axis: JoystickAxis): void;
  121216. private _drawVirtualJoystick;
  121217. /**
  121218. * Release internal HTML canvas
  121219. */
  121220. releaseCanvas(): void;
  121221. }
  121222. }
  121223. declare module BABYLON {
  121224. interface FreeCameraInputsManager {
  121225. /**
  121226. * Add virtual joystick input support to the input manager.
  121227. * @returns the current input manager
  121228. */
  121229. addVirtualJoystick(): FreeCameraInputsManager;
  121230. }
  121231. /**
  121232. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  121233. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121234. */
  121235. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  121236. /**
  121237. * Defines the camera the input is attached to.
  121238. */
  121239. camera: FreeCamera;
  121240. private _leftjoystick;
  121241. private _rightjoystick;
  121242. /**
  121243. * Gets the left stick of the virtual joystick.
  121244. * @returns The virtual Joystick
  121245. */
  121246. getLeftJoystick(): VirtualJoystick;
  121247. /**
  121248. * Gets the right stick of the virtual joystick.
  121249. * @returns The virtual Joystick
  121250. */
  121251. getRightJoystick(): VirtualJoystick;
  121252. /**
  121253. * Update the current camera state depending on the inputs that have been used this frame.
  121254. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121255. */
  121256. checkInputs(): void;
  121257. /**
  121258. * Attach the input controls to a specific dom element to get the input from.
  121259. * @param element Defines the element the controls should be listened from
  121260. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121261. */
  121262. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121263. /**
  121264. * Detach the current controls from the specified dom element.
  121265. * @param element Defines the element to stop listening the inputs from
  121266. */
  121267. detachControl(element: Nullable<HTMLElement>): void;
  121268. /**
  121269. * Gets the class name of the current intput.
  121270. * @returns the class name
  121271. */
  121272. getClassName(): string;
  121273. /**
  121274. * Get the friendly name associated with the input class.
  121275. * @returns the input friendly name
  121276. */
  121277. getSimpleName(): string;
  121278. }
  121279. }
  121280. declare module BABYLON {
  121281. /**
  121282. * This represents a FPS type of camera controlled by touch.
  121283. * This is like a universal camera minus the Gamepad controls.
  121284. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121285. */
  121286. export class TouchCamera extends FreeCamera {
  121287. /**
  121288. * Defines the touch sensibility for rotation.
  121289. * The higher the faster.
  121290. */
  121291. get touchAngularSensibility(): number;
  121292. set touchAngularSensibility(value: number);
  121293. /**
  121294. * Defines the touch sensibility for move.
  121295. * The higher the faster.
  121296. */
  121297. get touchMoveSensibility(): number;
  121298. set touchMoveSensibility(value: number);
  121299. /**
  121300. * Instantiates a new touch camera.
  121301. * This represents a FPS type of camera controlled by touch.
  121302. * This is like a universal camera minus the Gamepad controls.
  121303. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121304. * @param name Define the name of the camera in the scene
  121305. * @param position Define the start position of the camera in the scene
  121306. * @param scene Define the scene the camera belongs to
  121307. */
  121308. constructor(name: string, position: Vector3, scene: Scene);
  121309. /**
  121310. * Gets the current object class name.
  121311. * @return the class name
  121312. */
  121313. getClassName(): string;
  121314. /** @hidden */
  121315. _setupInputs(): void;
  121316. }
  121317. }
  121318. declare module BABYLON {
  121319. /**
  121320. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  121321. * being tilted forward or back and left or right.
  121322. */
  121323. export class DeviceOrientationCamera extends FreeCamera {
  121324. private _initialQuaternion;
  121325. private _quaternionCache;
  121326. private _tmpDragQuaternion;
  121327. private _disablePointerInputWhenUsingDeviceOrientation;
  121328. /**
  121329. * Creates a new device orientation camera
  121330. * @param name The name of the camera
  121331. * @param position The start position camera
  121332. * @param scene The scene the camera belongs to
  121333. */
  121334. constructor(name: string, position: Vector3, scene: Scene);
  121335. /**
  121336. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  121337. */
  121338. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  121339. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  121340. private _dragFactor;
  121341. /**
  121342. * Enabled turning on the y axis when the orientation sensor is active
  121343. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  121344. */
  121345. enableHorizontalDragging(dragFactor?: number): void;
  121346. /**
  121347. * Gets the current instance class name ("DeviceOrientationCamera").
  121348. * This helps avoiding instanceof at run time.
  121349. * @returns the class name
  121350. */
  121351. getClassName(): string;
  121352. /**
  121353. * @hidden
  121354. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  121355. */
  121356. _checkInputs(): void;
  121357. /**
  121358. * Reset the camera to its default orientation on the specified axis only.
  121359. * @param axis The axis to reset
  121360. */
  121361. resetToCurrentRotation(axis?: Axis): void;
  121362. }
  121363. }
  121364. declare module BABYLON {
  121365. /**
  121366. * Defines supported buttons for XBox360 compatible gamepads
  121367. */
  121368. export enum Xbox360Button {
  121369. /** A */
  121370. A = 0,
  121371. /** B */
  121372. B = 1,
  121373. /** X */
  121374. X = 2,
  121375. /** Y */
  121376. Y = 3,
  121377. /** Left button */
  121378. LB = 4,
  121379. /** Right button */
  121380. RB = 5,
  121381. /** Back */
  121382. Back = 8,
  121383. /** Start */
  121384. Start = 9,
  121385. /** Left stick */
  121386. LeftStick = 10,
  121387. /** Right stick */
  121388. RightStick = 11
  121389. }
  121390. /** Defines values for XBox360 DPad */
  121391. export enum Xbox360Dpad {
  121392. /** Up */
  121393. Up = 12,
  121394. /** Down */
  121395. Down = 13,
  121396. /** Left */
  121397. Left = 14,
  121398. /** Right */
  121399. Right = 15
  121400. }
  121401. /**
  121402. * Defines a XBox360 gamepad
  121403. */
  121404. export class Xbox360Pad extends Gamepad {
  121405. private _leftTrigger;
  121406. private _rightTrigger;
  121407. private _onlefttriggerchanged;
  121408. private _onrighttriggerchanged;
  121409. private _onbuttondown;
  121410. private _onbuttonup;
  121411. private _ondpaddown;
  121412. private _ondpadup;
  121413. /** Observable raised when a button is pressed */
  121414. onButtonDownObservable: Observable<Xbox360Button>;
  121415. /** Observable raised when a button is released */
  121416. onButtonUpObservable: Observable<Xbox360Button>;
  121417. /** Observable raised when a pad is pressed */
  121418. onPadDownObservable: Observable<Xbox360Dpad>;
  121419. /** Observable raised when a pad is released */
  121420. onPadUpObservable: Observable<Xbox360Dpad>;
  121421. private _buttonA;
  121422. private _buttonB;
  121423. private _buttonX;
  121424. private _buttonY;
  121425. private _buttonBack;
  121426. private _buttonStart;
  121427. private _buttonLB;
  121428. private _buttonRB;
  121429. private _buttonLeftStick;
  121430. private _buttonRightStick;
  121431. private _dPadUp;
  121432. private _dPadDown;
  121433. private _dPadLeft;
  121434. private _dPadRight;
  121435. private _isXboxOnePad;
  121436. /**
  121437. * Creates a new XBox360 gamepad object
  121438. * @param id defines the id of this gamepad
  121439. * @param index defines its index
  121440. * @param gamepad defines the internal HTML gamepad object
  121441. * @param xboxOne defines if it is a XBox One gamepad
  121442. */
  121443. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  121444. /**
  121445. * Defines the callback to call when left trigger is pressed
  121446. * @param callback defines the callback to use
  121447. */
  121448. onlefttriggerchanged(callback: (value: number) => void): void;
  121449. /**
  121450. * Defines the callback to call when right trigger is pressed
  121451. * @param callback defines the callback to use
  121452. */
  121453. onrighttriggerchanged(callback: (value: number) => void): void;
  121454. /**
  121455. * Gets the left trigger value
  121456. */
  121457. get leftTrigger(): number;
  121458. /**
  121459. * Sets the left trigger value
  121460. */
  121461. set leftTrigger(newValue: number);
  121462. /**
  121463. * Gets the right trigger value
  121464. */
  121465. get rightTrigger(): number;
  121466. /**
  121467. * Sets the right trigger value
  121468. */
  121469. set rightTrigger(newValue: number);
  121470. /**
  121471. * Defines the callback to call when a button is pressed
  121472. * @param callback defines the callback to use
  121473. */
  121474. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  121475. /**
  121476. * Defines the callback to call when a button is released
  121477. * @param callback defines the callback to use
  121478. */
  121479. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  121480. /**
  121481. * Defines the callback to call when a pad is pressed
  121482. * @param callback defines the callback to use
  121483. */
  121484. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  121485. /**
  121486. * Defines the callback to call when a pad is released
  121487. * @param callback defines the callback to use
  121488. */
  121489. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  121490. private _setButtonValue;
  121491. private _setDPadValue;
  121492. /**
  121493. * Gets the value of the `A` button
  121494. */
  121495. get buttonA(): number;
  121496. /**
  121497. * Sets the value of the `A` button
  121498. */
  121499. set buttonA(value: number);
  121500. /**
  121501. * Gets the value of the `B` button
  121502. */
  121503. get buttonB(): number;
  121504. /**
  121505. * Sets the value of the `B` button
  121506. */
  121507. set buttonB(value: number);
  121508. /**
  121509. * Gets the value of the `X` button
  121510. */
  121511. get buttonX(): number;
  121512. /**
  121513. * Sets the value of the `X` button
  121514. */
  121515. set buttonX(value: number);
  121516. /**
  121517. * Gets the value of the `Y` button
  121518. */
  121519. get buttonY(): number;
  121520. /**
  121521. * Sets the value of the `Y` button
  121522. */
  121523. set buttonY(value: number);
  121524. /**
  121525. * Gets the value of the `Start` button
  121526. */
  121527. get buttonStart(): number;
  121528. /**
  121529. * Sets the value of the `Start` button
  121530. */
  121531. set buttonStart(value: number);
  121532. /**
  121533. * Gets the value of the `Back` button
  121534. */
  121535. get buttonBack(): number;
  121536. /**
  121537. * Sets the value of the `Back` button
  121538. */
  121539. set buttonBack(value: number);
  121540. /**
  121541. * Gets the value of the `Left` button
  121542. */
  121543. get buttonLB(): number;
  121544. /**
  121545. * Sets the value of the `Left` button
  121546. */
  121547. set buttonLB(value: number);
  121548. /**
  121549. * Gets the value of the `Right` button
  121550. */
  121551. get buttonRB(): number;
  121552. /**
  121553. * Sets the value of the `Right` button
  121554. */
  121555. set buttonRB(value: number);
  121556. /**
  121557. * Gets the value of the Left joystick
  121558. */
  121559. get buttonLeftStick(): number;
  121560. /**
  121561. * Sets the value of the Left joystick
  121562. */
  121563. set buttonLeftStick(value: number);
  121564. /**
  121565. * Gets the value of the Right joystick
  121566. */
  121567. get buttonRightStick(): number;
  121568. /**
  121569. * Sets the value of the Right joystick
  121570. */
  121571. set buttonRightStick(value: number);
  121572. /**
  121573. * Gets the value of D-pad up
  121574. */
  121575. get dPadUp(): number;
  121576. /**
  121577. * Sets the value of D-pad up
  121578. */
  121579. set dPadUp(value: number);
  121580. /**
  121581. * Gets the value of D-pad down
  121582. */
  121583. get dPadDown(): number;
  121584. /**
  121585. * Sets the value of D-pad down
  121586. */
  121587. set dPadDown(value: number);
  121588. /**
  121589. * Gets the value of D-pad left
  121590. */
  121591. get dPadLeft(): number;
  121592. /**
  121593. * Sets the value of D-pad left
  121594. */
  121595. set dPadLeft(value: number);
  121596. /**
  121597. * Gets the value of D-pad right
  121598. */
  121599. get dPadRight(): number;
  121600. /**
  121601. * Sets the value of D-pad right
  121602. */
  121603. set dPadRight(value: number);
  121604. /**
  121605. * Force the gamepad to synchronize with device values
  121606. */
  121607. update(): void;
  121608. /**
  121609. * Disposes the gamepad
  121610. */
  121611. dispose(): void;
  121612. }
  121613. }
  121614. declare module BABYLON {
  121615. /**
  121616. * Defines supported buttons for DualShock compatible gamepads
  121617. */
  121618. export enum DualShockButton {
  121619. /** Cross */
  121620. Cross = 0,
  121621. /** Circle */
  121622. Circle = 1,
  121623. /** Square */
  121624. Square = 2,
  121625. /** Triangle */
  121626. Triangle = 3,
  121627. /** L1 */
  121628. L1 = 4,
  121629. /** R1 */
  121630. R1 = 5,
  121631. /** Share */
  121632. Share = 8,
  121633. /** Options */
  121634. Options = 9,
  121635. /** Left stick */
  121636. LeftStick = 10,
  121637. /** Right stick */
  121638. RightStick = 11
  121639. }
  121640. /** Defines values for DualShock DPad */
  121641. export enum DualShockDpad {
  121642. /** Up */
  121643. Up = 12,
  121644. /** Down */
  121645. Down = 13,
  121646. /** Left */
  121647. Left = 14,
  121648. /** Right */
  121649. Right = 15
  121650. }
  121651. /**
  121652. * Defines a DualShock gamepad
  121653. */
  121654. export class DualShockPad extends Gamepad {
  121655. private _leftTrigger;
  121656. private _rightTrigger;
  121657. private _onlefttriggerchanged;
  121658. private _onrighttriggerchanged;
  121659. private _onbuttondown;
  121660. private _onbuttonup;
  121661. private _ondpaddown;
  121662. private _ondpadup;
  121663. /** Observable raised when a button is pressed */
  121664. onButtonDownObservable: Observable<DualShockButton>;
  121665. /** Observable raised when a button is released */
  121666. onButtonUpObservable: Observable<DualShockButton>;
  121667. /** Observable raised when a pad is pressed */
  121668. onPadDownObservable: Observable<DualShockDpad>;
  121669. /** Observable raised when a pad is released */
  121670. onPadUpObservable: Observable<DualShockDpad>;
  121671. private _buttonCross;
  121672. private _buttonCircle;
  121673. private _buttonSquare;
  121674. private _buttonTriangle;
  121675. private _buttonShare;
  121676. private _buttonOptions;
  121677. private _buttonL1;
  121678. private _buttonR1;
  121679. private _buttonLeftStick;
  121680. private _buttonRightStick;
  121681. private _dPadUp;
  121682. private _dPadDown;
  121683. private _dPadLeft;
  121684. private _dPadRight;
  121685. /**
  121686. * Creates a new DualShock gamepad object
  121687. * @param id defines the id of this gamepad
  121688. * @param index defines its index
  121689. * @param gamepad defines the internal HTML gamepad object
  121690. */
  121691. constructor(id: string, index: number, gamepad: any);
  121692. /**
  121693. * Defines the callback to call when left trigger is pressed
  121694. * @param callback defines the callback to use
  121695. */
  121696. onlefttriggerchanged(callback: (value: number) => void): void;
  121697. /**
  121698. * Defines the callback to call when right trigger is pressed
  121699. * @param callback defines the callback to use
  121700. */
  121701. onrighttriggerchanged(callback: (value: number) => void): void;
  121702. /**
  121703. * Gets the left trigger value
  121704. */
  121705. get leftTrigger(): number;
  121706. /**
  121707. * Sets the left trigger value
  121708. */
  121709. set leftTrigger(newValue: number);
  121710. /**
  121711. * Gets the right trigger value
  121712. */
  121713. get rightTrigger(): number;
  121714. /**
  121715. * Sets the right trigger value
  121716. */
  121717. set rightTrigger(newValue: number);
  121718. /**
  121719. * Defines the callback to call when a button is pressed
  121720. * @param callback defines the callback to use
  121721. */
  121722. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  121723. /**
  121724. * Defines the callback to call when a button is released
  121725. * @param callback defines the callback to use
  121726. */
  121727. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  121728. /**
  121729. * Defines the callback to call when a pad is pressed
  121730. * @param callback defines the callback to use
  121731. */
  121732. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  121733. /**
  121734. * Defines the callback to call when a pad is released
  121735. * @param callback defines the callback to use
  121736. */
  121737. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  121738. private _setButtonValue;
  121739. private _setDPadValue;
  121740. /**
  121741. * Gets the value of the `Cross` button
  121742. */
  121743. get buttonCross(): number;
  121744. /**
  121745. * Sets the value of the `Cross` button
  121746. */
  121747. set buttonCross(value: number);
  121748. /**
  121749. * Gets the value of the `Circle` button
  121750. */
  121751. get buttonCircle(): number;
  121752. /**
  121753. * Sets the value of the `Circle` button
  121754. */
  121755. set buttonCircle(value: number);
  121756. /**
  121757. * Gets the value of the `Square` button
  121758. */
  121759. get buttonSquare(): number;
  121760. /**
  121761. * Sets the value of the `Square` button
  121762. */
  121763. set buttonSquare(value: number);
  121764. /**
  121765. * Gets the value of the `Triangle` button
  121766. */
  121767. get buttonTriangle(): number;
  121768. /**
  121769. * Sets the value of the `Triangle` button
  121770. */
  121771. set buttonTriangle(value: number);
  121772. /**
  121773. * Gets the value of the `Options` button
  121774. */
  121775. get buttonOptions(): number;
  121776. /**
  121777. * Sets the value of the `Options` button
  121778. */
  121779. set buttonOptions(value: number);
  121780. /**
  121781. * Gets the value of the `Share` button
  121782. */
  121783. get buttonShare(): number;
  121784. /**
  121785. * Sets the value of the `Share` button
  121786. */
  121787. set buttonShare(value: number);
  121788. /**
  121789. * Gets the value of the `L1` button
  121790. */
  121791. get buttonL1(): number;
  121792. /**
  121793. * Sets the value of the `L1` button
  121794. */
  121795. set buttonL1(value: number);
  121796. /**
  121797. * Gets the value of the `R1` button
  121798. */
  121799. get buttonR1(): number;
  121800. /**
  121801. * Sets the value of the `R1` button
  121802. */
  121803. set buttonR1(value: number);
  121804. /**
  121805. * Gets the value of the Left joystick
  121806. */
  121807. get buttonLeftStick(): number;
  121808. /**
  121809. * Sets the value of the Left joystick
  121810. */
  121811. set buttonLeftStick(value: number);
  121812. /**
  121813. * Gets the value of the Right joystick
  121814. */
  121815. get buttonRightStick(): number;
  121816. /**
  121817. * Sets the value of the Right joystick
  121818. */
  121819. set buttonRightStick(value: number);
  121820. /**
  121821. * Gets the value of D-pad up
  121822. */
  121823. get dPadUp(): number;
  121824. /**
  121825. * Sets the value of D-pad up
  121826. */
  121827. set dPadUp(value: number);
  121828. /**
  121829. * Gets the value of D-pad down
  121830. */
  121831. get dPadDown(): number;
  121832. /**
  121833. * Sets the value of D-pad down
  121834. */
  121835. set dPadDown(value: number);
  121836. /**
  121837. * Gets the value of D-pad left
  121838. */
  121839. get dPadLeft(): number;
  121840. /**
  121841. * Sets the value of D-pad left
  121842. */
  121843. set dPadLeft(value: number);
  121844. /**
  121845. * Gets the value of D-pad right
  121846. */
  121847. get dPadRight(): number;
  121848. /**
  121849. * Sets the value of D-pad right
  121850. */
  121851. set dPadRight(value: number);
  121852. /**
  121853. * Force the gamepad to synchronize with device values
  121854. */
  121855. update(): void;
  121856. /**
  121857. * Disposes the gamepad
  121858. */
  121859. dispose(): void;
  121860. }
  121861. }
  121862. declare module BABYLON {
  121863. /**
  121864. * Manager for handling gamepads
  121865. */
  121866. export class GamepadManager {
  121867. private _scene?;
  121868. private _babylonGamepads;
  121869. private _oneGamepadConnected;
  121870. /** @hidden */
  121871. _isMonitoring: boolean;
  121872. private _gamepadEventSupported;
  121873. private _gamepadSupport?;
  121874. /**
  121875. * observable to be triggered when the gamepad controller has been connected
  121876. */
  121877. onGamepadConnectedObservable: Observable<Gamepad>;
  121878. /**
  121879. * observable to be triggered when the gamepad controller has been disconnected
  121880. */
  121881. onGamepadDisconnectedObservable: Observable<Gamepad>;
  121882. private _onGamepadConnectedEvent;
  121883. private _onGamepadDisconnectedEvent;
  121884. /**
  121885. * Initializes the gamepad manager
  121886. * @param _scene BabylonJS scene
  121887. */
  121888. constructor(_scene?: Scene | undefined);
  121889. /**
  121890. * The gamepads in the game pad manager
  121891. */
  121892. get gamepads(): Gamepad[];
  121893. /**
  121894. * Get the gamepad controllers based on type
  121895. * @param type The type of gamepad controller
  121896. * @returns Nullable gamepad
  121897. */
  121898. getGamepadByType(type?: number): Nullable<Gamepad>;
  121899. /**
  121900. * Disposes the gamepad manager
  121901. */
  121902. dispose(): void;
  121903. private _addNewGamepad;
  121904. private _startMonitoringGamepads;
  121905. private _stopMonitoringGamepads;
  121906. /** @hidden */
  121907. _checkGamepadsStatus(): void;
  121908. private _updateGamepadObjects;
  121909. }
  121910. }
  121911. declare module BABYLON {
  121912. interface Scene {
  121913. /** @hidden */
  121914. _gamepadManager: Nullable<GamepadManager>;
  121915. /**
  121916. * Gets the gamepad manager associated with the scene
  121917. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  121918. */
  121919. gamepadManager: GamepadManager;
  121920. }
  121921. /**
  121922. * Interface representing a free camera inputs manager
  121923. */
  121924. interface FreeCameraInputsManager {
  121925. /**
  121926. * Adds gamepad input support to the FreeCameraInputsManager.
  121927. * @returns the FreeCameraInputsManager
  121928. */
  121929. addGamepad(): FreeCameraInputsManager;
  121930. }
  121931. /**
  121932. * Interface representing an arc rotate camera inputs manager
  121933. */
  121934. interface ArcRotateCameraInputsManager {
  121935. /**
  121936. * Adds gamepad input support to the ArcRotateCamera InputManager.
  121937. * @returns the camera inputs manager
  121938. */
  121939. addGamepad(): ArcRotateCameraInputsManager;
  121940. }
  121941. /**
  121942. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  121943. */
  121944. export class GamepadSystemSceneComponent implements ISceneComponent {
  121945. /**
  121946. * The component name helpfull to identify the component in the list of scene components.
  121947. */
  121948. readonly name: string;
  121949. /**
  121950. * The scene the component belongs to.
  121951. */
  121952. scene: Scene;
  121953. /**
  121954. * Creates a new instance of the component for the given scene
  121955. * @param scene Defines the scene to register the component in
  121956. */
  121957. constructor(scene: Scene);
  121958. /**
  121959. * Registers the component in a given scene
  121960. */
  121961. register(): void;
  121962. /**
  121963. * Rebuilds the elements related to this component in case of
  121964. * context lost for instance.
  121965. */
  121966. rebuild(): void;
  121967. /**
  121968. * Disposes the component and the associated ressources
  121969. */
  121970. dispose(): void;
  121971. private _beforeCameraUpdate;
  121972. }
  121973. }
  121974. declare module BABYLON {
  121975. /**
  121976. * 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,
  121977. * which still works and will still be found in many Playgrounds.
  121978. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121979. */
  121980. export class UniversalCamera extends TouchCamera {
  121981. /**
  121982. * Defines the gamepad rotation sensiblity.
  121983. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  121984. */
  121985. get gamepadAngularSensibility(): number;
  121986. set gamepadAngularSensibility(value: number);
  121987. /**
  121988. * Defines the gamepad move sensiblity.
  121989. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  121990. */
  121991. get gamepadMoveSensibility(): number;
  121992. set gamepadMoveSensibility(value: number);
  121993. /**
  121994. * 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,
  121995. * which still works and will still be found in many Playgrounds.
  121996. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121997. * @param name Define the name of the camera in the scene
  121998. * @param position Define the start position of the camera in the scene
  121999. * @param scene Define the scene the camera belongs to
  122000. */
  122001. constructor(name: string, position: Vector3, scene: Scene);
  122002. /**
  122003. * Gets the current object class name.
  122004. * @return the class name
  122005. */
  122006. getClassName(): string;
  122007. }
  122008. }
  122009. declare module BABYLON {
  122010. /**
  122011. * This represents a FPS type of camera. This is only here for back compat purpose.
  122012. * Please use the UniversalCamera instead as both are identical.
  122013. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122014. */
  122015. export class GamepadCamera extends UniversalCamera {
  122016. /**
  122017. * Instantiates a new Gamepad Camera
  122018. * This represents a FPS type of camera. This is only here for back compat purpose.
  122019. * Please use the UniversalCamera instead as both are identical.
  122020. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122021. * @param name Define the name of the camera in the scene
  122022. * @param position Define the start position of the camera in the scene
  122023. * @param scene Define the scene the camera belongs to
  122024. */
  122025. constructor(name: string, position: Vector3, scene: Scene);
  122026. /**
  122027. * Gets the current object class name.
  122028. * @return the class name
  122029. */
  122030. getClassName(): string;
  122031. }
  122032. }
  122033. declare module BABYLON {
  122034. /** @hidden */
  122035. export var passPixelShader: {
  122036. name: string;
  122037. shader: string;
  122038. };
  122039. }
  122040. declare module BABYLON {
  122041. /** @hidden */
  122042. export var passCubePixelShader: {
  122043. name: string;
  122044. shader: string;
  122045. };
  122046. }
  122047. declare module BABYLON {
  122048. /**
  122049. * PassPostProcess which produces an output the same as it's input
  122050. */
  122051. export class PassPostProcess extends PostProcess {
  122052. /**
  122053. * Creates the PassPostProcess
  122054. * @param name The name of the effect.
  122055. * @param options The required width/height ratio to downsize to before computing the render pass.
  122056. * @param camera The camera to apply the render pass to.
  122057. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122058. * @param engine The engine which the post process will be applied. (default: current engine)
  122059. * @param reusable If the post process can be reused on the same frame. (default: false)
  122060. * @param textureType The type of texture to be used when performing the post processing.
  122061. * @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)
  122062. */
  122063. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122064. }
  122065. /**
  122066. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  122067. */
  122068. export class PassCubePostProcess extends PostProcess {
  122069. private _face;
  122070. /**
  122071. * Gets or sets the cube face to display.
  122072. * * 0 is +X
  122073. * * 1 is -X
  122074. * * 2 is +Y
  122075. * * 3 is -Y
  122076. * * 4 is +Z
  122077. * * 5 is -Z
  122078. */
  122079. get face(): number;
  122080. set face(value: number);
  122081. /**
  122082. * Creates the PassCubePostProcess
  122083. * @param name The name of the effect.
  122084. * @param options The required width/height ratio to downsize to before computing the render pass.
  122085. * @param camera The camera to apply the render pass to.
  122086. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122087. * @param engine The engine which the post process will be applied. (default: current engine)
  122088. * @param reusable If the post process can be reused on the same frame. (default: false)
  122089. * @param textureType The type of texture to be used when performing the post processing.
  122090. * @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)
  122091. */
  122092. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122093. }
  122094. }
  122095. declare module BABYLON {
  122096. /** @hidden */
  122097. export var anaglyphPixelShader: {
  122098. name: string;
  122099. shader: string;
  122100. };
  122101. }
  122102. declare module BABYLON {
  122103. /**
  122104. * Postprocess used to generate anaglyphic rendering
  122105. */
  122106. export class AnaglyphPostProcess extends PostProcess {
  122107. private _passedProcess;
  122108. /**
  122109. * Creates a new AnaglyphPostProcess
  122110. * @param name defines postprocess name
  122111. * @param options defines creation options or target ratio scale
  122112. * @param rigCameras defines cameras using this postprocess
  122113. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  122114. * @param engine defines hosting engine
  122115. * @param reusable defines if the postprocess will be reused multiple times per frame
  122116. */
  122117. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  122118. }
  122119. }
  122120. declare module BABYLON {
  122121. /**
  122122. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  122123. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122124. */
  122125. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  122126. /**
  122127. * Creates a new AnaglyphArcRotateCamera
  122128. * @param name defines camera name
  122129. * @param alpha defines alpha angle (in radians)
  122130. * @param beta defines beta angle (in radians)
  122131. * @param radius defines radius
  122132. * @param target defines camera target
  122133. * @param interaxialDistance defines distance between each color axis
  122134. * @param scene defines the hosting scene
  122135. */
  122136. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  122137. /**
  122138. * Gets camera class name
  122139. * @returns AnaglyphArcRotateCamera
  122140. */
  122141. getClassName(): string;
  122142. }
  122143. }
  122144. declare module BABYLON {
  122145. /**
  122146. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  122147. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122148. */
  122149. export class AnaglyphFreeCamera extends FreeCamera {
  122150. /**
  122151. * Creates a new AnaglyphFreeCamera
  122152. * @param name defines camera name
  122153. * @param position defines initial position
  122154. * @param interaxialDistance defines distance between each color axis
  122155. * @param scene defines the hosting scene
  122156. */
  122157. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122158. /**
  122159. * Gets camera class name
  122160. * @returns AnaglyphFreeCamera
  122161. */
  122162. getClassName(): string;
  122163. }
  122164. }
  122165. declare module BABYLON {
  122166. /**
  122167. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  122168. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122169. */
  122170. export class AnaglyphGamepadCamera extends GamepadCamera {
  122171. /**
  122172. * Creates a new AnaglyphGamepadCamera
  122173. * @param name defines camera name
  122174. * @param position defines initial position
  122175. * @param interaxialDistance defines distance between each color axis
  122176. * @param scene defines the hosting scene
  122177. */
  122178. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122179. /**
  122180. * Gets camera class name
  122181. * @returns AnaglyphGamepadCamera
  122182. */
  122183. getClassName(): string;
  122184. }
  122185. }
  122186. declare module BABYLON {
  122187. /**
  122188. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  122189. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122190. */
  122191. export class AnaglyphUniversalCamera extends UniversalCamera {
  122192. /**
  122193. * Creates a new AnaglyphUniversalCamera
  122194. * @param name defines camera name
  122195. * @param position defines initial position
  122196. * @param interaxialDistance defines distance between each color axis
  122197. * @param scene defines the hosting scene
  122198. */
  122199. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122200. /**
  122201. * Gets camera class name
  122202. * @returns AnaglyphUniversalCamera
  122203. */
  122204. getClassName(): string;
  122205. }
  122206. }
  122207. declare module BABYLON {
  122208. /**
  122209. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  122210. * @see http://doc.babylonjs.com/features/cameras
  122211. */
  122212. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  122213. /**
  122214. * Creates a new StereoscopicArcRotateCamera
  122215. * @param name defines camera name
  122216. * @param alpha defines alpha angle (in radians)
  122217. * @param beta defines beta angle (in radians)
  122218. * @param radius defines radius
  122219. * @param target defines camera target
  122220. * @param interaxialDistance defines distance between each color axis
  122221. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122222. * @param scene defines the hosting scene
  122223. */
  122224. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122225. /**
  122226. * Gets camera class name
  122227. * @returns StereoscopicArcRotateCamera
  122228. */
  122229. getClassName(): string;
  122230. }
  122231. }
  122232. declare module BABYLON {
  122233. /**
  122234. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  122235. * @see http://doc.babylonjs.com/features/cameras
  122236. */
  122237. export class StereoscopicFreeCamera extends FreeCamera {
  122238. /**
  122239. * Creates a new StereoscopicFreeCamera
  122240. * @param name defines camera name
  122241. * @param position defines initial position
  122242. * @param interaxialDistance defines distance between each color axis
  122243. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122244. * @param scene defines the hosting scene
  122245. */
  122246. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122247. /**
  122248. * Gets camera class name
  122249. * @returns StereoscopicFreeCamera
  122250. */
  122251. getClassName(): string;
  122252. }
  122253. }
  122254. declare module BABYLON {
  122255. /**
  122256. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  122257. * @see http://doc.babylonjs.com/features/cameras
  122258. */
  122259. export class StereoscopicGamepadCamera extends GamepadCamera {
  122260. /**
  122261. * Creates a new StereoscopicGamepadCamera
  122262. * @param name defines camera name
  122263. * @param position defines initial position
  122264. * @param interaxialDistance defines distance between each color axis
  122265. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122266. * @param scene defines the hosting scene
  122267. */
  122268. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122269. /**
  122270. * Gets camera class name
  122271. * @returns StereoscopicGamepadCamera
  122272. */
  122273. getClassName(): string;
  122274. }
  122275. }
  122276. declare module BABYLON {
  122277. /**
  122278. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  122279. * @see http://doc.babylonjs.com/features/cameras
  122280. */
  122281. export class StereoscopicUniversalCamera extends UniversalCamera {
  122282. /**
  122283. * Creates a new StereoscopicUniversalCamera
  122284. * @param name defines camera name
  122285. * @param position defines initial position
  122286. * @param interaxialDistance defines distance between each color axis
  122287. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122288. * @param scene defines the hosting scene
  122289. */
  122290. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122291. /**
  122292. * Gets camera class name
  122293. * @returns StereoscopicUniversalCamera
  122294. */
  122295. getClassName(): string;
  122296. }
  122297. }
  122298. declare module BABYLON {
  122299. /**
  122300. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  122301. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  122302. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  122303. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  122304. */
  122305. export class VirtualJoysticksCamera extends FreeCamera {
  122306. /**
  122307. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  122308. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  122309. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  122310. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  122311. * @param name Define the name of the camera in the scene
  122312. * @param position Define the start position of the camera in the scene
  122313. * @param scene Define the scene the camera belongs to
  122314. */
  122315. constructor(name: string, position: Vector3, scene: Scene);
  122316. /**
  122317. * Gets the current object class name.
  122318. * @return the class name
  122319. */
  122320. getClassName(): string;
  122321. }
  122322. }
  122323. declare module BABYLON {
  122324. /**
  122325. * This represents all the required metrics to create a VR camera.
  122326. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  122327. */
  122328. export class VRCameraMetrics {
  122329. /**
  122330. * Define the horizontal resolution off the screen.
  122331. */
  122332. hResolution: number;
  122333. /**
  122334. * Define the vertical resolution off the screen.
  122335. */
  122336. vResolution: number;
  122337. /**
  122338. * Define the horizontal screen size.
  122339. */
  122340. hScreenSize: number;
  122341. /**
  122342. * Define the vertical screen size.
  122343. */
  122344. vScreenSize: number;
  122345. /**
  122346. * Define the vertical screen center position.
  122347. */
  122348. vScreenCenter: number;
  122349. /**
  122350. * Define the distance of the eyes to the screen.
  122351. */
  122352. eyeToScreenDistance: number;
  122353. /**
  122354. * Define the distance between both lenses
  122355. */
  122356. lensSeparationDistance: number;
  122357. /**
  122358. * Define the distance between both viewer's eyes.
  122359. */
  122360. interpupillaryDistance: number;
  122361. /**
  122362. * Define the distortion factor of the VR postprocess.
  122363. * Please, touch with care.
  122364. */
  122365. distortionK: number[];
  122366. /**
  122367. * Define the chromatic aberration correction factors for the VR post process.
  122368. */
  122369. chromaAbCorrection: number[];
  122370. /**
  122371. * Define the scale factor of the post process.
  122372. * The smaller the better but the slower.
  122373. */
  122374. postProcessScaleFactor: number;
  122375. /**
  122376. * Define an offset for the lens center.
  122377. */
  122378. lensCenterOffset: number;
  122379. /**
  122380. * Define if the current vr camera should compensate the distortion of the lense or not.
  122381. */
  122382. compensateDistortion: boolean;
  122383. /**
  122384. * Defines if multiview should be enabled when rendering (Default: false)
  122385. */
  122386. multiviewEnabled: boolean;
  122387. /**
  122388. * Gets the rendering aspect ratio based on the provided resolutions.
  122389. */
  122390. get aspectRatio(): number;
  122391. /**
  122392. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  122393. */
  122394. get aspectRatioFov(): number;
  122395. /**
  122396. * @hidden
  122397. */
  122398. get leftHMatrix(): Matrix;
  122399. /**
  122400. * @hidden
  122401. */
  122402. get rightHMatrix(): Matrix;
  122403. /**
  122404. * @hidden
  122405. */
  122406. get leftPreViewMatrix(): Matrix;
  122407. /**
  122408. * @hidden
  122409. */
  122410. get rightPreViewMatrix(): Matrix;
  122411. /**
  122412. * Get the default VRMetrics based on the most generic setup.
  122413. * @returns the default vr metrics
  122414. */
  122415. static GetDefault(): VRCameraMetrics;
  122416. }
  122417. }
  122418. declare module BABYLON {
  122419. /** @hidden */
  122420. export var vrDistortionCorrectionPixelShader: {
  122421. name: string;
  122422. shader: string;
  122423. };
  122424. }
  122425. declare module BABYLON {
  122426. /**
  122427. * VRDistortionCorrectionPostProcess used for mobile VR
  122428. */
  122429. export class VRDistortionCorrectionPostProcess extends PostProcess {
  122430. private _isRightEye;
  122431. private _distortionFactors;
  122432. private _postProcessScaleFactor;
  122433. private _lensCenterOffset;
  122434. private _scaleIn;
  122435. private _scaleFactor;
  122436. private _lensCenter;
  122437. /**
  122438. * Initializes the VRDistortionCorrectionPostProcess
  122439. * @param name The name of the effect.
  122440. * @param camera The camera to apply the render pass to.
  122441. * @param isRightEye If this is for the right eye distortion
  122442. * @param vrMetrics All the required metrics for the VR camera
  122443. */
  122444. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  122445. }
  122446. }
  122447. declare module BABYLON {
  122448. /**
  122449. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  122450. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  122451. */
  122452. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  122453. /**
  122454. * Creates a new VRDeviceOrientationArcRotateCamera
  122455. * @param name defines camera name
  122456. * @param alpha defines the camera rotation along the logitudinal axis
  122457. * @param beta defines the camera rotation along the latitudinal axis
  122458. * @param radius defines the camera distance from its target
  122459. * @param target defines the camera target
  122460. * @param scene defines the scene the camera belongs to
  122461. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  122462. * @param vrCameraMetrics defines the vr metrics associated to the camera
  122463. */
  122464. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  122465. /**
  122466. * Gets camera class name
  122467. * @returns VRDeviceOrientationArcRotateCamera
  122468. */
  122469. getClassName(): string;
  122470. }
  122471. }
  122472. declare module BABYLON {
  122473. /**
  122474. * Camera used to simulate VR rendering (based on FreeCamera)
  122475. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  122476. */
  122477. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  122478. /**
  122479. * Creates a new VRDeviceOrientationFreeCamera
  122480. * @param name defines camera name
  122481. * @param position defines the start position of the camera
  122482. * @param scene defines the scene the camera belongs to
  122483. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  122484. * @param vrCameraMetrics defines the vr metrics associated to the camera
  122485. */
  122486. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  122487. /**
  122488. * Gets camera class name
  122489. * @returns VRDeviceOrientationFreeCamera
  122490. */
  122491. getClassName(): string;
  122492. }
  122493. }
  122494. declare module BABYLON {
  122495. /**
  122496. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  122497. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  122498. */
  122499. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  122500. /**
  122501. * Creates a new VRDeviceOrientationGamepadCamera
  122502. * @param name defines camera name
  122503. * @param position defines the start position of the camera
  122504. * @param scene defines the scene the camera belongs to
  122505. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  122506. * @param vrCameraMetrics defines the vr metrics associated to the camera
  122507. */
  122508. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  122509. /**
  122510. * Gets camera class name
  122511. * @returns VRDeviceOrientationGamepadCamera
  122512. */
  122513. getClassName(): string;
  122514. }
  122515. }
  122516. declare module BABYLON {
  122517. /** @hidden */
  122518. export var imageProcessingPixelShader: {
  122519. name: string;
  122520. shader: string;
  122521. };
  122522. }
  122523. declare module BABYLON {
  122524. /**
  122525. * ImageProcessingPostProcess
  122526. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  122527. */
  122528. export class ImageProcessingPostProcess extends PostProcess {
  122529. /**
  122530. * Default configuration related to image processing available in the PBR Material.
  122531. */
  122532. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122533. /**
  122534. * Gets the image processing configuration used either in this material.
  122535. */
  122536. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  122537. /**
  122538. * Sets the Default image processing configuration used either in the this material.
  122539. *
  122540. * If sets to null, the scene one is in use.
  122541. */
  122542. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  122543. /**
  122544. * Keep track of the image processing observer to allow dispose and replace.
  122545. */
  122546. private _imageProcessingObserver;
  122547. /**
  122548. * Attaches a new image processing configuration to the PBR Material.
  122549. * @param configuration
  122550. */
  122551. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  122552. /**
  122553. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  122554. */
  122555. get colorCurves(): Nullable<ColorCurves>;
  122556. /**
  122557. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  122558. */
  122559. set colorCurves(value: Nullable<ColorCurves>);
  122560. /**
  122561. * Gets wether the color curves effect is enabled.
  122562. */
  122563. get colorCurvesEnabled(): boolean;
  122564. /**
  122565. * Sets wether the color curves effect is enabled.
  122566. */
  122567. set colorCurvesEnabled(value: boolean);
  122568. /**
  122569. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  122570. */
  122571. get colorGradingTexture(): Nullable<BaseTexture>;
  122572. /**
  122573. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  122574. */
  122575. set colorGradingTexture(value: Nullable<BaseTexture>);
  122576. /**
  122577. * Gets wether the color grading effect is enabled.
  122578. */
  122579. get colorGradingEnabled(): boolean;
  122580. /**
  122581. * Gets wether the color grading effect is enabled.
  122582. */
  122583. set colorGradingEnabled(value: boolean);
  122584. /**
  122585. * Gets exposure used in the effect.
  122586. */
  122587. get exposure(): number;
  122588. /**
  122589. * Sets exposure used in the effect.
  122590. */
  122591. set exposure(value: number);
  122592. /**
  122593. * Gets wether tonemapping is enabled or not.
  122594. */
  122595. get toneMappingEnabled(): boolean;
  122596. /**
  122597. * Sets wether tonemapping is enabled or not
  122598. */
  122599. set toneMappingEnabled(value: boolean);
  122600. /**
  122601. * Gets the type of tone mapping effect.
  122602. */
  122603. get toneMappingType(): number;
  122604. /**
  122605. * Sets the type of tone mapping effect.
  122606. */
  122607. set toneMappingType(value: number);
  122608. /**
  122609. * Gets contrast used in the effect.
  122610. */
  122611. get contrast(): number;
  122612. /**
  122613. * Sets contrast used in the effect.
  122614. */
  122615. set contrast(value: number);
  122616. /**
  122617. * Gets Vignette stretch size.
  122618. */
  122619. get vignetteStretch(): number;
  122620. /**
  122621. * Sets Vignette stretch size.
  122622. */
  122623. set vignetteStretch(value: number);
  122624. /**
  122625. * Gets Vignette centre X Offset.
  122626. */
  122627. get vignetteCentreX(): number;
  122628. /**
  122629. * Sets Vignette centre X Offset.
  122630. */
  122631. set vignetteCentreX(value: number);
  122632. /**
  122633. * Gets Vignette centre Y Offset.
  122634. */
  122635. get vignetteCentreY(): number;
  122636. /**
  122637. * Sets Vignette centre Y Offset.
  122638. */
  122639. set vignetteCentreY(value: number);
  122640. /**
  122641. * Gets Vignette weight or intensity of the vignette effect.
  122642. */
  122643. get vignetteWeight(): number;
  122644. /**
  122645. * Sets Vignette weight or intensity of the vignette effect.
  122646. */
  122647. set vignetteWeight(value: number);
  122648. /**
  122649. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  122650. * if vignetteEnabled is set to true.
  122651. */
  122652. get vignetteColor(): Color4;
  122653. /**
  122654. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  122655. * if vignetteEnabled is set to true.
  122656. */
  122657. set vignetteColor(value: Color4);
  122658. /**
  122659. * Gets Camera field of view used by the Vignette effect.
  122660. */
  122661. get vignetteCameraFov(): number;
  122662. /**
  122663. * Sets Camera field of view used by the Vignette effect.
  122664. */
  122665. set vignetteCameraFov(value: number);
  122666. /**
  122667. * Gets the vignette blend mode allowing different kind of effect.
  122668. */
  122669. get vignetteBlendMode(): number;
  122670. /**
  122671. * Sets the vignette blend mode allowing different kind of effect.
  122672. */
  122673. set vignetteBlendMode(value: number);
  122674. /**
  122675. * Gets wether the vignette effect is enabled.
  122676. */
  122677. get vignetteEnabled(): boolean;
  122678. /**
  122679. * Sets wether the vignette effect is enabled.
  122680. */
  122681. set vignetteEnabled(value: boolean);
  122682. private _fromLinearSpace;
  122683. /**
  122684. * Gets wether the input of the processing is in Gamma or Linear Space.
  122685. */
  122686. get fromLinearSpace(): boolean;
  122687. /**
  122688. * Sets wether the input of the processing is in Gamma or Linear Space.
  122689. */
  122690. set fromLinearSpace(value: boolean);
  122691. /**
  122692. * Defines cache preventing GC.
  122693. */
  122694. private _defines;
  122695. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  122696. /**
  122697. * "ImageProcessingPostProcess"
  122698. * @returns "ImageProcessingPostProcess"
  122699. */
  122700. getClassName(): string;
  122701. protected _updateParameters(): void;
  122702. dispose(camera?: Camera): void;
  122703. }
  122704. }
  122705. declare module BABYLON {
  122706. /**
  122707. * Class containing static functions to help procedurally build meshes
  122708. */
  122709. export class GroundBuilder {
  122710. /**
  122711. * Creates a ground mesh
  122712. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  122713. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  122714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122715. * @param name defines the name of the mesh
  122716. * @param options defines the options used to create the mesh
  122717. * @param scene defines the hosting scene
  122718. * @returns the ground mesh
  122719. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  122720. */
  122721. static CreateGround(name: string, options: {
  122722. width?: number;
  122723. height?: number;
  122724. subdivisions?: number;
  122725. subdivisionsX?: number;
  122726. subdivisionsY?: number;
  122727. updatable?: boolean;
  122728. }, scene: any): Mesh;
  122729. /**
  122730. * Creates a tiled ground mesh
  122731. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  122732. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  122733. * * 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
  122734. * * 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
  122735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122736. * @param name defines the name of the mesh
  122737. * @param options defines the options used to create the mesh
  122738. * @param scene defines the hosting scene
  122739. * @returns the tiled ground mesh
  122740. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  122741. */
  122742. static CreateTiledGround(name: string, options: {
  122743. xmin: number;
  122744. zmin: number;
  122745. xmax: number;
  122746. zmax: number;
  122747. subdivisions?: {
  122748. w: number;
  122749. h: number;
  122750. };
  122751. precision?: {
  122752. w: number;
  122753. h: number;
  122754. };
  122755. updatable?: boolean;
  122756. }, scene?: Nullable<Scene>): Mesh;
  122757. /**
  122758. * Creates a ground mesh from a height map
  122759. * * The parameter `url` sets the URL of the height map image resource.
  122760. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  122761. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  122762. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  122763. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  122764. * * 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.
  122765. * * 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).
  122766. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  122767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122768. * @param name defines the name of the mesh
  122769. * @param url defines the url to the height map
  122770. * @param options defines the options used to create the mesh
  122771. * @param scene defines the hosting scene
  122772. * @returns the ground mesh
  122773. * @see https://doc.babylonjs.com/babylon101/height_map
  122774. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  122775. */
  122776. static CreateGroundFromHeightMap(name: string, url: string, options: {
  122777. width?: number;
  122778. height?: number;
  122779. subdivisions?: number;
  122780. minHeight?: number;
  122781. maxHeight?: number;
  122782. colorFilter?: Color3;
  122783. alphaFilter?: number;
  122784. updatable?: boolean;
  122785. onReady?: (mesh: GroundMesh) => void;
  122786. }, scene?: Nullable<Scene>): GroundMesh;
  122787. }
  122788. }
  122789. declare module BABYLON {
  122790. /**
  122791. * Class containing static functions to help procedurally build meshes
  122792. */
  122793. export class TorusBuilder {
  122794. /**
  122795. * Creates a torus mesh
  122796. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  122797. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  122798. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  122799. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122800. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122802. * @param name defines the name of the mesh
  122803. * @param options defines the options used to create the mesh
  122804. * @param scene defines the hosting scene
  122805. * @returns the torus mesh
  122806. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  122807. */
  122808. static CreateTorus(name: string, options: {
  122809. diameter?: number;
  122810. thickness?: number;
  122811. tessellation?: number;
  122812. updatable?: boolean;
  122813. sideOrientation?: number;
  122814. frontUVs?: Vector4;
  122815. backUVs?: Vector4;
  122816. }, scene: any): Mesh;
  122817. }
  122818. }
  122819. declare module BABYLON {
  122820. /**
  122821. * Class containing static functions to help procedurally build meshes
  122822. */
  122823. export class CylinderBuilder {
  122824. /**
  122825. * Creates a cylinder or a cone mesh
  122826. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  122827. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  122828. * * 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.
  122829. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  122830. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  122831. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  122832. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  122833. * * 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).
  122834. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  122835. * * 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).
  122836. * * 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
  122837. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  122838. * * 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
  122839. * * 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.
  122840. * * If `enclose` is false, a ring surface is one element.
  122841. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  122842. * * 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
  122843. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122844. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122846. * @param name defines the name of the mesh
  122847. * @param options defines the options used to create the mesh
  122848. * @param scene defines the hosting scene
  122849. * @returns the cylinder mesh
  122850. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  122851. */
  122852. static CreateCylinder(name: string, options: {
  122853. height?: number;
  122854. diameterTop?: number;
  122855. diameterBottom?: number;
  122856. diameter?: number;
  122857. tessellation?: number;
  122858. subdivisions?: number;
  122859. arc?: number;
  122860. faceColors?: Color4[];
  122861. faceUV?: Vector4[];
  122862. updatable?: boolean;
  122863. hasRings?: boolean;
  122864. enclose?: boolean;
  122865. cap?: number;
  122866. sideOrientation?: number;
  122867. frontUVs?: Vector4;
  122868. backUVs?: Vector4;
  122869. }, scene: any): Mesh;
  122870. }
  122871. }
  122872. declare module BABYLON {
  122873. /**
  122874. * States of the webXR experience
  122875. */
  122876. export enum WebXRState {
  122877. /**
  122878. * Transitioning to being in XR mode
  122879. */
  122880. ENTERING_XR = 0,
  122881. /**
  122882. * Transitioning to non XR mode
  122883. */
  122884. EXITING_XR = 1,
  122885. /**
  122886. * In XR mode and presenting
  122887. */
  122888. IN_XR = 2,
  122889. /**
  122890. * Not entered XR mode
  122891. */
  122892. NOT_IN_XR = 3
  122893. }
  122894. /**
  122895. * Abstraction of the XR render target
  122896. */
  122897. export interface WebXRRenderTarget extends IDisposable {
  122898. /**
  122899. * xrpresent context of the canvas which can be used to display/mirror xr content
  122900. */
  122901. canvasContext: WebGLRenderingContext;
  122902. /**
  122903. * xr layer for the canvas
  122904. */
  122905. xrLayer: Nullable<XRWebGLLayer>;
  122906. /**
  122907. * Initializes the xr layer for the session
  122908. * @param xrSession xr session
  122909. * @returns a promise that will resolve once the XR Layer has been created
  122910. */
  122911. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  122912. }
  122913. }
  122914. declare module BABYLON {
  122915. /**
  122916. * COnfiguration object for WebXR output canvas
  122917. */
  122918. export class WebXRManagedOutputCanvasOptions {
  122919. /**
  122920. * An optional canvas in case you wish to create it yourself and provide it here.
  122921. * If not provided, a new canvas will be created
  122922. */
  122923. canvasElement?: HTMLCanvasElement;
  122924. /**
  122925. * Options for this XR Layer output
  122926. */
  122927. canvasOptions?: XRWebGLLayerOptions;
  122928. /**
  122929. * CSS styling for a newly created canvas (if not provided)
  122930. */
  122931. newCanvasCssStyle?: string;
  122932. /**
  122933. * Get the default values of the configuration object
  122934. * @returns default values of this configuration object
  122935. */
  122936. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  122937. }
  122938. /**
  122939. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  122940. */
  122941. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  122942. private _options;
  122943. private _canvas;
  122944. private _engine;
  122945. /**
  122946. * Rendering context of the canvas which can be used to display/mirror xr content
  122947. */
  122948. canvasContext: WebGLRenderingContext;
  122949. /**
  122950. * xr layer for the canvas
  122951. */
  122952. xrLayer: Nullable<XRWebGLLayer>;
  122953. /**
  122954. * Initializes the canvas to be added/removed upon entering/exiting xr
  122955. * @param _xrSessionManager The XR Session manager
  122956. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  122957. */
  122958. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  122959. /**
  122960. * Disposes of the object
  122961. */
  122962. dispose(): void;
  122963. /**
  122964. * Initializes the xr layer for the session
  122965. * @param xrSession xr session
  122966. * @returns a promise that will resolve once the XR Layer has been created
  122967. */
  122968. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  122969. private _addCanvas;
  122970. private _removeCanvas;
  122971. private _setManagedOutputCanvas;
  122972. }
  122973. }
  122974. declare module BABYLON {
  122975. /**
  122976. * Manages an XRSession to work with Babylon's engine
  122977. * @see https://doc.babylonjs.com/how_to/webxr
  122978. */
  122979. export class WebXRSessionManager implements IDisposable {
  122980. /** The scene which the session should be created for */
  122981. scene: Scene;
  122982. private _referenceSpace;
  122983. private _rttProvider;
  122984. private _sessionEnded;
  122985. private _xrNavigator;
  122986. private baseLayer;
  122987. /**
  122988. * The base reference space from which the session started. good if you want to reset your
  122989. * reference space
  122990. */
  122991. baseReferenceSpace: XRReferenceSpace;
  122992. /**
  122993. * Current XR frame
  122994. */
  122995. currentFrame: Nullable<XRFrame>;
  122996. /** WebXR timestamp updated every frame */
  122997. currentTimestamp: number;
  122998. /**
  122999. * Used just in case of a failure to initialize an immersive session.
  123000. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  123001. */
  123002. defaultHeightCompensation: number;
  123003. /**
  123004. * Fires every time a new xrFrame arrives which can be used to update the camera
  123005. */
  123006. onXRFrameObservable: Observable<XRFrame>;
  123007. /**
  123008. * Fires when the reference space changed
  123009. */
  123010. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  123011. /**
  123012. * Fires when the xr session is ended either by the device or manually done
  123013. */
  123014. onXRSessionEnded: Observable<any>;
  123015. /**
  123016. * Fires when the xr session is ended either by the device or manually done
  123017. */
  123018. onXRSessionInit: Observable<XRSession>;
  123019. /**
  123020. * Underlying xr session
  123021. */
  123022. session: XRSession;
  123023. /**
  123024. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  123025. * or get the offset the player is currently at.
  123026. */
  123027. viewerReferenceSpace: XRReferenceSpace;
  123028. /**
  123029. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  123030. * @param scene The scene which the session should be created for
  123031. */
  123032. constructor(
  123033. /** The scene which the session should be created for */
  123034. scene: Scene);
  123035. /**
  123036. * The current reference space used in this session. This reference space can constantly change!
  123037. * It is mainly used to offset the camera's position.
  123038. */
  123039. get referenceSpace(): XRReferenceSpace;
  123040. /**
  123041. * Set a new reference space and triggers the observable
  123042. */
  123043. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  123044. /**
  123045. * Disposes of the session manager
  123046. */
  123047. dispose(): void;
  123048. /**
  123049. * Stops the xrSession and restores the render loop
  123050. * @returns Promise which resolves after it exits XR
  123051. */
  123052. exitXRAsync(): Promise<void>;
  123053. /**
  123054. * Gets the correct render target texture to be rendered this frame for this eye
  123055. * @param eye the eye for which to get the render target
  123056. * @returns the render target for the specified eye
  123057. */
  123058. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  123059. /**
  123060. * Creates a WebXRRenderTarget object for the XR session
  123061. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  123062. * @param options optional options to provide when creating a new render target
  123063. * @returns a WebXR render target to which the session can render
  123064. */
  123065. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  123066. /**
  123067. * Initializes the manager
  123068. * After initialization enterXR can be called to start an XR session
  123069. * @returns Promise which resolves after it is initialized
  123070. */
  123071. initializeAsync(): Promise<void>;
  123072. /**
  123073. * Initializes an xr session
  123074. * @param xrSessionMode mode to initialize
  123075. * @param xrSessionInit defines optional and required values to pass to the session builder
  123076. * @returns a promise which will resolve once the session has been initialized
  123077. */
  123078. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  123079. /**
  123080. * Checks if a session would be supported for the creation options specified
  123081. * @param sessionMode session mode to check if supported eg. immersive-vr
  123082. * @returns A Promise that resolves to true if supported and false if not
  123083. */
  123084. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  123085. /**
  123086. * Resets the reference space to the one started the session
  123087. */
  123088. resetReferenceSpace(): void;
  123089. /**
  123090. * Starts rendering to the xr layer
  123091. */
  123092. runXRRenderLoop(): void;
  123093. /**
  123094. * Sets the reference space on the xr session
  123095. * @param referenceSpaceType space to set
  123096. * @returns a promise that will resolve once the reference space has been set
  123097. */
  123098. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  123099. /**
  123100. * Updates the render state of the session
  123101. * @param state state to set
  123102. * @returns a promise that resolves once the render state has been updated
  123103. */
  123104. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  123105. /**
  123106. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  123107. * @param sessionMode defines the session to test
  123108. * @returns a promise with boolean as final value
  123109. */
  123110. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  123111. private _createRenderTargetTexture;
  123112. }
  123113. }
  123114. declare module BABYLON {
  123115. /**
  123116. * WebXR Camera which holds the views for the xrSession
  123117. * @see https://doc.babylonjs.com/how_to/webxr_camera
  123118. */
  123119. export class WebXRCamera extends FreeCamera {
  123120. private _xrSessionManager;
  123121. private _firstFrame;
  123122. private _referenceQuaternion;
  123123. private _referencedPosition;
  123124. private _xrInvPositionCache;
  123125. private _xrInvQuaternionCache;
  123126. /**
  123127. * Should position compensation execute on first frame.
  123128. * This is used when copying the position from a native (non XR) camera
  123129. */
  123130. compensateOnFirstFrame: boolean;
  123131. /**
  123132. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  123133. * @param name the name of the camera
  123134. * @param scene the scene to add the camera to
  123135. * @param _xrSessionManager a constructed xr session manager
  123136. */
  123137. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  123138. /**
  123139. * Return the user's height, unrelated to the current ground.
  123140. * This will be the y position of this camera, when ground level is 0.
  123141. */
  123142. get realWorldHeight(): number;
  123143. /** @hidden */
  123144. _updateForDualEyeDebugging(): void;
  123145. /**
  123146. * Sets this camera's transformation based on a non-vr camera
  123147. * @param otherCamera the non-vr camera to copy the transformation from
  123148. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  123149. */
  123150. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  123151. /**
  123152. * Gets the current instance class name ("WebXRCamera").
  123153. * @returns the class name
  123154. */
  123155. getClassName(): string;
  123156. /**
  123157. * Overriding the _getViewMatrix function, as it is computed by WebXR
  123158. */
  123159. _getViewMatrix(): Matrix;
  123160. private _updateFromXRSession;
  123161. private _updateNumberOfRigCameras;
  123162. private _updateReferenceSpace;
  123163. private _updateReferenceSpaceOffset;
  123164. }
  123165. }
  123166. declare module BABYLON {
  123167. /**
  123168. * Defining the interface required for a (webxr) feature
  123169. */
  123170. export interface IWebXRFeature extends IDisposable {
  123171. /**
  123172. * Is this feature attached
  123173. */
  123174. attached: boolean;
  123175. /**
  123176. * Should auto-attach be disabled?
  123177. */
  123178. disableAutoAttach: boolean;
  123179. /**
  123180. * Attach the feature to the session
  123181. * Will usually be called by the features manager
  123182. *
  123183. * @param force should attachment be forced (even when already attached)
  123184. * @returns true if successful.
  123185. */
  123186. attach(force?: boolean): boolean;
  123187. /**
  123188. * Detach the feature from the session
  123189. * Will usually be called by the features manager
  123190. *
  123191. * @returns true if successful.
  123192. */
  123193. detach(): boolean;
  123194. }
  123195. /**
  123196. * A list of the currently available features without referencing them
  123197. */
  123198. export class WebXRFeatureName {
  123199. /**
  123200. * The name of the anchor system feature
  123201. */
  123202. static ANCHOR_SYSTEM: string;
  123203. /**
  123204. * The name of the background remover feature
  123205. */
  123206. static BACKGROUND_REMOVER: string;
  123207. /**
  123208. * The name of the hit test feature
  123209. */
  123210. static HIT_TEST: string;
  123211. /**
  123212. * physics impostors for xr controllers feature
  123213. */
  123214. static PHYSICS_CONTROLLERS: string;
  123215. /**
  123216. * The name of the plane detection feature
  123217. */
  123218. static PLANE_DETECTION: string;
  123219. /**
  123220. * The name of the pointer selection feature
  123221. */
  123222. static POINTER_SELECTION: string;
  123223. /**
  123224. * The name of the teleportation feature
  123225. */
  123226. static TELEPORTATION: string;
  123227. }
  123228. /**
  123229. * Defining the constructor of a feature. Used to register the modules.
  123230. */
  123231. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  123232. /**
  123233. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  123234. * It is mainly used in AR sessions.
  123235. *
  123236. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  123237. */
  123238. export class WebXRFeaturesManager implements IDisposable {
  123239. private _xrSessionManager;
  123240. private static readonly _AvailableFeatures;
  123241. private _features;
  123242. /**
  123243. * constructs a new features manages.
  123244. *
  123245. * @param _xrSessionManager an instance of WebXRSessionManager
  123246. */
  123247. constructor(_xrSessionManager: WebXRSessionManager);
  123248. /**
  123249. * Used to register a module. After calling this function a developer can use this feature in the scene.
  123250. * Mainly used internally.
  123251. *
  123252. * @param featureName the name of the feature to register
  123253. * @param constructorFunction the function used to construct the module
  123254. * @param version the (babylon) version of the module
  123255. * @param stable is that a stable version of this module
  123256. */
  123257. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  123258. /**
  123259. * Returns a constructor of a specific feature.
  123260. *
  123261. * @param featureName the name of the feature to construct
  123262. * @param version the version of the feature to load
  123263. * @param xrSessionManager the xrSessionManager. Used to construct the module
  123264. * @param options optional options provided to the module.
  123265. * @returns a function that, when called, will return a new instance of this feature
  123266. */
  123267. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  123268. /**
  123269. * Can be used to return the list of features currently registered
  123270. *
  123271. * @returns an Array of available features
  123272. */
  123273. static GetAvailableFeatures(): string[];
  123274. /**
  123275. * Gets the versions available for a specific feature
  123276. * @param featureName the name of the feature
  123277. * @returns an array with the available versions
  123278. */
  123279. static GetAvailableVersions(featureName: string): string[];
  123280. /**
  123281. * Return the latest unstable version of this feature
  123282. * @param featureName the name of the feature to search
  123283. * @returns the version number. if not found will return -1
  123284. */
  123285. static GetLatestVersionOfFeature(featureName: string): number;
  123286. /**
  123287. * Return the latest stable version of this feature
  123288. * @param featureName the name of the feature to search
  123289. * @returns the version number. if not found will return -1
  123290. */
  123291. static GetStableVersionOfFeature(featureName: string): number;
  123292. /**
  123293. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  123294. * Can be used during a session to start a feature
  123295. * @param featureName the name of feature to attach
  123296. */
  123297. attachFeature(featureName: string): void;
  123298. /**
  123299. * Can be used inside a session or when the session ends to detach a specific feature
  123300. * @param featureName the name of the feature to detach
  123301. */
  123302. detachFeature(featureName: string): void;
  123303. /**
  123304. * Used to disable an already-enabled feature
  123305. * The feature will be disposed and will be recreated once enabled.
  123306. * @param featureName the feature to disable
  123307. * @returns true if disable was successful
  123308. */
  123309. disableFeature(featureName: string | {
  123310. Name: string;
  123311. }): boolean;
  123312. /**
  123313. * dispose this features manager
  123314. */
  123315. dispose(): void;
  123316. /**
  123317. * 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.
  123318. * 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.
  123319. *
  123320. * @param featureName the name of the feature to load or the class of the feature
  123321. * @param version optional version to load. if not provided the latest version will be enabled
  123322. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  123323. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  123324. * @returns a new constructed feature or throws an error if feature not found.
  123325. */
  123326. enableFeature(featureName: string | {
  123327. Name: string;
  123328. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  123329. /**
  123330. * get the implementation of an enabled feature.
  123331. * @param featureName the name of the feature to load
  123332. * @returns the feature class, if found
  123333. */
  123334. getEnabledFeature(featureName: string): IWebXRFeature;
  123335. /**
  123336. * Get the list of enabled features
  123337. * @returns an array of enabled features
  123338. */
  123339. getEnabledFeatures(): string[];
  123340. }
  123341. }
  123342. declare module BABYLON {
  123343. /**
  123344. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  123345. * @see https://doc.babylonjs.com/how_to/webxr
  123346. */
  123347. export class WebXRExperienceHelper implements IDisposable {
  123348. private scene;
  123349. private _nonVRCamera;
  123350. private _originalSceneAutoClear;
  123351. private _supported;
  123352. /**
  123353. * Camera used to render xr content
  123354. */
  123355. camera: WebXRCamera;
  123356. /** A features manager for this xr session */
  123357. featuresManager: WebXRFeaturesManager;
  123358. /**
  123359. * Observers registered here will be triggered after the camera's initial transformation is set
  123360. * This can be used to set a different ground level or an extra rotation.
  123361. *
  123362. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  123363. * to the position set after this observable is done executing.
  123364. */
  123365. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  123366. /**
  123367. * Fires when the state of the experience helper has changed
  123368. */
  123369. onStateChangedObservable: Observable<WebXRState>;
  123370. /** Session manager used to keep track of xr session */
  123371. sessionManager: WebXRSessionManager;
  123372. /**
  123373. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  123374. */
  123375. state: WebXRState;
  123376. /**
  123377. * Creates a WebXRExperienceHelper
  123378. * @param scene The scene the helper should be created in
  123379. */
  123380. private constructor();
  123381. /**
  123382. * Creates the experience helper
  123383. * @param scene the scene to attach the experience helper to
  123384. * @returns a promise for the experience helper
  123385. */
  123386. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  123387. /**
  123388. * Disposes of the experience helper
  123389. */
  123390. dispose(): void;
  123391. /**
  123392. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  123393. * @param sessionMode options for the XR session
  123394. * @param referenceSpaceType frame of reference of the XR session
  123395. * @param renderTarget the output canvas that will be used to enter XR mode
  123396. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  123397. * @returns promise that resolves after xr mode has entered
  123398. */
  123399. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  123400. /**
  123401. * Exits XR mode and returns the scene to its original state
  123402. * @returns promise that resolves after xr mode has exited
  123403. */
  123404. exitXRAsync(): Promise<void>;
  123405. private _nonXRToXRCamera;
  123406. private _setState;
  123407. }
  123408. }
  123409. declare module BABYLON {
  123410. /**
  123411. * X-Y values for axes in WebXR
  123412. */
  123413. export interface IWebXRMotionControllerAxesValue {
  123414. /**
  123415. * The value of the x axis
  123416. */
  123417. x: number;
  123418. /**
  123419. * The value of the y-axis
  123420. */
  123421. y: number;
  123422. }
  123423. /**
  123424. * changed / previous values for the values of this component
  123425. */
  123426. export interface IWebXRMotionControllerComponentChangesValues<T> {
  123427. /**
  123428. * current (this frame) value
  123429. */
  123430. current: T;
  123431. /**
  123432. * previous (last change) value
  123433. */
  123434. previous: T;
  123435. }
  123436. /**
  123437. * Represents changes in the component between current frame and last values recorded
  123438. */
  123439. export interface IWebXRMotionControllerComponentChanges {
  123440. /**
  123441. * will be populated with previous and current values if axes changed
  123442. */
  123443. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  123444. /**
  123445. * will be populated with previous and current values if pressed changed
  123446. */
  123447. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  123448. /**
  123449. * will be populated with previous and current values if touched changed
  123450. */
  123451. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  123452. /**
  123453. * will be populated with previous and current values if value changed
  123454. */
  123455. value?: IWebXRMotionControllerComponentChangesValues<number>;
  123456. }
  123457. /**
  123458. * This class represents a single component (for example button or thumbstick) of a motion controller
  123459. */
  123460. export class WebXRControllerComponent implements IDisposable {
  123461. /**
  123462. * the id of this component
  123463. */
  123464. id: string;
  123465. /**
  123466. * the type of the component
  123467. */
  123468. type: MotionControllerComponentType;
  123469. private _buttonIndex;
  123470. private _axesIndices;
  123471. private _axes;
  123472. private _changes;
  123473. private _currentValue;
  123474. private _hasChanges;
  123475. private _pressed;
  123476. private _touched;
  123477. /**
  123478. * button component type
  123479. */
  123480. static BUTTON_TYPE: MotionControllerComponentType;
  123481. /**
  123482. * squeeze component type
  123483. */
  123484. static SQUEEZE_TYPE: MotionControllerComponentType;
  123485. /**
  123486. * Thumbstick component type
  123487. */
  123488. static THUMBSTICK_TYPE: MotionControllerComponentType;
  123489. /**
  123490. * Touchpad component type
  123491. */
  123492. static TOUCHPAD_TYPE: MotionControllerComponentType;
  123493. /**
  123494. * trigger component type
  123495. */
  123496. static TRIGGER_TYPE: MotionControllerComponentType;
  123497. /**
  123498. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  123499. * the axes data changes
  123500. */
  123501. onAxisValueChangedObservable: Observable<{
  123502. x: number;
  123503. y: number;
  123504. }>;
  123505. /**
  123506. * Observers registered here will be triggered when the state of a button changes
  123507. * State change is either pressed / touched / value
  123508. */
  123509. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  123510. /**
  123511. * Creates a new component for a motion controller.
  123512. * It is created by the motion controller itself
  123513. *
  123514. * @param id the id of this component
  123515. * @param type the type of the component
  123516. * @param _buttonIndex index in the buttons array of the gamepad
  123517. * @param _axesIndices indices of the values in the axes array of the gamepad
  123518. */
  123519. constructor(
  123520. /**
  123521. * the id of this component
  123522. */
  123523. id: string,
  123524. /**
  123525. * the type of the component
  123526. */
  123527. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  123528. /**
  123529. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  123530. */
  123531. get axes(): IWebXRMotionControllerAxesValue;
  123532. /**
  123533. * Get the changes. Elements will be populated only if they changed with their previous and current value
  123534. */
  123535. get changes(): IWebXRMotionControllerComponentChanges;
  123536. /**
  123537. * Return whether or not the component changed the last frame
  123538. */
  123539. get hasChanges(): boolean;
  123540. /**
  123541. * is the button currently pressed
  123542. */
  123543. get pressed(): boolean;
  123544. /**
  123545. * is the button currently touched
  123546. */
  123547. get touched(): boolean;
  123548. /**
  123549. * Get the current value of this component
  123550. */
  123551. get value(): number;
  123552. /**
  123553. * Dispose this component
  123554. */
  123555. dispose(): void;
  123556. /**
  123557. * Are there axes correlating to this component
  123558. * @return true is axes data is available
  123559. */
  123560. isAxes(): boolean;
  123561. /**
  123562. * Is this component a button (hence - pressable)
  123563. * @returns true if can be pressed
  123564. */
  123565. isButton(): boolean;
  123566. /**
  123567. * update this component using the gamepad object it is in. Called on every frame
  123568. * @param nativeController the native gamepad controller object
  123569. */
  123570. update(nativeController: IMinimalMotionControllerObject): void;
  123571. }
  123572. }
  123573. declare module BABYLON {
  123574. /**
  123575. * Class used to represent data loading progression
  123576. */
  123577. export class SceneLoaderProgressEvent {
  123578. /** defines if data length to load can be evaluated */
  123579. readonly lengthComputable: boolean;
  123580. /** defines the loaded data length */
  123581. readonly loaded: number;
  123582. /** defines the data length to load */
  123583. readonly total: number;
  123584. /**
  123585. * Create a new progress event
  123586. * @param lengthComputable defines if data length to load can be evaluated
  123587. * @param loaded defines the loaded data length
  123588. * @param total defines the data length to load
  123589. */
  123590. constructor(
  123591. /** defines if data length to load can be evaluated */
  123592. lengthComputable: boolean,
  123593. /** defines the loaded data length */
  123594. loaded: number,
  123595. /** defines the data length to load */
  123596. total: number);
  123597. /**
  123598. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  123599. * @param event defines the source event
  123600. * @returns a new SceneLoaderProgressEvent
  123601. */
  123602. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  123603. }
  123604. /**
  123605. * Interface used by SceneLoader plugins to define supported file extensions
  123606. */
  123607. export interface ISceneLoaderPluginExtensions {
  123608. /**
  123609. * Defines the list of supported extensions
  123610. */
  123611. [extension: string]: {
  123612. isBinary: boolean;
  123613. };
  123614. }
  123615. /**
  123616. * Interface used by SceneLoader plugin factory
  123617. */
  123618. export interface ISceneLoaderPluginFactory {
  123619. /**
  123620. * Defines the name of the factory
  123621. */
  123622. name: string;
  123623. /**
  123624. * Function called to create a new plugin
  123625. * @return the new plugin
  123626. */
  123627. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  123628. /**
  123629. * The callback that returns true if the data can be directly loaded.
  123630. * @param data string containing the file data
  123631. * @returns if the data can be loaded directly
  123632. */
  123633. canDirectLoad?(data: string): boolean;
  123634. }
  123635. /**
  123636. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  123637. */
  123638. export interface ISceneLoaderPluginBase {
  123639. /**
  123640. * The friendly name of this plugin.
  123641. */
  123642. name: string;
  123643. /**
  123644. * The file extensions supported by this plugin.
  123645. */
  123646. extensions: string | ISceneLoaderPluginExtensions;
  123647. /**
  123648. * The callback called when loading from a url.
  123649. * @param scene scene loading this url
  123650. * @param url url to load
  123651. * @param onSuccess callback called when the file successfully loads
  123652. * @param onProgress callback called while file is loading (if the server supports this mode)
  123653. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  123654. * @param onError callback called when the file fails to load
  123655. * @returns a file request object
  123656. */
  123657. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  123658. /**
  123659. * The callback called when loading from a file object.
  123660. * @param scene scene loading this file
  123661. * @param file defines the file to load
  123662. * @param onSuccess defines the callback to call when data is loaded
  123663. * @param onProgress defines the callback to call during loading process
  123664. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  123665. * @param onError defines the callback to call when an error occurs
  123666. * @returns a file request object
  123667. */
  123668. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  123669. /**
  123670. * The callback that returns true if the data can be directly loaded.
  123671. * @param data string containing the file data
  123672. * @returns if the data can be loaded directly
  123673. */
  123674. canDirectLoad?(data: string): boolean;
  123675. /**
  123676. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  123677. * @param scene scene loading this data
  123678. * @param data string containing the data
  123679. * @returns data to pass to the plugin
  123680. */
  123681. directLoad?(scene: Scene, data: string): any;
  123682. /**
  123683. * The callback that allows custom handling of the root url based on the response url.
  123684. * @param rootUrl the original root url
  123685. * @param responseURL the response url if available
  123686. * @returns the new root url
  123687. */
  123688. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  123689. }
  123690. /**
  123691. * Interface used to define a SceneLoader plugin
  123692. */
  123693. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  123694. /**
  123695. * Import meshes into a scene.
  123696. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  123697. * @param scene The scene to import into
  123698. * @param data The data to import
  123699. * @param rootUrl The root url for scene and resources
  123700. * @param meshes The meshes array to import into
  123701. * @param particleSystems The particle systems array to import into
  123702. * @param skeletons The skeletons array to import into
  123703. * @param onError The callback when import fails
  123704. * @returns True if successful or false otherwise
  123705. */
  123706. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  123707. /**
  123708. * Load into a scene.
  123709. * @param scene The scene to load into
  123710. * @param data The data to import
  123711. * @param rootUrl The root url for scene and resources
  123712. * @param onError The callback when import fails
  123713. * @returns True if successful or false otherwise
  123714. */
  123715. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  123716. /**
  123717. * Load into an asset container.
  123718. * @param scene The scene to load into
  123719. * @param data The data to import
  123720. * @param rootUrl The root url for scene and resources
  123721. * @param onError The callback when import fails
  123722. * @returns The loaded asset container
  123723. */
  123724. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  123725. }
  123726. /**
  123727. * Interface used to define an async SceneLoader plugin
  123728. */
  123729. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  123730. /**
  123731. * Import meshes into a scene.
  123732. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  123733. * @param scene The scene to import into
  123734. * @param data The data to import
  123735. * @param rootUrl The root url for scene and resources
  123736. * @param onProgress The callback when the load progresses
  123737. * @param fileName Defines the name of the file to load
  123738. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  123739. */
  123740. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  123741. meshes: AbstractMesh[];
  123742. particleSystems: IParticleSystem[];
  123743. skeletons: Skeleton[];
  123744. animationGroups: AnimationGroup[];
  123745. }>;
  123746. /**
  123747. * Load into a scene.
  123748. * @param scene The scene to load into
  123749. * @param data The data to import
  123750. * @param rootUrl The root url for scene and resources
  123751. * @param onProgress The callback when the load progresses
  123752. * @param fileName Defines the name of the file to load
  123753. * @returns Nothing
  123754. */
  123755. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  123756. /**
  123757. * Load into an asset container.
  123758. * @param scene The scene to load into
  123759. * @param data The data to import
  123760. * @param rootUrl The root url for scene and resources
  123761. * @param onProgress The callback when the load progresses
  123762. * @param fileName Defines the name of the file to load
  123763. * @returns The loaded asset container
  123764. */
  123765. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  123766. }
  123767. /**
  123768. * Mode that determines how to handle old animation groups before loading new ones.
  123769. */
  123770. export enum SceneLoaderAnimationGroupLoadingMode {
  123771. /**
  123772. * Reset all old animations to initial state then dispose them.
  123773. */
  123774. Clean = 0,
  123775. /**
  123776. * Stop all old animations.
  123777. */
  123778. Stop = 1,
  123779. /**
  123780. * Restart old animations from first frame.
  123781. */
  123782. Sync = 2,
  123783. /**
  123784. * Old animations remains untouched.
  123785. */
  123786. NoSync = 3
  123787. }
  123788. /**
  123789. * Class used to load scene from various file formats using registered plugins
  123790. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  123791. */
  123792. export class SceneLoader {
  123793. /**
  123794. * No logging while loading
  123795. */
  123796. static readonly NO_LOGGING: number;
  123797. /**
  123798. * Minimal logging while loading
  123799. */
  123800. static readonly MINIMAL_LOGGING: number;
  123801. /**
  123802. * Summary logging while loading
  123803. */
  123804. static readonly SUMMARY_LOGGING: number;
  123805. /**
  123806. * Detailled logging while loading
  123807. */
  123808. static readonly DETAILED_LOGGING: number;
  123809. /**
  123810. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  123811. */
  123812. static get ForceFullSceneLoadingForIncremental(): boolean;
  123813. static set ForceFullSceneLoadingForIncremental(value: boolean);
  123814. /**
  123815. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  123816. */
  123817. static get ShowLoadingScreen(): boolean;
  123818. static set ShowLoadingScreen(value: boolean);
  123819. /**
  123820. * Defines the current logging level (while loading the scene)
  123821. * @ignorenaming
  123822. */
  123823. static get loggingLevel(): number;
  123824. static set loggingLevel(value: number);
  123825. /**
  123826. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  123827. */
  123828. static get CleanBoneMatrixWeights(): boolean;
  123829. static set CleanBoneMatrixWeights(value: boolean);
  123830. /**
  123831. * Event raised when a plugin is used to load a scene
  123832. */
  123833. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  123834. private static _registeredPlugins;
  123835. private static _getDefaultPlugin;
  123836. private static _getPluginForExtension;
  123837. private static _getPluginForDirectLoad;
  123838. private static _getPluginForFilename;
  123839. private static _getDirectLoad;
  123840. private static _loadData;
  123841. private static _getFileInfo;
  123842. /**
  123843. * Gets a plugin that can load the given extension
  123844. * @param extension defines the extension to load
  123845. * @returns a plugin or null if none works
  123846. */
  123847. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  123848. /**
  123849. * Gets a boolean indicating that the given extension can be loaded
  123850. * @param extension defines the extension to load
  123851. * @returns true if the extension is supported
  123852. */
  123853. static IsPluginForExtensionAvailable(extension: string): boolean;
  123854. /**
  123855. * Adds a new plugin to the list of registered plugins
  123856. * @param plugin defines the plugin to add
  123857. */
  123858. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  123859. /**
  123860. * Import meshes into a scene
  123861. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  123862. * @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)
  123863. * @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)
  123864. * @param scene the instance of BABYLON.Scene to append to
  123865. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  123866. * @param onProgress a callback with a progress event for each file being loaded
  123867. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123868. * @param pluginExtension the extension used to determine the plugin
  123869. * @returns The loaded plugin
  123870. */
  123871. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  123872. /**
  123873. * Import meshes into a scene
  123874. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  123875. * @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)
  123876. * @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)
  123877. * @param scene the instance of BABYLON.Scene to append to
  123878. * @param onProgress a callback with a progress event for each file being loaded
  123879. * @param pluginExtension the extension used to determine the plugin
  123880. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  123881. */
  123882. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  123883. meshes: AbstractMesh[];
  123884. particleSystems: IParticleSystem[];
  123885. skeletons: Skeleton[];
  123886. animationGroups: AnimationGroup[];
  123887. }>;
  123888. /**
  123889. * Load a scene
  123890. * @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)
  123891. * @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)
  123892. * @param engine is the instance of BABYLON.Engine to use to create the scene
  123893. * @param onSuccess a callback with the scene when import succeeds
  123894. * @param onProgress a callback with a progress event for each file being loaded
  123895. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123896. * @param pluginExtension the extension used to determine the plugin
  123897. * @returns The loaded plugin
  123898. */
  123899. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  123900. /**
  123901. * Load a scene
  123902. * @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)
  123903. * @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)
  123904. * @param engine is the instance of BABYLON.Engine to use to create the scene
  123905. * @param onProgress a callback with a progress event for each file being loaded
  123906. * @param pluginExtension the extension used to determine the plugin
  123907. * @returns The loaded scene
  123908. */
  123909. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  123910. /**
  123911. * Append a scene
  123912. * @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)
  123913. * @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)
  123914. * @param scene is the instance of BABYLON.Scene to append to
  123915. * @param onSuccess a callback with the scene when import succeeds
  123916. * @param onProgress a callback with a progress event for each file being loaded
  123917. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123918. * @param pluginExtension the extension used to determine the plugin
  123919. * @returns The loaded plugin
  123920. */
  123921. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  123922. /**
  123923. * Append a scene
  123924. * @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)
  123925. * @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)
  123926. * @param scene is the instance of BABYLON.Scene to append to
  123927. * @param onProgress a callback with a progress event for each file being loaded
  123928. * @param pluginExtension the extension used to determine the plugin
  123929. * @returns The given scene
  123930. */
  123931. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  123932. /**
  123933. * Load a scene into an asset container
  123934. * @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)
  123935. * @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)
  123936. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  123937. * @param onSuccess a callback with the scene when import succeeds
  123938. * @param onProgress a callback with a progress event for each file being loaded
  123939. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123940. * @param pluginExtension the extension used to determine the plugin
  123941. * @returns The loaded plugin
  123942. */
  123943. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  123944. /**
  123945. * Load a scene into an asset container
  123946. * @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)
  123947. * @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)
  123948. * @param scene is the instance of Scene to append to
  123949. * @param onProgress a callback with a progress event for each file being loaded
  123950. * @param pluginExtension the extension used to determine the plugin
  123951. * @returns The loaded asset container
  123952. */
  123953. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  123954. /**
  123955. * Import animations from a file into a scene
  123956. * @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)
  123957. * @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)
  123958. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  123959. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  123960. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  123961. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  123962. * @param onSuccess a callback with the scene when import succeeds
  123963. * @param onProgress a callback with a progress event for each file being loaded
  123964. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123965. */
  123966. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  123967. /**
  123968. * Import animations from a file into a scene
  123969. * @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)
  123970. * @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)
  123971. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  123972. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  123973. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  123974. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  123975. * @param onSuccess a callback with the scene when import succeeds
  123976. * @param onProgress a callback with a progress event for each file being loaded
  123977. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123978. * @returns the updated scene with imported animations
  123979. */
  123980. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  123981. }
  123982. }
  123983. declare module BABYLON {
  123984. /**
  123985. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  123986. */
  123987. export type MotionControllerHandedness = "none" | "left" | "right";
  123988. /**
  123989. * The type of components available in motion controllers.
  123990. * This is not the name of the component.
  123991. */
  123992. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  123993. /**
  123994. * The state of a controller component
  123995. */
  123996. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  123997. /**
  123998. * The schema of motion controller layout.
  123999. * No object will be initialized using this interface
  124000. * This is used just to define the profile.
  124001. */
  124002. export interface IMotionControllerLayout {
  124003. /**
  124004. * Path to load the assets. Usually relative to the base path
  124005. */
  124006. assetPath: string;
  124007. /**
  124008. * Available components (unsorted)
  124009. */
  124010. components: {
  124011. /**
  124012. * A map of component Ids
  124013. */
  124014. [componentId: string]: {
  124015. /**
  124016. * The type of input the component outputs
  124017. */
  124018. type: MotionControllerComponentType;
  124019. /**
  124020. * The indices of this component in the gamepad object
  124021. */
  124022. gamepadIndices: {
  124023. /**
  124024. * Index of button
  124025. */
  124026. button?: number;
  124027. /**
  124028. * If available, index of x-axis
  124029. */
  124030. xAxis?: number;
  124031. /**
  124032. * If available, index of y-axis
  124033. */
  124034. yAxis?: number;
  124035. };
  124036. /**
  124037. * The mesh's root node name
  124038. */
  124039. rootNodeName: string;
  124040. /**
  124041. * Animation definitions for this model
  124042. */
  124043. visualResponses: {
  124044. [stateKey: string]: {
  124045. /**
  124046. * What property will be animated
  124047. */
  124048. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  124049. /**
  124050. * What states influence this visual response
  124051. */
  124052. states: MotionControllerComponentStateType[];
  124053. /**
  124054. * Type of animation - movement or visibility
  124055. */
  124056. valueNodeProperty: "transform" | "visibility";
  124057. /**
  124058. * Base node name to move. Its position will be calculated according to the min and max nodes
  124059. */
  124060. valueNodeName?: string;
  124061. /**
  124062. * Minimum movement node
  124063. */
  124064. minNodeName?: string;
  124065. /**
  124066. * Max movement node
  124067. */
  124068. maxNodeName?: string;
  124069. };
  124070. };
  124071. /**
  124072. * If touch enabled, what is the name of node to display user feedback
  124073. */
  124074. touchPointNodeName?: string;
  124075. };
  124076. };
  124077. /**
  124078. * Is it xr standard mapping or not
  124079. */
  124080. gamepadMapping: "" | "xr-standard";
  124081. /**
  124082. * Base root node of this entire model
  124083. */
  124084. rootNodeName: string;
  124085. /**
  124086. * Defines the main button component id
  124087. */
  124088. selectComponentId: string;
  124089. }
  124090. /**
  124091. * A definition for the layout map in the input profile
  124092. */
  124093. export interface IMotionControllerLayoutMap {
  124094. /**
  124095. * Layouts with handedness type as a key
  124096. */
  124097. [handedness: string]: IMotionControllerLayout;
  124098. }
  124099. /**
  124100. * The XR Input profile schema
  124101. * Profiles can be found here:
  124102. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  124103. */
  124104. export interface IMotionControllerProfile {
  124105. /**
  124106. * fallback profiles for this profileId
  124107. */
  124108. fallbackProfileIds: string[];
  124109. /**
  124110. * The layout map, with handedness as key
  124111. */
  124112. layouts: IMotionControllerLayoutMap;
  124113. /**
  124114. * The id of this profile
  124115. * correlates to the profile(s) in the xrInput.profiles array
  124116. */
  124117. profileId: string;
  124118. }
  124119. /**
  124120. * A helper-interface for the 3 meshes needed for controller button animation
  124121. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  124122. */
  124123. export interface IMotionControllerButtonMeshMap {
  124124. /**
  124125. * the mesh that defines the pressed value mesh position.
  124126. * This is used to find the max-position of this button
  124127. */
  124128. pressedMesh: AbstractMesh;
  124129. /**
  124130. * the mesh that defines the unpressed value mesh position.
  124131. * This is used to find the min (or initial) position of this button
  124132. */
  124133. unpressedMesh: AbstractMesh;
  124134. /**
  124135. * The mesh that will be changed when value changes
  124136. */
  124137. valueMesh: AbstractMesh;
  124138. }
  124139. /**
  124140. * A helper-interface for the 3 meshes needed for controller axis animation.
  124141. * This will be expanded when touchpad animations are fully supported
  124142. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  124143. */
  124144. export interface IMotionControllerMeshMap {
  124145. /**
  124146. * the mesh that defines the maximum value mesh position.
  124147. */
  124148. maxMesh?: AbstractMesh;
  124149. /**
  124150. * the mesh that defines the minimum value mesh position.
  124151. */
  124152. minMesh?: AbstractMesh;
  124153. /**
  124154. * The mesh that will be changed when axis value changes
  124155. */
  124156. valueMesh: AbstractMesh;
  124157. }
  124158. /**
  124159. * The elements needed for change-detection of the gamepad objects in motion controllers
  124160. */
  124161. export interface IMinimalMotionControllerObject {
  124162. /**
  124163. * Available axes of this controller
  124164. */
  124165. axes: number[];
  124166. /**
  124167. * An array of available buttons
  124168. */
  124169. buttons: Array<{
  124170. /**
  124171. * Value of the button/trigger
  124172. */
  124173. value: number;
  124174. /**
  124175. * If the button/trigger is currently touched
  124176. */
  124177. touched: boolean;
  124178. /**
  124179. * If the button/trigger is currently pressed
  124180. */
  124181. pressed: boolean;
  124182. }>;
  124183. /**
  124184. * EXPERIMENTAL haptic support.
  124185. */
  124186. hapticActuators?: Array<{
  124187. pulse: (value: number, duration: number) => Promise<boolean>;
  124188. }>;
  124189. }
  124190. /**
  124191. * An Abstract Motion controller
  124192. * This class receives an xrInput and a profile layout and uses those to initialize the components
  124193. * Each component has an observable to check for changes in value and state
  124194. */
  124195. export abstract class WebXRAbstractMotionController implements IDisposable {
  124196. protected scene: Scene;
  124197. protected layout: IMotionControllerLayout;
  124198. /**
  124199. * The gamepad object correlating to this controller
  124200. */
  124201. gamepadObject: IMinimalMotionControllerObject;
  124202. /**
  124203. * handedness (left/right/none) of this controller
  124204. */
  124205. handedness: MotionControllerHandedness;
  124206. private _initComponent;
  124207. private _modelReady;
  124208. /**
  124209. * A map of components (WebXRControllerComponent) in this motion controller
  124210. * Components have a ComponentType and can also have both button and axis definitions
  124211. */
  124212. readonly components: {
  124213. [id: string]: WebXRControllerComponent;
  124214. };
  124215. /**
  124216. * Disable the model's animation. Can be set at any time.
  124217. */
  124218. disableAnimation: boolean;
  124219. /**
  124220. * Observers registered here will be triggered when the model of this controller is done loading
  124221. */
  124222. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  124223. /**
  124224. * The profile id of this motion controller
  124225. */
  124226. abstract profileId: string;
  124227. /**
  124228. * The root mesh of the model. It is null if the model was not yet initialized
  124229. */
  124230. rootMesh: Nullable<AbstractMesh>;
  124231. /**
  124232. * constructs a new abstract motion controller
  124233. * @param scene the scene to which the model of the controller will be added
  124234. * @param layout The profile layout to load
  124235. * @param gamepadObject The gamepad object correlating to this controller
  124236. * @param handedness handedness (left/right/none) of this controller
  124237. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  124238. */
  124239. constructor(scene: Scene, layout: IMotionControllerLayout,
  124240. /**
  124241. * The gamepad object correlating to this controller
  124242. */
  124243. gamepadObject: IMinimalMotionControllerObject,
  124244. /**
  124245. * handedness (left/right/none) of this controller
  124246. */
  124247. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  124248. /**
  124249. * Dispose this controller, the model mesh and all its components
  124250. */
  124251. dispose(): void;
  124252. /**
  124253. * Returns all components of specific type
  124254. * @param type the type to search for
  124255. * @return an array of components with this type
  124256. */
  124257. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  124258. /**
  124259. * get a component based an its component id as defined in layout.components
  124260. * @param id the id of the component
  124261. * @returns the component correlates to the id or undefined if not found
  124262. */
  124263. getComponent(id: string): WebXRControllerComponent;
  124264. /**
  124265. * Get the list of components available in this motion controller
  124266. * @returns an array of strings correlating to available components
  124267. */
  124268. getComponentIds(): string[];
  124269. /**
  124270. * Get the first component of specific type
  124271. * @param type type of component to find
  124272. * @return a controller component or null if not found
  124273. */
  124274. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  124275. /**
  124276. * Get the main (Select) component of this controller as defined in the layout
  124277. * @returns the main component of this controller
  124278. */
  124279. getMainComponent(): WebXRControllerComponent;
  124280. /**
  124281. * Loads the model correlating to this controller
  124282. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  124283. * @returns A promise fulfilled with the result of the model loading
  124284. */
  124285. loadModel(): Promise<boolean>;
  124286. /**
  124287. * Update this model using the current XRFrame
  124288. * @param xrFrame the current xr frame to use and update the model
  124289. */
  124290. updateFromXRFrame(xrFrame: XRFrame): void;
  124291. /**
  124292. * Backwards compatibility due to a deeply-integrated typo
  124293. */
  124294. get handness(): XREye;
  124295. /**
  124296. * Pulse (vibrate) this controller
  124297. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  124298. * Consecutive calls to this function will cancel the last pulse call
  124299. *
  124300. * @param value the strength of the pulse in 0.0...1.0 range
  124301. * @param duration Duration of the pulse in milliseconds
  124302. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  124303. * @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
  124304. */
  124305. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  124306. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  124307. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  124308. /**
  124309. * Moves the axis on the controller mesh based on its current state
  124310. * @param axis the index of the axis
  124311. * @param axisValue the value of the axis which determines the meshes new position
  124312. * @hidden
  124313. */
  124314. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  124315. /**
  124316. * Update the model itself with the current frame data
  124317. * @param xrFrame the frame to use for updating the model mesh
  124318. */
  124319. protected updateModel(xrFrame: XRFrame): void;
  124320. /**
  124321. * Get the filename and path for this controller's model
  124322. * @returns a map of filename and path
  124323. */
  124324. protected abstract _getFilenameAndPath(): {
  124325. filename: string;
  124326. path: string;
  124327. };
  124328. /**
  124329. * This function is called before the mesh is loaded. It checks for loading constraints.
  124330. * For example, this function can check if the GLB loader is available
  124331. * If this function returns false, the generic controller will be loaded instead
  124332. * @returns Is the client ready to load the mesh
  124333. */
  124334. protected abstract _getModelLoadingConstraints(): boolean;
  124335. /**
  124336. * This function will be called after the model was successfully loaded and can be used
  124337. * for mesh transformations before it is available for the user
  124338. * @param meshes the loaded meshes
  124339. */
  124340. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  124341. /**
  124342. * Set the root mesh for this controller. Important for the WebXR controller class
  124343. * @param meshes the loaded meshes
  124344. */
  124345. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  124346. /**
  124347. * A function executed each frame that updates the mesh (if needed)
  124348. * @param xrFrame the current xrFrame
  124349. */
  124350. protected abstract _updateModel(xrFrame: XRFrame): void;
  124351. private _getGenericFilenameAndPath;
  124352. private _getGenericParentMesh;
  124353. }
  124354. }
  124355. declare module BABYLON {
  124356. /**
  124357. * A generic trigger-only motion controller for WebXR
  124358. */
  124359. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  124360. /**
  124361. * Static version of the profile id of this controller
  124362. */
  124363. static ProfileId: string;
  124364. profileId: string;
  124365. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  124366. protected _getFilenameAndPath(): {
  124367. filename: string;
  124368. path: string;
  124369. };
  124370. protected _getModelLoadingConstraints(): boolean;
  124371. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  124372. protected _setRootMesh(meshes: AbstractMesh[]): void;
  124373. protected _updateModel(): void;
  124374. }
  124375. }
  124376. declare module BABYLON {
  124377. /**
  124378. * Class containing static functions to help procedurally build meshes
  124379. */
  124380. export class SphereBuilder {
  124381. /**
  124382. * Creates a sphere mesh
  124383. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  124384. * * 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`)
  124385. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  124386. * * 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
  124387. * * 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)
  124388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124389. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124391. * @param name defines the name of the mesh
  124392. * @param options defines the options used to create the mesh
  124393. * @param scene defines the hosting scene
  124394. * @returns the sphere mesh
  124395. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  124396. */
  124397. static CreateSphere(name: string, options: {
  124398. segments?: number;
  124399. diameter?: number;
  124400. diameterX?: number;
  124401. diameterY?: number;
  124402. diameterZ?: number;
  124403. arc?: number;
  124404. slice?: number;
  124405. sideOrientation?: number;
  124406. frontUVs?: Vector4;
  124407. backUVs?: Vector4;
  124408. updatable?: boolean;
  124409. }, scene?: Nullable<Scene>): Mesh;
  124410. }
  124411. }
  124412. declare module BABYLON {
  124413. /**
  124414. * A profiled motion controller has its profile loaded from an online repository.
  124415. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  124416. */
  124417. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  124418. private _repositoryUrl;
  124419. private _buttonMeshMapping;
  124420. private _touchDots;
  124421. /**
  124422. * The profile ID of this controller. Will be populated when the controller initializes.
  124423. */
  124424. profileId: string;
  124425. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  124426. dispose(): void;
  124427. protected _getFilenameAndPath(): {
  124428. filename: string;
  124429. path: string;
  124430. };
  124431. protected _getModelLoadingConstraints(): boolean;
  124432. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  124433. protected _setRootMesh(meshes: AbstractMesh[]): void;
  124434. protected _updateModel(_xrFrame: XRFrame): void;
  124435. }
  124436. }
  124437. declare module BABYLON {
  124438. /**
  124439. * A construction function type to create a new controller based on an xrInput object
  124440. */
  124441. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  124442. /**
  124443. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  124444. *
  124445. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  124446. * it should be replaced with auto-loaded controllers.
  124447. *
  124448. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  124449. */
  124450. export class WebXRMotionControllerManager {
  124451. private static _AvailableControllers;
  124452. private static _Fallbacks;
  124453. private static _ProfileLoadingPromises;
  124454. private static _ProfilesList;
  124455. /**
  124456. * The base URL of the online controller repository. Can be changed at any time.
  124457. */
  124458. static BaseRepositoryUrl: string;
  124459. /**
  124460. * Which repository gets priority - local or online
  124461. */
  124462. static PrioritizeOnlineRepository: boolean;
  124463. /**
  124464. * Use the online repository, or use only locally-defined controllers
  124465. */
  124466. static UseOnlineRepository: boolean;
  124467. /**
  124468. * Clear the cache used for profile loading and reload when requested again
  124469. */
  124470. static ClearProfilesCache(): void;
  124471. /**
  124472. * Register the default fallbacks.
  124473. * This function is called automatically when this file is imported.
  124474. */
  124475. static DefaultFallbacks(): void;
  124476. /**
  124477. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  124478. * @param profileId the profile to which a fallback needs to be found
  124479. * @return an array with corresponding fallback profiles
  124480. */
  124481. static FindFallbackWithProfileId(profileId: string): string[];
  124482. /**
  124483. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  124484. * The order of search:
  124485. *
  124486. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  124487. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  124488. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  124489. * 4) return the generic trigger controller if none were found
  124490. *
  124491. * @param xrInput the xrInput to which a new controller is initialized
  124492. * @param scene the scene to which the model will be added
  124493. * @param forceProfile force a certain profile for this controller
  124494. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  124495. */
  124496. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  124497. /**
  124498. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  124499. *
  124500. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  124501. *
  124502. * @param type the profile type to register
  124503. * @param constructFunction the function to be called when loading this profile
  124504. */
  124505. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  124506. /**
  124507. * Register a fallback to a specific profile.
  124508. * @param profileId the profileId that will receive the fallbacks
  124509. * @param fallbacks A list of fallback profiles
  124510. */
  124511. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  124512. /**
  124513. * Will update the list of profiles available in the repository
  124514. * @return a promise that resolves to a map of profiles available online
  124515. */
  124516. static UpdateProfilesList(): Promise<{
  124517. [profile: string]: string;
  124518. }>;
  124519. private static _LoadProfileFromRepository;
  124520. private static _LoadProfilesFromAvailableControllers;
  124521. }
  124522. }
  124523. declare module BABYLON {
  124524. /**
  124525. * Configuration options for the WebXR controller creation
  124526. */
  124527. export interface IWebXRControllerOptions {
  124528. /**
  124529. * Should the controller mesh be animated when a user interacts with it
  124530. * The pressed buttons / thumbstick and touchpad animations will be disabled
  124531. */
  124532. disableMotionControllerAnimation?: boolean;
  124533. /**
  124534. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  124535. */
  124536. doNotLoadControllerMesh?: boolean;
  124537. /**
  124538. * Force a specific controller type for this controller.
  124539. * This can be used when creating your own profile or when testing different controllers
  124540. */
  124541. forceControllerProfile?: string;
  124542. /**
  124543. * Defines a rendering group ID for meshes that will be loaded.
  124544. * This is for the default controllers only.
  124545. */
  124546. renderingGroupId?: number;
  124547. }
  124548. /**
  124549. * Represents an XR controller
  124550. */
  124551. export class WebXRInputSource {
  124552. private _scene;
  124553. /** The underlying input source for the controller */
  124554. inputSource: XRInputSource;
  124555. private _options;
  124556. private _tmpVector;
  124557. private _uniqueId;
  124558. /**
  124559. * 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
  124560. */
  124561. grip?: AbstractMesh;
  124562. /**
  124563. * If available, this is the gamepad object related to this controller.
  124564. * Using this object it is possible to get click events and trackpad changes of the
  124565. * webxr controller that is currently being used.
  124566. */
  124567. motionController?: WebXRAbstractMotionController;
  124568. /**
  124569. * Event that fires when the controller is removed/disposed.
  124570. * The object provided as event data is this controller, after associated assets were disposed.
  124571. * uniqueId is still available.
  124572. */
  124573. onDisposeObservable: Observable<WebXRInputSource>;
  124574. /**
  124575. * Will be triggered when the mesh associated with the motion controller is done loading.
  124576. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  124577. * A shortened version of controller -> motion controller -> on mesh loaded.
  124578. */
  124579. onMeshLoadedObservable: Observable<AbstractMesh>;
  124580. /**
  124581. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  124582. */
  124583. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  124584. /**
  124585. * Pointer which can be used to select objects or attach a visible laser to
  124586. */
  124587. pointer: AbstractMesh;
  124588. /**
  124589. * Creates the controller
  124590. * @see https://doc.babylonjs.com/how_to/webxr
  124591. * @param _scene the scene which the controller should be associated to
  124592. * @param inputSource the underlying input source for the controller
  124593. * @param _options options for this controller creation
  124594. */
  124595. constructor(_scene: Scene,
  124596. /** The underlying input source for the controller */
  124597. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  124598. /**
  124599. * Get this controllers unique id
  124600. */
  124601. get uniqueId(): string;
  124602. /**
  124603. * Disposes of the object
  124604. */
  124605. dispose(): void;
  124606. /**
  124607. * Gets a world space ray coming from the pointer or grip
  124608. * @param result the resulting ray
  124609. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  124610. */
  124611. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  124612. /**
  124613. * Updates the controller pose based on the given XRFrame
  124614. * @param xrFrame xr frame to update the pose with
  124615. * @param referenceSpace reference space to use
  124616. */
  124617. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  124618. }
  124619. }
  124620. declare module BABYLON {
  124621. /**
  124622. * The schema for initialization options of the XR Input class
  124623. */
  124624. export interface IWebXRInputOptions {
  124625. /**
  124626. * If set to true no model will be automatically loaded
  124627. */
  124628. doNotLoadControllerMeshes?: boolean;
  124629. /**
  124630. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  124631. * If not found, the xr input profile data will be used.
  124632. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  124633. */
  124634. forceInputProfile?: string;
  124635. /**
  124636. * Do not send a request to the controller repository to load the profile.
  124637. *
  124638. * Instead, use the controllers available in babylon itself.
  124639. */
  124640. disableOnlineControllerRepository?: boolean;
  124641. /**
  124642. * A custom URL for the controllers repository
  124643. */
  124644. customControllersRepositoryURL?: string;
  124645. /**
  124646. * Should the controller model's components not move according to the user input
  124647. */
  124648. disableControllerAnimation?: boolean;
  124649. /**
  124650. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  124651. */
  124652. controllerOptions?: IWebXRControllerOptions;
  124653. }
  124654. /**
  124655. * XR input used to track XR inputs such as controllers/rays
  124656. */
  124657. export class WebXRInput implements IDisposable {
  124658. /**
  124659. * the xr session manager for this session
  124660. */
  124661. xrSessionManager: WebXRSessionManager;
  124662. /**
  124663. * the WebXR camera for this session. Mainly used for teleportation
  124664. */
  124665. xrCamera: WebXRCamera;
  124666. private readonly options;
  124667. /**
  124668. * XR controllers being tracked
  124669. */
  124670. controllers: Array<WebXRInputSource>;
  124671. private _frameObserver;
  124672. private _sessionEndedObserver;
  124673. private _sessionInitObserver;
  124674. /**
  124675. * Event when a controller has been connected/added
  124676. */
  124677. onControllerAddedObservable: Observable<WebXRInputSource>;
  124678. /**
  124679. * Event when a controller has been removed/disconnected
  124680. */
  124681. onControllerRemovedObservable: Observable<WebXRInputSource>;
  124682. /**
  124683. * Initializes the WebXRInput
  124684. * @param xrSessionManager the xr session manager for this session
  124685. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  124686. * @param options = initialization options for this xr input
  124687. */
  124688. constructor(
  124689. /**
  124690. * the xr session manager for this session
  124691. */
  124692. xrSessionManager: WebXRSessionManager,
  124693. /**
  124694. * the WebXR camera for this session. Mainly used for teleportation
  124695. */
  124696. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  124697. private _onInputSourcesChange;
  124698. private _addAndRemoveControllers;
  124699. /**
  124700. * Disposes of the object
  124701. */
  124702. dispose(): void;
  124703. }
  124704. }
  124705. declare module BABYLON {
  124706. /**
  124707. * This is the base class for all WebXR features.
  124708. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  124709. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  124710. */
  124711. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  124712. protected _xrSessionManager: WebXRSessionManager;
  124713. private _attached;
  124714. private _removeOnDetach;
  124715. /**
  124716. * Should auto-attach be disabled?
  124717. */
  124718. disableAutoAttach: boolean;
  124719. /**
  124720. * Construct a new (abstract) WebXR feature
  124721. * @param _xrSessionManager the xr session manager for this feature
  124722. */
  124723. constructor(_xrSessionManager: WebXRSessionManager);
  124724. /**
  124725. * Is this feature attached
  124726. */
  124727. get attached(): boolean;
  124728. /**
  124729. * attach this feature
  124730. *
  124731. * @param force should attachment be forced (even when already attached)
  124732. * @returns true if successful, false is failed or already attached
  124733. */
  124734. attach(force?: boolean): boolean;
  124735. /**
  124736. * detach this feature.
  124737. *
  124738. * @returns true if successful, false if failed or already detached
  124739. */
  124740. detach(): boolean;
  124741. /**
  124742. * Dispose this feature and all of the resources attached
  124743. */
  124744. dispose(): void;
  124745. /**
  124746. * This is used to register callbacks that will automatically be removed when detach is called.
  124747. * @param observable the observable to which the observer will be attached
  124748. * @param callback the callback to register
  124749. */
  124750. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  124751. /**
  124752. * Code in this function will be executed on each xrFrame received from the browser.
  124753. * This function will not execute after the feature is detached.
  124754. * @param _xrFrame the current frame
  124755. */
  124756. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  124757. }
  124758. }
  124759. declare module BABYLON {
  124760. /**
  124761. * Renders a layer on top of an existing scene
  124762. */
  124763. export class UtilityLayerRenderer implements IDisposable {
  124764. /** the original scene that will be rendered on top of */
  124765. originalScene: Scene;
  124766. private _pointerCaptures;
  124767. private _lastPointerEvents;
  124768. private static _DefaultUtilityLayer;
  124769. private static _DefaultKeepDepthUtilityLayer;
  124770. private _sharedGizmoLight;
  124771. private _renderCamera;
  124772. /**
  124773. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  124774. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  124775. * @returns the camera that is used when rendering the utility layer
  124776. */
  124777. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  124778. /**
  124779. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  124780. * @param cam the camera that should be used when rendering the utility layer
  124781. */
  124782. setRenderCamera(cam: Nullable<Camera>): void;
  124783. /**
  124784. * @hidden
  124785. * Light which used by gizmos to get light shading
  124786. */
  124787. _getSharedGizmoLight(): HemisphericLight;
  124788. /**
  124789. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  124790. */
  124791. pickUtilitySceneFirst: boolean;
  124792. /**
  124793. * 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)
  124794. */
  124795. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  124796. /**
  124797. * 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)
  124798. */
  124799. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  124800. /**
  124801. * The scene that is rendered on top of the original scene
  124802. */
  124803. utilityLayerScene: Scene;
  124804. /**
  124805. * If the utility layer should automatically be rendered on top of existing scene
  124806. */
  124807. shouldRender: boolean;
  124808. /**
  124809. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  124810. */
  124811. onlyCheckPointerDownEvents: boolean;
  124812. /**
  124813. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  124814. */
  124815. processAllEvents: boolean;
  124816. /**
  124817. * Observable raised when the pointer move from the utility layer scene to the main scene
  124818. */
  124819. onPointerOutObservable: Observable<number>;
  124820. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  124821. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  124822. private _afterRenderObserver;
  124823. private _sceneDisposeObserver;
  124824. private _originalPointerObserver;
  124825. /**
  124826. * Instantiates a UtilityLayerRenderer
  124827. * @param originalScene the original scene that will be rendered on top of
  124828. * @param handleEvents boolean indicating if the utility layer should handle events
  124829. */
  124830. constructor(
  124831. /** the original scene that will be rendered on top of */
  124832. originalScene: Scene, handleEvents?: boolean);
  124833. private _notifyObservers;
  124834. /**
  124835. * Renders the utility layers scene on top of the original scene
  124836. */
  124837. render(): void;
  124838. /**
  124839. * Disposes of the renderer
  124840. */
  124841. dispose(): void;
  124842. private _updateCamera;
  124843. }
  124844. }
  124845. declare module BABYLON {
  124846. /**
  124847. * Options interface for the pointer selection module
  124848. */
  124849. export interface IWebXRControllerPointerSelectionOptions {
  124850. /**
  124851. * if provided, this scene will be used to render meshes.
  124852. */
  124853. customUtilityLayerScene?: Scene;
  124854. /**
  124855. * 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)
  124856. * If not disabled, the last picked point will be used to execute a pointer up event
  124857. * If disabled, pointer up event will be triggered right after the pointer down event.
  124858. * Used in screen and gaze target ray mode only
  124859. */
  124860. disablePointerUpOnTouchOut: boolean;
  124861. /**
  124862. * For gaze mode (time to select instead of press)
  124863. */
  124864. forceGazeMode: boolean;
  124865. /**
  124866. * 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
  124867. * to start a new countdown to the pointer down event.
  124868. * Defaults to 1.
  124869. */
  124870. gazeModePointerMovedFactor?: number;
  124871. /**
  124872. * Different button type to use instead of the main component
  124873. */
  124874. overrideButtonId?: string;
  124875. /**
  124876. * use this rendering group id for the meshes (optional)
  124877. */
  124878. renderingGroupId?: number;
  124879. /**
  124880. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  124881. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  124882. * 3000 means 3 seconds between pointing at something and selecting it
  124883. */
  124884. timeToSelect?: number;
  124885. /**
  124886. * Should meshes created here be added to a utility layer or the main scene
  124887. */
  124888. useUtilityLayer?: boolean;
  124889. /**
  124890. * the xr input to use with this pointer selection
  124891. */
  124892. xrInput: WebXRInput;
  124893. }
  124894. /**
  124895. * A module that will enable pointer selection for motion controllers of XR Input Sources
  124896. */
  124897. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  124898. private readonly _options;
  124899. private static _idCounter;
  124900. private _attachController;
  124901. private _controllers;
  124902. private _scene;
  124903. private _tmpVectorForPickCompare;
  124904. /**
  124905. * The module's name
  124906. */
  124907. static readonly Name: string;
  124908. /**
  124909. * The (Babylon) version of this module.
  124910. * This is an integer representing the implementation version.
  124911. * This number does not correspond to the WebXR specs version
  124912. */
  124913. static readonly Version: number;
  124914. /**
  124915. * Disable lighting on the laser pointer (so it will always be visible)
  124916. */
  124917. disablePointerLighting: boolean;
  124918. /**
  124919. * Disable lighting on the selection mesh (so it will always be visible)
  124920. */
  124921. disableSelectionMeshLighting: boolean;
  124922. /**
  124923. * Should the laser pointer be displayed
  124924. */
  124925. displayLaserPointer: boolean;
  124926. /**
  124927. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  124928. */
  124929. displaySelectionMesh: boolean;
  124930. /**
  124931. * This color will be set to the laser pointer when selection is triggered
  124932. */
  124933. laserPointerPickedColor: Color3;
  124934. /**
  124935. * Default color of the laser pointer
  124936. */
  124937. lasterPointerDefaultColor: Color3;
  124938. /**
  124939. * default color of the selection ring
  124940. */
  124941. selectionMeshDefaultColor: Color3;
  124942. /**
  124943. * This color will be applied to the selection ring when selection is triggered
  124944. */
  124945. selectionMeshPickedColor: Color3;
  124946. /**
  124947. * Optional filter to be used for ray selection. This predicate shares behavior with
  124948. * scene.pointerMovePredicate which takes priority if it is also assigned.
  124949. */
  124950. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  124951. /**
  124952. * constructs a new background remover module
  124953. * @param _xrSessionManager the session manager for this module
  124954. * @param _options read-only options to be used in this module
  124955. */
  124956. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  124957. /**
  124958. * attach this feature
  124959. * Will usually be called by the features manager
  124960. *
  124961. * @returns true if successful.
  124962. */
  124963. attach(): boolean;
  124964. /**
  124965. * detach this feature.
  124966. * Will usually be called by the features manager
  124967. *
  124968. * @returns true if successful.
  124969. */
  124970. detach(): boolean;
  124971. /**
  124972. * Will get the mesh under a specific pointer.
  124973. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  124974. * @param controllerId the controllerId to check
  124975. * @returns The mesh under pointer or null if no mesh is under the pointer
  124976. */
  124977. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  124978. /**
  124979. * Get the xr controller that correlates to the pointer id in the pointer event
  124980. *
  124981. * @param id the pointer id to search for
  124982. * @returns the controller that correlates to this id or null if not found
  124983. */
  124984. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  124985. protected _onXRFrame(_xrFrame: XRFrame): void;
  124986. private _attachGazeMode;
  124987. private _attachScreenRayMode;
  124988. private _attachTrackedPointerRayMode;
  124989. private _convertNormalToDirectionOfRay;
  124990. private _detachController;
  124991. private _generateNewMeshPair;
  124992. private _pickingMoved;
  124993. private _updatePointerDistance;
  124994. }
  124995. }
  124996. declare module BABYLON {
  124997. /**
  124998. * Button which can be used to enter a different mode of XR
  124999. */
  125000. export class WebXREnterExitUIButton {
  125001. /** button element */
  125002. element: HTMLElement;
  125003. /** XR initialization options for the button */
  125004. sessionMode: XRSessionMode;
  125005. /** Reference space type */
  125006. referenceSpaceType: XRReferenceSpaceType;
  125007. /**
  125008. * Creates a WebXREnterExitUIButton
  125009. * @param element button element
  125010. * @param sessionMode XR initialization session mode
  125011. * @param referenceSpaceType the type of reference space to be used
  125012. */
  125013. constructor(
  125014. /** button element */
  125015. element: HTMLElement,
  125016. /** XR initialization options for the button */
  125017. sessionMode: XRSessionMode,
  125018. /** Reference space type */
  125019. referenceSpaceType: XRReferenceSpaceType);
  125020. /**
  125021. * Extendable function which can be used to update the button's visuals when the state changes
  125022. * @param activeButton the current active button in the UI
  125023. */
  125024. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  125025. }
  125026. /**
  125027. * Options to create the webXR UI
  125028. */
  125029. export class WebXREnterExitUIOptions {
  125030. /**
  125031. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  125032. */
  125033. customButtons?: Array<WebXREnterExitUIButton>;
  125034. /**
  125035. * A reference space type to use when creating the default button.
  125036. * Default is local-floor
  125037. */
  125038. referenceSpaceType?: XRReferenceSpaceType;
  125039. /**
  125040. * Context to enter xr with
  125041. */
  125042. renderTarget?: Nullable<WebXRRenderTarget>;
  125043. /**
  125044. * A session mode to use when creating the default button.
  125045. * Default is immersive-vr
  125046. */
  125047. sessionMode?: XRSessionMode;
  125048. /**
  125049. * A list of optional features to init the session with
  125050. */
  125051. optionalFeatures?: string[];
  125052. }
  125053. /**
  125054. * UI to allow the user to enter/exit XR mode
  125055. */
  125056. export class WebXREnterExitUI implements IDisposable {
  125057. private scene;
  125058. /** version of the options passed to this UI */
  125059. options: WebXREnterExitUIOptions;
  125060. private _activeButton;
  125061. private _buttons;
  125062. private _overlay;
  125063. /**
  125064. * Fired every time the active button is changed.
  125065. *
  125066. * When xr is entered via a button that launches xr that button will be the callback parameter
  125067. *
  125068. * When exiting xr the callback parameter will be null)
  125069. */
  125070. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  125071. /**
  125072. *
  125073. * @param scene babylon scene object to use
  125074. * @param options (read-only) version of the options passed to this UI
  125075. */
  125076. private constructor();
  125077. /**
  125078. * Creates UI to allow the user to enter/exit XR mode
  125079. * @param scene the scene to add the ui to
  125080. * @param helper the xr experience helper to enter/exit xr with
  125081. * @param options options to configure the UI
  125082. * @returns the created ui
  125083. */
  125084. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  125085. /**
  125086. * Disposes of the XR UI component
  125087. */
  125088. dispose(): void;
  125089. private _updateButtons;
  125090. }
  125091. }
  125092. declare module BABYLON {
  125093. /**
  125094. * Class containing static functions to help procedurally build meshes
  125095. */
  125096. export class LinesBuilder {
  125097. /**
  125098. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  125099. * * 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
  125100. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  125101. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  125102. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  125103. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  125104. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  125105. * * 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
  125106. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  125107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125108. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  125109. * @param name defines the name of the new line system
  125110. * @param options defines the options used to create the line system
  125111. * @param scene defines the hosting scene
  125112. * @returns a new line system mesh
  125113. */
  125114. static CreateLineSystem(name: string, options: {
  125115. lines: Vector3[][];
  125116. updatable?: boolean;
  125117. instance?: Nullable<LinesMesh>;
  125118. colors?: Nullable<Color4[][]>;
  125119. useVertexAlpha?: boolean;
  125120. }, scene: Nullable<Scene>): LinesMesh;
  125121. /**
  125122. * Creates a line mesh
  125123. * 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
  125124. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125125. * * The parameter `points` is an array successive Vector3
  125126. * * 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
  125127. * * The optional parameter `colors` is an array of successive Color4, one per line point
  125128. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  125129. * * When updating an instance, remember that only point positions can change, not the number of points
  125130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125131. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  125132. * @param name defines the name of the new line system
  125133. * @param options defines the options used to create the line system
  125134. * @param scene defines the hosting scene
  125135. * @returns a new line mesh
  125136. */
  125137. static CreateLines(name: string, options: {
  125138. points: Vector3[];
  125139. updatable?: boolean;
  125140. instance?: Nullable<LinesMesh>;
  125141. colors?: Color4[];
  125142. useVertexAlpha?: boolean;
  125143. }, scene?: Nullable<Scene>): LinesMesh;
  125144. /**
  125145. * Creates a dashed line mesh
  125146. * * 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
  125147. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125148. * * The parameter `points` is an array successive Vector3
  125149. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  125150. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  125151. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  125152. * * 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
  125153. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  125154. * * When updating an instance, remember that only point positions can change, not the number of points
  125155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125156. * @param name defines the name of the mesh
  125157. * @param options defines the options used to create the mesh
  125158. * @param scene defines the hosting scene
  125159. * @returns the dashed line mesh
  125160. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  125161. */
  125162. static CreateDashedLines(name: string, options: {
  125163. points: Vector3[];
  125164. dashSize?: number;
  125165. gapSize?: number;
  125166. dashNb?: number;
  125167. updatable?: boolean;
  125168. instance?: LinesMesh;
  125169. useVertexAlpha?: boolean;
  125170. }, scene?: Nullable<Scene>): LinesMesh;
  125171. }
  125172. }
  125173. declare module BABYLON {
  125174. /**
  125175. * The options container for the teleportation module
  125176. */
  125177. export interface IWebXRTeleportationOptions {
  125178. /**
  125179. * if provided, this scene will be used to render meshes.
  125180. */
  125181. customUtilityLayerScene?: Scene;
  125182. /**
  125183. * Values to configure the default target mesh
  125184. */
  125185. defaultTargetMeshOptions?: {
  125186. /**
  125187. * Fill color of the teleportation area
  125188. */
  125189. teleportationFillColor?: string;
  125190. /**
  125191. * Border color for the teleportation area
  125192. */
  125193. teleportationBorderColor?: string;
  125194. /**
  125195. * Disable the mesh's animation sequence
  125196. */
  125197. disableAnimation?: boolean;
  125198. /**
  125199. * Disable lighting on the material or the ring and arrow
  125200. */
  125201. disableLighting?: boolean;
  125202. /**
  125203. * Override the default material of the torus and arrow
  125204. */
  125205. torusArrowMaterial?: Material;
  125206. };
  125207. /**
  125208. * A list of meshes to use as floor meshes.
  125209. * Meshes can be added and removed after initializing the feature using the
  125210. * addFloorMesh and removeFloorMesh functions
  125211. * If empty, rotation will still work
  125212. */
  125213. floorMeshes?: AbstractMesh[];
  125214. /**
  125215. * use this rendering group id for the meshes (optional)
  125216. */
  125217. renderingGroupId?: number;
  125218. /**
  125219. * Should teleportation move only to snap points
  125220. */
  125221. snapPointsOnly?: boolean;
  125222. /**
  125223. * An array of points to which the teleportation will snap to.
  125224. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  125225. */
  125226. snapPositions?: Vector3[];
  125227. /**
  125228. * How close should the teleportation ray be in order to snap to position.
  125229. * Default to 0.8 units (meters)
  125230. */
  125231. snapToPositionRadius?: number;
  125232. /**
  125233. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  125234. * If you want to support rotation, make sure your mesh has a direction indicator.
  125235. *
  125236. * When left untouched, the default mesh will be initialized.
  125237. */
  125238. teleportationTargetMesh?: AbstractMesh;
  125239. /**
  125240. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  125241. */
  125242. timeToTeleport?: number;
  125243. /**
  125244. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  125245. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  125246. */
  125247. useMainComponentOnly?: boolean;
  125248. /**
  125249. * Should meshes created here be added to a utility layer or the main scene
  125250. */
  125251. useUtilityLayer?: boolean;
  125252. /**
  125253. * Babylon XR Input class for controller
  125254. */
  125255. xrInput: WebXRInput;
  125256. }
  125257. /**
  125258. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  125259. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  125260. * the input of the attached controllers.
  125261. */
  125262. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  125263. private _options;
  125264. private _controllers;
  125265. private _currentTeleportationControllerId;
  125266. private _floorMeshes;
  125267. private _quadraticBezierCurve;
  125268. private _selectionFeature;
  125269. private _snapToPositions;
  125270. private _snappedToPoint;
  125271. private _teleportationRingMaterial?;
  125272. private _tmpRay;
  125273. private _tmpVector;
  125274. /**
  125275. * The module's name
  125276. */
  125277. static readonly Name: string;
  125278. /**
  125279. * The (Babylon) version of this module.
  125280. * This is an integer representing the implementation version.
  125281. * This number does not correspond to the webxr specs version
  125282. */
  125283. static readonly Version: number;
  125284. /**
  125285. * Is movement backwards enabled
  125286. */
  125287. backwardsMovementEnabled: boolean;
  125288. /**
  125289. * Distance to travel when moving backwards
  125290. */
  125291. backwardsTeleportationDistance: number;
  125292. /**
  125293. * The distance from the user to the inspection point in the direction of the controller
  125294. * A higher number will allow the user to move further
  125295. * defaults to 5 (meters, in xr units)
  125296. */
  125297. parabolicCheckRadius: number;
  125298. /**
  125299. * Should the module support parabolic ray on top of direct ray
  125300. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  125301. * Very helpful when moving between floors / different heights
  125302. */
  125303. parabolicRayEnabled: boolean;
  125304. /**
  125305. * How much rotation should be applied when rotating right and left
  125306. */
  125307. rotationAngle: number;
  125308. /**
  125309. * Is rotation enabled when moving forward?
  125310. * Disabling this feature will prevent the user from deciding the direction when teleporting
  125311. */
  125312. rotationEnabled: boolean;
  125313. /**
  125314. * constructs a new anchor system
  125315. * @param _xrSessionManager an instance of WebXRSessionManager
  125316. * @param _options configuration object for this feature
  125317. */
  125318. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  125319. /**
  125320. * Get the snapPointsOnly flag
  125321. */
  125322. get snapPointsOnly(): boolean;
  125323. /**
  125324. * Sets the snapPointsOnly flag
  125325. * @param snapToPoints should teleportation be exclusively to snap points
  125326. */
  125327. set snapPointsOnly(snapToPoints: boolean);
  125328. /**
  125329. * Add a new mesh to the floor meshes array
  125330. * @param mesh the mesh to use as floor mesh
  125331. */
  125332. addFloorMesh(mesh: AbstractMesh): void;
  125333. /**
  125334. * Add a new snap-to point to fix teleportation to this position
  125335. * @param newSnapPoint The new Snap-To point
  125336. */
  125337. addSnapPoint(newSnapPoint: Vector3): void;
  125338. attach(): boolean;
  125339. detach(): boolean;
  125340. dispose(): void;
  125341. /**
  125342. * Remove a mesh from the floor meshes array
  125343. * @param mesh the mesh to remove
  125344. */
  125345. removeFloorMesh(mesh: AbstractMesh): void;
  125346. /**
  125347. * Remove a mesh from the floor meshes array using its name
  125348. * @param name the mesh name to remove
  125349. */
  125350. removeFloorMeshByName(name: string): void;
  125351. /**
  125352. * 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
  125353. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  125354. * @returns was the point found and removed or not
  125355. */
  125356. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  125357. /**
  125358. * This function sets a selection feature that will be disabled when
  125359. * the forward ray is shown and will be reattached when hidden.
  125360. * This is used to remove the selection rays when moving.
  125361. * @param selectionFeature the feature to disable when forward movement is enabled
  125362. */
  125363. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  125364. protected _onXRFrame(_xrFrame: XRFrame): void;
  125365. private _attachController;
  125366. private _createDefaultTargetMesh;
  125367. private _detachController;
  125368. private _findClosestSnapPointWithRadius;
  125369. private _setTargetMeshPosition;
  125370. private _setTargetMeshVisibility;
  125371. private _showParabolicPath;
  125372. private _teleportForward;
  125373. }
  125374. }
  125375. declare module BABYLON {
  125376. /**
  125377. * Options for the default xr helper
  125378. */
  125379. export class WebXRDefaultExperienceOptions {
  125380. /**
  125381. * Enable or disable default UI to enter XR
  125382. */
  125383. disableDefaultUI?: boolean;
  125384. /**
  125385. * Should teleportation not initialize. defaults to false.
  125386. */
  125387. disableTeleportation?: boolean;
  125388. /**
  125389. * Floor meshes that will be used for teleport
  125390. */
  125391. floorMeshes?: Array<AbstractMesh>;
  125392. /**
  125393. * If set to true, the first frame will not be used to reset position
  125394. * The first frame is mainly used when copying transformation from the old camera
  125395. * Mainly used in AR
  125396. */
  125397. ignoreNativeCameraTransformation?: boolean;
  125398. /**
  125399. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  125400. */
  125401. inputOptions?: IWebXRInputOptions;
  125402. /**
  125403. * optional configuration for the output canvas
  125404. */
  125405. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  125406. /**
  125407. * optional UI options. This can be used among other to change session mode and reference space type
  125408. */
  125409. uiOptions?: WebXREnterExitUIOptions;
  125410. /**
  125411. * When loading teleportation and pointer select, use stable versions instead of latest.
  125412. */
  125413. useStablePlugins?: boolean;
  125414. /**
  125415. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  125416. */
  125417. renderingGroupId?: number;
  125418. /**
  125419. * A list of optional features to init the session with
  125420. * If set to true, all features we support will be added
  125421. */
  125422. optionalFeatures?: boolean | string[];
  125423. }
  125424. /**
  125425. * Default experience which provides a similar setup to the previous webVRExperience
  125426. */
  125427. export class WebXRDefaultExperience {
  125428. /**
  125429. * Base experience
  125430. */
  125431. baseExperience: WebXRExperienceHelper;
  125432. /**
  125433. * Enables ui for entering/exiting xr
  125434. */
  125435. enterExitUI: WebXREnterExitUI;
  125436. /**
  125437. * Input experience extension
  125438. */
  125439. input: WebXRInput;
  125440. /**
  125441. * Enables laser pointer and selection
  125442. */
  125443. pointerSelection: WebXRControllerPointerSelection;
  125444. /**
  125445. * Default target xr should render to
  125446. */
  125447. renderTarget: WebXRRenderTarget;
  125448. /**
  125449. * Enables teleportation
  125450. */
  125451. teleportation: WebXRMotionControllerTeleportation;
  125452. private constructor();
  125453. /**
  125454. * Creates the default xr experience
  125455. * @param scene scene
  125456. * @param options options for basic configuration
  125457. * @returns resulting WebXRDefaultExperience
  125458. */
  125459. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125460. /**
  125461. * DIsposes of the experience helper
  125462. */
  125463. dispose(): void;
  125464. }
  125465. }
  125466. declare module BABYLON {
  125467. /**
  125468. * Options to modify the vr teleportation behavior.
  125469. */
  125470. export interface VRTeleportationOptions {
  125471. /**
  125472. * The name of the mesh which should be used as the teleportation floor. (default: null)
  125473. */
  125474. floorMeshName?: string;
  125475. /**
  125476. * A list of meshes to be used as the teleportation floor. (default: empty)
  125477. */
  125478. floorMeshes?: Mesh[];
  125479. /**
  125480. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  125481. */
  125482. teleportationMode?: number;
  125483. /**
  125484. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  125485. */
  125486. teleportationTime?: number;
  125487. /**
  125488. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  125489. */
  125490. teleportationSpeed?: number;
  125491. /**
  125492. * The easing function used in the animation or null for Linear. (default CircleEase)
  125493. */
  125494. easingFunction?: EasingFunction;
  125495. }
  125496. /**
  125497. * Options to modify the vr experience helper's behavior.
  125498. */
  125499. export interface VRExperienceHelperOptions extends WebVROptions {
  125500. /**
  125501. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  125502. */
  125503. createDeviceOrientationCamera?: boolean;
  125504. /**
  125505. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  125506. */
  125507. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  125508. /**
  125509. * Uses the main button on the controller to toggle the laser casted. (default: true)
  125510. */
  125511. laserToggle?: boolean;
  125512. /**
  125513. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  125514. */
  125515. floorMeshes?: Mesh[];
  125516. /**
  125517. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  125518. */
  125519. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  125520. /**
  125521. * Defines if WebXR should be used instead of WebVR (if available)
  125522. */
  125523. useXR?: boolean;
  125524. }
  125525. /**
  125526. * Event containing information after VR has been entered
  125527. */
  125528. export class OnAfterEnteringVRObservableEvent {
  125529. /**
  125530. * If entering vr was successful
  125531. */
  125532. success: boolean;
  125533. }
  125534. /**
  125535. * Helps to quickly add VR support to an existing scene.
  125536. * See http://doc.babylonjs.com/how_to/webvr_helper
  125537. */
  125538. export class VRExperienceHelper {
  125539. /** Options to modify the vr experience helper's behavior. */
  125540. webVROptions: VRExperienceHelperOptions;
  125541. private _scene;
  125542. private _position;
  125543. private _btnVR;
  125544. private _btnVRDisplayed;
  125545. private _webVRsupported;
  125546. private _webVRready;
  125547. private _webVRrequesting;
  125548. private _webVRpresenting;
  125549. private _hasEnteredVR;
  125550. private _fullscreenVRpresenting;
  125551. private _inputElement;
  125552. private _webVRCamera;
  125553. private _vrDeviceOrientationCamera;
  125554. private _deviceOrientationCamera;
  125555. private _existingCamera;
  125556. private _onKeyDown;
  125557. private _onVrDisplayPresentChange;
  125558. private _onVRDisplayChanged;
  125559. private _onVRRequestPresentStart;
  125560. private _onVRRequestPresentComplete;
  125561. /**
  125562. * 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)
  125563. */
  125564. enableGazeEvenWhenNoPointerLock: boolean;
  125565. /**
  125566. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  125567. */
  125568. exitVROnDoubleTap: boolean;
  125569. /**
  125570. * Observable raised right before entering VR.
  125571. */
  125572. onEnteringVRObservable: Observable<VRExperienceHelper>;
  125573. /**
  125574. * Observable raised when entering VR has completed.
  125575. */
  125576. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  125577. /**
  125578. * Observable raised when exiting VR.
  125579. */
  125580. onExitingVRObservable: Observable<VRExperienceHelper>;
  125581. /**
  125582. * Observable raised when controller mesh is loaded.
  125583. */
  125584. onControllerMeshLoadedObservable: Observable<WebVRController>;
  125585. /** Return this.onEnteringVRObservable
  125586. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  125587. */
  125588. get onEnteringVR(): Observable<VRExperienceHelper>;
  125589. /** Return this.onExitingVRObservable
  125590. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  125591. */
  125592. get onExitingVR(): Observable<VRExperienceHelper>;
  125593. /** Return this.onControllerMeshLoadedObservable
  125594. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  125595. */
  125596. get onControllerMeshLoaded(): Observable<WebVRController>;
  125597. private _rayLength;
  125598. private _useCustomVRButton;
  125599. private _teleportationRequested;
  125600. private _teleportActive;
  125601. private _floorMeshName;
  125602. private _floorMeshesCollection;
  125603. private _teleportationMode;
  125604. private _teleportationTime;
  125605. private _teleportationSpeed;
  125606. private _teleportationEasing;
  125607. private _rotationAllowed;
  125608. private _teleportBackwardsVector;
  125609. private _teleportationTarget;
  125610. private _isDefaultTeleportationTarget;
  125611. private _postProcessMove;
  125612. private _teleportationFillColor;
  125613. private _teleportationBorderColor;
  125614. private _rotationAngle;
  125615. private _haloCenter;
  125616. private _cameraGazer;
  125617. private _padSensibilityUp;
  125618. private _padSensibilityDown;
  125619. private _leftController;
  125620. private _rightController;
  125621. private _gazeColor;
  125622. private _laserColor;
  125623. private _pickedLaserColor;
  125624. private _pickedGazeColor;
  125625. /**
  125626. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  125627. */
  125628. onNewMeshSelected: Observable<AbstractMesh>;
  125629. /**
  125630. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  125631. * This observable will provide the mesh and the controller used to select the mesh
  125632. */
  125633. onMeshSelectedWithController: Observable<{
  125634. mesh: AbstractMesh;
  125635. controller: WebVRController;
  125636. }>;
  125637. /**
  125638. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  125639. */
  125640. onNewMeshPicked: Observable<PickingInfo>;
  125641. private _circleEase;
  125642. /**
  125643. * Observable raised before camera teleportation
  125644. */
  125645. onBeforeCameraTeleport: Observable<Vector3>;
  125646. /**
  125647. * Observable raised after camera teleportation
  125648. */
  125649. onAfterCameraTeleport: Observable<Vector3>;
  125650. /**
  125651. * Observable raised when current selected mesh gets unselected
  125652. */
  125653. onSelectedMeshUnselected: Observable<AbstractMesh>;
  125654. private _raySelectionPredicate;
  125655. /**
  125656. * To be optionaly changed by user to define custom ray selection
  125657. */
  125658. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  125659. /**
  125660. * To be optionaly changed by user to define custom selection logic (after ray selection)
  125661. */
  125662. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  125663. /**
  125664. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  125665. */
  125666. teleportationEnabled: boolean;
  125667. private _defaultHeight;
  125668. private _teleportationInitialized;
  125669. private _interactionsEnabled;
  125670. private _interactionsRequested;
  125671. private _displayGaze;
  125672. private _displayLaserPointer;
  125673. /**
  125674. * The mesh used to display where the user is going to teleport.
  125675. */
  125676. get teleportationTarget(): Mesh;
  125677. /**
  125678. * Sets the mesh to be used to display where the user is going to teleport.
  125679. */
  125680. set teleportationTarget(value: Mesh);
  125681. /**
  125682. * 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
  125683. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  125684. * See http://doc.babylonjs.com/resources/baking_transformations
  125685. */
  125686. get gazeTrackerMesh(): Mesh;
  125687. set gazeTrackerMesh(value: Mesh);
  125688. /**
  125689. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  125690. */
  125691. updateGazeTrackerScale: boolean;
  125692. /**
  125693. * If the gaze trackers color should be updated when selecting meshes
  125694. */
  125695. updateGazeTrackerColor: boolean;
  125696. /**
  125697. * If the controller laser color should be updated when selecting meshes
  125698. */
  125699. updateControllerLaserColor: boolean;
  125700. /**
  125701. * The gaze tracking mesh corresponding to the left controller
  125702. */
  125703. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  125704. /**
  125705. * The gaze tracking mesh corresponding to the right controller
  125706. */
  125707. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  125708. /**
  125709. * If the ray of the gaze should be displayed.
  125710. */
  125711. get displayGaze(): boolean;
  125712. /**
  125713. * Sets if the ray of the gaze should be displayed.
  125714. */
  125715. set displayGaze(value: boolean);
  125716. /**
  125717. * If the ray of the LaserPointer should be displayed.
  125718. */
  125719. get displayLaserPointer(): boolean;
  125720. /**
  125721. * Sets if the ray of the LaserPointer should be displayed.
  125722. */
  125723. set displayLaserPointer(value: boolean);
  125724. /**
  125725. * The deviceOrientationCamera used as the camera when not in VR.
  125726. */
  125727. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  125728. /**
  125729. * Based on the current WebVR support, returns the current VR camera used.
  125730. */
  125731. get currentVRCamera(): Nullable<Camera>;
  125732. /**
  125733. * The webVRCamera which is used when in VR.
  125734. */
  125735. get webVRCamera(): WebVRFreeCamera;
  125736. /**
  125737. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  125738. */
  125739. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  125740. /**
  125741. * The html button that is used to trigger entering into VR.
  125742. */
  125743. get vrButton(): Nullable<HTMLButtonElement>;
  125744. private get _teleportationRequestInitiated();
  125745. /**
  125746. * Defines whether or not Pointer lock should be requested when switching to
  125747. * full screen.
  125748. */
  125749. requestPointerLockOnFullScreen: boolean;
  125750. /**
  125751. * If asking to force XR, this will be populated with the default xr experience
  125752. */
  125753. xr: WebXRDefaultExperience;
  125754. /**
  125755. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  125756. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  125757. */
  125758. xrTestDone: boolean;
  125759. /**
  125760. * Instantiates a VRExperienceHelper.
  125761. * Helps to quickly add VR support to an existing scene.
  125762. * @param scene The scene the VRExperienceHelper belongs to.
  125763. * @param webVROptions Options to modify the vr experience helper's behavior.
  125764. */
  125765. constructor(scene: Scene,
  125766. /** Options to modify the vr experience helper's behavior. */
  125767. webVROptions?: VRExperienceHelperOptions);
  125768. private completeVRInit;
  125769. private _onDefaultMeshLoaded;
  125770. private _onResize;
  125771. private _onFullscreenChange;
  125772. /**
  125773. * Gets a value indicating if we are currently in VR mode.
  125774. */
  125775. get isInVRMode(): boolean;
  125776. private onVrDisplayPresentChange;
  125777. private onVRDisplayChanged;
  125778. private moveButtonToBottomRight;
  125779. private displayVRButton;
  125780. private updateButtonVisibility;
  125781. private _cachedAngularSensibility;
  125782. /**
  125783. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  125784. * Otherwise, will use the fullscreen API.
  125785. */
  125786. enterVR(): void;
  125787. /**
  125788. * Attempt to exit VR, or fullscreen.
  125789. */
  125790. exitVR(): void;
  125791. /**
  125792. * The position of the vr experience helper.
  125793. */
  125794. get position(): Vector3;
  125795. /**
  125796. * Sets the position of the vr experience helper.
  125797. */
  125798. set position(value: Vector3);
  125799. /**
  125800. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  125801. */
  125802. enableInteractions(): void;
  125803. private get _noControllerIsActive();
  125804. private beforeRender;
  125805. private _isTeleportationFloor;
  125806. /**
  125807. * Adds a floor mesh to be used for teleportation.
  125808. * @param floorMesh the mesh to be used for teleportation.
  125809. */
  125810. addFloorMesh(floorMesh: Mesh): void;
  125811. /**
  125812. * Removes a floor mesh from being used for teleportation.
  125813. * @param floorMesh the mesh to be removed.
  125814. */
  125815. removeFloorMesh(floorMesh: Mesh): void;
  125816. /**
  125817. * Enables interactions and teleportation using the VR controllers and gaze.
  125818. * @param vrTeleportationOptions options to modify teleportation behavior.
  125819. */
  125820. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  125821. private _onNewGamepadConnected;
  125822. private _tryEnableInteractionOnController;
  125823. private _onNewGamepadDisconnected;
  125824. private _enableInteractionOnController;
  125825. private _checkTeleportWithRay;
  125826. private _checkRotate;
  125827. private _checkTeleportBackwards;
  125828. private _enableTeleportationOnController;
  125829. private _createTeleportationCircles;
  125830. private _displayTeleportationTarget;
  125831. private _hideTeleportationTarget;
  125832. private _rotateCamera;
  125833. private _moveTeleportationSelectorTo;
  125834. private _workingVector;
  125835. private _workingQuaternion;
  125836. private _workingMatrix;
  125837. /**
  125838. * Time Constant Teleportation Mode
  125839. */
  125840. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  125841. /**
  125842. * Speed Constant Teleportation Mode
  125843. */
  125844. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  125845. /**
  125846. * Teleports the users feet to the desired location
  125847. * @param location The location where the user's feet should be placed
  125848. */
  125849. teleportCamera(location: Vector3): void;
  125850. private _convertNormalToDirectionOfRay;
  125851. private _castRayAndSelectObject;
  125852. private _notifySelectedMeshUnselected;
  125853. /**
  125854. * Permanently set new colors for the laser pointer
  125855. * @param color the new laser color
  125856. * @param pickedColor the new laser color when picked mesh detected
  125857. */
  125858. setLaserColor(color: Color3, pickedColor?: Color3): void;
  125859. /**
  125860. * Set lighting enabled / disabled on the laser pointer of both controllers
  125861. * @param enabled should the lighting be enabled on the laser pointer
  125862. */
  125863. setLaserLightingState(enabled?: boolean): void;
  125864. /**
  125865. * Permanently set new colors for the gaze pointer
  125866. * @param color the new gaze color
  125867. * @param pickedColor the new gaze color when picked mesh detected
  125868. */
  125869. setGazeColor(color: Color3, pickedColor?: Color3): void;
  125870. /**
  125871. * Sets the color of the laser ray from the vr controllers.
  125872. * @param color new color for the ray.
  125873. */
  125874. changeLaserColor(color: Color3): void;
  125875. /**
  125876. * Sets the color of the ray from the vr headsets gaze.
  125877. * @param color new color for the ray.
  125878. */
  125879. changeGazeColor(color: Color3): void;
  125880. /**
  125881. * Exits VR and disposes of the vr experience helper
  125882. */
  125883. dispose(): void;
  125884. /**
  125885. * Gets the name of the VRExperienceHelper class
  125886. * @returns "VRExperienceHelper"
  125887. */
  125888. getClassName(): string;
  125889. }
  125890. }
  125891. declare module BABYLON {
  125892. /**
  125893. * Contains an array of blocks representing the octree
  125894. */
  125895. export interface IOctreeContainer<T> {
  125896. /**
  125897. * Blocks within the octree
  125898. */
  125899. blocks: Array<OctreeBlock<T>>;
  125900. }
  125901. /**
  125902. * Class used to store a cell in an octree
  125903. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125904. */
  125905. export class OctreeBlock<T> {
  125906. /**
  125907. * Gets the content of the current block
  125908. */
  125909. entries: T[];
  125910. /**
  125911. * Gets the list of block children
  125912. */
  125913. blocks: Array<OctreeBlock<T>>;
  125914. private _depth;
  125915. private _maxDepth;
  125916. private _capacity;
  125917. private _minPoint;
  125918. private _maxPoint;
  125919. private _boundingVectors;
  125920. private _creationFunc;
  125921. /**
  125922. * Creates a new block
  125923. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  125924. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  125925. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  125926. * @param depth defines the current depth of this block in the octree
  125927. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  125928. * @param creationFunc defines a callback to call when an element is added to the block
  125929. */
  125930. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  125931. /**
  125932. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  125933. */
  125934. get capacity(): number;
  125935. /**
  125936. * Gets the minimum vector (in world space) of the block's bounding box
  125937. */
  125938. get minPoint(): Vector3;
  125939. /**
  125940. * Gets the maximum vector (in world space) of the block's bounding box
  125941. */
  125942. get maxPoint(): Vector3;
  125943. /**
  125944. * Add a new element to this block
  125945. * @param entry defines the element to add
  125946. */
  125947. addEntry(entry: T): void;
  125948. /**
  125949. * Remove an element from this block
  125950. * @param entry defines the element to remove
  125951. */
  125952. removeEntry(entry: T): void;
  125953. /**
  125954. * Add an array of elements to this block
  125955. * @param entries defines the array of elements to add
  125956. */
  125957. addEntries(entries: T[]): void;
  125958. /**
  125959. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  125960. * @param frustumPlanes defines the frustum planes to test
  125961. * @param selection defines the array to store current content if selection is positive
  125962. * @param allowDuplicate defines if the selection array can contains duplicated entries
  125963. */
  125964. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  125965. /**
  125966. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  125967. * @param sphereCenter defines the bounding sphere center
  125968. * @param sphereRadius defines the bounding sphere radius
  125969. * @param selection defines the array to store current content if selection is positive
  125970. * @param allowDuplicate defines if the selection array can contains duplicated entries
  125971. */
  125972. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  125973. /**
  125974. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  125975. * @param ray defines the ray to test with
  125976. * @param selection defines the array to store current content if selection is positive
  125977. */
  125978. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  125979. /**
  125980. * Subdivide the content into child blocks (this block will then be empty)
  125981. */
  125982. createInnerBlocks(): void;
  125983. /**
  125984. * @hidden
  125985. */
  125986. 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;
  125987. }
  125988. }
  125989. declare module BABYLON {
  125990. /**
  125991. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  125992. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125993. */
  125994. export class Octree<T> {
  125995. /** 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.) */
  125996. maxDepth: number;
  125997. /**
  125998. * Blocks within the octree containing objects
  125999. */
  126000. blocks: Array<OctreeBlock<T>>;
  126001. /**
  126002. * Content stored in the octree
  126003. */
  126004. dynamicContent: T[];
  126005. private _maxBlockCapacity;
  126006. private _selectionContent;
  126007. private _creationFunc;
  126008. /**
  126009. * Creates a octree
  126010. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126011. * @param creationFunc function to be used to instatiate the octree
  126012. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  126013. * @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.)
  126014. */
  126015. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  126016. /** 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.) */
  126017. maxDepth?: number);
  126018. /**
  126019. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  126020. * @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);
  126021. * @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);
  126022. * @param entries meshes to be added to the octree blocks
  126023. */
  126024. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  126025. /**
  126026. * Adds a mesh to the octree
  126027. * @param entry Mesh to add to the octree
  126028. */
  126029. addMesh(entry: T): void;
  126030. /**
  126031. * Remove an element from the octree
  126032. * @param entry defines the element to remove
  126033. */
  126034. removeMesh(entry: T): void;
  126035. /**
  126036. * Selects an array of meshes within the frustum
  126037. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  126038. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  126039. * @returns array of meshes within the frustum
  126040. */
  126041. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  126042. /**
  126043. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  126044. * @param sphereCenter defines the bounding sphere center
  126045. * @param sphereRadius defines the bounding sphere radius
  126046. * @param allowDuplicate defines if the selection array can contains duplicated entries
  126047. * @returns an array of objects that intersect the sphere
  126048. */
  126049. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  126050. /**
  126051. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  126052. * @param ray defines the ray to test with
  126053. * @returns array of intersected objects
  126054. */
  126055. intersectsRay(ray: Ray): SmartArray<T>;
  126056. /**
  126057. * Adds a mesh into the octree block if it intersects the block
  126058. */
  126059. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  126060. /**
  126061. * Adds a submesh into the octree block if it intersects the block
  126062. */
  126063. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  126064. }
  126065. }
  126066. declare module BABYLON {
  126067. interface Scene {
  126068. /**
  126069. * @hidden
  126070. * Backing Filed
  126071. */
  126072. _selectionOctree: Octree<AbstractMesh>;
  126073. /**
  126074. * Gets the octree used to boost mesh selection (picking)
  126075. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126076. */
  126077. selectionOctree: Octree<AbstractMesh>;
  126078. /**
  126079. * Creates or updates the octree used to boost selection (picking)
  126080. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126081. * @param maxCapacity defines the maximum capacity per leaf
  126082. * @param maxDepth defines the maximum depth of the octree
  126083. * @returns an octree of AbstractMesh
  126084. */
  126085. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  126086. }
  126087. interface AbstractMesh {
  126088. /**
  126089. * @hidden
  126090. * Backing Field
  126091. */
  126092. _submeshesOctree: Octree<SubMesh>;
  126093. /**
  126094. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  126095. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  126096. * @param maxCapacity defines the maximum size of each block (64 by default)
  126097. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  126098. * @returns the new octree
  126099. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  126100. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126101. */
  126102. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  126103. }
  126104. /**
  126105. * Defines the octree scene component responsible to manage any octrees
  126106. * in a given scene.
  126107. */
  126108. export class OctreeSceneComponent {
  126109. /**
  126110. * The component name help to identify the component in the list of scene components.
  126111. */
  126112. readonly name: string;
  126113. /**
  126114. * The scene the component belongs to.
  126115. */
  126116. scene: Scene;
  126117. /**
  126118. * Indicates if the meshes have been checked to make sure they are isEnabled()
  126119. */
  126120. readonly checksIsEnabled: boolean;
  126121. /**
  126122. * Creates a new instance of the component for the given scene
  126123. * @param scene Defines the scene to register the component in
  126124. */
  126125. constructor(scene: Scene);
  126126. /**
  126127. * Registers the component in a given scene
  126128. */
  126129. register(): void;
  126130. /**
  126131. * Return the list of active meshes
  126132. * @returns the list of active meshes
  126133. */
  126134. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  126135. /**
  126136. * Return the list of active sub meshes
  126137. * @param mesh The mesh to get the candidates sub meshes from
  126138. * @returns the list of active sub meshes
  126139. */
  126140. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  126141. private _tempRay;
  126142. /**
  126143. * Return the list of sub meshes intersecting with a given local ray
  126144. * @param mesh defines the mesh to find the submesh for
  126145. * @param localRay defines the ray in local space
  126146. * @returns the list of intersecting sub meshes
  126147. */
  126148. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  126149. /**
  126150. * Return the list of sub meshes colliding with a collider
  126151. * @param mesh defines the mesh to find the submesh for
  126152. * @param collider defines the collider to evaluate the collision against
  126153. * @returns the list of colliding sub meshes
  126154. */
  126155. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  126156. /**
  126157. * Rebuilds the elements related to this component in case of
  126158. * context lost for instance.
  126159. */
  126160. rebuild(): void;
  126161. /**
  126162. * Disposes the component and the associated ressources.
  126163. */
  126164. dispose(): void;
  126165. }
  126166. }
  126167. declare module BABYLON {
  126168. /**
  126169. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  126170. */
  126171. export class Gizmo implements IDisposable {
  126172. /** The utility layer the gizmo will be added to */
  126173. gizmoLayer: UtilityLayerRenderer;
  126174. /**
  126175. * The root mesh of the gizmo
  126176. */
  126177. _rootMesh: Mesh;
  126178. private _attachedMesh;
  126179. /**
  126180. * Ratio for the scale of the gizmo (Default: 1)
  126181. */
  126182. scaleRatio: number;
  126183. /**
  126184. * If a custom mesh has been set (Default: false)
  126185. */
  126186. protected _customMeshSet: boolean;
  126187. /**
  126188. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  126189. * * When set, interactions will be enabled
  126190. */
  126191. get attachedMesh(): Nullable<AbstractMesh>;
  126192. set attachedMesh(value: Nullable<AbstractMesh>);
  126193. /**
  126194. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  126195. * @param mesh The mesh to replace the default mesh of the gizmo
  126196. */
  126197. setCustomMesh(mesh: Mesh): void;
  126198. /**
  126199. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  126200. */
  126201. updateGizmoRotationToMatchAttachedMesh: boolean;
  126202. /**
  126203. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  126204. */
  126205. updateGizmoPositionToMatchAttachedMesh: boolean;
  126206. /**
  126207. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  126208. */
  126209. updateScale: boolean;
  126210. protected _interactionsEnabled: boolean;
  126211. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  126212. private _beforeRenderObserver;
  126213. private _tempVector;
  126214. /**
  126215. * Creates a gizmo
  126216. * @param gizmoLayer The utility layer the gizmo will be added to
  126217. */
  126218. constructor(
  126219. /** The utility layer the gizmo will be added to */
  126220. gizmoLayer?: UtilityLayerRenderer);
  126221. /**
  126222. * Updates the gizmo to match the attached mesh's position/rotation
  126223. */
  126224. protected _update(): void;
  126225. /**
  126226. * Disposes of the gizmo
  126227. */
  126228. dispose(): void;
  126229. }
  126230. }
  126231. declare module BABYLON {
  126232. /**
  126233. * Single plane drag gizmo
  126234. */
  126235. export class PlaneDragGizmo extends Gizmo {
  126236. /**
  126237. * Drag behavior responsible for the gizmos dragging interactions
  126238. */
  126239. dragBehavior: PointerDragBehavior;
  126240. private _pointerObserver;
  126241. /**
  126242. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  126243. */
  126244. snapDistance: number;
  126245. /**
  126246. * Event that fires each time the gizmo snaps to a new location.
  126247. * * snapDistance is the the change in distance
  126248. */
  126249. onSnapObservable: Observable<{
  126250. snapDistance: number;
  126251. }>;
  126252. private _plane;
  126253. private _coloredMaterial;
  126254. private _hoverMaterial;
  126255. private _isEnabled;
  126256. private _parent;
  126257. /** @hidden */
  126258. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  126259. /** @hidden */
  126260. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  126261. /**
  126262. * Creates a PlaneDragGizmo
  126263. * @param gizmoLayer The utility layer the gizmo will be added to
  126264. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  126265. * @param color The color of the gizmo
  126266. */
  126267. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  126268. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  126269. /**
  126270. * If the gizmo is enabled
  126271. */
  126272. set isEnabled(value: boolean);
  126273. get isEnabled(): boolean;
  126274. /**
  126275. * Disposes of the gizmo
  126276. */
  126277. dispose(): void;
  126278. }
  126279. }
  126280. declare module BABYLON {
  126281. /**
  126282. * Gizmo that enables dragging a mesh along 3 axis
  126283. */
  126284. export class PositionGizmo extends Gizmo {
  126285. /**
  126286. * Internal gizmo used for interactions on the x axis
  126287. */
  126288. xGizmo: AxisDragGizmo;
  126289. /**
  126290. * Internal gizmo used for interactions on the y axis
  126291. */
  126292. yGizmo: AxisDragGizmo;
  126293. /**
  126294. * Internal gizmo used for interactions on the z axis
  126295. */
  126296. zGizmo: AxisDragGizmo;
  126297. /**
  126298. * Internal gizmo used for interactions on the yz plane
  126299. */
  126300. xPlaneGizmo: PlaneDragGizmo;
  126301. /**
  126302. * Internal gizmo used for interactions on the xz plane
  126303. */
  126304. yPlaneGizmo: PlaneDragGizmo;
  126305. /**
  126306. * Internal gizmo used for interactions on the xy plane
  126307. */
  126308. zPlaneGizmo: PlaneDragGizmo;
  126309. /**
  126310. * private variables
  126311. */
  126312. private _meshAttached;
  126313. private _updateGizmoRotationToMatchAttachedMesh;
  126314. private _snapDistance;
  126315. private _scaleRatio;
  126316. /** Fires an event when any of it's sub gizmos are dragged */
  126317. onDragStartObservable: Observable<unknown>;
  126318. /** Fires an event when any of it's sub gizmos are released from dragging */
  126319. onDragEndObservable: Observable<unknown>;
  126320. /**
  126321. * If set to true, planar drag is enabled
  126322. */
  126323. private _planarGizmoEnabled;
  126324. get attachedMesh(): Nullable<AbstractMesh>;
  126325. set attachedMesh(mesh: Nullable<AbstractMesh>);
  126326. /**
  126327. * Creates a PositionGizmo
  126328. * @param gizmoLayer The utility layer the gizmo will be added to
  126329. */
  126330. constructor(gizmoLayer?: UtilityLayerRenderer);
  126331. /**
  126332. * If the planar drag gizmo is enabled
  126333. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  126334. */
  126335. set planarGizmoEnabled(value: boolean);
  126336. get planarGizmoEnabled(): boolean;
  126337. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  126338. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  126339. /**
  126340. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  126341. */
  126342. set snapDistance(value: number);
  126343. get snapDistance(): number;
  126344. /**
  126345. * Ratio for the scale of the gizmo (Default: 1)
  126346. */
  126347. set scaleRatio(value: number);
  126348. get scaleRatio(): number;
  126349. /**
  126350. * Disposes of the gizmo
  126351. */
  126352. dispose(): void;
  126353. /**
  126354. * CustomMeshes are not supported by this gizmo
  126355. * @param mesh The mesh to replace the default mesh of the gizmo
  126356. */
  126357. setCustomMesh(mesh: Mesh): void;
  126358. }
  126359. }
  126360. declare module BABYLON {
  126361. /**
  126362. * Single axis drag gizmo
  126363. */
  126364. export class AxisDragGizmo extends Gizmo {
  126365. /**
  126366. * Drag behavior responsible for the gizmos dragging interactions
  126367. */
  126368. dragBehavior: PointerDragBehavior;
  126369. private _pointerObserver;
  126370. /**
  126371. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  126372. */
  126373. snapDistance: number;
  126374. /**
  126375. * Event that fires each time the gizmo snaps to a new location.
  126376. * * snapDistance is the the change in distance
  126377. */
  126378. onSnapObservable: Observable<{
  126379. snapDistance: number;
  126380. }>;
  126381. private _isEnabled;
  126382. private _parent;
  126383. private _arrow;
  126384. private _coloredMaterial;
  126385. private _hoverMaterial;
  126386. /** @hidden */
  126387. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  126388. /** @hidden */
  126389. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  126390. /**
  126391. * Creates an AxisDragGizmo
  126392. * @param gizmoLayer The utility layer the gizmo will be added to
  126393. * @param dragAxis The axis which the gizmo will be able to drag on
  126394. * @param color The color of the gizmo
  126395. */
  126396. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  126397. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  126398. /**
  126399. * If the gizmo is enabled
  126400. */
  126401. set isEnabled(value: boolean);
  126402. get isEnabled(): boolean;
  126403. /**
  126404. * Disposes of the gizmo
  126405. */
  126406. dispose(): void;
  126407. }
  126408. }
  126409. declare module BABYLON.Debug {
  126410. /**
  126411. * The Axes viewer will show 3 axes in a specific point in space
  126412. */
  126413. export class AxesViewer {
  126414. private _xAxis;
  126415. private _yAxis;
  126416. private _zAxis;
  126417. private _scaleLinesFactor;
  126418. private _instanced;
  126419. /**
  126420. * Gets the hosting scene
  126421. */
  126422. scene: Scene;
  126423. /**
  126424. * Gets or sets a number used to scale line length
  126425. */
  126426. scaleLines: number;
  126427. /** Gets the node hierarchy used to render x-axis */
  126428. get xAxis(): TransformNode;
  126429. /** Gets the node hierarchy used to render y-axis */
  126430. get yAxis(): TransformNode;
  126431. /** Gets the node hierarchy used to render z-axis */
  126432. get zAxis(): TransformNode;
  126433. /**
  126434. * Creates a new AxesViewer
  126435. * @param scene defines the hosting scene
  126436. * @param scaleLines defines a number used to scale line length (1 by default)
  126437. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  126438. * @param xAxis defines the node hierarchy used to render the x-axis
  126439. * @param yAxis defines the node hierarchy used to render the y-axis
  126440. * @param zAxis defines the node hierarchy used to render the z-axis
  126441. */
  126442. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  126443. /**
  126444. * Force the viewer to update
  126445. * @param position defines the position of the viewer
  126446. * @param xaxis defines the x axis of the viewer
  126447. * @param yaxis defines the y axis of the viewer
  126448. * @param zaxis defines the z axis of the viewer
  126449. */
  126450. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  126451. /**
  126452. * Creates an instance of this axes viewer.
  126453. * @returns a new axes viewer with instanced meshes
  126454. */
  126455. createInstance(): AxesViewer;
  126456. /** Releases resources */
  126457. dispose(): void;
  126458. private static _SetRenderingGroupId;
  126459. }
  126460. }
  126461. declare module BABYLON.Debug {
  126462. /**
  126463. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  126464. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  126465. */
  126466. export class BoneAxesViewer extends AxesViewer {
  126467. /**
  126468. * Gets or sets the target mesh where to display the axes viewer
  126469. */
  126470. mesh: Nullable<Mesh>;
  126471. /**
  126472. * Gets or sets the target bone where to display the axes viewer
  126473. */
  126474. bone: Nullable<Bone>;
  126475. /** Gets current position */
  126476. pos: Vector3;
  126477. /** Gets direction of X axis */
  126478. xaxis: Vector3;
  126479. /** Gets direction of Y axis */
  126480. yaxis: Vector3;
  126481. /** Gets direction of Z axis */
  126482. zaxis: Vector3;
  126483. /**
  126484. * Creates a new BoneAxesViewer
  126485. * @param scene defines the hosting scene
  126486. * @param bone defines the target bone
  126487. * @param mesh defines the target mesh
  126488. * @param scaleLines defines a scaling factor for line length (1 by default)
  126489. */
  126490. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  126491. /**
  126492. * Force the viewer to update
  126493. */
  126494. update(): void;
  126495. /** Releases resources */
  126496. dispose(): void;
  126497. }
  126498. }
  126499. declare module BABYLON {
  126500. /**
  126501. * Interface used to define scene explorer extensibility option
  126502. */
  126503. export interface IExplorerExtensibilityOption {
  126504. /**
  126505. * Define the option label
  126506. */
  126507. label: string;
  126508. /**
  126509. * Defines the action to execute on click
  126510. */
  126511. action: (entity: any) => void;
  126512. }
  126513. /**
  126514. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  126515. */
  126516. export interface IExplorerExtensibilityGroup {
  126517. /**
  126518. * Defines a predicate to test if a given type mut be extended
  126519. */
  126520. predicate: (entity: any) => boolean;
  126521. /**
  126522. * Gets the list of options added to a type
  126523. */
  126524. entries: IExplorerExtensibilityOption[];
  126525. }
  126526. /**
  126527. * Interface used to define the options to use to create the Inspector
  126528. */
  126529. export interface IInspectorOptions {
  126530. /**
  126531. * Display in overlay mode (default: false)
  126532. */
  126533. overlay?: boolean;
  126534. /**
  126535. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  126536. */
  126537. globalRoot?: HTMLElement;
  126538. /**
  126539. * Display the Scene explorer
  126540. */
  126541. showExplorer?: boolean;
  126542. /**
  126543. * Display the property inspector
  126544. */
  126545. showInspector?: boolean;
  126546. /**
  126547. * Display in embed mode (both panes on the right)
  126548. */
  126549. embedMode?: boolean;
  126550. /**
  126551. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  126552. */
  126553. handleResize?: boolean;
  126554. /**
  126555. * Allow the panes to popup (default: true)
  126556. */
  126557. enablePopup?: boolean;
  126558. /**
  126559. * Allow the panes to be closed by users (default: true)
  126560. */
  126561. enableClose?: boolean;
  126562. /**
  126563. * Optional list of extensibility entries
  126564. */
  126565. explorerExtensibility?: IExplorerExtensibilityGroup[];
  126566. /**
  126567. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  126568. */
  126569. inspectorURL?: string;
  126570. /**
  126571. * Optional initial tab (default to DebugLayerTab.Properties)
  126572. */
  126573. initialTab?: DebugLayerTab;
  126574. }
  126575. interface Scene {
  126576. /**
  126577. * @hidden
  126578. * Backing field
  126579. */
  126580. _debugLayer: DebugLayer;
  126581. /**
  126582. * Gets the debug layer (aka Inspector) associated with the scene
  126583. * @see http://doc.babylonjs.com/features/playground_debuglayer
  126584. */
  126585. debugLayer: DebugLayer;
  126586. }
  126587. /**
  126588. * Enum of inspector action tab
  126589. */
  126590. export enum DebugLayerTab {
  126591. /**
  126592. * Properties tag (default)
  126593. */
  126594. Properties = 0,
  126595. /**
  126596. * Debug tab
  126597. */
  126598. Debug = 1,
  126599. /**
  126600. * Statistics tab
  126601. */
  126602. Statistics = 2,
  126603. /**
  126604. * Tools tab
  126605. */
  126606. Tools = 3,
  126607. /**
  126608. * Settings tab
  126609. */
  126610. Settings = 4
  126611. }
  126612. /**
  126613. * The debug layer (aka Inspector) is the go to tool in order to better understand
  126614. * what is happening in your scene
  126615. * @see http://doc.babylonjs.com/features/playground_debuglayer
  126616. */
  126617. export class DebugLayer {
  126618. /**
  126619. * Define the url to get the inspector script from.
  126620. * By default it uses the babylonjs CDN.
  126621. * @ignoreNaming
  126622. */
  126623. static InspectorURL: string;
  126624. private _scene;
  126625. private BJSINSPECTOR;
  126626. private _onPropertyChangedObservable?;
  126627. /**
  126628. * Observable triggered when a property is changed through the inspector.
  126629. */
  126630. get onPropertyChangedObservable(): any;
  126631. /**
  126632. * Instantiates a new debug layer.
  126633. * The debug layer (aka Inspector) is the go to tool in order to better understand
  126634. * what is happening in your scene
  126635. * @see http://doc.babylonjs.com/features/playground_debuglayer
  126636. * @param scene Defines the scene to inspect
  126637. */
  126638. constructor(scene: Scene);
  126639. /** Creates the inspector window. */
  126640. private _createInspector;
  126641. /**
  126642. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  126643. * @param entity defines the entity to select
  126644. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  126645. */
  126646. select(entity: any, lineContainerTitles?: string | string[]): void;
  126647. /** Get the inspector from bundle or global */
  126648. private _getGlobalInspector;
  126649. /**
  126650. * Get if the inspector is visible or not.
  126651. * @returns true if visible otherwise, false
  126652. */
  126653. isVisible(): boolean;
  126654. /**
  126655. * Hide the inspector and close its window.
  126656. */
  126657. hide(): void;
  126658. /**
  126659. * Update the scene in the inspector
  126660. */
  126661. setAsActiveScene(): void;
  126662. /**
  126663. * Launch the debugLayer.
  126664. * @param config Define the configuration of the inspector
  126665. * @return a promise fulfilled when the debug layer is visible
  126666. */
  126667. show(config?: IInspectorOptions): Promise<DebugLayer>;
  126668. }
  126669. }
  126670. declare module BABYLON {
  126671. /**
  126672. * Class containing static functions to help procedurally build meshes
  126673. */
  126674. export class BoxBuilder {
  126675. /**
  126676. * Creates a box mesh
  126677. * * The parameter `size` sets the size (float) of each box side (default 1)
  126678. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  126679. * * 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)
  126680. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126681. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126682. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126684. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  126685. * @param name defines the name of the mesh
  126686. * @param options defines the options used to create the mesh
  126687. * @param scene defines the hosting scene
  126688. * @returns the box mesh
  126689. */
  126690. static CreateBox(name: string, options: {
  126691. size?: number;
  126692. width?: number;
  126693. height?: number;
  126694. depth?: number;
  126695. faceUV?: Vector4[];
  126696. faceColors?: Color4[];
  126697. sideOrientation?: number;
  126698. frontUVs?: Vector4;
  126699. backUVs?: Vector4;
  126700. wrap?: boolean;
  126701. topBaseAt?: number;
  126702. bottomBaseAt?: number;
  126703. updatable?: boolean;
  126704. }, scene?: Nullable<Scene>): Mesh;
  126705. }
  126706. }
  126707. declare module BABYLON.Debug {
  126708. /**
  126709. * Used to show the physics impostor around the specific mesh
  126710. */
  126711. export class PhysicsViewer {
  126712. /** @hidden */
  126713. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  126714. /** @hidden */
  126715. protected _meshes: Array<Nullable<AbstractMesh>>;
  126716. /** @hidden */
  126717. protected _scene: Nullable<Scene>;
  126718. /** @hidden */
  126719. protected _numMeshes: number;
  126720. /** @hidden */
  126721. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  126722. private _renderFunction;
  126723. private _utilityLayer;
  126724. private _debugBoxMesh;
  126725. private _debugSphereMesh;
  126726. private _debugCylinderMesh;
  126727. private _debugMaterial;
  126728. private _debugMeshMeshes;
  126729. /**
  126730. * Creates a new PhysicsViewer
  126731. * @param scene defines the hosting scene
  126732. */
  126733. constructor(scene: Scene);
  126734. /** @hidden */
  126735. protected _updateDebugMeshes(): void;
  126736. /**
  126737. * Renders a specified physic impostor
  126738. * @param impostor defines the impostor to render
  126739. * @param targetMesh defines the mesh represented by the impostor
  126740. * @returns the new debug mesh used to render the impostor
  126741. */
  126742. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  126743. /**
  126744. * Hides a specified physic impostor
  126745. * @param impostor defines the impostor to hide
  126746. */
  126747. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  126748. private _getDebugMaterial;
  126749. private _getDebugBoxMesh;
  126750. private _getDebugSphereMesh;
  126751. private _getDebugCylinderMesh;
  126752. private _getDebugMeshMesh;
  126753. private _getDebugMesh;
  126754. /** Releases all resources */
  126755. dispose(): void;
  126756. }
  126757. }
  126758. declare module BABYLON {
  126759. /**
  126760. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  126761. * in order to better appreciate the issue one might have.
  126762. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  126763. */
  126764. export class RayHelper {
  126765. /**
  126766. * Defines the ray we are currently tryin to visualize.
  126767. */
  126768. ray: Nullable<Ray>;
  126769. private _renderPoints;
  126770. private _renderLine;
  126771. private _renderFunction;
  126772. private _scene;
  126773. private _updateToMeshFunction;
  126774. private _attachedToMesh;
  126775. private _meshSpaceDirection;
  126776. private _meshSpaceOrigin;
  126777. /**
  126778. * Helper function to create a colored helper in a scene in one line.
  126779. * @param ray Defines the ray we are currently tryin to visualize
  126780. * @param scene Defines the scene the ray is used in
  126781. * @param color Defines the color we want to see the ray in
  126782. * @returns The newly created ray helper.
  126783. */
  126784. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  126785. /**
  126786. * Instantiate a new ray helper.
  126787. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  126788. * in order to better appreciate the issue one might have.
  126789. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  126790. * @param ray Defines the ray we are currently tryin to visualize
  126791. */
  126792. constructor(ray: Ray);
  126793. /**
  126794. * Shows the ray we are willing to debug.
  126795. * @param scene Defines the scene the ray needs to be rendered in
  126796. * @param color Defines the color the ray needs to be rendered in
  126797. */
  126798. show(scene: Scene, color?: Color3): void;
  126799. /**
  126800. * Hides the ray we are debugging.
  126801. */
  126802. hide(): void;
  126803. private _render;
  126804. /**
  126805. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  126806. * @param mesh Defines the mesh we want the helper attached to
  126807. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  126808. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  126809. * @param length Defines the length of the ray
  126810. */
  126811. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  126812. /**
  126813. * Detach the ray helper from the mesh it has previously been attached to.
  126814. */
  126815. detachFromMesh(): void;
  126816. private _updateToMesh;
  126817. /**
  126818. * Dispose the helper and release its associated resources.
  126819. */
  126820. dispose(): void;
  126821. }
  126822. }
  126823. declare module BABYLON.Debug {
  126824. /**
  126825. * Class used to render a debug view of a given skeleton
  126826. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  126827. */
  126828. export class SkeletonViewer {
  126829. /** defines the skeleton to render */
  126830. skeleton: Skeleton;
  126831. /** defines the mesh attached to the skeleton */
  126832. mesh: AbstractMesh;
  126833. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  126834. autoUpdateBonesMatrices: boolean;
  126835. /** defines the rendering group id to use with the viewer */
  126836. renderingGroupId: number;
  126837. /** Gets or sets the color used to render the skeleton */
  126838. color: Color3;
  126839. private _scene;
  126840. private _debugLines;
  126841. private _debugMesh;
  126842. private _isEnabled;
  126843. private _renderFunction;
  126844. private _utilityLayer;
  126845. /**
  126846. * Returns the mesh used to render the bones
  126847. */
  126848. get debugMesh(): Nullable<LinesMesh>;
  126849. /**
  126850. * Creates a new SkeletonViewer
  126851. * @param skeleton defines the skeleton to render
  126852. * @param mesh defines the mesh attached to the skeleton
  126853. * @param scene defines the hosting scene
  126854. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  126855. * @param renderingGroupId defines the rendering group id to use with the viewer
  126856. */
  126857. constructor(
  126858. /** defines the skeleton to render */
  126859. skeleton: Skeleton,
  126860. /** defines the mesh attached to the skeleton */
  126861. mesh: AbstractMesh, scene: Scene,
  126862. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  126863. autoUpdateBonesMatrices?: boolean,
  126864. /** defines the rendering group id to use with the viewer */
  126865. renderingGroupId?: number);
  126866. /** Gets or sets a boolean indicating if the viewer is enabled */
  126867. set isEnabled(value: boolean);
  126868. get isEnabled(): boolean;
  126869. private _getBonePosition;
  126870. private _getLinesForBonesWithLength;
  126871. private _getLinesForBonesNoLength;
  126872. /** Update the viewer to sync with current skeleton state */
  126873. update(): void;
  126874. /** Release associated resources */
  126875. dispose(): void;
  126876. }
  126877. }
  126878. declare module BABYLON {
  126879. /**
  126880. * Enum for Device Types
  126881. */
  126882. export enum DeviceType {
  126883. /** Generic */
  126884. Generic = 0,
  126885. /** Keyboard */
  126886. Keyboard = 1,
  126887. /** Mouse */
  126888. Mouse = 2,
  126889. /** Touch Pointers */
  126890. Touch = 3,
  126891. /** PS4 Dual Shock */
  126892. DualShock = 4,
  126893. /** Xbox */
  126894. Xbox = 5,
  126895. /** Switch Controller */
  126896. Switch = 6
  126897. }
  126898. /**
  126899. * Enum for All Pointers (Touch/Mouse)
  126900. */
  126901. export enum PointerInput {
  126902. /** Horizontal Axis */
  126903. Horizontal = 0,
  126904. /** Vertical Axis */
  126905. Vertical = 1,
  126906. /** Left Click or Touch */
  126907. LeftClick = 2,
  126908. /** Middle Click */
  126909. MiddleClick = 3,
  126910. /** Right Click */
  126911. RightClick = 4,
  126912. /** Browser Back */
  126913. BrowserBack = 5,
  126914. /** Browser Forward */
  126915. BrowserForward = 6
  126916. }
  126917. /**
  126918. * Enum for Dual Shock Gamepad
  126919. */
  126920. export enum DualShockInput {
  126921. /** Cross */
  126922. Cross = 0,
  126923. /** Circle */
  126924. Circle = 1,
  126925. /** Square */
  126926. Square = 2,
  126927. /** Triangle */
  126928. Triangle = 3,
  126929. /** L1 */
  126930. L1 = 4,
  126931. /** R1 */
  126932. R1 = 5,
  126933. /** L2 */
  126934. L2 = 6,
  126935. /** R2 */
  126936. R2 = 7,
  126937. /** Share */
  126938. Share = 8,
  126939. /** Options */
  126940. Options = 9,
  126941. /** L3 */
  126942. L3 = 10,
  126943. /** R3 */
  126944. R3 = 11,
  126945. /** DPadUp */
  126946. DPadUp = 12,
  126947. /** DPadDown */
  126948. DPadDown = 13,
  126949. /** DPadLeft */
  126950. DPadLeft = 14,
  126951. /** DRight */
  126952. DPadRight = 15,
  126953. /** Home */
  126954. Home = 16,
  126955. /** TouchPad */
  126956. TouchPad = 17,
  126957. /** LStickXAxis */
  126958. LStickXAxis = 18,
  126959. /** LStickYAxis */
  126960. LStickYAxis = 19,
  126961. /** RStickXAxis */
  126962. RStickXAxis = 20,
  126963. /** RStickYAxis */
  126964. RStickYAxis = 21
  126965. }
  126966. /**
  126967. * Enum for Xbox Gamepad
  126968. */
  126969. export enum XboxInput {
  126970. /** A */
  126971. A = 0,
  126972. /** B */
  126973. B = 1,
  126974. /** X */
  126975. X = 2,
  126976. /** Y */
  126977. Y = 3,
  126978. /** LB */
  126979. LB = 4,
  126980. /** RB */
  126981. RB = 5,
  126982. /** LT */
  126983. LT = 6,
  126984. /** RT */
  126985. RT = 7,
  126986. /** Back */
  126987. Back = 8,
  126988. /** Start */
  126989. Start = 9,
  126990. /** LS */
  126991. LS = 10,
  126992. /** RS */
  126993. RS = 11,
  126994. /** DPadUp */
  126995. DPadUp = 12,
  126996. /** DPadDown */
  126997. DPadDown = 13,
  126998. /** DPadLeft */
  126999. DPadLeft = 14,
  127000. /** DRight */
  127001. DPadRight = 15,
  127002. /** Home */
  127003. Home = 16,
  127004. /** LStickXAxis */
  127005. LStickXAxis = 17,
  127006. /** LStickYAxis */
  127007. LStickYAxis = 18,
  127008. /** RStickXAxis */
  127009. RStickXAxis = 19,
  127010. /** RStickYAxis */
  127011. RStickYAxis = 20
  127012. }
  127013. /**
  127014. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  127015. */
  127016. export enum SwitchInput {
  127017. /** B */
  127018. B = 0,
  127019. /** A */
  127020. A = 1,
  127021. /** Y */
  127022. Y = 2,
  127023. /** X */
  127024. X = 3,
  127025. /** L */
  127026. L = 4,
  127027. /** R */
  127028. R = 5,
  127029. /** ZL */
  127030. ZL = 6,
  127031. /** ZR */
  127032. ZR = 7,
  127033. /** Minus */
  127034. Minus = 8,
  127035. /** Plus */
  127036. Plus = 9,
  127037. /** LS */
  127038. LS = 10,
  127039. /** RS */
  127040. RS = 11,
  127041. /** DPadUp */
  127042. DPadUp = 12,
  127043. /** DPadDown */
  127044. DPadDown = 13,
  127045. /** DPadLeft */
  127046. DPadLeft = 14,
  127047. /** DRight */
  127048. DPadRight = 15,
  127049. /** Home */
  127050. Home = 16,
  127051. /** Capture */
  127052. Capture = 17,
  127053. /** LStickXAxis */
  127054. LStickXAxis = 18,
  127055. /** LStickYAxis */
  127056. LStickYAxis = 19,
  127057. /** RStickXAxis */
  127058. RStickXAxis = 20,
  127059. /** RStickYAxis */
  127060. RStickYAxis = 21
  127061. }
  127062. }
  127063. declare module BABYLON {
  127064. /**
  127065. * This class will take all inputs from Keyboard, Pointer, and
  127066. * any Gamepads and provide a polling system that all devices
  127067. * will use. This class assumes that there will only be one
  127068. * pointer device and one keyboard.
  127069. */
  127070. export class DeviceInputSystem implements IDisposable {
  127071. /**
  127072. * Callback to be triggered when a device is connected
  127073. */
  127074. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  127075. /**
  127076. * Callback to be triggered when a device is disconnected
  127077. */
  127078. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  127079. /**
  127080. * Callback to be triggered when event driven input is updated
  127081. */
  127082. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  127083. private _inputs;
  127084. private _gamepads;
  127085. private _keyboardActive;
  127086. private _pointerActive;
  127087. private _elementToAttachTo;
  127088. private _keyboardDownEvent;
  127089. private _keyboardUpEvent;
  127090. private _pointerMoveEvent;
  127091. private _pointerDownEvent;
  127092. private _pointerUpEvent;
  127093. private _gamepadConnectedEvent;
  127094. private _gamepadDisconnectedEvent;
  127095. private static _MAX_KEYCODES;
  127096. private static _MAX_POINTER_INPUTS;
  127097. private constructor();
  127098. /**
  127099. * Creates a new DeviceInputSystem instance
  127100. * @param engine Engine to pull input element from
  127101. * @returns The new instance
  127102. */
  127103. static Create(engine: Engine): DeviceInputSystem;
  127104. /**
  127105. * Checks for current device input value, given an id and input index
  127106. * @param deviceName Id of connected device
  127107. * @param inputIndex Index of device input
  127108. * @returns Current value of input
  127109. */
  127110. /**
  127111. * Checks for current device input value, given an id and input index
  127112. * @param deviceType Enum specifiying device type
  127113. * @param deviceSlot "Slot" or index that device is referenced in
  127114. * @param inputIndex Id of input to be checked
  127115. * @returns Current value of input
  127116. */
  127117. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  127118. /**
  127119. * Dispose of all the eventlisteners
  127120. */
  127121. dispose(): void;
  127122. /**
  127123. * Add device and inputs to device array
  127124. * @param deviceType Enum specifiying device type
  127125. * @param deviceSlot "Slot" or index that device is referenced in
  127126. * @param numberOfInputs Number of input entries to create for given device
  127127. */
  127128. private _registerDevice;
  127129. /**
  127130. * Given a specific device name, remove that device from the device map
  127131. * @param deviceType Enum specifiying device type
  127132. * @param deviceSlot "Slot" or index that device is referenced in
  127133. */
  127134. private _unregisterDevice;
  127135. /**
  127136. * Handle all actions that come from keyboard interaction
  127137. */
  127138. private _handleKeyActions;
  127139. /**
  127140. * Handle all actions that come from pointer interaction
  127141. */
  127142. private _handlePointerActions;
  127143. /**
  127144. * Handle all actions that come from gamepad interaction
  127145. */
  127146. private _handleGamepadActions;
  127147. /**
  127148. * Update all non-event based devices with each frame
  127149. * @param deviceType Enum specifiying device type
  127150. * @param deviceSlot "Slot" or index that device is referenced in
  127151. * @param inputIndex Id of input to be checked
  127152. */
  127153. private _updateDevice;
  127154. /**
  127155. * Gets DeviceType from the device name
  127156. * @param deviceName Name of Device from DeviceInputSystem
  127157. * @returns DeviceType enum value
  127158. */
  127159. private _getGamepadDeviceType;
  127160. }
  127161. }
  127162. declare module BABYLON {
  127163. /**
  127164. * Type to handle enforcement of inputs
  127165. */
  127166. 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;
  127167. }
  127168. declare module BABYLON {
  127169. /**
  127170. * Class that handles all input for a specific device
  127171. */
  127172. export class DeviceSource<T extends DeviceType> {
  127173. /** Type of device */
  127174. readonly deviceType: DeviceType;
  127175. /** "Slot" or index that device is referenced in */
  127176. readonly deviceSlot: number;
  127177. /**
  127178. * Observable to handle device input changes per device
  127179. */
  127180. readonly onInputChangedObservable: Observable<{
  127181. inputIndex: DeviceInput<T>;
  127182. previousState: Nullable<number>;
  127183. currentState: Nullable<number>;
  127184. }>;
  127185. private readonly _deviceInputSystem;
  127186. /**
  127187. * Default Constructor
  127188. * @param deviceInputSystem Reference to DeviceInputSystem
  127189. * @param deviceType Type of device
  127190. * @param deviceSlot "Slot" or index that device is referenced in
  127191. */
  127192. constructor(deviceInputSystem: DeviceInputSystem,
  127193. /** Type of device */
  127194. deviceType: DeviceType,
  127195. /** "Slot" or index that device is referenced in */
  127196. deviceSlot?: number);
  127197. /**
  127198. * Get input for specific input
  127199. * @param inputIndex index of specific input on device
  127200. * @returns Input value from DeviceInputSystem
  127201. */
  127202. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  127203. }
  127204. /**
  127205. * Class to keep track of devices
  127206. */
  127207. export class DeviceSourceManager implements IDisposable {
  127208. /**
  127209. * Observable to be triggered when before a device is connected
  127210. */
  127211. readonly onBeforeDeviceConnectedObservable: Observable<{
  127212. deviceType: DeviceType;
  127213. deviceSlot: number;
  127214. }>;
  127215. /**
  127216. * Observable to be triggered when before a device is disconnected
  127217. */
  127218. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  127219. deviceType: DeviceType;
  127220. deviceSlot: number;
  127221. }>;
  127222. /**
  127223. * Observable to be triggered when after a device is connected
  127224. */
  127225. readonly onAfterDeviceConnectedObservable: Observable<{
  127226. deviceType: DeviceType;
  127227. deviceSlot: number;
  127228. }>;
  127229. /**
  127230. * Observable to be triggered when after a device is disconnected
  127231. */
  127232. readonly onAfterDeviceDisconnectedObservable: Observable<{
  127233. deviceType: DeviceType;
  127234. deviceSlot: number;
  127235. }>;
  127236. private readonly _devices;
  127237. private readonly _firstDevice;
  127238. private readonly _deviceInputSystem;
  127239. /**
  127240. * Default Constructor
  127241. * @param engine engine to pull input element from
  127242. */
  127243. constructor(engine: Engine);
  127244. /**
  127245. * Gets a DeviceSource, given a type and slot
  127246. * @param deviceType Enum specifying device type
  127247. * @param deviceSlot "Slot" or index that device is referenced in
  127248. * @returns DeviceSource object
  127249. */
  127250. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  127251. /**
  127252. * Gets an array of DeviceSource objects for a given device type
  127253. * @param deviceType Enum specifying device type
  127254. * @returns Array of DeviceSource objects
  127255. */
  127256. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  127257. /**
  127258. * Dispose of DeviceInputSystem and other parts
  127259. */
  127260. dispose(): void;
  127261. /**
  127262. * Function to add device name to device list
  127263. * @param deviceType Enum specifying device type
  127264. * @param deviceSlot "Slot" or index that device is referenced in
  127265. */
  127266. private _addDevice;
  127267. /**
  127268. * Function to remove device name to device list
  127269. * @param deviceType Enum specifying device type
  127270. * @param deviceSlot "Slot" or index that device is referenced in
  127271. */
  127272. private _removeDevice;
  127273. /**
  127274. * Updates array storing first connected device of each type
  127275. * @param type Type of Device
  127276. */
  127277. private _updateFirstDevices;
  127278. }
  127279. }
  127280. declare module BABYLON {
  127281. /**
  127282. * Options to create the null engine
  127283. */
  127284. export class NullEngineOptions {
  127285. /**
  127286. * Render width (Default: 512)
  127287. */
  127288. renderWidth: number;
  127289. /**
  127290. * Render height (Default: 256)
  127291. */
  127292. renderHeight: number;
  127293. /**
  127294. * Texture size (Default: 512)
  127295. */
  127296. textureSize: number;
  127297. /**
  127298. * If delta time between frames should be constant
  127299. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127300. */
  127301. deterministicLockstep: boolean;
  127302. /**
  127303. * Maximum about of steps between frames (Default: 4)
  127304. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127305. */
  127306. lockstepMaxSteps: number;
  127307. }
  127308. /**
  127309. * The null engine class provides support for headless version of babylon.js.
  127310. * This can be used in server side scenario or for testing purposes
  127311. */
  127312. export class NullEngine extends Engine {
  127313. private _options;
  127314. /**
  127315. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  127316. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127317. * @returns true if engine is in deterministic lock step mode
  127318. */
  127319. isDeterministicLockStep(): boolean;
  127320. /**
  127321. * Gets the max steps when engine is running in deterministic lock step
  127322. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127323. * @returns the max steps
  127324. */
  127325. getLockstepMaxSteps(): number;
  127326. /**
  127327. * Gets the current hardware scaling level.
  127328. * By default the hardware scaling level is computed from the window device ratio.
  127329. * 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.
  127330. * @returns a number indicating the current hardware scaling level
  127331. */
  127332. getHardwareScalingLevel(): number;
  127333. constructor(options?: NullEngineOptions);
  127334. /**
  127335. * Creates a vertex buffer
  127336. * @param vertices the data for the vertex buffer
  127337. * @returns the new WebGL static buffer
  127338. */
  127339. createVertexBuffer(vertices: FloatArray): DataBuffer;
  127340. /**
  127341. * Creates a new index buffer
  127342. * @param indices defines the content of the index buffer
  127343. * @param updatable defines if the index buffer must be updatable
  127344. * @returns a new webGL buffer
  127345. */
  127346. createIndexBuffer(indices: IndicesArray): DataBuffer;
  127347. /**
  127348. * Clear the current render buffer or the current render target (if any is set up)
  127349. * @param color defines the color to use
  127350. * @param backBuffer defines if the back buffer must be cleared
  127351. * @param depth defines if the depth buffer must be cleared
  127352. * @param stencil defines if the stencil buffer must be cleared
  127353. */
  127354. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  127355. /**
  127356. * Gets the current render width
  127357. * @param useScreen defines if screen size must be used (or the current render target if any)
  127358. * @returns a number defining the current render width
  127359. */
  127360. getRenderWidth(useScreen?: boolean): number;
  127361. /**
  127362. * Gets the current render height
  127363. * @param useScreen defines if screen size must be used (or the current render target if any)
  127364. * @returns a number defining the current render height
  127365. */
  127366. getRenderHeight(useScreen?: boolean): number;
  127367. /**
  127368. * Set the WebGL's viewport
  127369. * @param viewport defines the viewport element to be used
  127370. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  127371. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  127372. */
  127373. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  127374. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  127375. /**
  127376. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  127377. * @param pipelineContext defines the pipeline context to use
  127378. * @param uniformsNames defines the list of uniform names
  127379. * @returns an array of webGL uniform locations
  127380. */
  127381. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  127382. /**
  127383. * Gets the lsit of active attributes for a given webGL program
  127384. * @param pipelineContext defines the pipeline context to use
  127385. * @param attributesNames defines the list of attribute names to get
  127386. * @returns an array of indices indicating the offset of each attribute
  127387. */
  127388. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  127389. /**
  127390. * Binds an effect to the webGL context
  127391. * @param effect defines the effect to bind
  127392. */
  127393. bindSamplers(effect: Effect): void;
  127394. /**
  127395. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  127396. * @param effect defines the effect to activate
  127397. */
  127398. enableEffect(effect: Effect): void;
  127399. /**
  127400. * Set various states to the webGL context
  127401. * @param culling defines backface culling state
  127402. * @param zOffset defines the value to apply to zOffset (0 by default)
  127403. * @param force defines if states must be applied even if cache is up to date
  127404. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  127405. */
  127406. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  127407. /**
  127408. * Set the value of an uniform to an array of int32
  127409. * @param uniform defines the webGL uniform location where to store the value
  127410. * @param array defines the array of int32 to store
  127411. */
  127412. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  127413. /**
  127414. * Set the value of an uniform to an array of int32 (stored as vec2)
  127415. * @param uniform defines the webGL uniform location where to store the value
  127416. * @param array defines the array of int32 to store
  127417. */
  127418. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  127419. /**
  127420. * Set the value of an uniform to an array of int32 (stored as vec3)
  127421. * @param uniform defines the webGL uniform location where to store the value
  127422. * @param array defines the array of int32 to store
  127423. */
  127424. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  127425. /**
  127426. * Set the value of an uniform to an array of int32 (stored as vec4)
  127427. * @param uniform defines the webGL uniform location where to store the value
  127428. * @param array defines the array of int32 to store
  127429. */
  127430. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  127431. /**
  127432. * Set the value of an uniform to an array of float32
  127433. * @param uniform defines the webGL uniform location where to store the value
  127434. * @param array defines the array of float32 to store
  127435. */
  127436. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  127437. /**
  127438. * Set the value of an uniform to an array of float32 (stored as vec2)
  127439. * @param uniform defines the webGL uniform location where to store the value
  127440. * @param array defines the array of float32 to store
  127441. */
  127442. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  127443. /**
  127444. * Set the value of an uniform to an array of float32 (stored as vec3)
  127445. * @param uniform defines the webGL uniform location where to store the value
  127446. * @param array defines the array of float32 to store
  127447. */
  127448. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  127449. /**
  127450. * Set the value of an uniform to an array of float32 (stored as vec4)
  127451. * @param uniform defines the webGL uniform location where to store the value
  127452. * @param array defines the array of float32 to store
  127453. */
  127454. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  127455. /**
  127456. * Set the value of an uniform to an array of number
  127457. * @param uniform defines the webGL uniform location where to store the value
  127458. * @param array defines the array of number to store
  127459. */
  127460. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  127461. /**
  127462. * Set the value of an uniform to an array of number (stored as vec2)
  127463. * @param uniform defines the webGL uniform location where to store the value
  127464. * @param array defines the array of number to store
  127465. */
  127466. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  127467. /**
  127468. * Set the value of an uniform to an array of number (stored as vec3)
  127469. * @param uniform defines the webGL uniform location where to store the value
  127470. * @param array defines the array of number to store
  127471. */
  127472. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  127473. /**
  127474. * Set the value of an uniform to an array of number (stored as vec4)
  127475. * @param uniform defines the webGL uniform location where to store the value
  127476. * @param array defines the array of number to store
  127477. */
  127478. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  127479. /**
  127480. * Set the value of an uniform to an array of float32 (stored as matrices)
  127481. * @param uniform defines the webGL uniform location where to store the value
  127482. * @param matrices defines the array of float32 to store
  127483. */
  127484. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  127485. /**
  127486. * Set the value of an uniform to a matrix (3x3)
  127487. * @param uniform defines the webGL uniform location where to store the value
  127488. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  127489. */
  127490. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  127491. /**
  127492. * Set the value of an uniform to a matrix (2x2)
  127493. * @param uniform defines the webGL uniform location where to store the value
  127494. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  127495. */
  127496. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  127497. /**
  127498. * Set the value of an uniform to a number (float)
  127499. * @param uniform defines the webGL uniform location where to store the value
  127500. * @param value defines the float number to store
  127501. */
  127502. setFloat(uniform: WebGLUniformLocation, value: number): void;
  127503. /**
  127504. * Set the value of an uniform to a vec2
  127505. * @param uniform defines the webGL uniform location where to store the value
  127506. * @param x defines the 1st component of the value
  127507. * @param y defines the 2nd component of the value
  127508. */
  127509. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  127510. /**
  127511. * Set the value of an uniform to a vec3
  127512. * @param uniform defines the webGL uniform location where to store the value
  127513. * @param x defines the 1st component of the value
  127514. * @param y defines the 2nd component of the value
  127515. * @param z defines the 3rd component of the value
  127516. */
  127517. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  127518. /**
  127519. * Set the value of an uniform to a boolean
  127520. * @param uniform defines the webGL uniform location where to store the value
  127521. * @param bool defines the boolean to store
  127522. */
  127523. setBool(uniform: WebGLUniformLocation, bool: number): void;
  127524. /**
  127525. * Set the value of an uniform to a vec4
  127526. * @param uniform defines the webGL uniform location where to store the value
  127527. * @param x defines the 1st component of the value
  127528. * @param y defines the 2nd component of the value
  127529. * @param z defines the 3rd component of the value
  127530. * @param w defines the 4th component of the value
  127531. */
  127532. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  127533. /**
  127534. * Sets the current alpha mode
  127535. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  127536. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  127537. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  127538. */
  127539. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  127540. /**
  127541. * Bind webGl buffers directly to the webGL context
  127542. * @param vertexBuffers defines the vertex buffer to bind
  127543. * @param indexBuffer defines the index buffer to bind
  127544. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  127545. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  127546. * @param effect defines the effect associated with the vertex buffer
  127547. */
  127548. bindBuffers(vertexBuffers: {
  127549. [key: string]: VertexBuffer;
  127550. }, indexBuffer: DataBuffer, effect: Effect): void;
  127551. /**
  127552. * Force the entire cache to be cleared
  127553. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  127554. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  127555. */
  127556. wipeCaches(bruteForce?: boolean): void;
  127557. /**
  127558. * Send a draw order
  127559. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  127560. * @param indexStart defines the starting index
  127561. * @param indexCount defines the number of index to draw
  127562. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  127563. */
  127564. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  127565. /**
  127566. * Draw a list of indexed primitives
  127567. * @param fillMode defines the primitive to use
  127568. * @param indexStart defines the starting index
  127569. * @param indexCount defines the number of index to draw
  127570. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  127571. */
  127572. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  127573. /**
  127574. * Draw a list of unindexed primitives
  127575. * @param fillMode defines the primitive to use
  127576. * @param verticesStart defines the index of first vertex to draw
  127577. * @param verticesCount defines the count of vertices to draw
  127578. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  127579. */
  127580. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  127581. /** @hidden */
  127582. _createTexture(): WebGLTexture;
  127583. /** @hidden */
  127584. _releaseTexture(texture: InternalTexture): void;
  127585. /**
  127586. * Usually called from Texture.ts.
  127587. * Passed information to create a WebGLTexture
  127588. * @param urlArg defines a value which contains one of the following:
  127589. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  127590. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  127591. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  127592. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  127593. * @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)
  127594. * @param scene needed for loading to the correct scene
  127595. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  127596. * @param onLoad optional callback to be called upon successful completion
  127597. * @param onError optional callback to be called upon failure
  127598. * @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
  127599. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  127600. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  127601. * @param forcedExtension defines the extension to use to pick the right loader
  127602. * @param mimeType defines an optional mime type
  127603. * @returns a InternalTexture for assignment back into BABYLON.Texture
  127604. */
  127605. 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;
  127606. /**
  127607. * Creates a new render target texture
  127608. * @param size defines the size of the texture
  127609. * @param options defines the options used to create the texture
  127610. * @returns a new render target texture stored in an InternalTexture
  127611. */
  127612. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  127613. /**
  127614. * Update the sampling mode of a given texture
  127615. * @param samplingMode defines the required sampling mode
  127616. * @param texture defines the texture to update
  127617. */
  127618. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  127619. /**
  127620. * Binds the frame buffer to the specified texture.
  127621. * @param texture The texture to render to or null for the default canvas
  127622. * @param faceIndex The face of the texture to render to in case of cube texture
  127623. * @param requiredWidth The width of the target to render to
  127624. * @param requiredHeight The height of the target to render to
  127625. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  127626. * @param lodLevel defines le lod level to bind to the frame buffer
  127627. */
  127628. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  127629. /**
  127630. * Unbind the current render target texture from the webGL context
  127631. * @param texture defines the render target texture to unbind
  127632. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  127633. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  127634. */
  127635. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  127636. /**
  127637. * Creates a dynamic vertex buffer
  127638. * @param vertices the data for the dynamic vertex buffer
  127639. * @returns the new WebGL dynamic buffer
  127640. */
  127641. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  127642. /**
  127643. * Update the content of a dynamic texture
  127644. * @param texture defines the texture to update
  127645. * @param canvas defines the canvas containing the source
  127646. * @param invertY defines if data must be stored with Y axis inverted
  127647. * @param premulAlpha defines if alpha is stored as premultiplied
  127648. * @param format defines the format of the data
  127649. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  127650. */
  127651. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  127652. /**
  127653. * Gets a boolean indicating if all created effects are ready
  127654. * @returns true if all effects are ready
  127655. */
  127656. areAllEffectsReady(): boolean;
  127657. /**
  127658. * @hidden
  127659. * Get the current error code of the webGL context
  127660. * @returns the error code
  127661. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  127662. */
  127663. getError(): number;
  127664. /** @hidden */
  127665. _getUnpackAlignement(): number;
  127666. /** @hidden */
  127667. _unpackFlipY(value: boolean): void;
  127668. /**
  127669. * Update a dynamic index buffer
  127670. * @param indexBuffer defines the target index buffer
  127671. * @param indices defines the data to update
  127672. * @param offset defines the offset in the target index buffer where update should start
  127673. */
  127674. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  127675. /**
  127676. * Updates a dynamic vertex buffer.
  127677. * @param vertexBuffer the vertex buffer to update
  127678. * @param vertices the data used to update the vertex buffer
  127679. * @param byteOffset the byte offset of the data (optional)
  127680. * @param byteLength the byte length of the data (optional)
  127681. */
  127682. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  127683. /** @hidden */
  127684. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  127685. /** @hidden */
  127686. _bindTexture(channel: number, texture: InternalTexture): void;
  127687. protected _deleteBuffer(buffer: WebGLBuffer): void;
  127688. /**
  127689. * 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
  127690. */
  127691. releaseEffects(): void;
  127692. displayLoadingUI(): void;
  127693. hideLoadingUI(): void;
  127694. /** @hidden */
  127695. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  127696. /** @hidden */
  127697. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  127698. /** @hidden */
  127699. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  127700. /** @hidden */
  127701. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  127702. }
  127703. }
  127704. declare module BABYLON {
  127705. /**
  127706. * @hidden
  127707. **/
  127708. export class _TimeToken {
  127709. _startTimeQuery: Nullable<WebGLQuery>;
  127710. _endTimeQuery: Nullable<WebGLQuery>;
  127711. _timeElapsedQuery: Nullable<WebGLQuery>;
  127712. _timeElapsedQueryEnded: boolean;
  127713. }
  127714. }
  127715. declare module BABYLON {
  127716. /** @hidden */
  127717. export class _OcclusionDataStorage {
  127718. /** @hidden */
  127719. occlusionInternalRetryCounter: number;
  127720. /** @hidden */
  127721. isOcclusionQueryInProgress: boolean;
  127722. /** @hidden */
  127723. isOccluded: boolean;
  127724. /** @hidden */
  127725. occlusionRetryCount: number;
  127726. /** @hidden */
  127727. occlusionType: number;
  127728. /** @hidden */
  127729. occlusionQueryAlgorithmType: number;
  127730. }
  127731. interface Engine {
  127732. /**
  127733. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  127734. * @return the new query
  127735. */
  127736. createQuery(): WebGLQuery;
  127737. /**
  127738. * Delete and release a webGL query
  127739. * @param query defines the query to delete
  127740. * @return the current engine
  127741. */
  127742. deleteQuery(query: WebGLQuery): Engine;
  127743. /**
  127744. * Check if a given query has resolved and got its value
  127745. * @param query defines the query to check
  127746. * @returns true if the query got its value
  127747. */
  127748. isQueryResultAvailable(query: WebGLQuery): boolean;
  127749. /**
  127750. * Gets the value of a given query
  127751. * @param query defines the query to check
  127752. * @returns the value of the query
  127753. */
  127754. getQueryResult(query: WebGLQuery): number;
  127755. /**
  127756. * Initiates an occlusion query
  127757. * @param algorithmType defines the algorithm to use
  127758. * @param query defines the query to use
  127759. * @returns the current engine
  127760. * @see http://doc.babylonjs.com/features/occlusionquery
  127761. */
  127762. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  127763. /**
  127764. * Ends an occlusion query
  127765. * @see http://doc.babylonjs.com/features/occlusionquery
  127766. * @param algorithmType defines the algorithm to use
  127767. * @returns the current engine
  127768. */
  127769. endOcclusionQuery(algorithmType: number): Engine;
  127770. /**
  127771. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  127772. * Please note that only one query can be issued at a time
  127773. * @returns a time token used to track the time span
  127774. */
  127775. startTimeQuery(): Nullable<_TimeToken>;
  127776. /**
  127777. * Ends a time query
  127778. * @param token defines the token used to measure the time span
  127779. * @returns the time spent (in ns)
  127780. */
  127781. endTimeQuery(token: _TimeToken): int;
  127782. /** @hidden */
  127783. _currentNonTimestampToken: Nullable<_TimeToken>;
  127784. /** @hidden */
  127785. _createTimeQuery(): WebGLQuery;
  127786. /** @hidden */
  127787. _deleteTimeQuery(query: WebGLQuery): void;
  127788. /** @hidden */
  127789. _getGlAlgorithmType(algorithmType: number): number;
  127790. /** @hidden */
  127791. _getTimeQueryResult(query: WebGLQuery): any;
  127792. /** @hidden */
  127793. _getTimeQueryAvailability(query: WebGLQuery): any;
  127794. }
  127795. interface AbstractMesh {
  127796. /**
  127797. * Backing filed
  127798. * @hidden
  127799. */
  127800. __occlusionDataStorage: _OcclusionDataStorage;
  127801. /**
  127802. * Access property
  127803. * @hidden
  127804. */
  127805. _occlusionDataStorage: _OcclusionDataStorage;
  127806. /**
  127807. * 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.
  127808. * The default value is -1 which means don't break the query and wait till the result
  127809. * @see http://doc.babylonjs.com/features/occlusionquery
  127810. */
  127811. occlusionRetryCount: number;
  127812. /**
  127813. * 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:
  127814. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  127815. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  127816. * * 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.
  127817. * @see http://doc.babylonjs.com/features/occlusionquery
  127818. */
  127819. occlusionType: number;
  127820. /**
  127821. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  127822. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  127823. * * 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.
  127824. * @see http://doc.babylonjs.com/features/occlusionquery
  127825. */
  127826. occlusionQueryAlgorithmType: number;
  127827. /**
  127828. * 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
  127829. * @see http://doc.babylonjs.com/features/occlusionquery
  127830. */
  127831. isOccluded: boolean;
  127832. /**
  127833. * Flag to check the progress status of the query
  127834. * @see http://doc.babylonjs.com/features/occlusionquery
  127835. */
  127836. isOcclusionQueryInProgress: boolean;
  127837. }
  127838. }
  127839. declare module BABYLON {
  127840. /** @hidden */
  127841. export var _forceTransformFeedbackToBundle: boolean;
  127842. interface Engine {
  127843. /**
  127844. * Creates a webGL transform feedback object
  127845. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  127846. * @returns the webGL transform feedback object
  127847. */
  127848. createTransformFeedback(): WebGLTransformFeedback;
  127849. /**
  127850. * Delete a webGL transform feedback object
  127851. * @param value defines the webGL transform feedback object to delete
  127852. */
  127853. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  127854. /**
  127855. * Bind a webGL transform feedback object to the webgl context
  127856. * @param value defines the webGL transform feedback object to bind
  127857. */
  127858. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  127859. /**
  127860. * Begins a transform feedback operation
  127861. * @param usePoints defines if points or triangles must be used
  127862. */
  127863. beginTransformFeedback(usePoints: boolean): void;
  127864. /**
  127865. * Ends a transform feedback operation
  127866. */
  127867. endTransformFeedback(): void;
  127868. /**
  127869. * Specify the varyings to use with transform feedback
  127870. * @param program defines the associated webGL program
  127871. * @param value defines the list of strings representing the varying names
  127872. */
  127873. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  127874. /**
  127875. * Bind a webGL buffer for a transform feedback operation
  127876. * @param value defines the webGL buffer to bind
  127877. */
  127878. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  127879. }
  127880. }
  127881. declare module BABYLON {
  127882. /**
  127883. * Creation options of the multi render target texture.
  127884. */
  127885. export interface IMultiRenderTargetOptions {
  127886. /**
  127887. * Define if the texture needs to create mip maps after render.
  127888. */
  127889. generateMipMaps?: boolean;
  127890. /**
  127891. * Define the types of all the draw buffers we want to create
  127892. */
  127893. types?: number[];
  127894. /**
  127895. * Define the sampling modes of all the draw buffers we want to create
  127896. */
  127897. samplingModes?: number[];
  127898. /**
  127899. * Define if a depth buffer is required
  127900. */
  127901. generateDepthBuffer?: boolean;
  127902. /**
  127903. * Define if a stencil buffer is required
  127904. */
  127905. generateStencilBuffer?: boolean;
  127906. /**
  127907. * Define if a depth texture is required instead of a depth buffer
  127908. */
  127909. generateDepthTexture?: boolean;
  127910. /**
  127911. * Define the number of desired draw buffers
  127912. */
  127913. textureCount?: number;
  127914. /**
  127915. * Define if aspect ratio should be adapted to the texture or stay the scene one
  127916. */
  127917. doNotChangeAspectRatio?: boolean;
  127918. /**
  127919. * Define the default type of the buffers we are creating
  127920. */
  127921. defaultType?: number;
  127922. }
  127923. /**
  127924. * A multi render target, like a render target provides the ability to render to a texture.
  127925. * Unlike the render target, it can render to several draw buffers in one draw.
  127926. * This is specially interesting in deferred rendering or for any effects requiring more than
  127927. * just one color from a single pass.
  127928. */
  127929. export class MultiRenderTarget extends RenderTargetTexture {
  127930. private _internalTextures;
  127931. private _textures;
  127932. private _multiRenderTargetOptions;
  127933. /**
  127934. * Get if draw buffers are currently supported by the used hardware and browser.
  127935. */
  127936. get isSupported(): boolean;
  127937. /**
  127938. * Get the list of textures generated by the multi render target.
  127939. */
  127940. get textures(): Texture[];
  127941. /**
  127942. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  127943. */
  127944. get depthTexture(): Texture;
  127945. /**
  127946. * Set the wrapping mode on U of all the textures we are rendering to.
  127947. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  127948. */
  127949. set wrapU(wrap: number);
  127950. /**
  127951. * Set the wrapping mode on V of all the textures we are rendering to.
  127952. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  127953. */
  127954. set wrapV(wrap: number);
  127955. /**
  127956. * Instantiate a new multi render target texture.
  127957. * A multi render target, like a render target provides the ability to render to a texture.
  127958. * Unlike the render target, it can render to several draw buffers in one draw.
  127959. * This is specially interesting in deferred rendering or for any effects requiring more than
  127960. * just one color from a single pass.
  127961. * @param name Define the name of the texture
  127962. * @param size Define the size of the buffers to render to
  127963. * @param count Define the number of target we are rendering into
  127964. * @param scene Define the scene the texture belongs to
  127965. * @param options Define the options used to create the multi render target
  127966. */
  127967. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  127968. /** @hidden */
  127969. _rebuild(): void;
  127970. private _createInternalTextures;
  127971. private _createTextures;
  127972. /**
  127973. * Define the number of samples used if MSAA is enabled.
  127974. */
  127975. get samples(): number;
  127976. set samples(value: number);
  127977. /**
  127978. * Resize all the textures in the multi render target.
  127979. * Be carrefull as it will recreate all the data in the new texture.
  127980. * @param size Define the new size
  127981. */
  127982. resize(size: any): void;
  127983. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  127984. /**
  127985. * Dispose the render targets and their associated resources
  127986. */
  127987. dispose(): void;
  127988. /**
  127989. * Release all the underlying texture used as draw buffers.
  127990. */
  127991. releaseInternalTextures(): void;
  127992. }
  127993. }
  127994. declare module BABYLON {
  127995. interface ThinEngine {
  127996. /**
  127997. * Unbind a list of render target textures from the webGL context
  127998. * This is used only when drawBuffer extension or webGL2 are active
  127999. * @param textures defines the render target textures to unbind
  128000. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  128001. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  128002. */
  128003. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  128004. /**
  128005. * Create a multi render target texture
  128006. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  128007. * @param size defines the size of the texture
  128008. * @param options defines the creation options
  128009. * @returns the cube texture as an InternalTexture
  128010. */
  128011. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  128012. /**
  128013. * Update the sample count for a given multiple render target texture
  128014. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  128015. * @param textures defines the textures to update
  128016. * @param samples defines the sample count to set
  128017. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  128018. */
  128019. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  128020. }
  128021. }
  128022. declare module BABYLON {
  128023. /**
  128024. * Class used to define an additional view for the engine
  128025. * @see https://doc.babylonjs.com/how_to/multi_canvases
  128026. */
  128027. export class EngineView {
  128028. /** Defines the canvas where to render the view */
  128029. target: HTMLCanvasElement;
  128030. /** Defines an optional camera used to render the view (will use active camera else) */
  128031. camera?: Camera;
  128032. }
  128033. interface Engine {
  128034. /**
  128035. * Gets or sets the HTML element to use for attaching events
  128036. */
  128037. inputElement: Nullable<HTMLElement>;
  128038. /**
  128039. * Gets the current engine view
  128040. * @see https://doc.babylonjs.com/how_to/multi_canvases
  128041. */
  128042. activeView: Nullable<EngineView>;
  128043. /** Gets or sets the list of views */
  128044. views: EngineView[];
  128045. /**
  128046. * Register a new child canvas
  128047. * @param canvas defines the canvas to register
  128048. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  128049. * @returns the associated view
  128050. */
  128051. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  128052. /**
  128053. * Remove a registered child canvas
  128054. * @param canvas defines the canvas to remove
  128055. * @returns the current engine
  128056. */
  128057. unRegisterView(canvas: HTMLCanvasElement): Engine;
  128058. }
  128059. }
  128060. declare module BABYLON {
  128061. interface Engine {
  128062. /** @hidden */
  128063. _excludedCompressedTextures: string[];
  128064. /** @hidden */
  128065. _textureFormatInUse: string;
  128066. /**
  128067. * Gets the list of texture formats supported
  128068. */
  128069. readonly texturesSupported: Array<string>;
  128070. /**
  128071. * Gets the texture format in use
  128072. */
  128073. readonly textureFormatInUse: Nullable<string>;
  128074. /**
  128075. * Set the compressed texture extensions or file names to skip.
  128076. *
  128077. * @param skippedFiles defines the list of those texture files you want to skip
  128078. * Example: [".dds", ".env", "myfile.png"]
  128079. */
  128080. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  128081. /**
  128082. * Set the compressed texture format to use, based on the formats you have, and the formats
  128083. * supported by the hardware / browser.
  128084. *
  128085. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  128086. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  128087. * to API arguments needed to compressed textures. This puts the burden on the container
  128088. * generator to house the arcane code for determining these for current & future formats.
  128089. *
  128090. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  128091. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  128092. *
  128093. * Note: The result of this call is not taken into account when a texture is base64.
  128094. *
  128095. * @param formatsAvailable defines the list of those format families you have created
  128096. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  128097. *
  128098. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  128099. * @returns The extension selected.
  128100. */
  128101. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  128102. }
  128103. }
  128104. declare module BABYLON {
  128105. /**
  128106. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  128107. */
  128108. export interface CubeMapInfo {
  128109. /**
  128110. * The pixel array for the front face.
  128111. * This is stored in format, left to right, up to down format.
  128112. */
  128113. front: Nullable<ArrayBufferView>;
  128114. /**
  128115. * The pixel array for the back face.
  128116. * This is stored in format, left to right, up to down format.
  128117. */
  128118. back: Nullable<ArrayBufferView>;
  128119. /**
  128120. * The pixel array for the left face.
  128121. * This is stored in format, left to right, up to down format.
  128122. */
  128123. left: Nullable<ArrayBufferView>;
  128124. /**
  128125. * The pixel array for the right face.
  128126. * This is stored in format, left to right, up to down format.
  128127. */
  128128. right: Nullable<ArrayBufferView>;
  128129. /**
  128130. * The pixel array for the up face.
  128131. * This is stored in format, left to right, up to down format.
  128132. */
  128133. up: Nullable<ArrayBufferView>;
  128134. /**
  128135. * The pixel array for the down face.
  128136. * This is stored in format, left to right, up to down format.
  128137. */
  128138. down: Nullable<ArrayBufferView>;
  128139. /**
  128140. * The size of the cubemap stored.
  128141. *
  128142. * Each faces will be size * size pixels.
  128143. */
  128144. size: number;
  128145. /**
  128146. * The format of the texture.
  128147. *
  128148. * RGBA, RGB.
  128149. */
  128150. format: number;
  128151. /**
  128152. * The type of the texture data.
  128153. *
  128154. * UNSIGNED_INT, FLOAT.
  128155. */
  128156. type: number;
  128157. /**
  128158. * Specifies whether the texture is in gamma space.
  128159. */
  128160. gammaSpace: boolean;
  128161. }
  128162. /**
  128163. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  128164. */
  128165. export class PanoramaToCubeMapTools {
  128166. private static FACE_LEFT;
  128167. private static FACE_RIGHT;
  128168. private static FACE_FRONT;
  128169. private static FACE_BACK;
  128170. private static FACE_DOWN;
  128171. private static FACE_UP;
  128172. /**
  128173. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  128174. *
  128175. * @param float32Array The source data.
  128176. * @param inputWidth The width of the input panorama.
  128177. * @param inputHeight The height of the input panorama.
  128178. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  128179. * @return The cubemap data
  128180. */
  128181. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  128182. private static CreateCubemapTexture;
  128183. private static CalcProjectionSpherical;
  128184. }
  128185. }
  128186. declare module BABYLON {
  128187. /**
  128188. * Helper class dealing with the extraction of spherical polynomial dataArray
  128189. * from a cube map.
  128190. */
  128191. export class CubeMapToSphericalPolynomialTools {
  128192. private static FileFaces;
  128193. /**
  128194. * Converts a texture to the according Spherical Polynomial data.
  128195. * This extracts the first 3 orders only as they are the only one used in the lighting.
  128196. *
  128197. * @param texture The texture to extract the information from.
  128198. * @return The Spherical Polynomial data.
  128199. */
  128200. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  128201. /**
  128202. * Converts a cubemap to the according Spherical Polynomial data.
  128203. * This extracts the first 3 orders only as they are the only one used in the lighting.
  128204. *
  128205. * @param cubeInfo The Cube map to extract the information from.
  128206. * @return The Spherical Polynomial data.
  128207. */
  128208. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  128209. }
  128210. }
  128211. declare module BABYLON {
  128212. interface BaseTexture {
  128213. /**
  128214. * Get the polynomial representation of the texture data.
  128215. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  128216. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  128217. */
  128218. sphericalPolynomial: Nullable<SphericalPolynomial>;
  128219. }
  128220. }
  128221. declare module BABYLON {
  128222. /** @hidden */
  128223. export var rgbdEncodePixelShader: {
  128224. name: string;
  128225. shader: string;
  128226. };
  128227. }
  128228. declare module BABYLON {
  128229. /** @hidden */
  128230. export var rgbdDecodePixelShader: {
  128231. name: string;
  128232. shader: string;
  128233. };
  128234. }
  128235. declare module BABYLON {
  128236. /**
  128237. * Raw texture data and descriptor sufficient for WebGL texture upload
  128238. */
  128239. export interface EnvironmentTextureInfo {
  128240. /**
  128241. * Version of the environment map
  128242. */
  128243. version: number;
  128244. /**
  128245. * Width of image
  128246. */
  128247. width: number;
  128248. /**
  128249. * Irradiance information stored in the file.
  128250. */
  128251. irradiance: any;
  128252. /**
  128253. * Specular information stored in the file.
  128254. */
  128255. specular: any;
  128256. }
  128257. /**
  128258. * Defines One Image in the file. It requires only the position in the file
  128259. * as well as the length.
  128260. */
  128261. interface BufferImageData {
  128262. /**
  128263. * Length of the image data.
  128264. */
  128265. length: number;
  128266. /**
  128267. * Position of the data from the null terminator delimiting the end of the JSON.
  128268. */
  128269. position: number;
  128270. }
  128271. /**
  128272. * Defines the specular data enclosed in the file.
  128273. * This corresponds to the version 1 of the data.
  128274. */
  128275. export interface EnvironmentTextureSpecularInfoV1 {
  128276. /**
  128277. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  128278. */
  128279. specularDataPosition?: number;
  128280. /**
  128281. * This contains all the images data needed to reconstruct the cubemap.
  128282. */
  128283. mipmaps: Array<BufferImageData>;
  128284. /**
  128285. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  128286. */
  128287. lodGenerationScale: number;
  128288. }
  128289. /**
  128290. * Sets of helpers addressing the serialization and deserialization of environment texture
  128291. * stored in a BabylonJS env file.
  128292. * Those files are usually stored as .env files.
  128293. */
  128294. export class EnvironmentTextureTools {
  128295. /**
  128296. * Magic number identifying the env file.
  128297. */
  128298. private static _MagicBytes;
  128299. /**
  128300. * Gets the environment info from an env file.
  128301. * @param data The array buffer containing the .env bytes.
  128302. * @returns the environment file info (the json header) if successfully parsed.
  128303. */
  128304. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  128305. /**
  128306. * Creates an environment texture from a loaded cube texture.
  128307. * @param texture defines the cube texture to convert in env file
  128308. * @return a promise containing the environment data if succesfull.
  128309. */
  128310. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  128311. /**
  128312. * Creates a JSON representation of the spherical data.
  128313. * @param texture defines the texture containing the polynomials
  128314. * @return the JSON representation of the spherical info
  128315. */
  128316. private static _CreateEnvTextureIrradiance;
  128317. /**
  128318. * Creates the ArrayBufferViews used for initializing environment texture image data.
  128319. * @param data the image data
  128320. * @param info parameters that determine what views will be created for accessing the underlying buffer
  128321. * @return the views described by info providing access to the underlying buffer
  128322. */
  128323. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  128324. /**
  128325. * Uploads the texture info contained in the env file to the GPU.
  128326. * @param texture defines the internal texture to upload to
  128327. * @param data defines the data to load
  128328. * @param info defines the texture info retrieved through the GetEnvInfo method
  128329. * @returns a promise
  128330. */
  128331. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  128332. private static _OnImageReadyAsync;
  128333. /**
  128334. * Uploads the levels of image data to the GPU.
  128335. * @param texture defines the internal texture to upload to
  128336. * @param imageData defines the array buffer views of image data [mipmap][face]
  128337. * @returns a promise
  128338. */
  128339. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  128340. /**
  128341. * Uploads spherical polynomials information to the texture.
  128342. * @param texture defines the texture we are trying to upload the information to
  128343. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  128344. */
  128345. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  128346. /** @hidden */
  128347. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  128348. }
  128349. }
  128350. declare module BABYLON {
  128351. /** @hidden */
  128352. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  128353. private _genericAttributeLocation;
  128354. private _varyingLocationCount;
  128355. private _varyingLocationMap;
  128356. private _replacements;
  128357. private _textureCount;
  128358. private _uniforms;
  128359. lineProcessor(line: string): string;
  128360. attributeProcessor(attribute: string): string;
  128361. varyingProcessor(varying: string, isFragment: boolean): string;
  128362. uniformProcessor(uniform: string): string;
  128363. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  128364. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  128365. }
  128366. }
  128367. declare module BABYLON {
  128368. /**
  128369. * Class used to inline functions in shader code
  128370. */
  128371. export class ShaderCodeInliner {
  128372. private static readonly _RegexpFindFunctionNameAndType;
  128373. private _sourceCode;
  128374. private _functionDescr;
  128375. private _numMaxIterations;
  128376. /** Gets or sets the token used to mark the functions to inline */
  128377. inlineToken: string;
  128378. /** Gets or sets the debug mode */
  128379. debug: boolean;
  128380. /** Gets the code after the inlining process */
  128381. get code(): string;
  128382. /**
  128383. * Initializes the inliner
  128384. * @param sourceCode shader code source to inline
  128385. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  128386. */
  128387. constructor(sourceCode: string, numMaxIterations?: number);
  128388. /**
  128389. * Start the processing of the shader code
  128390. */
  128391. processCode(): void;
  128392. private _collectFunctions;
  128393. private _processInlining;
  128394. private _extractBetweenMarkers;
  128395. private _skipWhitespaces;
  128396. private _removeComments;
  128397. private _replaceFunctionCallsByCode;
  128398. private _findBackward;
  128399. private _escapeRegExp;
  128400. private _replaceNames;
  128401. }
  128402. }
  128403. declare module BABYLON {
  128404. /**
  128405. * Container for accessors for natively-stored mesh data buffers.
  128406. */
  128407. class NativeDataBuffer extends DataBuffer {
  128408. /**
  128409. * Accessor value used to identify/retrieve a natively-stored index buffer.
  128410. */
  128411. nativeIndexBuffer?: any;
  128412. /**
  128413. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  128414. */
  128415. nativeVertexBuffer?: any;
  128416. }
  128417. /** @hidden */
  128418. class NativeTexture extends InternalTexture {
  128419. getInternalTexture(): InternalTexture;
  128420. getViewCount(): number;
  128421. }
  128422. /** @hidden */
  128423. export class NativeEngine extends Engine {
  128424. private readonly _native;
  128425. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  128426. private readonly INVALID_HANDLE;
  128427. getHardwareScalingLevel(): number;
  128428. constructor();
  128429. dispose(): void;
  128430. /**
  128431. * Can be used to override the current requestAnimationFrame requester.
  128432. * @hidden
  128433. */
  128434. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  128435. /**
  128436. * Override default engine behavior.
  128437. * @param color
  128438. * @param backBuffer
  128439. * @param depth
  128440. * @param stencil
  128441. */
  128442. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  128443. /**
  128444. * Gets host document
  128445. * @returns the host document object
  128446. */
  128447. getHostDocument(): Nullable<Document>;
  128448. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  128449. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  128450. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  128451. recordVertexArrayObject(vertexBuffers: {
  128452. [key: string]: VertexBuffer;
  128453. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  128454. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  128455. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  128456. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  128457. /**
  128458. * Draw a list of indexed primitives
  128459. * @param fillMode defines the primitive to use
  128460. * @param indexStart defines the starting index
  128461. * @param indexCount defines the number of index to draw
  128462. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128463. */
  128464. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  128465. /**
  128466. * Draw a list of unindexed primitives
  128467. * @param fillMode defines the primitive to use
  128468. * @param verticesStart defines the index of first vertex to draw
  128469. * @param verticesCount defines the count of vertices to draw
  128470. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128471. */
  128472. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  128473. createPipelineContext(): IPipelineContext;
  128474. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  128475. /** @hidden */
  128476. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  128477. /** @hidden */
  128478. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  128479. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  128480. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  128481. protected _setProgram(program: WebGLProgram): void;
  128482. _releaseEffect(effect: Effect): void;
  128483. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  128484. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  128485. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  128486. bindSamplers(effect: Effect): void;
  128487. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  128488. getRenderWidth(useScreen?: boolean): number;
  128489. getRenderHeight(useScreen?: boolean): number;
  128490. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  128491. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  128492. /**
  128493. * Set the z offset to apply to current rendering
  128494. * @param value defines the offset to apply
  128495. */
  128496. setZOffset(value: number): void;
  128497. /**
  128498. * Gets the current value of the zOffset
  128499. * @returns the current zOffset state
  128500. */
  128501. getZOffset(): number;
  128502. /**
  128503. * Enable or disable depth buffering
  128504. * @param enable defines the state to set
  128505. */
  128506. setDepthBuffer(enable: boolean): void;
  128507. /**
  128508. * Gets a boolean indicating if depth writing is enabled
  128509. * @returns the current depth writing state
  128510. */
  128511. getDepthWrite(): boolean;
  128512. /**
  128513. * Enable or disable depth writing
  128514. * @param enable defines the state to set
  128515. */
  128516. setDepthWrite(enable: boolean): void;
  128517. /**
  128518. * Enable or disable color writing
  128519. * @param enable defines the state to set
  128520. */
  128521. setColorWrite(enable: boolean): void;
  128522. /**
  128523. * Gets a boolean indicating if color writing is enabled
  128524. * @returns the current color writing state
  128525. */
  128526. getColorWrite(): boolean;
  128527. /**
  128528. * Sets alpha constants used by some alpha blending modes
  128529. * @param r defines the red component
  128530. * @param g defines the green component
  128531. * @param b defines the blue component
  128532. * @param a defines the alpha component
  128533. */
  128534. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  128535. /**
  128536. * Sets the current alpha mode
  128537. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  128538. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  128539. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  128540. */
  128541. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  128542. /**
  128543. * Gets the current alpha mode
  128544. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  128545. * @returns the current alpha mode
  128546. */
  128547. getAlphaMode(): number;
  128548. setInt(uniform: WebGLUniformLocation, int: number): void;
  128549. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  128550. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  128551. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  128552. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  128553. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  128554. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  128555. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  128556. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  128557. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  128558. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  128559. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  128560. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  128561. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  128562. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128563. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128564. setFloat(uniform: WebGLUniformLocation, value: number): void;
  128565. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  128566. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  128567. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  128568. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  128569. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  128570. wipeCaches(bruteForce?: boolean): void;
  128571. _createTexture(): WebGLTexture;
  128572. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  128573. /**
  128574. * Usually called from Texture.ts.
  128575. * Passed information to create a WebGLTexture
  128576. * @param url defines a value which contains one of the following:
  128577. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  128578. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  128579. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  128580. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  128581. * @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)
  128582. * @param scene needed for loading to the correct scene
  128583. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  128584. * @param onLoad optional callback to be called upon successful completion
  128585. * @param onError optional callback to be called upon failure
  128586. * @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
  128587. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  128588. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  128589. * @param forcedExtension defines the extension to use to pick the right loader
  128590. * @param mimeType defines an optional mime type
  128591. * @returns a InternalTexture for assignment back into BABYLON.Texture
  128592. */
  128593. 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;
  128594. /**
  128595. * Creates a cube texture
  128596. * @param rootUrl defines the url where the files to load is located
  128597. * @param scene defines the current scene
  128598. * @param files defines the list of files to load (1 per face)
  128599. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  128600. * @param onLoad defines an optional callback raised when the texture is loaded
  128601. * @param onError defines an optional callback raised if there is an issue to load the texture
  128602. * @param format defines the format of the data
  128603. * @param forcedExtension defines the extension to use to pick the right loader
  128604. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  128605. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  128606. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  128607. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  128608. * @returns the cube texture as an InternalTexture
  128609. */
  128610. 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;
  128611. private _getSamplingFilter;
  128612. private static _GetNativeTextureFormat;
  128613. createRenderTargetTexture(size: number | {
  128614. width: number;
  128615. height: number;
  128616. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  128617. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  128618. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  128619. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  128620. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  128621. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  128622. /**
  128623. * Updates a dynamic vertex buffer.
  128624. * @param vertexBuffer the vertex buffer to update
  128625. * @param data the data used to update the vertex buffer
  128626. * @param byteOffset the byte offset of the data (optional)
  128627. * @param byteLength the byte length of the data (optional)
  128628. */
  128629. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  128630. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  128631. private _updateAnisotropicLevel;
  128632. private _getAddressMode;
  128633. /** @hidden */
  128634. _bindTexture(channel: number, texture: InternalTexture): void;
  128635. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  128636. releaseEffects(): void;
  128637. /** @hidden */
  128638. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128639. /** @hidden */
  128640. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128641. /** @hidden */
  128642. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128643. /** @hidden */
  128644. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  128645. }
  128646. }
  128647. declare module BABYLON {
  128648. /**
  128649. * Gather the list of clipboard event types as constants.
  128650. */
  128651. export class ClipboardEventTypes {
  128652. /**
  128653. * The clipboard event is fired when a copy command is active (pressed).
  128654. */
  128655. static readonly COPY: number;
  128656. /**
  128657. * The clipboard event is fired when a cut command is active (pressed).
  128658. */
  128659. static readonly CUT: number;
  128660. /**
  128661. * The clipboard event is fired when a paste command is active (pressed).
  128662. */
  128663. static readonly PASTE: number;
  128664. }
  128665. /**
  128666. * This class is used to store clipboard related info for the onClipboardObservable event.
  128667. */
  128668. export class ClipboardInfo {
  128669. /**
  128670. * Defines the type of event (BABYLON.ClipboardEventTypes)
  128671. */
  128672. type: number;
  128673. /**
  128674. * Defines the related dom event
  128675. */
  128676. event: ClipboardEvent;
  128677. /**
  128678. *Creates an instance of ClipboardInfo.
  128679. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  128680. * @param event Defines the related dom event
  128681. */
  128682. constructor(
  128683. /**
  128684. * Defines the type of event (BABYLON.ClipboardEventTypes)
  128685. */
  128686. type: number,
  128687. /**
  128688. * Defines the related dom event
  128689. */
  128690. event: ClipboardEvent);
  128691. /**
  128692. * Get the clipboard event's type from the keycode.
  128693. * @param keyCode Defines the keyCode for the current keyboard event.
  128694. * @return {number}
  128695. */
  128696. static GetTypeFromCharacter(keyCode: number): number;
  128697. }
  128698. }
  128699. declare module BABYLON {
  128700. /**
  128701. * Google Daydream controller
  128702. */
  128703. export class DaydreamController extends WebVRController {
  128704. /**
  128705. * Base Url for the controller model.
  128706. */
  128707. static MODEL_BASE_URL: string;
  128708. /**
  128709. * File name for the controller model.
  128710. */
  128711. static MODEL_FILENAME: string;
  128712. /**
  128713. * Gamepad Id prefix used to identify Daydream Controller.
  128714. */
  128715. static readonly GAMEPAD_ID_PREFIX: string;
  128716. /**
  128717. * Creates a new DaydreamController from a gamepad
  128718. * @param vrGamepad the gamepad that the controller should be created from
  128719. */
  128720. constructor(vrGamepad: any);
  128721. /**
  128722. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128723. * @param scene scene in which to add meshes
  128724. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128725. */
  128726. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128727. /**
  128728. * Called once for each button that changed state since the last frame
  128729. * @param buttonIdx Which button index changed
  128730. * @param state New state of the button
  128731. * @param changes Which properties on the state changed since last frame
  128732. */
  128733. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128734. }
  128735. }
  128736. declare module BABYLON {
  128737. /**
  128738. * Gear VR Controller
  128739. */
  128740. export class GearVRController extends WebVRController {
  128741. /**
  128742. * Base Url for the controller model.
  128743. */
  128744. static MODEL_BASE_URL: string;
  128745. /**
  128746. * File name for the controller model.
  128747. */
  128748. static MODEL_FILENAME: string;
  128749. /**
  128750. * Gamepad Id prefix used to identify this controller.
  128751. */
  128752. static readonly GAMEPAD_ID_PREFIX: string;
  128753. private readonly _buttonIndexToObservableNameMap;
  128754. /**
  128755. * Creates a new GearVRController from a gamepad
  128756. * @param vrGamepad the gamepad that the controller should be created from
  128757. */
  128758. constructor(vrGamepad: any);
  128759. /**
  128760. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128761. * @param scene scene in which to add meshes
  128762. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128763. */
  128764. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128765. /**
  128766. * Called once for each button that changed state since the last frame
  128767. * @param buttonIdx Which button index changed
  128768. * @param state New state of the button
  128769. * @param changes Which properties on the state changed since last frame
  128770. */
  128771. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128772. }
  128773. }
  128774. declare module BABYLON {
  128775. /**
  128776. * Generic Controller
  128777. */
  128778. export class GenericController extends WebVRController {
  128779. /**
  128780. * Base Url for the controller model.
  128781. */
  128782. static readonly MODEL_BASE_URL: string;
  128783. /**
  128784. * File name for the controller model.
  128785. */
  128786. static readonly MODEL_FILENAME: string;
  128787. /**
  128788. * Creates a new GenericController from a gamepad
  128789. * @param vrGamepad the gamepad that the controller should be created from
  128790. */
  128791. constructor(vrGamepad: any);
  128792. /**
  128793. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128794. * @param scene scene in which to add meshes
  128795. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128796. */
  128797. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128798. /**
  128799. * Called once for each button that changed state since the last frame
  128800. * @param buttonIdx Which button index changed
  128801. * @param state New state of the button
  128802. * @param changes Which properties on the state changed since last frame
  128803. */
  128804. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128805. }
  128806. }
  128807. declare module BABYLON {
  128808. /**
  128809. * Oculus Touch Controller
  128810. */
  128811. export class OculusTouchController extends WebVRController {
  128812. /**
  128813. * Base Url for the controller model.
  128814. */
  128815. static MODEL_BASE_URL: string;
  128816. /**
  128817. * File name for the left controller model.
  128818. */
  128819. static MODEL_LEFT_FILENAME: string;
  128820. /**
  128821. * File name for the right controller model.
  128822. */
  128823. static MODEL_RIGHT_FILENAME: string;
  128824. /**
  128825. * Base Url for the Quest controller model.
  128826. */
  128827. static QUEST_MODEL_BASE_URL: string;
  128828. /**
  128829. * @hidden
  128830. * If the controllers are running on a device that needs the updated Quest controller models
  128831. */
  128832. static _IsQuest: boolean;
  128833. /**
  128834. * Fired when the secondary trigger on this controller is modified
  128835. */
  128836. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  128837. /**
  128838. * Fired when the thumb rest on this controller is modified
  128839. */
  128840. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  128841. /**
  128842. * Creates a new OculusTouchController from a gamepad
  128843. * @param vrGamepad the gamepad that the controller should be created from
  128844. */
  128845. constructor(vrGamepad: any);
  128846. /**
  128847. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128848. * @param scene scene in which to add meshes
  128849. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128850. */
  128851. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128852. /**
  128853. * Fired when the A button on this controller is modified
  128854. */
  128855. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128856. /**
  128857. * Fired when the B button on this controller is modified
  128858. */
  128859. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128860. /**
  128861. * Fired when the X button on this controller is modified
  128862. */
  128863. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128864. /**
  128865. * Fired when the Y button on this controller is modified
  128866. */
  128867. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128868. /**
  128869. * Called once for each button that changed state since the last frame
  128870. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  128871. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  128872. * 2) secondary trigger (same)
  128873. * 3) A (right) X (left), touch, pressed = value
  128874. * 4) B / Y
  128875. * 5) thumb rest
  128876. * @param buttonIdx Which button index changed
  128877. * @param state New state of the button
  128878. * @param changes Which properties on the state changed since last frame
  128879. */
  128880. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128881. }
  128882. }
  128883. declare module BABYLON {
  128884. /**
  128885. * Vive Controller
  128886. */
  128887. export class ViveController extends WebVRController {
  128888. /**
  128889. * Base Url for the controller model.
  128890. */
  128891. static MODEL_BASE_URL: string;
  128892. /**
  128893. * File name for the controller model.
  128894. */
  128895. static MODEL_FILENAME: string;
  128896. /**
  128897. * Creates a new ViveController from a gamepad
  128898. * @param vrGamepad the gamepad that the controller should be created from
  128899. */
  128900. constructor(vrGamepad: any);
  128901. /**
  128902. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128903. * @param scene scene in which to add meshes
  128904. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128905. */
  128906. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128907. /**
  128908. * Fired when the left button on this controller is modified
  128909. */
  128910. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128911. /**
  128912. * Fired when the right button on this controller is modified
  128913. */
  128914. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128915. /**
  128916. * Fired when the menu button on this controller is modified
  128917. */
  128918. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128919. /**
  128920. * Called once for each button that changed state since the last frame
  128921. * Vive mapping:
  128922. * 0: touchpad
  128923. * 1: trigger
  128924. * 2: left AND right buttons
  128925. * 3: menu button
  128926. * @param buttonIdx Which button index changed
  128927. * @param state New state of the button
  128928. * @param changes Which properties on the state changed since last frame
  128929. */
  128930. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128931. }
  128932. }
  128933. declare module BABYLON {
  128934. /**
  128935. * Defines the WindowsMotionController object that the state of the windows motion controller
  128936. */
  128937. export class WindowsMotionController extends WebVRController {
  128938. /**
  128939. * The base url used to load the left and right controller models
  128940. */
  128941. static MODEL_BASE_URL: string;
  128942. /**
  128943. * The name of the left controller model file
  128944. */
  128945. static MODEL_LEFT_FILENAME: string;
  128946. /**
  128947. * The name of the right controller model file
  128948. */
  128949. static MODEL_RIGHT_FILENAME: string;
  128950. /**
  128951. * The controller name prefix for this controller type
  128952. */
  128953. static readonly GAMEPAD_ID_PREFIX: string;
  128954. /**
  128955. * The controller id pattern for this controller type
  128956. */
  128957. private static readonly GAMEPAD_ID_PATTERN;
  128958. private _loadedMeshInfo;
  128959. protected readonly _mapping: {
  128960. buttons: string[];
  128961. buttonMeshNames: {
  128962. trigger: string;
  128963. menu: string;
  128964. grip: string;
  128965. thumbstick: string;
  128966. trackpad: string;
  128967. };
  128968. buttonObservableNames: {
  128969. trigger: string;
  128970. menu: string;
  128971. grip: string;
  128972. thumbstick: string;
  128973. trackpad: string;
  128974. };
  128975. axisMeshNames: string[];
  128976. pointingPoseMeshName: string;
  128977. };
  128978. /**
  128979. * Fired when the trackpad on this controller is clicked
  128980. */
  128981. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  128982. /**
  128983. * Fired when the trackpad on this controller is modified
  128984. */
  128985. onTrackpadValuesChangedObservable: Observable<StickValues>;
  128986. /**
  128987. * The current x and y values of this controller's trackpad
  128988. */
  128989. trackpad: StickValues;
  128990. /**
  128991. * Creates a new WindowsMotionController from a gamepad
  128992. * @param vrGamepad the gamepad that the controller should be created from
  128993. */
  128994. constructor(vrGamepad: any);
  128995. /**
  128996. * Fired when the trigger on this controller is modified
  128997. */
  128998. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128999. /**
  129000. * Fired when the menu button on this controller is modified
  129001. */
  129002. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129003. /**
  129004. * Fired when the grip button on this controller is modified
  129005. */
  129006. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129007. /**
  129008. * Fired when the thumbstick button on this controller is modified
  129009. */
  129010. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129011. /**
  129012. * Fired when the touchpad button on this controller is modified
  129013. */
  129014. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129015. /**
  129016. * Fired when the touchpad values on this controller are modified
  129017. */
  129018. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  129019. protected _updateTrackpad(): void;
  129020. /**
  129021. * Called once per frame by the engine.
  129022. */
  129023. update(): void;
  129024. /**
  129025. * Called once for each button that changed state since the last frame
  129026. * @param buttonIdx Which button index changed
  129027. * @param state New state of the button
  129028. * @param changes Which properties on the state changed since last frame
  129029. */
  129030. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129031. /**
  129032. * Moves the buttons on the controller mesh based on their current state
  129033. * @param buttonName the name of the button to move
  129034. * @param buttonValue the value of the button which determines the buttons new position
  129035. */
  129036. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  129037. /**
  129038. * Moves the axis on the controller mesh based on its current state
  129039. * @param axis the index of the axis
  129040. * @param axisValue the value of the axis which determines the meshes new position
  129041. * @hidden
  129042. */
  129043. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  129044. /**
  129045. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129046. * @param scene scene in which to add meshes
  129047. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129048. */
  129049. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  129050. /**
  129051. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  129052. * can be transformed by button presses and axes values, based on this._mapping.
  129053. *
  129054. * @param scene scene in which the meshes exist
  129055. * @param meshes list of meshes that make up the controller model to process
  129056. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  129057. */
  129058. private processModel;
  129059. private createMeshInfo;
  129060. /**
  129061. * Gets the ray of the controller in the direction the controller is pointing
  129062. * @param length the length the resulting ray should be
  129063. * @returns a ray in the direction the controller is pointing
  129064. */
  129065. getForwardRay(length?: number): Ray;
  129066. /**
  129067. * Disposes of the controller
  129068. */
  129069. dispose(): void;
  129070. }
  129071. /**
  129072. * This class represents a new windows motion controller in XR.
  129073. */
  129074. export class XRWindowsMotionController extends WindowsMotionController {
  129075. /**
  129076. * Changing the original WIndowsMotionController mapping to fir the new mapping
  129077. */
  129078. protected readonly _mapping: {
  129079. buttons: string[];
  129080. buttonMeshNames: {
  129081. trigger: string;
  129082. menu: string;
  129083. grip: string;
  129084. thumbstick: string;
  129085. trackpad: string;
  129086. };
  129087. buttonObservableNames: {
  129088. trigger: string;
  129089. menu: string;
  129090. grip: string;
  129091. thumbstick: string;
  129092. trackpad: string;
  129093. };
  129094. axisMeshNames: string[];
  129095. pointingPoseMeshName: string;
  129096. };
  129097. /**
  129098. * Construct a new XR-Based windows motion controller
  129099. *
  129100. * @param gamepadInfo the gamepad object from the browser
  129101. */
  129102. constructor(gamepadInfo: any);
  129103. /**
  129104. * holds the thumbstick values (X,Y)
  129105. */
  129106. thumbstickValues: StickValues;
  129107. /**
  129108. * Fired when the thumbstick on this controller is clicked
  129109. */
  129110. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  129111. /**
  129112. * Fired when the thumbstick on this controller is modified
  129113. */
  129114. onThumbstickValuesChangedObservable: Observable<StickValues>;
  129115. /**
  129116. * Fired when the touchpad button on this controller is modified
  129117. */
  129118. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  129119. /**
  129120. * Fired when the touchpad values on this controller are modified
  129121. */
  129122. onTrackpadValuesChangedObservable: Observable<StickValues>;
  129123. /**
  129124. * Fired when the thumbstick button on this controller is modified
  129125. * here to prevent breaking changes
  129126. */
  129127. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129128. /**
  129129. * updating the thumbstick(!) and not the trackpad.
  129130. * This is named this way due to the difference between WebVR and XR and to avoid
  129131. * changing the parent class.
  129132. */
  129133. protected _updateTrackpad(): void;
  129134. /**
  129135. * Disposes the class with joy
  129136. */
  129137. dispose(): void;
  129138. }
  129139. }
  129140. declare module BABYLON {
  129141. /**
  129142. * Class containing static functions to help procedurally build meshes
  129143. */
  129144. export class PolyhedronBuilder {
  129145. /**
  129146. * Creates a polyhedron mesh
  129147. * * 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
  129148. * * The parameter `size` (positive float, default 1) sets the polygon size
  129149. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  129150. * * 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`
  129151. * * 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
  129152. * * 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)`)
  129153. * * 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
  129154. * * 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
  129155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129156. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129158. * @param name defines the name of the mesh
  129159. * @param options defines the options used to create the mesh
  129160. * @param scene defines the hosting scene
  129161. * @returns the polyhedron mesh
  129162. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  129163. */
  129164. static CreatePolyhedron(name: string, options: {
  129165. type?: number;
  129166. size?: number;
  129167. sizeX?: number;
  129168. sizeY?: number;
  129169. sizeZ?: number;
  129170. custom?: any;
  129171. faceUV?: Vector4[];
  129172. faceColors?: Color4[];
  129173. flat?: boolean;
  129174. updatable?: boolean;
  129175. sideOrientation?: number;
  129176. frontUVs?: Vector4;
  129177. backUVs?: Vector4;
  129178. }, scene?: Nullable<Scene>): Mesh;
  129179. }
  129180. }
  129181. declare module BABYLON {
  129182. /**
  129183. * Gizmo that enables scaling a mesh along 3 axis
  129184. */
  129185. export class ScaleGizmo extends Gizmo {
  129186. /**
  129187. * Internal gizmo used for interactions on the x axis
  129188. */
  129189. xGizmo: AxisScaleGizmo;
  129190. /**
  129191. * Internal gizmo used for interactions on the y axis
  129192. */
  129193. yGizmo: AxisScaleGizmo;
  129194. /**
  129195. * Internal gizmo used for interactions on the z axis
  129196. */
  129197. zGizmo: AxisScaleGizmo;
  129198. /**
  129199. * Internal gizmo used to scale all axis equally
  129200. */
  129201. uniformScaleGizmo: AxisScaleGizmo;
  129202. private _meshAttached;
  129203. private _updateGizmoRotationToMatchAttachedMesh;
  129204. private _snapDistance;
  129205. private _scaleRatio;
  129206. private _uniformScalingMesh;
  129207. private _octahedron;
  129208. private _sensitivity;
  129209. /** Fires an event when any of it's sub gizmos are dragged */
  129210. onDragStartObservable: Observable<unknown>;
  129211. /** Fires an event when any of it's sub gizmos are released from dragging */
  129212. onDragEndObservable: Observable<unknown>;
  129213. get attachedMesh(): Nullable<AbstractMesh>;
  129214. set attachedMesh(mesh: Nullable<AbstractMesh>);
  129215. /**
  129216. * Creates a ScaleGizmo
  129217. * @param gizmoLayer The utility layer the gizmo will be added to
  129218. */
  129219. constructor(gizmoLayer?: UtilityLayerRenderer);
  129220. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  129221. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  129222. /**
  129223. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129224. */
  129225. set snapDistance(value: number);
  129226. get snapDistance(): number;
  129227. /**
  129228. * Ratio for the scale of the gizmo (Default: 1)
  129229. */
  129230. set scaleRatio(value: number);
  129231. get scaleRatio(): number;
  129232. /**
  129233. * Sensitivity factor for dragging (Default: 1)
  129234. */
  129235. set sensitivity(value: number);
  129236. get sensitivity(): number;
  129237. /**
  129238. * Disposes of the gizmo
  129239. */
  129240. dispose(): void;
  129241. }
  129242. }
  129243. declare module BABYLON {
  129244. /**
  129245. * Single axis scale gizmo
  129246. */
  129247. export class AxisScaleGizmo extends Gizmo {
  129248. /**
  129249. * Drag behavior responsible for the gizmos dragging interactions
  129250. */
  129251. dragBehavior: PointerDragBehavior;
  129252. private _pointerObserver;
  129253. /**
  129254. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129255. */
  129256. snapDistance: number;
  129257. /**
  129258. * Event that fires each time the gizmo snaps to a new location.
  129259. * * snapDistance is the the change in distance
  129260. */
  129261. onSnapObservable: Observable<{
  129262. snapDistance: number;
  129263. }>;
  129264. /**
  129265. * If the scaling operation should be done on all axis (default: false)
  129266. */
  129267. uniformScaling: boolean;
  129268. /**
  129269. * Custom sensitivity value for the drag strength
  129270. */
  129271. sensitivity: number;
  129272. private _isEnabled;
  129273. private _parent;
  129274. private _arrow;
  129275. private _coloredMaterial;
  129276. private _hoverMaterial;
  129277. /**
  129278. * Creates an AxisScaleGizmo
  129279. * @param gizmoLayer The utility layer the gizmo will be added to
  129280. * @param dragAxis The axis which the gizmo will be able to scale on
  129281. * @param color The color of the gizmo
  129282. */
  129283. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  129284. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  129285. /**
  129286. * If the gizmo is enabled
  129287. */
  129288. set isEnabled(value: boolean);
  129289. get isEnabled(): boolean;
  129290. /**
  129291. * Disposes of the gizmo
  129292. */
  129293. dispose(): void;
  129294. /**
  129295. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  129296. * @param mesh The mesh to replace the default mesh of the gizmo
  129297. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  129298. */
  129299. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  129300. }
  129301. }
  129302. declare module BABYLON {
  129303. /**
  129304. * Bounding box gizmo
  129305. */
  129306. export class BoundingBoxGizmo extends Gizmo {
  129307. private _lineBoundingBox;
  129308. private _rotateSpheresParent;
  129309. private _scaleBoxesParent;
  129310. private _boundingDimensions;
  129311. private _renderObserver;
  129312. private _pointerObserver;
  129313. private _scaleDragSpeed;
  129314. private _tmpQuaternion;
  129315. private _tmpVector;
  129316. private _tmpRotationMatrix;
  129317. /**
  129318. * 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)
  129319. */
  129320. ignoreChildren: boolean;
  129321. /**
  129322. * 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)
  129323. */
  129324. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  129325. /**
  129326. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  129327. */
  129328. rotationSphereSize: number;
  129329. /**
  129330. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  129331. */
  129332. scaleBoxSize: number;
  129333. /**
  129334. * 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)
  129335. */
  129336. fixedDragMeshScreenSize: boolean;
  129337. /**
  129338. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  129339. */
  129340. fixedDragMeshScreenSizeDistanceFactor: number;
  129341. /**
  129342. * Fired when a rotation sphere or scale box is dragged
  129343. */
  129344. onDragStartObservable: Observable<{}>;
  129345. /**
  129346. * Fired when a scale box is dragged
  129347. */
  129348. onScaleBoxDragObservable: Observable<{}>;
  129349. /**
  129350. * Fired when a scale box drag is ended
  129351. */
  129352. onScaleBoxDragEndObservable: Observable<{}>;
  129353. /**
  129354. * Fired when a rotation sphere is dragged
  129355. */
  129356. onRotationSphereDragObservable: Observable<{}>;
  129357. /**
  129358. * Fired when a rotation sphere drag is ended
  129359. */
  129360. onRotationSphereDragEndObservable: Observable<{}>;
  129361. /**
  129362. * 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)
  129363. */
  129364. scalePivot: Nullable<Vector3>;
  129365. /**
  129366. * Mesh used as a pivot to rotate the attached mesh
  129367. */
  129368. private _anchorMesh;
  129369. private _existingMeshScale;
  129370. private _dragMesh;
  129371. private pointerDragBehavior;
  129372. private coloredMaterial;
  129373. private hoverColoredMaterial;
  129374. /**
  129375. * Sets the color of the bounding box gizmo
  129376. * @param color the color to set
  129377. */
  129378. setColor(color: Color3): void;
  129379. /**
  129380. * Creates an BoundingBoxGizmo
  129381. * @param gizmoLayer The utility layer the gizmo will be added to
  129382. * @param color The color of the gizmo
  129383. */
  129384. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  129385. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  129386. private _selectNode;
  129387. /**
  129388. * Updates the bounding box information for the Gizmo
  129389. */
  129390. updateBoundingBox(): void;
  129391. private _updateRotationSpheres;
  129392. private _updateScaleBoxes;
  129393. /**
  129394. * Enables rotation on the specified axis and disables rotation on the others
  129395. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  129396. */
  129397. setEnabledRotationAxis(axis: string): void;
  129398. /**
  129399. * Enables/disables scaling
  129400. * @param enable if scaling should be enabled
  129401. * @param homogeneousScaling defines if scaling should only be homogeneous
  129402. */
  129403. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  129404. private _updateDummy;
  129405. /**
  129406. * Enables a pointer drag behavior on the bounding box of the gizmo
  129407. */
  129408. enableDragBehavior(): void;
  129409. /**
  129410. * Disposes of the gizmo
  129411. */
  129412. dispose(): void;
  129413. /**
  129414. * 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)
  129415. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  129416. * @returns the bounding box mesh with the passed in mesh as a child
  129417. */
  129418. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  129419. /**
  129420. * CustomMeshes are not supported by this gizmo
  129421. * @param mesh The mesh to replace the default mesh of the gizmo
  129422. */
  129423. setCustomMesh(mesh: Mesh): void;
  129424. }
  129425. }
  129426. declare module BABYLON {
  129427. /**
  129428. * Single plane rotation gizmo
  129429. */
  129430. export class PlaneRotationGizmo extends Gizmo {
  129431. /**
  129432. * Drag behavior responsible for the gizmos dragging interactions
  129433. */
  129434. dragBehavior: PointerDragBehavior;
  129435. private _pointerObserver;
  129436. /**
  129437. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  129438. */
  129439. snapDistance: number;
  129440. /**
  129441. * Event that fires each time the gizmo snaps to a new location.
  129442. * * snapDistance is the the change in distance
  129443. */
  129444. onSnapObservable: Observable<{
  129445. snapDistance: number;
  129446. }>;
  129447. private _isEnabled;
  129448. private _parent;
  129449. /**
  129450. * Creates a PlaneRotationGizmo
  129451. * @param gizmoLayer The utility layer the gizmo will be added to
  129452. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  129453. * @param color The color of the gizmo
  129454. * @param tessellation Amount of tessellation to be used when creating rotation circles
  129455. * @param useEulerRotation Use and update Euler angle instead of quaternion
  129456. */
  129457. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  129458. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  129459. /**
  129460. * If the gizmo is enabled
  129461. */
  129462. set isEnabled(value: boolean);
  129463. get isEnabled(): boolean;
  129464. /**
  129465. * Disposes of the gizmo
  129466. */
  129467. dispose(): void;
  129468. }
  129469. }
  129470. declare module BABYLON {
  129471. /**
  129472. * Gizmo that enables rotating a mesh along 3 axis
  129473. */
  129474. export class RotationGizmo extends Gizmo {
  129475. /**
  129476. * Internal gizmo used for interactions on the x axis
  129477. */
  129478. xGizmo: PlaneRotationGizmo;
  129479. /**
  129480. * Internal gizmo used for interactions on the y axis
  129481. */
  129482. yGizmo: PlaneRotationGizmo;
  129483. /**
  129484. * Internal gizmo used for interactions on the z axis
  129485. */
  129486. zGizmo: PlaneRotationGizmo;
  129487. /** Fires an event when any of it's sub gizmos are dragged */
  129488. onDragStartObservable: Observable<unknown>;
  129489. /** Fires an event when any of it's sub gizmos are released from dragging */
  129490. onDragEndObservable: Observable<unknown>;
  129491. private _meshAttached;
  129492. get attachedMesh(): Nullable<AbstractMesh>;
  129493. set attachedMesh(mesh: Nullable<AbstractMesh>);
  129494. /**
  129495. * Creates a RotationGizmo
  129496. * @param gizmoLayer The utility layer the gizmo will be added to
  129497. * @param tessellation Amount of tessellation to be used when creating rotation circles
  129498. * @param useEulerRotation Use and update Euler angle instead of quaternion
  129499. */
  129500. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  129501. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  129502. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  129503. /**
  129504. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129505. */
  129506. set snapDistance(value: number);
  129507. get snapDistance(): number;
  129508. /**
  129509. * Ratio for the scale of the gizmo (Default: 1)
  129510. */
  129511. set scaleRatio(value: number);
  129512. get scaleRatio(): number;
  129513. /**
  129514. * Disposes of the gizmo
  129515. */
  129516. dispose(): void;
  129517. /**
  129518. * CustomMeshes are not supported by this gizmo
  129519. * @param mesh The mesh to replace the default mesh of the gizmo
  129520. */
  129521. setCustomMesh(mesh: Mesh): void;
  129522. }
  129523. }
  129524. declare module BABYLON {
  129525. /**
  129526. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  129527. */
  129528. export class GizmoManager implements IDisposable {
  129529. private scene;
  129530. /**
  129531. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  129532. */
  129533. gizmos: {
  129534. positionGizmo: Nullable<PositionGizmo>;
  129535. rotationGizmo: Nullable<RotationGizmo>;
  129536. scaleGizmo: Nullable<ScaleGizmo>;
  129537. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  129538. };
  129539. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  129540. clearGizmoOnEmptyPointerEvent: boolean;
  129541. /** Fires an event when the manager is attached to a mesh */
  129542. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  129543. private _gizmosEnabled;
  129544. private _pointerObserver;
  129545. private _attachedMesh;
  129546. private _boundingBoxColor;
  129547. private _defaultUtilityLayer;
  129548. private _defaultKeepDepthUtilityLayer;
  129549. /**
  129550. * When bounding box gizmo is enabled, this can be used to track drag/end events
  129551. */
  129552. boundingBoxDragBehavior: SixDofDragBehavior;
  129553. /**
  129554. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  129555. */
  129556. attachableMeshes: Nullable<Array<AbstractMesh>>;
  129557. /**
  129558. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  129559. */
  129560. usePointerToAttachGizmos: boolean;
  129561. /**
  129562. * Utility layer that the bounding box gizmo belongs to
  129563. */
  129564. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  129565. /**
  129566. * Utility layer that all gizmos besides bounding box belong to
  129567. */
  129568. get utilityLayer(): UtilityLayerRenderer;
  129569. /**
  129570. * Instatiates a gizmo manager
  129571. * @param scene the scene to overlay the gizmos on top of
  129572. */
  129573. constructor(scene: Scene);
  129574. /**
  129575. * Attaches a set of gizmos to the specified mesh
  129576. * @param mesh The mesh the gizmo's should be attached to
  129577. */
  129578. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  129579. /**
  129580. * If the position gizmo is enabled
  129581. */
  129582. set positionGizmoEnabled(value: boolean);
  129583. get positionGizmoEnabled(): boolean;
  129584. /**
  129585. * If the rotation gizmo is enabled
  129586. */
  129587. set rotationGizmoEnabled(value: boolean);
  129588. get rotationGizmoEnabled(): boolean;
  129589. /**
  129590. * If the scale gizmo is enabled
  129591. */
  129592. set scaleGizmoEnabled(value: boolean);
  129593. get scaleGizmoEnabled(): boolean;
  129594. /**
  129595. * If the boundingBox gizmo is enabled
  129596. */
  129597. set boundingBoxGizmoEnabled(value: boolean);
  129598. get boundingBoxGizmoEnabled(): boolean;
  129599. /**
  129600. * Disposes of the gizmo manager
  129601. */
  129602. dispose(): void;
  129603. }
  129604. }
  129605. declare module BABYLON {
  129606. /**
  129607. * A directional light is defined by a direction (what a surprise!).
  129608. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  129609. * 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.
  129610. * Documentation: https://doc.babylonjs.com/babylon101/lights
  129611. */
  129612. export class DirectionalLight extends ShadowLight {
  129613. private _shadowFrustumSize;
  129614. /**
  129615. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  129616. */
  129617. get shadowFrustumSize(): number;
  129618. /**
  129619. * Specifies a fix frustum size for the shadow generation.
  129620. */
  129621. set shadowFrustumSize(value: number);
  129622. private _shadowOrthoScale;
  129623. /**
  129624. * Gets the shadow projection scale against the optimal computed one.
  129625. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  129626. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  129627. */
  129628. get shadowOrthoScale(): number;
  129629. /**
  129630. * Sets the shadow projection scale against the optimal computed one.
  129631. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  129632. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  129633. */
  129634. set shadowOrthoScale(value: number);
  129635. /**
  129636. * Automatically compute the projection matrix to best fit (including all the casters)
  129637. * on each frame.
  129638. */
  129639. autoUpdateExtends: boolean;
  129640. /**
  129641. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  129642. * on each frame. autoUpdateExtends must be set to true for this to work
  129643. */
  129644. autoCalcShadowZBounds: boolean;
  129645. private _orthoLeft;
  129646. private _orthoRight;
  129647. private _orthoTop;
  129648. private _orthoBottom;
  129649. /**
  129650. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  129651. * The directional light is emitted from everywhere in the given direction.
  129652. * It can cast shadows.
  129653. * Documentation : https://doc.babylonjs.com/babylon101/lights
  129654. * @param name The friendly name of the light
  129655. * @param direction The direction of the light
  129656. * @param scene The scene the light belongs to
  129657. */
  129658. constructor(name: string, direction: Vector3, scene: Scene);
  129659. /**
  129660. * Returns the string "DirectionalLight".
  129661. * @return The class name
  129662. */
  129663. getClassName(): string;
  129664. /**
  129665. * Returns the integer 1.
  129666. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  129667. */
  129668. getTypeID(): number;
  129669. /**
  129670. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  129671. * Returns the DirectionalLight Shadow projection matrix.
  129672. */
  129673. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129674. /**
  129675. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  129676. * Returns the DirectionalLight Shadow projection matrix.
  129677. */
  129678. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  129679. /**
  129680. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  129681. * Returns the DirectionalLight Shadow projection matrix.
  129682. */
  129683. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129684. protected _buildUniformLayout(): void;
  129685. /**
  129686. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  129687. * @param effect The effect to update
  129688. * @param lightIndex The index of the light in the effect to update
  129689. * @returns The directional light
  129690. */
  129691. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  129692. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  129693. /**
  129694. * Gets the minZ used for shadow according to both the scene and the light.
  129695. *
  129696. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  129697. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  129698. * @param activeCamera The camera we are returning the min for
  129699. * @returns the depth min z
  129700. */
  129701. getDepthMinZ(activeCamera: Camera): number;
  129702. /**
  129703. * Gets the maxZ used for shadow according to both the scene and the light.
  129704. *
  129705. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  129706. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  129707. * @param activeCamera The camera we are returning the max for
  129708. * @returns the depth max z
  129709. */
  129710. getDepthMaxZ(activeCamera: Camera): number;
  129711. /**
  129712. * Prepares the list of defines specific to the light type.
  129713. * @param defines the list of defines
  129714. * @param lightIndex defines the index of the light for the effect
  129715. */
  129716. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  129717. }
  129718. }
  129719. declare module BABYLON {
  129720. /**
  129721. * Class containing static functions to help procedurally build meshes
  129722. */
  129723. export class HemisphereBuilder {
  129724. /**
  129725. * Creates a hemisphere mesh
  129726. * @param name defines the name of the mesh
  129727. * @param options defines the options used to create the mesh
  129728. * @param scene defines the hosting scene
  129729. * @returns the hemisphere mesh
  129730. */
  129731. static CreateHemisphere(name: string, options: {
  129732. segments?: number;
  129733. diameter?: number;
  129734. sideOrientation?: number;
  129735. }, scene: any): Mesh;
  129736. }
  129737. }
  129738. declare module BABYLON {
  129739. /**
  129740. * A spot light is defined by a position, a direction, an angle, and an exponent.
  129741. * These values define a cone of light starting from the position, emitting toward the direction.
  129742. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  129743. * and the exponent defines the speed of the decay of the light with distance (reach).
  129744. * Documentation: https://doc.babylonjs.com/babylon101/lights
  129745. */
  129746. export class SpotLight extends ShadowLight {
  129747. private _angle;
  129748. private _innerAngle;
  129749. private _cosHalfAngle;
  129750. private _lightAngleScale;
  129751. private _lightAngleOffset;
  129752. /**
  129753. * Gets the cone angle of the spot light in Radians.
  129754. */
  129755. get angle(): number;
  129756. /**
  129757. * Sets the cone angle of the spot light in Radians.
  129758. */
  129759. set angle(value: number);
  129760. /**
  129761. * Only used in gltf falloff mode, this defines the angle where
  129762. * the directional falloff will start before cutting at angle which could be seen
  129763. * as outer angle.
  129764. */
  129765. get innerAngle(): number;
  129766. /**
  129767. * Only used in gltf falloff mode, this defines the angle where
  129768. * the directional falloff will start before cutting at angle which could be seen
  129769. * as outer angle.
  129770. */
  129771. set innerAngle(value: number);
  129772. private _shadowAngleScale;
  129773. /**
  129774. * Allows scaling the angle of the light for shadow generation only.
  129775. */
  129776. get shadowAngleScale(): number;
  129777. /**
  129778. * Allows scaling the angle of the light for shadow generation only.
  129779. */
  129780. set shadowAngleScale(value: number);
  129781. /**
  129782. * The light decay speed with the distance from the emission spot.
  129783. */
  129784. exponent: number;
  129785. private _projectionTextureMatrix;
  129786. /**
  129787. * Allows reading the projecton texture
  129788. */
  129789. get projectionTextureMatrix(): Matrix;
  129790. protected _projectionTextureLightNear: number;
  129791. /**
  129792. * Gets the near clip of the Spotlight for texture projection.
  129793. */
  129794. get projectionTextureLightNear(): number;
  129795. /**
  129796. * Sets the near clip of the Spotlight for texture projection.
  129797. */
  129798. set projectionTextureLightNear(value: number);
  129799. protected _projectionTextureLightFar: number;
  129800. /**
  129801. * Gets the far clip of the Spotlight for texture projection.
  129802. */
  129803. get projectionTextureLightFar(): number;
  129804. /**
  129805. * Sets the far clip of the Spotlight for texture projection.
  129806. */
  129807. set projectionTextureLightFar(value: number);
  129808. protected _projectionTextureUpDirection: Vector3;
  129809. /**
  129810. * Gets the Up vector of the Spotlight for texture projection.
  129811. */
  129812. get projectionTextureUpDirection(): Vector3;
  129813. /**
  129814. * Sets the Up vector of the Spotlight for texture projection.
  129815. */
  129816. set projectionTextureUpDirection(value: Vector3);
  129817. private _projectionTexture;
  129818. /**
  129819. * Gets the projection texture of the light.
  129820. */
  129821. get projectionTexture(): Nullable<BaseTexture>;
  129822. /**
  129823. * Sets the projection texture of the light.
  129824. */
  129825. set projectionTexture(value: Nullable<BaseTexture>);
  129826. private _projectionTextureViewLightDirty;
  129827. private _projectionTextureProjectionLightDirty;
  129828. private _projectionTextureDirty;
  129829. private _projectionTextureViewTargetVector;
  129830. private _projectionTextureViewLightMatrix;
  129831. private _projectionTextureProjectionLightMatrix;
  129832. private _projectionTextureScalingMatrix;
  129833. /**
  129834. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  129835. * It can cast shadows.
  129836. * Documentation : https://doc.babylonjs.com/babylon101/lights
  129837. * @param name The light friendly name
  129838. * @param position The position of the spot light in the scene
  129839. * @param direction The direction of the light in the scene
  129840. * @param angle The cone angle of the light in Radians
  129841. * @param exponent The light decay speed with the distance from the emission spot
  129842. * @param scene The scene the lights belongs to
  129843. */
  129844. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  129845. /**
  129846. * Returns the string "SpotLight".
  129847. * @returns the class name
  129848. */
  129849. getClassName(): string;
  129850. /**
  129851. * Returns the integer 2.
  129852. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  129853. */
  129854. getTypeID(): number;
  129855. /**
  129856. * Overrides the direction setter to recompute the projection texture view light Matrix.
  129857. */
  129858. protected _setDirection(value: Vector3): void;
  129859. /**
  129860. * Overrides the position setter to recompute the projection texture view light Matrix.
  129861. */
  129862. protected _setPosition(value: Vector3): void;
  129863. /**
  129864. * 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.
  129865. * Returns the SpotLight.
  129866. */
  129867. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129868. protected _computeProjectionTextureViewLightMatrix(): void;
  129869. protected _computeProjectionTextureProjectionLightMatrix(): void;
  129870. /**
  129871. * Main function for light texture projection matrix computing.
  129872. */
  129873. protected _computeProjectionTextureMatrix(): void;
  129874. protected _buildUniformLayout(): void;
  129875. private _computeAngleValues;
  129876. /**
  129877. * Sets the passed Effect "effect" with the Light textures.
  129878. * @param effect The effect to update
  129879. * @param lightIndex The index of the light in the effect to update
  129880. * @returns The light
  129881. */
  129882. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  129883. /**
  129884. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  129885. * @param effect The effect to update
  129886. * @param lightIndex The index of the light in the effect to update
  129887. * @returns The spot light
  129888. */
  129889. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  129890. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  129891. /**
  129892. * Disposes the light and the associated resources.
  129893. */
  129894. dispose(): void;
  129895. /**
  129896. * Prepares the list of defines specific to the light type.
  129897. * @param defines the list of defines
  129898. * @param lightIndex defines the index of the light for the effect
  129899. */
  129900. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  129901. }
  129902. }
  129903. declare module BABYLON {
  129904. /**
  129905. * Gizmo that enables viewing a light
  129906. */
  129907. export class LightGizmo extends Gizmo {
  129908. private _lightMesh;
  129909. private _material;
  129910. private _cachedPosition;
  129911. private _cachedForward;
  129912. private _attachedMeshParent;
  129913. /**
  129914. * Creates a LightGizmo
  129915. * @param gizmoLayer The utility layer the gizmo will be added to
  129916. */
  129917. constructor(gizmoLayer?: UtilityLayerRenderer);
  129918. private _light;
  129919. /**
  129920. * The light that the gizmo is attached to
  129921. */
  129922. set light(light: Nullable<Light>);
  129923. get light(): Nullable<Light>;
  129924. /**
  129925. * Gets the material used to render the light gizmo
  129926. */
  129927. get material(): StandardMaterial;
  129928. /**
  129929. * @hidden
  129930. * Updates the gizmo to match the attached mesh's position/rotation
  129931. */
  129932. protected _update(): void;
  129933. private static _Scale;
  129934. /**
  129935. * Creates the lines for a light mesh
  129936. */
  129937. private static _CreateLightLines;
  129938. /**
  129939. * Disposes of the light gizmo
  129940. */
  129941. dispose(): void;
  129942. private static _CreateHemisphericLightMesh;
  129943. private static _CreatePointLightMesh;
  129944. private static _CreateSpotLightMesh;
  129945. private static _CreateDirectionalLightMesh;
  129946. }
  129947. }
  129948. declare module BABYLON {
  129949. /** @hidden */
  129950. export var backgroundFragmentDeclaration: {
  129951. name: string;
  129952. shader: string;
  129953. };
  129954. }
  129955. declare module BABYLON {
  129956. /** @hidden */
  129957. export var backgroundUboDeclaration: {
  129958. name: string;
  129959. shader: string;
  129960. };
  129961. }
  129962. declare module BABYLON {
  129963. /** @hidden */
  129964. export var backgroundPixelShader: {
  129965. name: string;
  129966. shader: string;
  129967. };
  129968. }
  129969. declare module BABYLON {
  129970. /** @hidden */
  129971. export var backgroundVertexDeclaration: {
  129972. name: string;
  129973. shader: string;
  129974. };
  129975. }
  129976. declare module BABYLON {
  129977. /** @hidden */
  129978. export var backgroundVertexShader: {
  129979. name: string;
  129980. shader: string;
  129981. };
  129982. }
  129983. declare module BABYLON {
  129984. /**
  129985. * Background material used to create an efficient environement around your scene.
  129986. */
  129987. export class BackgroundMaterial extends PushMaterial {
  129988. /**
  129989. * Standard reflectance value at parallel view angle.
  129990. */
  129991. static StandardReflectance0: number;
  129992. /**
  129993. * Standard reflectance value at grazing angle.
  129994. */
  129995. static StandardReflectance90: number;
  129996. protected _primaryColor: Color3;
  129997. /**
  129998. * Key light Color (multiply against the environement texture)
  129999. */
  130000. primaryColor: Color3;
  130001. protected __perceptualColor: Nullable<Color3>;
  130002. /**
  130003. * Experimental Internal Use Only.
  130004. *
  130005. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  130006. * This acts as a helper to set the primary color to a more "human friendly" value.
  130007. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  130008. * output color as close as possible from the chosen value.
  130009. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  130010. * part of lighting setup.)
  130011. */
  130012. get _perceptualColor(): Nullable<Color3>;
  130013. set _perceptualColor(value: Nullable<Color3>);
  130014. protected _primaryColorShadowLevel: float;
  130015. /**
  130016. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  130017. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  130018. */
  130019. get primaryColorShadowLevel(): float;
  130020. set primaryColorShadowLevel(value: float);
  130021. protected _primaryColorHighlightLevel: float;
  130022. /**
  130023. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  130024. * The primary color is used at the level chosen to define what the white area would look.
  130025. */
  130026. get primaryColorHighlightLevel(): float;
  130027. set primaryColorHighlightLevel(value: float);
  130028. protected _reflectionTexture: Nullable<BaseTexture>;
  130029. /**
  130030. * Reflection Texture used in the material.
  130031. * Should be author in a specific way for the best result (refer to the documentation).
  130032. */
  130033. reflectionTexture: Nullable<BaseTexture>;
  130034. protected _reflectionBlur: float;
  130035. /**
  130036. * Reflection Texture level of blur.
  130037. *
  130038. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  130039. * texture twice.
  130040. */
  130041. reflectionBlur: float;
  130042. protected _diffuseTexture: Nullable<BaseTexture>;
  130043. /**
  130044. * Diffuse Texture used in the material.
  130045. * Should be author in a specific way for the best result (refer to the documentation).
  130046. */
  130047. diffuseTexture: Nullable<BaseTexture>;
  130048. protected _shadowLights: Nullable<IShadowLight[]>;
  130049. /**
  130050. * Specify the list of lights casting shadow on the material.
  130051. * All scene shadow lights will be included if null.
  130052. */
  130053. shadowLights: Nullable<IShadowLight[]>;
  130054. protected _shadowLevel: float;
  130055. /**
  130056. * Helps adjusting the shadow to a softer level if required.
  130057. * 0 means black shadows and 1 means no shadows.
  130058. */
  130059. shadowLevel: float;
  130060. protected _sceneCenter: Vector3;
  130061. /**
  130062. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  130063. * It is usually zero but might be interesting to modify according to your setup.
  130064. */
  130065. sceneCenter: Vector3;
  130066. protected _opacityFresnel: boolean;
  130067. /**
  130068. * This helps specifying that the material is falling off to the sky box at grazing angle.
  130069. * This helps ensuring a nice transition when the camera goes under the ground.
  130070. */
  130071. opacityFresnel: boolean;
  130072. protected _reflectionFresnel: boolean;
  130073. /**
  130074. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  130075. * This helps adding a mirror texture on the ground.
  130076. */
  130077. reflectionFresnel: boolean;
  130078. protected _reflectionFalloffDistance: number;
  130079. /**
  130080. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  130081. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  130082. */
  130083. reflectionFalloffDistance: number;
  130084. protected _reflectionAmount: number;
  130085. /**
  130086. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  130087. */
  130088. reflectionAmount: number;
  130089. protected _reflectionReflectance0: number;
  130090. /**
  130091. * This specifies the weight of the reflection at grazing angle.
  130092. */
  130093. reflectionReflectance0: number;
  130094. protected _reflectionReflectance90: number;
  130095. /**
  130096. * This specifies the weight of the reflection at a perpendicular point of view.
  130097. */
  130098. reflectionReflectance90: number;
  130099. /**
  130100. * Sets the reflection reflectance fresnel values according to the default standard
  130101. * empirically know to work well :-)
  130102. */
  130103. set reflectionStandardFresnelWeight(value: number);
  130104. protected _useRGBColor: boolean;
  130105. /**
  130106. * Helps to directly use the maps channels instead of their level.
  130107. */
  130108. useRGBColor: boolean;
  130109. protected _enableNoise: boolean;
  130110. /**
  130111. * This helps reducing the banding effect that could occur on the background.
  130112. */
  130113. enableNoise: boolean;
  130114. /**
  130115. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  130116. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  130117. * Recommended to be keep at 1.0 except for special cases.
  130118. */
  130119. get fovMultiplier(): number;
  130120. set fovMultiplier(value: number);
  130121. private _fovMultiplier;
  130122. /**
  130123. * Enable the FOV adjustment feature controlled by fovMultiplier.
  130124. */
  130125. useEquirectangularFOV: boolean;
  130126. private _maxSimultaneousLights;
  130127. /**
  130128. * Number of Simultaneous lights allowed on the material.
  130129. */
  130130. maxSimultaneousLights: int;
  130131. /**
  130132. * Default configuration related to image processing available in the Background Material.
  130133. */
  130134. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130135. /**
  130136. * Keep track of the image processing observer to allow dispose and replace.
  130137. */
  130138. private _imageProcessingObserver;
  130139. /**
  130140. * Attaches a new image processing configuration to the PBR Material.
  130141. * @param configuration (if null the scene configuration will be use)
  130142. */
  130143. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130144. /**
  130145. * Gets the image processing configuration used either in this material.
  130146. */
  130147. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  130148. /**
  130149. * Sets the Default image processing configuration used either in the this material.
  130150. *
  130151. * If sets to null, the scene one is in use.
  130152. */
  130153. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  130154. /**
  130155. * Gets wether the color curves effect is enabled.
  130156. */
  130157. get cameraColorCurvesEnabled(): boolean;
  130158. /**
  130159. * Sets wether the color curves effect is enabled.
  130160. */
  130161. set cameraColorCurvesEnabled(value: boolean);
  130162. /**
  130163. * Gets wether the color grading effect is enabled.
  130164. */
  130165. get cameraColorGradingEnabled(): boolean;
  130166. /**
  130167. * Gets wether the color grading effect is enabled.
  130168. */
  130169. set cameraColorGradingEnabled(value: boolean);
  130170. /**
  130171. * Gets wether tonemapping is enabled or not.
  130172. */
  130173. get cameraToneMappingEnabled(): boolean;
  130174. /**
  130175. * Sets wether tonemapping is enabled or not
  130176. */
  130177. set cameraToneMappingEnabled(value: boolean);
  130178. /**
  130179. * The camera exposure used on this material.
  130180. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  130181. * This corresponds to a photographic exposure.
  130182. */
  130183. get cameraExposure(): float;
  130184. /**
  130185. * The camera exposure used on this material.
  130186. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  130187. * This corresponds to a photographic exposure.
  130188. */
  130189. set cameraExposure(value: float);
  130190. /**
  130191. * Gets The camera contrast used on this material.
  130192. */
  130193. get cameraContrast(): float;
  130194. /**
  130195. * Sets The camera contrast used on this material.
  130196. */
  130197. set cameraContrast(value: float);
  130198. /**
  130199. * Gets the Color Grading 2D Lookup Texture.
  130200. */
  130201. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  130202. /**
  130203. * Sets the Color Grading 2D Lookup Texture.
  130204. */
  130205. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  130206. /**
  130207. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  130208. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  130209. * 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;
  130210. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  130211. */
  130212. get cameraColorCurves(): Nullable<ColorCurves>;
  130213. /**
  130214. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  130215. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  130216. * 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;
  130217. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  130218. */
  130219. set cameraColorCurves(value: Nullable<ColorCurves>);
  130220. /**
  130221. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  130222. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  130223. */
  130224. switchToBGR: boolean;
  130225. private _renderTargets;
  130226. private _reflectionControls;
  130227. private _white;
  130228. private _primaryShadowColor;
  130229. private _primaryHighlightColor;
  130230. /**
  130231. * Instantiates a Background Material in the given scene
  130232. * @param name The friendly name of the material
  130233. * @param scene The scene to add the material to
  130234. */
  130235. constructor(name: string, scene: Scene);
  130236. /**
  130237. * Gets a boolean indicating that current material needs to register RTT
  130238. */
  130239. get hasRenderTargetTextures(): boolean;
  130240. /**
  130241. * The entire material has been created in order to prevent overdraw.
  130242. * @returns false
  130243. */
  130244. needAlphaTesting(): boolean;
  130245. /**
  130246. * The entire material has been created in order to prevent overdraw.
  130247. * @returns true if blending is enable
  130248. */
  130249. needAlphaBlending(): boolean;
  130250. /**
  130251. * Checks wether the material is ready to be rendered for a given mesh.
  130252. * @param mesh The mesh to render
  130253. * @param subMesh The submesh to check against
  130254. * @param useInstances Specify wether or not the material is used with instances
  130255. * @returns true if all the dependencies are ready (Textures, Effects...)
  130256. */
  130257. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130258. /**
  130259. * Compute the primary color according to the chosen perceptual color.
  130260. */
  130261. private _computePrimaryColorFromPerceptualColor;
  130262. /**
  130263. * Compute the highlights and shadow colors according to their chosen levels.
  130264. */
  130265. private _computePrimaryColors;
  130266. /**
  130267. * Build the uniform buffer used in the material.
  130268. */
  130269. buildUniformLayout(): void;
  130270. /**
  130271. * Unbind the material.
  130272. */
  130273. unbind(): void;
  130274. /**
  130275. * Bind only the world matrix to the material.
  130276. * @param world The world matrix to bind.
  130277. */
  130278. bindOnlyWorldMatrix(world: Matrix): void;
  130279. /**
  130280. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  130281. * @param world The world matrix to bind.
  130282. * @param subMesh The submesh to bind for.
  130283. */
  130284. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130285. /**
  130286. * Checks to see if a texture is used in the material.
  130287. * @param texture - Base texture to use.
  130288. * @returns - Boolean specifying if a texture is used in the material.
  130289. */
  130290. hasTexture(texture: BaseTexture): boolean;
  130291. /**
  130292. * Dispose the material.
  130293. * @param forceDisposeEffect Force disposal of the associated effect.
  130294. * @param forceDisposeTextures Force disposal of the associated textures.
  130295. */
  130296. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  130297. /**
  130298. * Clones the material.
  130299. * @param name The cloned name.
  130300. * @returns The cloned material.
  130301. */
  130302. clone(name: string): BackgroundMaterial;
  130303. /**
  130304. * Serializes the current material to its JSON representation.
  130305. * @returns The JSON representation.
  130306. */
  130307. serialize(): any;
  130308. /**
  130309. * Gets the class name of the material
  130310. * @returns "BackgroundMaterial"
  130311. */
  130312. getClassName(): string;
  130313. /**
  130314. * Parse a JSON input to create back a background material.
  130315. * @param source The JSON data to parse
  130316. * @param scene The scene to create the parsed material in
  130317. * @param rootUrl The root url of the assets the material depends upon
  130318. * @returns the instantiated BackgroundMaterial.
  130319. */
  130320. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  130321. }
  130322. }
  130323. declare module BABYLON {
  130324. /**
  130325. * Represents the different options available during the creation of
  130326. * a Environment helper.
  130327. *
  130328. * This can control the default ground, skybox and image processing setup of your scene.
  130329. */
  130330. export interface IEnvironmentHelperOptions {
  130331. /**
  130332. * Specifies whether or not to create a ground.
  130333. * True by default.
  130334. */
  130335. createGround: boolean;
  130336. /**
  130337. * Specifies the ground size.
  130338. * 15 by default.
  130339. */
  130340. groundSize: number;
  130341. /**
  130342. * The texture used on the ground for the main color.
  130343. * Comes from the BabylonJS CDN by default.
  130344. *
  130345. * Remarks: Can be either a texture or a url.
  130346. */
  130347. groundTexture: string | BaseTexture;
  130348. /**
  130349. * The color mixed in the ground texture by default.
  130350. * BabylonJS clearColor by default.
  130351. */
  130352. groundColor: Color3;
  130353. /**
  130354. * Specifies the ground opacity.
  130355. * 1 by default.
  130356. */
  130357. groundOpacity: number;
  130358. /**
  130359. * Enables the ground to receive shadows.
  130360. * True by default.
  130361. */
  130362. enableGroundShadow: boolean;
  130363. /**
  130364. * Helps preventing the shadow to be fully black on the ground.
  130365. * 0.5 by default.
  130366. */
  130367. groundShadowLevel: number;
  130368. /**
  130369. * Creates a mirror texture attach to the ground.
  130370. * false by default.
  130371. */
  130372. enableGroundMirror: boolean;
  130373. /**
  130374. * Specifies the ground mirror size ratio.
  130375. * 0.3 by default as the default kernel is 64.
  130376. */
  130377. groundMirrorSizeRatio: number;
  130378. /**
  130379. * Specifies the ground mirror blur kernel size.
  130380. * 64 by default.
  130381. */
  130382. groundMirrorBlurKernel: number;
  130383. /**
  130384. * Specifies the ground mirror visibility amount.
  130385. * 1 by default
  130386. */
  130387. groundMirrorAmount: number;
  130388. /**
  130389. * Specifies the ground mirror reflectance weight.
  130390. * This uses the standard weight of the background material to setup the fresnel effect
  130391. * of the mirror.
  130392. * 1 by default.
  130393. */
  130394. groundMirrorFresnelWeight: number;
  130395. /**
  130396. * Specifies the ground mirror Falloff distance.
  130397. * This can helps reducing the size of the reflection.
  130398. * 0 by Default.
  130399. */
  130400. groundMirrorFallOffDistance: number;
  130401. /**
  130402. * Specifies the ground mirror texture type.
  130403. * Unsigned Int by Default.
  130404. */
  130405. groundMirrorTextureType: number;
  130406. /**
  130407. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  130408. * the shown objects.
  130409. */
  130410. groundYBias: number;
  130411. /**
  130412. * Specifies whether or not to create a skybox.
  130413. * True by default.
  130414. */
  130415. createSkybox: boolean;
  130416. /**
  130417. * Specifies the skybox size.
  130418. * 20 by default.
  130419. */
  130420. skyboxSize: number;
  130421. /**
  130422. * The texture used on the skybox for the main color.
  130423. * Comes from the BabylonJS CDN by default.
  130424. *
  130425. * Remarks: Can be either a texture or a url.
  130426. */
  130427. skyboxTexture: string | BaseTexture;
  130428. /**
  130429. * The color mixed in the skybox texture by default.
  130430. * BabylonJS clearColor by default.
  130431. */
  130432. skyboxColor: Color3;
  130433. /**
  130434. * The background rotation around the Y axis of the scene.
  130435. * This helps aligning the key lights of your scene with the background.
  130436. * 0 by default.
  130437. */
  130438. backgroundYRotation: number;
  130439. /**
  130440. * Compute automatically the size of the elements to best fit with the scene.
  130441. */
  130442. sizeAuto: boolean;
  130443. /**
  130444. * Default position of the rootMesh if autoSize is not true.
  130445. */
  130446. rootPosition: Vector3;
  130447. /**
  130448. * Sets up the image processing in the scene.
  130449. * true by default.
  130450. */
  130451. setupImageProcessing: boolean;
  130452. /**
  130453. * The texture used as your environment texture in the scene.
  130454. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  130455. *
  130456. * Remarks: Can be either a texture or a url.
  130457. */
  130458. environmentTexture: string | BaseTexture;
  130459. /**
  130460. * The value of the exposure to apply to the scene.
  130461. * 0.6 by default if setupImageProcessing is true.
  130462. */
  130463. cameraExposure: number;
  130464. /**
  130465. * The value of the contrast to apply to the scene.
  130466. * 1.6 by default if setupImageProcessing is true.
  130467. */
  130468. cameraContrast: number;
  130469. /**
  130470. * Specifies whether or not tonemapping should be enabled in the scene.
  130471. * true by default if setupImageProcessing is true.
  130472. */
  130473. toneMappingEnabled: boolean;
  130474. }
  130475. /**
  130476. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  130477. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  130478. * It also helps with the default setup of your imageProcessing configuration.
  130479. */
  130480. export class EnvironmentHelper {
  130481. /**
  130482. * Default ground texture URL.
  130483. */
  130484. private static _groundTextureCDNUrl;
  130485. /**
  130486. * Default skybox texture URL.
  130487. */
  130488. private static _skyboxTextureCDNUrl;
  130489. /**
  130490. * Default environment texture URL.
  130491. */
  130492. private static _environmentTextureCDNUrl;
  130493. /**
  130494. * Creates the default options for the helper.
  130495. */
  130496. private static _getDefaultOptions;
  130497. private _rootMesh;
  130498. /**
  130499. * Gets the root mesh created by the helper.
  130500. */
  130501. get rootMesh(): Mesh;
  130502. private _skybox;
  130503. /**
  130504. * Gets the skybox created by the helper.
  130505. */
  130506. get skybox(): Nullable<Mesh>;
  130507. private _skyboxTexture;
  130508. /**
  130509. * Gets the skybox texture created by the helper.
  130510. */
  130511. get skyboxTexture(): Nullable<BaseTexture>;
  130512. private _skyboxMaterial;
  130513. /**
  130514. * Gets the skybox material created by the helper.
  130515. */
  130516. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  130517. private _ground;
  130518. /**
  130519. * Gets the ground mesh created by the helper.
  130520. */
  130521. get ground(): Nullable<Mesh>;
  130522. private _groundTexture;
  130523. /**
  130524. * Gets the ground texture created by the helper.
  130525. */
  130526. get groundTexture(): Nullable<BaseTexture>;
  130527. private _groundMirror;
  130528. /**
  130529. * Gets the ground mirror created by the helper.
  130530. */
  130531. get groundMirror(): Nullable<MirrorTexture>;
  130532. /**
  130533. * Gets the ground mirror render list to helps pushing the meshes
  130534. * you wish in the ground reflection.
  130535. */
  130536. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  130537. private _groundMaterial;
  130538. /**
  130539. * Gets the ground material created by the helper.
  130540. */
  130541. get groundMaterial(): Nullable<BackgroundMaterial>;
  130542. /**
  130543. * Stores the creation options.
  130544. */
  130545. private readonly _scene;
  130546. private _options;
  130547. /**
  130548. * This observable will be notified with any error during the creation of the environment,
  130549. * mainly texture creation errors.
  130550. */
  130551. onErrorObservable: Observable<{
  130552. message?: string;
  130553. exception?: any;
  130554. }>;
  130555. /**
  130556. * constructor
  130557. * @param options Defines the options we want to customize the helper
  130558. * @param scene The scene to add the material to
  130559. */
  130560. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  130561. /**
  130562. * Updates the background according to the new options
  130563. * @param options
  130564. */
  130565. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  130566. /**
  130567. * Sets the primary color of all the available elements.
  130568. * @param color the main color to affect to the ground and the background
  130569. */
  130570. setMainColor(color: Color3): void;
  130571. /**
  130572. * Setup the image processing according to the specified options.
  130573. */
  130574. private _setupImageProcessing;
  130575. /**
  130576. * Setup the environment texture according to the specified options.
  130577. */
  130578. private _setupEnvironmentTexture;
  130579. /**
  130580. * Setup the background according to the specified options.
  130581. */
  130582. private _setupBackground;
  130583. /**
  130584. * Get the scene sizes according to the setup.
  130585. */
  130586. private _getSceneSize;
  130587. /**
  130588. * Setup the ground according to the specified options.
  130589. */
  130590. private _setupGround;
  130591. /**
  130592. * Setup the ground material according to the specified options.
  130593. */
  130594. private _setupGroundMaterial;
  130595. /**
  130596. * Setup the ground diffuse texture according to the specified options.
  130597. */
  130598. private _setupGroundDiffuseTexture;
  130599. /**
  130600. * Setup the ground mirror texture according to the specified options.
  130601. */
  130602. private _setupGroundMirrorTexture;
  130603. /**
  130604. * Setup the ground to receive the mirror texture.
  130605. */
  130606. private _setupMirrorInGroundMaterial;
  130607. /**
  130608. * Setup the skybox according to the specified options.
  130609. */
  130610. private _setupSkybox;
  130611. /**
  130612. * Setup the skybox material according to the specified options.
  130613. */
  130614. private _setupSkyboxMaterial;
  130615. /**
  130616. * Setup the skybox reflection texture according to the specified options.
  130617. */
  130618. private _setupSkyboxReflectionTexture;
  130619. private _errorHandler;
  130620. /**
  130621. * Dispose all the elements created by the Helper.
  130622. */
  130623. dispose(): void;
  130624. }
  130625. }
  130626. declare module BABYLON {
  130627. /**
  130628. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  130629. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  130630. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  130631. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  130632. */
  130633. export class PhotoDome extends TransformNode {
  130634. /**
  130635. * Define the image as a Monoscopic panoramic 360 image.
  130636. */
  130637. static readonly MODE_MONOSCOPIC: number;
  130638. /**
  130639. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  130640. */
  130641. static readonly MODE_TOPBOTTOM: number;
  130642. /**
  130643. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  130644. */
  130645. static readonly MODE_SIDEBYSIDE: number;
  130646. private _useDirectMapping;
  130647. /**
  130648. * The texture being displayed on the sphere
  130649. */
  130650. protected _photoTexture: Texture;
  130651. /**
  130652. * Gets or sets the texture being displayed on the sphere
  130653. */
  130654. get photoTexture(): Texture;
  130655. set photoTexture(value: Texture);
  130656. /**
  130657. * Observable raised when an error occured while loading the 360 image
  130658. */
  130659. onLoadErrorObservable: Observable<string>;
  130660. /**
  130661. * The skybox material
  130662. */
  130663. protected _material: BackgroundMaterial;
  130664. /**
  130665. * The surface used for the skybox
  130666. */
  130667. protected _mesh: Mesh;
  130668. /**
  130669. * Gets the mesh used for the skybox.
  130670. */
  130671. get mesh(): Mesh;
  130672. /**
  130673. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  130674. * Also see the options.resolution property.
  130675. */
  130676. get fovMultiplier(): number;
  130677. set fovMultiplier(value: number);
  130678. private _imageMode;
  130679. /**
  130680. * Gets or set the current video mode for the video. It can be:
  130681. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  130682. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  130683. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  130684. */
  130685. get imageMode(): number;
  130686. set imageMode(value: number);
  130687. /**
  130688. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  130689. * @param name Element's name, child elements will append suffixes for their own names.
  130690. * @param urlsOfPhoto defines the url of the photo to display
  130691. * @param options defines an object containing optional or exposed sub element properties
  130692. * @param onError defines a callback called when an error occured while loading the texture
  130693. */
  130694. constructor(name: string, urlOfPhoto: string, options: {
  130695. resolution?: number;
  130696. size?: number;
  130697. useDirectMapping?: boolean;
  130698. faceForward?: boolean;
  130699. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  130700. private _onBeforeCameraRenderObserver;
  130701. private _changeImageMode;
  130702. /**
  130703. * Releases resources associated with this node.
  130704. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  130705. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  130706. */
  130707. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  130708. }
  130709. }
  130710. declare module BABYLON {
  130711. /**
  130712. * Class used to host RGBD texture specific utilities
  130713. */
  130714. export class RGBDTextureTools {
  130715. /**
  130716. * Expand the RGBD Texture from RGBD to Half Float if possible.
  130717. * @param texture the texture to expand.
  130718. */
  130719. static ExpandRGBDTexture(texture: Texture): void;
  130720. }
  130721. }
  130722. declare module BABYLON {
  130723. /**
  130724. * Class used to host texture specific utilities
  130725. */
  130726. export class BRDFTextureTools {
  130727. /**
  130728. * Prevents texture cache collision
  130729. */
  130730. private static _instanceNumber;
  130731. /**
  130732. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  130733. * @param scene defines the hosting scene
  130734. * @returns the environment BRDF texture
  130735. */
  130736. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  130737. private static _environmentBRDFBase64Texture;
  130738. }
  130739. }
  130740. declare module BABYLON {
  130741. /**
  130742. * @hidden
  130743. */
  130744. export interface IMaterialClearCoatDefines {
  130745. CLEARCOAT: boolean;
  130746. CLEARCOAT_DEFAULTIOR: boolean;
  130747. CLEARCOAT_TEXTURE: boolean;
  130748. CLEARCOAT_TEXTUREDIRECTUV: number;
  130749. CLEARCOAT_BUMP: boolean;
  130750. CLEARCOAT_BUMPDIRECTUV: number;
  130751. CLEARCOAT_TINT: boolean;
  130752. CLEARCOAT_TINT_TEXTURE: boolean;
  130753. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  130754. /** @hidden */
  130755. _areTexturesDirty: boolean;
  130756. }
  130757. /**
  130758. * Define the code related to the clear coat parameters of the pbr material.
  130759. */
  130760. export class PBRClearCoatConfiguration {
  130761. /**
  130762. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  130763. * The default fits with a polyurethane material.
  130764. */
  130765. private static readonly _DefaultIndexOfRefraction;
  130766. private _isEnabled;
  130767. /**
  130768. * Defines if the clear coat is enabled in the material.
  130769. */
  130770. isEnabled: boolean;
  130771. /**
  130772. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  130773. */
  130774. intensity: number;
  130775. /**
  130776. * Defines the clear coat layer roughness.
  130777. */
  130778. roughness: number;
  130779. private _indexOfRefraction;
  130780. /**
  130781. * Defines the index of refraction of the clear coat.
  130782. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  130783. * The default fits with a polyurethane material.
  130784. * Changing the default value is more performance intensive.
  130785. */
  130786. indexOfRefraction: number;
  130787. private _texture;
  130788. /**
  130789. * Stores the clear coat values in a texture.
  130790. */
  130791. texture: Nullable<BaseTexture>;
  130792. private _bumpTexture;
  130793. /**
  130794. * Define the clear coat specific bump texture.
  130795. */
  130796. bumpTexture: Nullable<BaseTexture>;
  130797. private _isTintEnabled;
  130798. /**
  130799. * Defines if the clear coat tint is enabled in the material.
  130800. */
  130801. isTintEnabled: boolean;
  130802. /**
  130803. * Defines the clear coat tint of the material.
  130804. * This is only use if tint is enabled
  130805. */
  130806. tintColor: Color3;
  130807. /**
  130808. * Defines the distance at which the tint color should be found in the
  130809. * clear coat media.
  130810. * This is only use if tint is enabled
  130811. */
  130812. tintColorAtDistance: number;
  130813. /**
  130814. * Defines the clear coat layer thickness.
  130815. * This is only use if tint is enabled
  130816. */
  130817. tintThickness: number;
  130818. private _tintTexture;
  130819. /**
  130820. * Stores the clear tint values in a texture.
  130821. * rgb is tint
  130822. * a is a thickness factor
  130823. */
  130824. tintTexture: Nullable<BaseTexture>;
  130825. /** @hidden */
  130826. private _internalMarkAllSubMeshesAsTexturesDirty;
  130827. /** @hidden */
  130828. _markAllSubMeshesAsTexturesDirty(): void;
  130829. /**
  130830. * Instantiate a new istance of clear coat configuration.
  130831. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  130832. */
  130833. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  130834. /**
  130835. * Gets wehter the submesh is ready to be used or not.
  130836. * @param defines the list of "defines" to update.
  130837. * @param scene defines the scene the material belongs to.
  130838. * @param engine defines the engine the material belongs to.
  130839. * @param disableBumpMap defines wether the material disables bump or not.
  130840. * @returns - boolean indicating that the submesh is ready or not.
  130841. */
  130842. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  130843. /**
  130844. * Checks to see if a texture is used in the material.
  130845. * @param defines the list of "defines" to update.
  130846. * @param scene defines the scene to the material belongs to.
  130847. */
  130848. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  130849. /**
  130850. * Binds the material data.
  130851. * @param uniformBuffer defines the Uniform buffer to fill in.
  130852. * @param scene defines the scene the material belongs to.
  130853. * @param engine defines the engine the material belongs to.
  130854. * @param disableBumpMap defines wether the material disables bump or not.
  130855. * @param isFrozen defines wether the material is frozen or not.
  130856. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  130857. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  130858. */
  130859. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  130860. /**
  130861. * Checks to see if a texture is used in the material.
  130862. * @param texture - Base texture to use.
  130863. * @returns - Boolean specifying if a texture is used in the material.
  130864. */
  130865. hasTexture(texture: BaseTexture): boolean;
  130866. /**
  130867. * Returns an array of the actively used textures.
  130868. * @param activeTextures Array of BaseTextures
  130869. */
  130870. getActiveTextures(activeTextures: BaseTexture[]): void;
  130871. /**
  130872. * Returns the animatable textures.
  130873. * @param animatables Array of animatable textures.
  130874. */
  130875. getAnimatables(animatables: IAnimatable[]): void;
  130876. /**
  130877. * Disposes the resources of the material.
  130878. * @param forceDisposeTextures - Forces the disposal of all textures.
  130879. */
  130880. dispose(forceDisposeTextures?: boolean): void;
  130881. /**
  130882. * Get the current class name of the texture useful for serialization or dynamic coding.
  130883. * @returns "PBRClearCoatConfiguration"
  130884. */
  130885. getClassName(): string;
  130886. /**
  130887. * Add fallbacks to the effect fallbacks list.
  130888. * @param defines defines the Base texture to use.
  130889. * @param fallbacks defines the current fallback list.
  130890. * @param currentRank defines the current fallback rank.
  130891. * @returns the new fallback rank.
  130892. */
  130893. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  130894. /**
  130895. * Add the required uniforms to the current list.
  130896. * @param uniforms defines the current uniform list.
  130897. */
  130898. static AddUniforms(uniforms: string[]): void;
  130899. /**
  130900. * Add the required samplers to the current list.
  130901. * @param samplers defines the current sampler list.
  130902. */
  130903. static AddSamplers(samplers: string[]): void;
  130904. /**
  130905. * Add the required uniforms to the current buffer.
  130906. * @param uniformBuffer defines the current uniform buffer.
  130907. */
  130908. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  130909. /**
  130910. * Makes a duplicate of the current configuration into another one.
  130911. * @param clearCoatConfiguration define the config where to copy the info
  130912. */
  130913. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  130914. /**
  130915. * Serializes this clear coat configuration.
  130916. * @returns - An object with the serialized config.
  130917. */
  130918. serialize(): any;
  130919. /**
  130920. * Parses a anisotropy Configuration from a serialized object.
  130921. * @param source - Serialized object.
  130922. * @param scene Defines the scene we are parsing for
  130923. * @param rootUrl Defines the rootUrl to load from
  130924. */
  130925. parse(source: any, scene: Scene, rootUrl: string): void;
  130926. }
  130927. }
  130928. declare module BABYLON {
  130929. /**
  130930. * @hidden
  130931. */
  130932. export interface IMaterialAnisotropicDefines {
  130933. ANISOTROPIC: boolean;
  130934. ANISOTROPIC_TEXTURE: boolean;
  130935. ANISOTROPIC_TEXTUREDIRECTUV: number;
  130936. MAINUV1: boolean;
  130937. _areTexturesDirty: boolean;
  130938. _needUVs: boolean;
  130939. }
  130940. /**
  130941. * Define the code related to the anisotropic parameters of the pbr material.
  130942. */
  130943. export class PBRAnisotropicConfiguration {
  130944. private _isEnabled;
  130945. /**
  130946. * Defines if the anisotropy is enabled in the material.
  130947. */
  130948. isEnabled: boolean;
  130949. /**
  130950. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  130951. */
  130952. intensity: number;
  130953. /**
  130954. * Defines if the effect is along the tangents, bitangents or in between.
  130955. * By default, the effect is "strectching" the highlights along the tangents.
  130956. */
  130957. direction: Vector2;
  130958. private _texture;
  130959. /**
  130960. * Stores the anisotropy values in a texture.
  130961. * rg is direction (like normal from -1 to 1)
  130962. * b is a intensity
  130963. */
  130964. texture: Nullable<BaseTexture>;
  130965. /** @hidden */
  130966. private _internalMarkAllSubMeshesAsTexturesDirty;
  130967. /** @hidden */
  130968. _markAllSubMeshesAsTexturesDirty(): void;
  130969. /**
  130970. * Instantiate a new istance of anisotropy configuration.
  130971. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  130972. */
  130973. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  130974. /**
  130975. * Specifies that the submesh is ready to be used.
  130976. * @param defines the list of "defines" to update.
  130977. * @param scene defines the scene the material belongs to.
  130978. * @returns - boolean indicating that the submesh is ready or not.
  130979. */
  130980. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  130981. /**
  130982. * Checks to see if a texture is used in the material.
  130983. * @param defines the list of "defines" to update.
  130984. * @param mesh the mesh we are preparing the defines for.
  130985. * @param scene defines the scene the material belongs to.
  130986. */
  130987. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  130988. /**
  130989. * Binds the material data.
  130990. * @param uniformBuffer defines the Uniform buffer to fill in.
  130991. * @param scene defines the scene the material belongs to.
  130992. * @param isFrozen defines wether the material is frozen or not.
  130993. */
  130994. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  130995. /**
  130996. * Checks to see if a texture is used in the material.
  130997. * @param texture - Base texture to use.
  130998. * @returns - Boolean specifying if a texture is used in the material.
  130999. */
  131000. hasTexture(texture: BaseTexture): boolean;
  131001. /**
  131002. * Returns an array of the actively used textures.
  131003. * @param activeTextures Array of BaseTextures
  131004. */
  131005. getActiveTextures(activeTextures: BaseTexture[]): void;
  131006. /**
  131007. * Returns the animatable textures.
  131008. * @param animatables Array of animatable textures.
  131009. */
  131010. getAnimatables(animatables: IAnimatable[]): void;
  131011. /**
  131012. * Disposes the resources of the material.
  131013. * @param forceDisposeTextures - Forces the disposal of all textures.
  131014. */
  131015. dispose(forceDisposeTextures?: boolean): void;
  131016. /**
  131017. * Get the current class name of the texture useful for serialization or dynamic coding.
  131018. * @returns "PBRAnisotropicConfiguration"
  131019. */
  131020. getClassName(): string;
  131021. /**
  131022. * Add fallbacks to the effect fallbacks list.
  131023. * @param defines defines the Base texture to use.
  131024. * @param fallbacks defines the current fallback list.
  131025. * @param currentRank defines the current fallback rank.
  131026. * @returns the new fallback rank.
  131027. */
  131028. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  131029. /**
  131030. * Add the required uniforms to the current list.
  131031. * @param uniforms defines the current uniform list.
  131032. */
  131033. static AddUniforms(uniforms: string[]): void;
  131034. /**
  131035. * Add the required uniforms to the current buffer.
  131036. * @param uniformBuffer defines the current uniform buffer.
  131037. */
  131038. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  131039. /**
  131040. * Add the required samplers to the current list.
  131041. * @param samplers defines the current sampler list.
  131042. */
  131043. static AddSamplers(samplers: string[]): void;
  131044. /**
  131045. * Makes a duplicate of the current configuration into another one.
  131046. * @param anisotropicConfiguration define the config where to copy the info
  131047. */
  131048. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  131049. /**
  131050. * Serializes this anisotropy configuration.
  131051. * @returns - An object with the serialized config.
  131052. */
  131053. serialize(): any;
  131054. /**
  131055. * Parses a anisotropy Configuration from a serialized object.
  131056. * @param source - Serialized object.
  131057. * @param scene Defines the scene we are parsing for
  131058. * @param rootUrl Defines the rootUrl to load from
  131059. */
  131060. parse(source: any, scene: Scene, rootUrl: string): void;
  131061. }
  131062. }
  131063. declare module BABYLON {
  131064. /**
  131065. * @hidden
  131066. */
  131067. export interface IMaterialBRDFDefines {
  131068. BRDF_V_HEIGHT_CORRELATED: boolean;
  131069. MS_BRDF_ENERGY_CONSERVATION: boolean;
  131070. SPHERICAL_HARMONICS: boolean;
  131071. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  131072. /** @hidden */
  131073. _areMiscDirty: boolean;
  131074. }
  131075. /**
  131076. * Define the code related to the BRDF parameters of the pbr material.
  131077. */
  131078. export class PBRBRDFConfiguration {
  131079. /**
  131080. * Default value used for the energy conservation.
  131081. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  131082. */
  131083. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  131084. /**
  131085. * Default value used for the Smith Visibility Height Correlated mode.
  131086. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  131087. */
  131088. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  131089. /**
  131090. * Default value used for the IBL diffuse part.
  131091. * This can help switching back to the polynomials mode globally which is a tiny bit
  131092. * less GPU intensive at the drawback of a lower quality.
  131093. */
  131094. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  131095. /**
  131096. * Default value used for activating energy conservation for the specular workflow.
  131097. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  131098. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  131099. */
  131100. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  131101. private _useEnergyConservation;
  131102. /**
  131103. * Defines if the material uses energy conservation.
  131104. */
  131105. useEnergyConservation: boolean;
  131106. private _useSmithVisibilityHeightCorrelated;
  131107. /**
  131108. * LEGACY Mode set to false
  131109. * Defines if the material uses height smith correlated visibility term.
  131110. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  131111. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  131112. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  131113. * Not relying on height correlated will also disable energy conservation.
  131114. */
  131115. useSmithVisibilityHeightCorrelated: boolean;
  131116. private _useSphericalHarmonics;
  131117. /**
  131118. * LEGACY Mode set to false
  131119. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  131120. * diffuse part of the IBL.
  131121. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  131122. * to the ground truth.
  131123. */
  131124. useSphericalHarmonics: boolean;
  131125. private _useSpecularGlossinessInputEnergyConservation;
  131126. /**
  131127. * Defines if the material uses energy conservation, when the specular workflow is active.
  131128. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  131129. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  131130. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  131131. */
  131132. useSpecularGlossinessInputEnergyConservation: boolean;
  131133. /** @hidden */
  131134. private _internalMarkAllSubMeshesAsMiscDirty;
  131135. /** @hidden */
  131136. _markAllSubMeshesAsMiscDirty(): void;
  131137. /**
  131138. * Instantiate a new istance of clear coat configuration.
  131139. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  131140. */
  131141. constructor(markAllSubMeshesAsMiscDirty: () => void);
  131142. /**
  131143. * Checks to see if a texture is used in the material.
  131144. * @param defines the list of "defines" to update.
  131145. */
  131146. prepareDefines(defines: IMaterialBRDFDefines): void;
  131147. /**
  131148. * Get the current class name of the texture useful for serialization or dynamic coding.
  131149. * @returns "PBRClearCoatConfiguration"
  131150. */
  131151. getClassName(): string;
  131152. /**
  131153. * Makes a duplicate of the current configuration into another one.
  131154. * @param brdfConfiguration define the config where to copy the info
  131155. */
  131156. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  131157. /**
  131158. * Serializes this BRDF configuration.
  131159. * @returns - An object with the serialized config.
  131160. */
  131161. serialize(): any;
  131162. /**
  131163. * Parses a anisotropy Configuration from a serialized object.
  131164. * @param source - Serialized object.
  131165. * @param scene Defines the scene we are parsing for
  131166. * @param rootUrl Defines the rootUrl to load from
  131167. */
  131168. parse(source: any, scene: Scene, rootUrl: string): void;
  131169. }
  131170. }
  131171. declare module BABYLON {
  131172. /**
  131173. * @hidden
  131174. */
  131175. export interface IMaterialSheenDefines {
  131176. SHEEN: boolean;
  131177. SHEEN_TEXTURE: boolean;
  131178. SHEEN_TEXTUREDIRECTUV: number;
  131179. SHEEN_LINKWITHALBEDO: boolean;
  131180. SHEEN_ROUGHNESS: boolean;
  131181. SHEEN_ALBEDOSCALING: boolean;
  131182. /** @hidden */
  131183. _areTexturesDirty: boolean;
  131184. }
  131185. /**
  131186. * Define the code related to the Sheen parameters of the pbr material.
  131187. */
  131188. export class PBRSheenConfiguration {
  131189. private _isEnabled;
  131190. /**
  131191. * Defines if the material uses sheen.
  131192. */
  131193. isEnabled: boolean;
  131194. private _linkSheenWithAlbedo;
  131195. /**
  131196. * Defines if the sheen is linked to the sheen color.
  131197. */
  131198. linkSheenWithAlbedo: boolean;
  131199. /**
  131200. * Defines the sheen intensity.
  131201. */
  131202. intensity: number;
  131203. /**
  131204. * Defines the sheen color.
  131205. */
  131206. color: Color3;
  131207. private _texture;
  131208. /**
  131209. * Stores the sheen tint values in a texture.
  131210. * rgb is tint
  131211. * a is a intensity
  131212. */
  131213. texture: Nullable<BaseTexture>;
  131214. private _roughness;
  131215. /**
  131216. * Defines the sheen roughness.
  131217. * It is not taken into account if linkSheenWithAlbedo is true.
  131218. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  131219. */
  131220. roughness: Nullable<number>;
  131221. private _albedoScaling;
  131222. /**
  131223. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  131224. * It allows the strength of the sheen effect to not depend on the base color of the material,
  131225. * making it easier to setup and tweak the effect
  131226. */
  131227. albedoScaling: boolean;
  131228. /** @hidden */
  131229. private _internalMarkAllSubMeshesAsTexturesDirty;
  131230. /** @hidden */
  131231. _markAllSubMeshesAsTexturesDirty(): void;
  131232. /**
  131233. * Instantiate a new istance of clear coat configuration.
  131234. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  131235. */
  131236. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  131237. /**
  131238. * Specifies that the submesh is ready to be used.
  131239. * @param defines the list of "defines" to update.
  131240. * @param scene defines the scene the material belongs to.
  131241. * @returns - boolean indicating that the submesh is ready or not.
  131242. */
  131243. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  131244. /**
  131245. * Checks to see if a texture is used in the material.
  131246. * @param defines the list of "defines" to update.
  131247. * @param scene defines the scene the material belongs to.
  131248. */
  131249. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  131250. /**
  131251. * Binds the material data.
  131252. * @param uniformBuffer defines the Uniform buffer to fill in.
  131253. * @param scene defines the scene the material belongs to.
  131254. * @param isFrozen defines wether the material is frozen or not.
  131255. */
  131256. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  131257. /**
  131258. * Checks to see if a texture is used in the material.
  131259. * @param texture - Base texture to use.
  131260. * @returns - Boolean specifying if a texture is used in the material.
  131261. */
  131262. hasTexture(texture: BaseTexture): boolean;
  131263. /**
  131264. * Returns an array of the actively used textures.
  131265. * @param activeTextures Array of BaseTextures
  131266. */
  131267. getActiveTextures(activeTextures: BaseTexture[]): void;
  131268. /**
  131269. * Returns the animatable textures.
  131270. * @param animatables Array of animatable textures.
  131271. */
  131272. getAnimatables(animatables: IAnimatable[]): void;
  131273. /**
  131274. * Disposes the resources of the material.
  131275. * @param forceDisposeTextures - Forces the disposal of all textures.
  131276. */
  131277. dispose(forceDisposeTextures?: boolean): void;
  131278. /**
  131279. * Get the current class name of the texture useful for serialization or dynamic coding.
  131280. * @returns "PBRSheenConfiguration"
  131281. */
  131282. getClassName(): string;
  131283. /**
  131284. * Add fallbacks to the effect fallbacks list.
  131285. * @param defines defines the Base texture to use.
  131286. * @param fallbacks defines the current fallback list.
  131287. * @param currentRank defines the current fallback rank.
  131288. * @returns the new fallback rank.
  131289. */
  131290. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  131291. /**
  131292. * Add the required uniforms to the current list.
  131293. * @param uniforms defines the current uniform list.
  131294. */
  131295. static AddUniforms(uniforms: string[]): void;
  131296. /**
  131297. * Add the required uniforms to the current buffer.
  131298. * @param uniformBuffer defines the current uniform buffer.
  131299. */
  131300. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  131301. /**
  131302. * Add the required samplers to the current list.
  131303. * @param samplers defines the current sampler list.
  131304. */
  131305. static AddSamplers(samplers: string[]): void;
  131306. /**
  131307. * Makes a duplicate of the current configuration into another one.
  131308. * @param sheenConfiguration define the config where to copy the info
  131309. */
  131310. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  131311. /**
  131312. * Serializes this BRDF configuration.
  131313. * @returns - An object with the serialized config.
  131314. */
  131315. serialize(): any;
  131316. /**
  131317. * Parses a anisotropy Configuration from a serialized object.
  131318. * @param source - Serialized object.
  131319. * @param scene Defines the scene we are parsing for
  131320. * @param rootUrl Defines the rootUrl to load from
  131321. */
  131322. parse(source: any, scene: Scene, rootUrl: string): void;
  131323. }
  131324. }
  131325. declare module BABYLON {
  131326. /**
  131327. * @hidden
  131328. */
  131329. export interface IMaterialSubSurfaceDefines {
  131330. SUBSURFACE: boolean;
  131331. SS_REFRACTION: boolean;
  131332. SS_TRANSLUCENCY: boolean;
  131333. SS_SCATERRING: boolean;
  131334. SS_THICKNESSANDMASK_TEXTURE: boolean;
  131335. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  131336. SS_REFRACTIONMAP_3D: boolean;
  131337. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  131338. SS_LODINREFRACTIONALPHA: boolean;
  131339. SS_GAMMAREFRACTION: boolean;
  131340. SS_RGBDREFRACTION: boolean;
  131341. SS_LINEARSPECULARREFRACTION: boolean;
  131342. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  131343. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  131344. /** @hidden */
  131345. _areTexturesDirty: boolean;
  131346. }
  131347. /**
  131348. * Define the code related to the sub surface parameters of the pbr material.
  131349. */
  131350. export class PBRSubSurfaceConfiguration {
  131351. private _isRefractionEnabled;
  131352. /**
  131353. * Defines if the refraction is enabled in the material.
  131354. */
  131355. isRefractionEnabled: boolean;
  131356. private _isTranslucencyEnabled;
  131357. /**
  131358. * Defines if the translucency is enabled in the material.
  131359. */
  131360. isTranslucencyEnabled: boolean;
  131361. private _isScatteringEnabled;
  131362. /**
  131363. * Defines the refraction intensity of the material.
  131364. * The refraction when enabled replaces the Diffuse part of the material.
  131365. * The intensity helps transitionning between diffuse and refraction.
  131366. */
  131367. refractionIntensity: number;
  131368. /**
  131369. * Defines the translucency intensity of the material.
  131370. * When translucency has been enabled, this defines how much of the "translucency"
  131371. * is addded to the diffuse part of the material.
  131372. */
  131373. translucencyIntensity: number;
  131374. /**
  131375. * Defines the scattering intensity of the material.
  131376. * When scattering has been enabled, this defines how much of the "scattered light"
  131377. * is addded to the diffuse part of the material.
  131378. */
  131379. scatteringIntensity: number;
  131380. private _thicknessTexture;
  131381. /**
  131382. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  131383. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  131384. * 0 would mean minimumThickness
  131385. * 1 would mean maximumThickness
  131386. * The other channels might be use as a mask to vary the different effects intensity.
  131387. */
  131388. thicknessTexture: Nullable<BaseTexture>;
  131389. private _refractionTexture;
  131390. /**
  131391. * Defines the texture to use for refraction.
  131392. */
  131393. refractionTexture: Nullable<BaseTexture>;
  131394. private _indexOfRefraction;
  131395. /**
  131396. * Index of refraction of the material base layer.
  131397. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  131398. *
  131399. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  131400. *
  131401. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  131402. */
  131403. indexOfRefraction: number;
  131404. private _invertRefractionY;
  131405. /**
  131406. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  131407. */
  131408. invertRefractionY: boolean;
  131409. private _linkRefractionWithTransparency;
  131410. /**
  131411. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  131412. * Materials half opaque for instance using refraction could benefit from this control.
  131413. */
  131414. linkRefractionWithTransparency: boolean;
  131415. /**
  131416. * Defines the minimum thickness stored in the thickness map.
  131417. * If no thickness map is defined, this value will be used to simulate thickness.
  131418. */
  131419. minimumThickness: number;
  131420. /**
  131421. * Defines the maximum thickness stored in the thickness map.
  131422. */
  131423. maximumThickness: number;
  131424. /**
  131425. * Defines the volume tint of the material.
  131426. * This is used for both translucency and scattering.
  131427. */
  131428. tintColor: Color3;
  131429. /**
  131430. * Defines the distance at which the tint color should be found in the media.
  131431. * This is used for refraction only.
  131432. */
  131433. tintColorAtDistance: number;
  131434. /**
  131435. * Defines how far each channel transmit through the media.
  131436. * It is defined as a color to simplify it selection.
  131437. */
  131438. diffusionDistance: Color3;
  131439. private _useMaskFromThicknessTexture;
  131440. /**
  131441. * Stores the intensity of the different subsurface effects in the thickness texture.
  131442. * * the green channel is the translucency intensity.
  131443. * * the blue channel is the scattering intensity.
  131444. * * the alpha channel is the refraction intensity.
  131445. */
  131446. useMaskFromThicknessTexture: boolean;
  131447. /** @hidden */
  131448. private _internalMarkAllSubMeshesAsTexturesDirty;
  131449. /** @hidden */
  131450. _markAllSubMeshesAsTexturesDirty(): void;
  131451. /**
  131452. * Instantiate a new istance of sub surface configuration.
  131453. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  131454. */
  131455. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  131456. /**
  131457. * Gets wehter the submesh is ready to be used or not.
  131458. * @param defines the list of "defines" to update.
  131459. * @param scene defines the scene the material belongs to.
  131460. * @returns - boolean indicating that the submesh is ready or not.
  131461. */
  131462. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  131463. /**
  131464. * Checks to see if a texture is used in the material.
  131465. * @param defines the list of "defines" to update.
  131466. * @param scene defines the scene to the material belongs to.
  131467. */
  131468. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  131469. /**
  131470. * Binds the material data.
  131471. * @param uniformBuffer defines the Uniform buffer to fill in.
  131472. * @param scene defines the scene the material belongs to.
  131473. * @param engine defines the engine the material belongs to.
  131474. * @param isFrozen defines whether the material is frozen or not.
  131475. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  131476. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  131477. */
  131478. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  131479. /**
  131480. * Unbinds the material from the mesh.
  131481. * @param activeEffect defines the effect that should be unbound from.
  131482. * @returns true if unbound, otherwise false
  131483. */
  131484. unbind(activeEffect: Effect): boolean;
  131485. /**
  131486. * Returns the texture used for refraction or null if none is used.
  131487. * @param scene defines the scene the material belongs to.
  131488. * @returns - Refraction texture if present. If no refraction texture and refraction
  131489. * is linked with transparency, returns environment texture. Otherwise, returns null.
  131490. */
  131491. private _getRefractionTexture;
  131492. /**
  131493. * Returns true if alpha blending should be disabled.
  131494. */
  131495. get disableAlphaBlending(): boolean;
  131496. /**
  131497. * Fills the list of render target textures.
  131498. * @param renderTargets the list of render targets to update
  131499. */
  131500. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  131501. /**
  131502. * Checks to see if a texture is used in the material.
  131503. * @param texture - Base texture to use.
  131504. * @returns - Boolean specifying if a texture is used in the material.
  131505. */
  131506. hasTexture(texture: BaseTexture): boolean;
  131507. /**
  131508. * Gets a boolean indicating that current material needs to register RTT
  131509. * @returns true if this uses a render target otherwise false.
  131510. */
  131511. hasRenderTargetTextures(): boolean;
  131512. /**
  131513. * Returns an array of the actively used textures.
  131514. * @param activeTextures Array of BaseTextures
  131515. */
  131516. getActiveTextures(activeTextures: BaseTexture[]): void;
  131517. /**
  131518. * Returns the animatable textures.
  131519. * @param animatables Array of animatable textures.
  131520. */
  131521. getAnimatables(animatables: IAnimatable[]): void;
  131522. /**
  131523. * Disposes the resources of the material.
  131524. * @param forceDisposeTextures - Forces the disposal of all textures.
  131525. */
  131526. dispose(forceDisposeTextures?: boolean): void;
  131527. /**
  131528. * Get the current class name of the texture useful for serialization or dynamic coding.
  131529. * @returns "PBRSubSurfaceConfiguration"
  131530. */
  131531. getClassName(): string;
  131532. /**
  131533. * Add fallbacks to the effect fallbacks list.
  131534. * @param defines defines the Base texture to use.
  131535. * @param fallbacks defines the current fallback list.
  131536. * @param currentRank defines the current fallback rank.
  131537. * @returns the new fallback rank.
  131538. */
  131539. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  131540. /**
  131541. * Add the required uniforms to the current list.
  131542. * @param uniforms defines the current uniform list.
  131543. */
  131544. static AddUniforms(uniforms: string[]): void;
  131545. /**
  131546. * Add the required samplers to the current list.
  131547. * @param samplers defines the current sampler list.
  131548. */
  131549. static AddSamplers(samplers: string[]): void;
  131550. /**
  131551. * Add the required uniforms to the current buffer.
  131552. * @param uniformBuffer defines the current uniform buffer.
  131553. */
  131554. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  131555. /**
  131556. * Makes a duplicate of the current configuration into another one.
  131557. * @param configuration define the config where to copy the info
  131558. */
  131559. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  131560. /**
  131561. * Serializes this Sub Surface configuration.
  131562. * @returns - An object with the serialized config.
  131563. */
  131564. serialize(): any;
  131565. /**
  131566. * Parses a anisotropy Configuration from a serialized object.
  131567. * @param source - Serialized object.
  131568. * @param scene Defines the scene we are parsing for
  131569. * @param rootUrl Defines the rootUrl to load from
  131570. */
  131571. parse(source: any, scene: Scene, rootUrl: string): void;
  131572. }
  131573. }
  131574. declare module BABYLON {
  131575. /** @hidden */
  131576. export var pbrFragmentDeclaration: {
  131577. name: string;
  131578. shader: string;
  131579. };
  131580. }
  131581. declare module BABYLON {
  131582. /** @hidden */
  131583. export var pbrUboDeclaration: {
  131584. name: string;
  131585. shader: string;
  131586. };
  131587. }
  131588. declare module BABYLON {
  131589. /** @hidden */
  131590. export var pbrFragmentExtraDeclaration: {
  131591. name: string;
  131592. shader: string;
  131593. };
  131594. }
  131595. declare module BABYLON {
  131596. /** @hidden */
  131597. export var pbrFragmentSamplersDeclaration: {
  131598. name: string;
  131599. shader: string;
  131600. };
  131601. }
  131602. declare module BABYLON {
  131603. /** @hidden */
  131604. export var importanceSampling: {
  131605. name: string;
  131606. shader: string;
  131607. };
  131608. }
  131609. declare module BABYLON {
  131610. /** @hidden */
  131611. export var pbrHelperFunctions: {
  131612. name: string;
  131613. shader: string;
  131614. };
  131615. }
  131616. declare module BABYLON {
  131617. /** @hidden */
  131618. export var harmonicsFunctions: {
  131619. name: string;
  131620. shader: string;
  131621. };
  131622. }
  131623. declare module BABYLON {
  131624. /** @hidden */
  131625. export var pbrDirectLightingSetupFunctions: {
  131626. name: string;
  131627. shader: string;
  131628. };
  131629. }
  131630. declare module BABYLON {
  131631. /** @hidden */
  131632. export var pbrDirectLightingFalloffFunctions: {
  131633. name: string;
  131634. shader: string;
  131635. };
  131636. }
  131637. declare module BABYLON {
  131638. /** @hidden */
  131639. export var pbrBRDFFunctions: {
  131640. name: string;
  131641. shader: string;
  131642. };
  131643. }
  131644. declare module BABYLON {
  131645. /** @hidden */
  131646. export var hdrFilteringFunctions: {
  131647. name: string;
  131648. shader: string;
  131649. };
  131650. }
  131651. declare module BABYLON {
  131652. /** @hidden */
  131653. export var pbrDirectLightingFunctions: {
  131654. name: string;
  131655. shader: string;
  131656. };
  131657. }
  131658. declare module BABYLON {
  131659. /** @hidden */
  131660. export var pbrIBLFunctions: {
  131661. name: string;
  131662. shader: string;
  131663. };
  131664. }
  131665. declare module BABYLON {
  131666. /** @hidden */
  131667. export var pbrBlockAlbedoOpacity: {
  131668. name: string;
  131669. shader: string;
  131670. };
  131671. }
  131672. declare module BABYLON {
  131673. /** @hidden */
  131674. export var pbrBlockReflectivity: {
  131675. name: string;
  131676. shader: string;
  131677. };
  131678. }
  131679. declare module BABYLON {
  131680. /** @hidden */
  131681. export var pbrBlockAmbientOcclusion: {
  131682. name: string;
  131683. shader: string;
  131684. };
  131685. }
  131686. declare module BABYLON {
  131687. /** @hidden */
  131688. export var pbrBlockAlphaFresnel: {
  131689. name: string;
  131690. shader: string;
  131691. };
  131692. }
  131693. declare module BABYLON {
  131694. /** @hidden */
  131695. export var pbrBlockAnisotropic: {
  131696. name: string;
  131697. shader: string;
  131698. };
  131699. }
  131700. declare module BABYLON {
  131701. /** @hidden */
  131702. export var pbrBlockReflection: {
  131703. name: string;
  131704. shader: string;
  131705. };
  131706. }
  131707. declare module BABYLON {
  131708. /** @hidden */
  131709. export var pbrBlockSheen: {
  131710. name: string;
  131711. shader: string;
  131712. };
  131713. }
  131714. declare module BABYLON {
  131715. /** @hidden */
  131716. export var pbrBlockClearcoat: {
  131717. name: string;
  131718. shader: string;
  131719. };
  131720. }
  131721. declare module BABYLON {
  131722. /** @hidden */
  131723. export var pbrBlockSubSurface: {
  131724. name: string;
  131725. shader: string;
  131726. };
  131727. }
  131728. declare module BABYLON {
  131729. /** @hidden */
  131730. export var pbrBlockNormalGeometric: {
  131731. name: string;
  131732. shader: string;
  131733. };
  131734. }
  131735. declare module BABYLON {
  131736. /** @hidden */
  131737. export var pbrBlockNormalFinal: {
  131738. name: string;
  131739. shader: string;
  131740. };
  131741. }
  131742. declare module BABYLON {
  131743. /** @hidden */
  131744. export var pbrBlockGeometryInfo: {
  131745. name: string;
  131746. shader: string;
  131747. };
  131748. }
  131749. declare module BABYLON {
  131750. /** @hidden */
  131751. export var pbrBlockReflectance0: {
  131752. name: string;
  131753. shader: string;
  131754. };
  131755. }
  131756. declare module BABYLON {
  131757. /** @hidden */
  131758. export var pbrBlockReflectance: {
  131759. name: string;
  131760. shader: string;
  131761. };
  131762. }
  131763. declare module BABYLON {
  131764. /** @hidden */
  131765. export var pbrBlockDirectLighting: {
  131766. name: string;
  131767. shader: string;
  131768. };
  131769. }
  131770. declare module BABYLON {
  131771. /** @hidden */
  131772. export var pbrBlockFinalLitComponents: {
  131773. name: string;
  131774. shader: string;
  131775. };
  131776. }
  131777. declare module BABYLON {
  131778. /** @hidden */
  131779. export var pbrBlockFinalUnlitComponents: {
  131780. name: string;
  131781. shader: string;
  131782. };
  131783. }
  131784. declare module BABYLON {
  131785. /** @hidden */
  131786. export var pbrBlockFinalColorComposition: {
  131787. name: string;
  131788. shader: string;
  131789. };
  131790. }
  131791. declare module BABYLON {
  131792. /** @hidden */
  131793. export var pbrBlockImageProcessing: {
  131794. name: string;
  131795. shader: string;
  131796. };
  131797. }
  131798. declare module BABYLON {
  131799. /** @hidden */
  131800. export var pbrDebug: {
  131801. name: string;
  131802. shader: string;
  131803. };
  131804. }
  131805. declare module BABYLON {
  131806. /** @hidden */
  131807. export var pbrPixelShader: {
  131808. name: string;
  131809. shader: string;
  131810. };
  131811. }
  131812. declare module BABYLON {
  131813. /** @hidden */
  131814. export var pbrVertexDeclaration: {
  131815. name: string;
  131816. shader: string;
  131817. };
  131818. }
  131819. declare module BABYLON {
  131820. /** @hidden */
  131821. export var pbrVertexShader: {
  131822. name: string;
  131823. shader: string;
  131824. };
  131825. }
  131826. declare module BABYLON {
  131827. /**
  131828. * Manages the defines for the PBR Material.
  131829. * @hidden
  131830. */
  131831. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  131832. PBR: boolean;
  131833. NUM_SAMPLES: string;
  131834. REALTIME_FILTERING: boolean;
  131835. MAINUV1: boolean;
  131836. MAINUV2: boolean;
  131837. UV1: boolean;
  131838. UV2: boolean;
  131839. ALBEDO: boolean;
  131840. GAMMAALBEDO: boolean;
  131841. ALBEDODIRECTUV: number;
  131842. VERTEXCOLOR: boolean;
  131843. AMBIENT: boolean;
  131844. AMBIENTDIRECTUV: number;
  131845. AMBIENTINGRAYSCALE: boolean;
  131846. OPACITY: boolean;
  131847. VERTEXALPHA: boolean;
  131848. OPACITYDIRECTUV: number;
  131849. OPACITYRGB: boolean;
  131850. ALPHATEST: boolean;
  131851. DEPTHPREPASS: boolean;
  131852. ALPHABLEND: boolean;
  131853. ALPHAFROMALBEDO: boolean;
  131854. ALPHATESTVALUE: string;
  131855. SPECULAROVERALPHA: boolean;
  131856. RADIANCEOVERALPHA: boolean;
  131857. ALPHAFRESNEL: boolean;
  131858. LINEARALPHAFRESNEL: boolean;
  131859. PREMULTIPLYALPHA: boolean;
  131860. EMISSIVE: boolean;
  131861. EMISSIVEDIRECTUV: number;
  131862. REFLECTIVITY: boolean;
  131863. REFLECTIVITYDIRECTUV: number;
  131864. SPECULARTERM: boolean;
  131865. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  131866. MICROSURFACEAUTOMATIC: boolean;
  131867. LODBASEDMICROSFURACE: boolean;
  131868. MICROSURFACEMAP: boolean;
  131869. MICROSURFACEMAPDIRECTUV: number;
  131870. METALLICWORKFLOW: boolean;
  131871. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  131872. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  131873. METALLNESSSTOREINMETALMAPBLUE: boolean;
  131874. AOSTOREINMETALMAPRED: boolean;
  131875. METALLIC_REFLECTANCE: boolean;
  131876. METALLIC_REFLECTANCEDIRECTUV: number;
  131877. ENVIRONMENTBRDF: boolean;
  131878. ENVIRONMENTBRDF_RGBD: boolean;
  131879. NORMAL: boolean;
  131880. TANGENT: boolean;
  131881. BUMP: boolean;
  131882. BUMPDIRECTUV: number;
  131883. OBJECTSPACE_NORMALMAP: boolean;
  131884. PARALLAX: boolean;
  131885. PARALLAXOCCLUSION: boolean;
  131886. NORMALXYSCALE: boolean;
  131887. LIGHTMAP: boolean;
  131888. LIGHTMAPDIRECTUV: number;
  131889. USELIGHTMAPASSHADOWMAP: boolean;
  131890. GAMMALIGHTMAP: boolean;
  131891. RGBDLIGHTMAP: boolean;
  131892. REFLECTION: boolean;
  131893. REFLECTIONMAP_3D: boolean;
  131894. REFLECTIONMAP_SPHERICAL: boolean;
  131895. REFLECTIONMAP_PLANAR: boolean;
  131896. REFLECTIONMAP_CUBIC: boolean;
  131897. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  131898. REFLECTIONMAP_PROJECTION: boolean;
  131899. REFLECTIONMAP_SKYBOX: boolean;
  131900. REFLECTIONMAP_EXPLICIT: boolean;
  131901. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  131902. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  131903. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  131904. INVERTCUBICMAP: boolean;
  131905. USESPHERICALFROMREFLECTIONMAP: boolean;
  131906. USEIRRADIANCEMAP: boolean;
  131907. SPHERICAL_HARMONICS: boolean;
  131908. USESPHERICALINVERTEX: boolean;
  131909. REFLECTIONMAP_OPPOSITEZ: boolean;
  131910. LODINREFLECTIONALPHA: boolean;
  131911. GAMMAREFLECTION: boolean;
  131912. RGBDREFLECTION: boolean;
  131913. LINEARSPECULARREFLECTION: boolean;
  131914. RADIANCEOCCLUSION: boolean;
  131915. HORIZONOCCLUSION: boolean;
  131916. INSTANCES: boolean;
  131917. THIN_INSTANCES: boolean;
  131918. NUM_BONE_INFLUENCERS: number;
  131919. BonesPerMesh: number;
  131920. BONETEXTURE: boolean;
  131921. NONUNIFORMSCALING: boolean;
  131922. MORPHTARGETS: boolean;
  131923. MORPHTARGETS_NORMAL: boolean;
  131924. MORPHTARGETS_TANGENT: boolean;
  131925. MORPHTARGETS_UV: boolean;
  131926. NUM_MORPH_INFLUENCERS: number;
  131927. IMAGEPROCESSING: boolean;
  131928. VIGNETTE: boolean;
  131929. VIGNETTEBLENDMODEMULTIPLY: boolean;
  131930. VIGNETTEBLENDMODEOPAQUE: boolean;
  131931. TONEMAPPING: boolean;
  131932. TONEMAPPING_ACES: boolean;
  131933. CONTRAST: boolean;
  131934. COLORCURVES: boolean;
  131935. COLORGRADING: boolean;
  131936. COLORGRADING3D: boolean;
  131937. SAMPLER3DGREENDEPTH: boolean;
  131938. SAMPLER3DBGRMAP: boolean;
  131939. IMAGEPROCESSINGPOSTPROCESS: boolean;
  131940. EXPOSURE: boolean;
  131941. MULTIVIEW: boolean;
  131942. USEPHYSICALLIGHTFALLOFF: boolean;
  131943. USEGLTFLIGHTFALLOFF: boolean;
  131944. TWOSIDEDLIGHTING: boolean;
  131945. SHADOWFLOAT: boolean;
  131946. CLIPPLANE: boolean;
  131947. CLIPPLANE2: boolean;
  131948. CLIPPLANE3: boolean;
  131949. CLIPPLANE4: boolean;
  131950. CLIPPLANE5: boolean;
  131951. CLIPPLANE6: boolean;
  131952. POINTSIZE: boolean;
  131953. FOG: boolean;
  131954. LOGARITHMICDEPTH: boolean;
  131955. FORCENORMALFORWARD: boolean;
  131956. SPECULARAA: boolean;
  131957. CLEARCOAT: boolean;
  131958. CLEARCOAT_DEFAULTIOR: boolean;
  131959. CLEARCOAT_TEXTURE: boolean;
  131960. CLEARCOAT_TEXTUREDIRECTUV: number;
  131961. CLEARCOAT_BUMP: boolean;
  131962. CLEARCOAT_BUMPDIRECTUV: number;
  131963. CLEARCOAT_TINT: boolean;
  131964. CLEARCOAT_TINT_TEXTURE: boolean;
  131965. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  131966. ANISOTROPIC: boolean;
  131967. ANISOTROPIC_TEXTURE: boolean;
  131968. ANISOTROPIC_TEXTUREDIRECTUV: number;
  131969. BRDF_V_HEIGHT_CORRELATED: boolean;
  131970. MS_BRDF_ENERGY_CONSERVATION: boolean;
  131971. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  131972. SHEEN: boolean;
  131973. SHEEN_TEXTURE: boolean;
  131974. SHEEN_TEXTUREDIRECTUV: number;
  131975. SHEEN_LINKWITHALBEDO: boolean;
  131976. SHEEN_ROUGHNESS: boolean;
  131977. SHEEN_ALBEDOSCALING: boolean;
  131978. SUBSURFACE: boolean;
  131979. SS_REFRACTION: boolean;
  131980. SS_TRANSLUCENCY: boolean;
  131981. SS_SCATERRING: boolean;
  131982. SS_THICKNESSANDMASK_TEXTURE: boolean;
  131983. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  131984. SS_REFRACTIONMAP_3D: boolean;
  131985. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  131986. SS_LODINREFRACTIONALPHA: boolean;
  131987. SS_GAMMAREFRACTION: boolean;
  131988. SS_RGBDREFRACTION: boolean;
  131989. SS_LINEARSPECULARREFRACTION: boolean;
  131990. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  131991. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  131992. UNLIT: boolean;
  131993. DEBUGMODE: number;
  131994. /**
  131995. * Initializes the PBR Material defines.
  131996. */
  131997. constructor();
  131998. /**
  131999. * Resets the PBR Material defines.
  132000. */
  132001. reset(): void;
  132002. }
  132003. /**
  132004. * The Physically based material base class of BJS.
  132005. *
  132006. * This offers the main features of a standard PBR material.
  132007. * For more information, please refer to the documentation :
  132008. * https://doc.babylonjs.com/how_to/physically_based_rendering
  132009. */
  132010. export abstract class PBRBaseMaterial extends PushMaterial {
  132011. /**
  132012. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  132013. */
  132014. static readonly PBRMATERIAL_OPAQUE: number;
  132015. /**
  132016. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  132017. */
  132018. static readonly PBRMATERIAL_ALPHATEST: number;
  132019. /**
  132020. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  132021. */
  132022. static readonly PBRMATERIAL_ALPHABLEND: number;
  132023. /**
  132024. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  132025. * They are also discarded below the alpha cutoff threshold to improve performances.
  132026. */
  132027. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  132028. /**
  132029. * Defines the default value of how much AO map is occluding the analytical lights
  132030. * (point spot...).
  132031. */
  132032. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  132033. /**
  132034. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  132035. */
  132036. static readonly LIGHTFALLOFF_PHYSICAL: number;
  132037. /**
  132038. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  132039. * to enhance interoperability with other engines.
  132040. */
  132041. static readonly LIGHTFALLOFF_GLTF: number;
  132042. /**
  132043. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  132044. * to enhance interoperability with other materials.
  132045. */
  132046. static readonly LIGHTFALLOFF_STANDARD: number;
  132047. /**
  132048. * Intensity of the direct lights e.g. the four lights available in your scene.
  132049. * This impacts both the direct diffuse and specular highlights.
  132050. */
  132051. protected _directIntensity: number;
  132052. /**
  132053. * Intensity of the emissive part of the material.
  132054. * This helps controlling the emissive effect without modifying the emissive color.
  132055. */
  132056. protected _emissiveIntensity: number;
  132057. /**
  132058. * Intensity of the environment e.g. how much the environment will light the object
  132059. * either through harmonics for rough material or through the refelction for shiny ones.
  132060. */
  132061. protected _environmentIntensity: number;
  132062. /**
  132063. * This is a special control allowing the reduction of the specular highlights coming from the
  132064. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  132065. */
  132066. protected _specularIntensity: number;
  132067. /**
  132068. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  132069. */
  132070. private _lightingInfos;
  132071. /**
  132072. * Debug Control allowing disabling the bump map on this material.
  132073. */
  132074. protected _disableBumpMap: boolean;
  132075. /**
  132076. * AKA Diffuse Texture in standard nomenclature.
  132077. */
  132078. protected _albedoTexture: Nullable<BaseTexture>;
  132079. /**
  132080. * AKA Occlusion Texture in other nomenclature.
  132081. */
  132082. protected _ambientTexture: Nullable<BaseTexture>;
  132083. /**
  132084. * AKA Occlusion Texture Intensity in other nomenclature.
  132085. */
  132086. protected _ambientTextureStrength: number;
  132087. /**
  132088. * Defines how much the AO map is occluding the analytical lights (point spot...).
  132089. * 1 means it completely occludes it
  132090. * 0 mean it has no impact
  132091. */
  132092. protected _ambientTextureImpactOnAnalyticalLights: number;
  132093. /**
  132094. * Stores the alpha values in a texture.
  132095. */
  132096. protected _opacityTexture: Nullable<BaseTexture>;
  132097. /**
  132098. * Stores the reflection values in a texture.
  132099. */
  132100. protected _reflectionTexture: Nullable<BaseTexture>;
  132101. /**
  132102. * Stores the emissive values in a texture.
  132103. */
  132104. protected _emissiveTexture: Nullable<BaseTexture>;
  132105. /**
  132106. * AKA Specular texture in other nomenclature.
  132107. */
  132108. protected _reflectivityTexture: Nullable<BaseTexture>;
  132109. /**
  132110. * Used to switch from specular/glossiness to metallic/roughness workflow.
  132111. */
  132112. protected _metallicTexture: Nullable<BaseTexture>;
  132113. /**
  132114. * Specifies the metallic scalar of the metallic/roughness workflow.
  132115. * Can also be used to scale the metalness values of the metallic texture.
  132116. */
  132117. protected _metallic: Nullable<number>;
  132118. /**
  132119. * Specifies the roughness scalar of the metallic/roughness workflow.
  132120. * Can also be used to scale the roughness values of the metallic texture.
  132121. */
  132122. protected _roughness: Nullable<number>;
  132123. /**
  132124. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  132125. * By default the indexOfrefraction is used to compute F0;
  132126. *
  132127. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  132128. *
  132129. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  132130. * F90 = metallicReflectanceColor;
  132131. */
  132132. protected _metallicF0Factor: number;
  132133. /**
  132134. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  132135. * By default the F90 is always 1;
  132136. *
  132137. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  132138. *
  132139. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  132140. * F90 = metallicReflectanceColor;
  132141. */
  132142. protected _metallicReflectanceColor: Color3;
  132143. /**
  132144. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  132145. * This is multiply against the scalar values defined in the material.
  132146. */
  132147. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  132148. /**
  132149. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  132150. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  132151. */
  132152. protected _microSurfaceTexture: Nullable<BaseTexture>;
  132153. /**
  132154. * Stores surface normal data used to displace a mesh in a texture.
  132155. */
  132156. protected _bumpTexture: Nullable<BaseTexture>;
  132157. /**
  132158. * Stores the pre-calculated light information of a mesh in a texture.
  132159. */
  132160. protected _lightmapTexture: Nullable<BaseTexture>;
  132161. /**
  132162. * The color of a material in ambient lighting.
  132163. */
  132164. protected _ambientColor: Color3;
  132165. /**
  132166. * AKA Diffuse Color in other nomenclature.
  132167. */
  132168. protected _albedoColor: Color3;
  132169. /**
  132170. * AKA Specular Color in other nomenclature.
  132171. */
  132172. protected _reflectivityColor: Color3;
  132173. /**
  132174. * The color applied when light is reflected from a material.
  132175. */
  132176. protected _reflectionColor: Color3;
  132177. /**
  132178. * The color applied when light is emitted from a material.
  132179. */
  132180. protected _emissiveColor: Color3;
  132181. /**
  132182. * AKA Glossiness in other nomenclature.
  132183. */
  132184. protected _microSurface: number;
  132185. /**
  132186. * Specifies that the material will use the light map as a show map.
  132187. */
  132188. protected _useLightmapAsShadowmap: boolean;
  132189. /**
  132190. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  132191. * makes the reflect vector face the model (under horizon).
  132192. */
  132193. protected _useHorizonOcclusion: boolean;
  132194. /**
  132195. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  132196. * too much the area relying on ambient texture to define their ambient occlusion.
  132197. */
  132198. protected _useRadianceOcclusion: boolean;
  132199. /**
  132200. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  132201. */
  132202. protected _useAlphaFromAlbedoTexture: boolean;
  132203. /**
  132204. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  132205. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  132206. */
  132207. protected _useSpecularOverAlpha: boolean;
  132208. /**
  132209. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  132210. */
  132211. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  132212. /**
  132213. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  132214. */
  132215. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  132216. /**
  132217. * Specifies if the metallic texture contains the roughness information in its green channel.
  132218. */
  132219. protected _useRoughnessFromMetallicTextureGreen: boolean;
  132220. /**
  132221. * Specifies if the metallic texture contains the metallness information in its blue channel.
  132222. */
  132223. protected _useMetallnessFromMetallicTextureBlue: boolean;
  132224. /**
  132225. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  132226. */
  132227. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  132228. /**
  132229. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  132230. */
  132231. protected _useAmbientInGrayScale: boolean;
  132232. /**
  132233. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  132234. * The material will try to infer what glossiness each pixel should be.
  132235. */
  132236. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  132237. /**
  132238. * Defines the falloff type used in this material.
  132239. * It by default is Physical.
  132240. */
  132241. protected _lightFalloff: number;
  132242. /**
  132243. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  132244. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  132245. */
  132246. protected _useRadianceOverAlpha: boolean;
  132247. /**
  132248. * Allows using an object space normal map (instead of tangent space).
  132249. */
  132250. protected _useObjectSpaceNormalMap: boolean;
  132251. /**
  132252. * Allows using the bump map in parallax mode.
  132253. */
  132254. protected _useParallax: boolean;
  132255. /**
  132256. * Allows using the bump map in parallax occlusion mode.
  132257. */
  132258. protected _useParallaxOcclusion: boolean;
  132259. /**
  132260. * Controls the scale bias of the parallax mode.
  132261. */
  132262. protected _parallaxScaleBias: number;
  132263. /**
  132264. * If sets to true, disables all the lights affecting the material.
  132265. */
  132266. protected _disableLighting: boolean;
  132267. /**
  132268. * Number of Simultaneous lights allowed on the material.
  132269. */
  132270. protected _maxSimultaneousLights: number;
  132271. /**
  132272. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  132273. */
  132274. protected _invertNormalMapX: boolean;
  132275. /**
  132276. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  132277. */
  132278. protected _invertNormalMapY: boolean;
  132279. /**
  132280. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  132281. */
  132282. protected _twoSidedLighting: boolean;
  132283. /**
  132284. * Defines the alpha limits in alpha test mode.
  132285. */
  132286. protected _alphaCutOff: number;
  132287. /**
  132288. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  132289. */
  132290. protected _forceAlphaTest: boolean;
  132291. /**
  132292. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  132293. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  132294. */
  132295. protected _useAlphaFresnel: boolean;
  132296. /**
  132297. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  132298. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  132299. */
  132300. protected _useLinearAlphaFresnel: boolean;
  132301. /**
  132302. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  132303. * from cos thetav and roughness:
  132304. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  132305. */
  132306. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  132307. /**
  132308. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  132309. */
  132310. protected _forceIrradianceInFragment: boolean;
  132311. private _realTimeFiltering;
  132312. /**
  132313. * Enables realtime filtering on the texture.
  132314. */
  132315. get realTimeFiltering(): boolean;
  132316. set realTimeFiltering(b: boolean);
  132317. private _realTimeFilteringQuality;
  132318. /**
  132319. * Quality switch for realtime filtering
  132320. */
  132321. get realTimeFilteringQuality(): number;
  132322. set realTimeFilteringQuality(n: number);
  132323. /**
  132324. * Force normal to face away from face.
  132325. */
  132326. protected _forceNormalForward: boolean;
  132327. /**
  132328. * Enables specular anti aliasing in the PBR shader.
  132329. * It will both interacts on the Geometry for analytical and IBL lighting.
  132330. * It also prefilter the roughness map based on the bump values.
  132331. */
  132332. protected _enableSpecularAntiAliasing: boolean;
  132333. /**
  132334. * Default configuration related to image processing available in the PBR Material.
  132335. */
  132336. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  132337. /**
  132338. * Keep track of the image processing observer to allow dispose and replace.
  132339. */
  132340. private _imageProcessingObserver;
  132341. /**
  132342. * Attaches a new image processing configuration to the PBR Material.
  132343. * @param configuration
  132344. */
  132345. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  132346. /**
  132347. * Stores the available render targets.
  132348. */
  132349. private _renderTargets;
  132350. /**
  132351. * Sets the global ambient color for the material used in lighting calculations.
  132352. */
  132353. private _globalAmbientColor;
  132354. /**
  132355. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  132356. */
  132357. private _useLogarithmicDepth;
  132358. /**
  132359. * If set to true, no lighting calculations will be applied.
  132360. */
  132361. private _unlit;
  132362. private _debugMode;
  132363. /**
  132364. * @hidden
  132365. * This is reserved for the inspector.
  132366. * Defines the material debug mode.
  132367. * It helps seeing only some components of the material while troubleshooting.
  132368. */
  132369. debugMode: number;
  132370. /**
  132371. * @hidden
  132372. * This is reserved for the inspector.
  132373. * Specify from where on screen the debug mode should start.
  132374. * The value goes from -1 (full screen) to 1 (not visible)
  132375. * It helps with side by side comparison against the final render
  132376. * This defaults to -1
  132377. */
  132378. private debugLimit;
  132379. /**
  132380. * @hidden
  132381. * This is reserved for the inspector.
  132382. * As the default viewing range might not be enough (if the ambient is really small for instance)
  132383. * You can use the factor to better multiply the final value.
  132384. */
  132385. private debugFactor;
  132386. /**
  132387. * Defines the clear coat layer parameters for the material.
  132388. */
  132389. readonly clearCoat: PBRClearCoatConfiguration;
  132390. /**
  132391. * Defines the anisotropic parameters for the material.
  132392. */
  132393. readonly anisotropy: PBRAnisotropicConfiguration;
  132394. /**
  132395. * Defines the BRDF parameters for the material.
  132396. */
  132397. readonly brdf: PBRBRDFConfiguration;
  132398. /**
  132399. * Defines the Sheen parameters for the material.
  132400. */
  132401. readonly sheen: PBRSheenConfiguration;
  132402. /**
  132403. * Defines the SubSurface parameters for the material.
  132404. */
  132405. readonly subSurface: PBRSubSurfaceConfiguration;
  132406. protected _rebuildInParallel: boolean;
  132407. /**
  132408. * Instantiates a new PBRMaterial instance.
  132409. *
  132410. * @param name The material name
  132411. * @param scene The scene the material will be use in.
  132412. */
  132413. constructor(name: string, scene: Scene);
  132414. /**
  132415. * Gets a boolean indicating that current material needs to register RTT
  132416. */
  132417. get hasRenderTargetTextures(): boolean;
  132418. /**
  132419. * Gets the name of the material class.
  132420. */
  132421. getClassName(): string;
  132422. /**
  132423. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  132424. */
  132425. get useLogarithmicDepth(): boolean;
  132426. /**
  132427. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  132428. */
  132429. set useLogarithmicDepth(value: boolean);
  132430. /**
  132431. * Returns true if alpha blending should be disabled.
  132432. */
  132433. protected get _disableAlphaBlending(): boolean;
  132434. /**
  132435. * Specifies whether or not this material should be rendered in alpha blend mode.
  132436. */
  132437. needAlphaBlending(): boolean;
  132438. /**
  132439. * Specifies whether or not this material should be rendered in alpha test mode.
  132440. */
  132441. needAlphaTesting(): boolean;
  132442. /**
  132443. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  132444. */
  132445. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  132446. /**
  132447. * Gets the texture used for the alpha test.
  132448. */
  132449. getAlphaTestTexture(): Nullable<BaseTexture>;
  132450. /**
  132451. * Specifies that the submesh is ready to be used.
  132452. * @param mesh - BJS mesh.
  132453. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  132454. * @param useInstances - Specifies that instances should be used.
  132455. * @returns - boolean indicating that the submesh is ready or not.
  132456. */
  132457. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  132458. /**
  132459. * Specifies if the material uses metallic roughness workflow.
  132460. * @returns boolean specifiying if the material uses metallic roughness workflow.
  132461. */
  132462. isMetallicWorkflow(): boolean;
  132463. private _prepareEffect;
  132464. private _prepareDefines;
  132465. /**
  132466. * Force shader compilation
  132467. */
  132468. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  132469. /**
  132470. * Initializes the uniform buffer layout for the shader.
  132471. */
  132472. buildUniformLayout(): void;
  132473. /**
  132474. * Unbinds the material from the mesh
  132475. */
  132476. unbind(): void;
  132477. /**
  132478. * Binds the submesh data.
  132479. * @param world - The world matrix.
  132480. * @param mesh - The BJS mesh.
  132481. * @param subMesh - A submesh of the BJS mesh.
  132482. */
  132483. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  132484. /**
  132485. * Returns the animatable textures.
  132486. * @returns - Array of animatable textures.
  132487. */
  132488. getAnimatables(): IAnimatable[];
  132489. /**
  132490. * Returns the texture used for reflections.
  132491. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  132492. */
  132493. private _getReflectionTexture;
  132494. /**
  132495. * Returns an array of the actively used textures.
  132496. * @returns - Array of BaseTextures
  132497. */
  132498. getActiveTextures(): BaseTexture[];
  132499. /**
  132500. * Checks to see if a texture is used in the material.
  132501. * @param texture - Base texture to use.
  132502. * @returns - Boolean specifying if a texture is used in the material.
  132503. */
  132504. hasTexture(texture: BaseTexture): boolean;
  132505. /**
  132506. * Disposes the resources of the material.
  132507. * @param forceDisposeEffect - Forces the disposal of effects.
  132508. * @param forceDisposeTextures - Forces the disposal of all textures.
  132509. */
  132510. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  132511. }
  132512. }
  132513. declare module BABYLON {
  132514. /**
  132515. * The Physically based material of BJS.
  132516. *
  132517. * This offers the main features of a standard PBR material.
  132518. * For more information, please refer to the documentation :
  132519. * https://doc.babylonjs.com/how_to/physically_based_rendering
  132520. */
  132521. export class PBRMaterial extends PBRBaseMaterial {
  132522. /**
  132523. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  132524. */
  132525. static readonly PBRMATERIAL_OPAQUE: number;
  132526. /**
  132527. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  132528. */
  132529. static readonly PBRMATERIAL_ALPHATEST: number;
  132530. /**
  132531. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  132532. */
  132533. static readonly PBRMATERIAL_ALPHABLEND: number;
  132534. /**
  132535. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  132536. * They are also discarded below the alpha cutoff threshold to improve performances.
  132537. */
  132538. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  132539. /**
  132540. * Defines the default value of how much AO map is occluding the analytical lights
  132541. * (point spot...).
  132542. */
  132543. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  132544. /**
  132545. * Intensity of the direct lights e.g. the four lights available in your scene.
  132546. * This impacts both the direct diffuse and specular highlights.
  132547. */
  132548. directIntensity: number;
  132549. /**
  132550. * Intensity of the emissive part of the material.
  132551. * This helps controlling the emissive effect without modifying the emissive color.
  132552. */
  132553. emissiveIntensity: number;
  132554. /**
  132555. * Intensity of the environment e.g. how much the environment will light the object
  132556. * either through harmonics for rough material or through the refelction for shiny ones.
  132557. */
  132558. environmentIntensity: number;
  132559. /**
  132560. * This is a special control allowing the reduction of the specular highlights coming from the
  132561. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  132562. */
  132563. specularIntensity: number;
  132564. /**
  132565. * Debug Control allowing disabling the bump map on this material.
  132566. */
  132567. disableBumpMap: boolean;
  132568. /**
  132569. * AKA Diffuse Texture in standard nomenclature.
  132570. */
  132571. albedoTexture: BaseTexture;
  132572. /**
  132573. * AKA Occlusion Texture in other nomenclature.
  132574. */
  132575. ambientTexture: BaseTexture;
  132576. /**
  132577. * AKA Occlusion Texture Intensity in other nomenclature.
  132578. */
  132579. ambientTextureStrength: number;
  132580. /**
  132581. * Defines how much the AO map is occluding the analytical lights (point spot...).
  132582. * 1 means it completely occludes it
  132583. * 0 mean it has no impact
  132584. */
  132585. ambientTextureImpactOnAnalyticalLights: number;
  132586. /**
  132587. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  132588. */
  132589. opacityTexture: BaseTexture;
  132590. /**
  132591. * Stores the reflection values in a texture.
  132592. */
  132593. reflectionTexture: Nullable<BaseTexture>;
  132594. /**
  132595. * Stores the emissive values in a texture.
  132596. */
  132597. emissiveTexture: BaseTexture;
  132598. /**
  132599. * AKA Specular texture in other nomenclature.
  132600. */
  132601. reflectivityTexture: BaseTexture;
  132602. /**
  132603. * Used to switch from specular/glossiness to metallic/roughness workflow.
  132604. */
  132605. metallicTexture: BaseTexture;
  132606. /**
  132607. * Specifies the metallic scalar of the metallic/roughness workflow.
  132608. * Can also be used to scale the metalness values of the metallic texture.
  132609. */
  132610. metallic: Nullable<number>;
  132611. /**
  132612. * Specifies the roughness scalar of the metallic/roughness workflow.
  132613. * Can also be used to scale the roughness values of the metallic texture.
  132614. */
  132615. roughness: Nullable<number>;
  132616. /**
  132617. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  132618. * By default the indexOfrefraction is used to compute F0;
  132619. *
  132620. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  132621. *
  132622. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  132623. * F90 = metallicReflectanceColor;
  132624. */
  132625. metallicF0Factor: number;
  132626. /**
  132627. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  132628. * By default the F90 is always 1;
  132629. *
  132630. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  132631. *
  132632. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  132633. * F90 = metallicReflectanceColor;
  132634. */
  132635. metallicReflectanceColor: Color3;
  132636. /**
  132637. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  132638. * This is multiply against the scalar values defined in the material.
  132639. */
  132640. metallicReflectanceTexture: Nullable<BaseTexture>;
  132641. /**
  132642. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  132643. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  132644. */
  132645. microSurfaceTexture: BaseTexture;
  132646. /**
  132647. * Stores surface normal data used to displace a mesh in a texture.
  132648. */
  132649. bumpTexture: BaseTexture;
  132650. /**
  132651. * Stores the pre-calculated light information of a mesh in a texture.
  132652. */
  132653. lightmapTexture: BaseTexture;
  132654. /**
  132655. * Stores the refracted light information in a texture.
  132656. */
  132657. get refractionTexture(): Nullable<BaseTexture>;
  132658. set refractionTexture(value: Nullable<BaseTexture>);
  132659. /**
  132660. * The color of a material in ambient lighting.
  132661. */
  132662. ambientColor: Color3;
  132663. /**
  132664. * AKA Diffuse Color in other nomenclature.
  132665. */
  132666. albedoColor: Color3;
  132667. /**
  132668. * AKA Specular Color in other nomenclature.
  132669. */
  132670. reflectivityColor: Color3;
  132671. /**
  132672. * The color reflected from the material.
  132673. */
  132674. reflectionColor: Color3;
  132675. /**
  132676. * The color emitted from the material.
  132677. */
  132678. emissiveColor: Color3;
  132679. /**
  132680. * AKA Glossiness in other nomenclature.
  132681. */
  132682. microSurface: number;
  132683. /**
  132684. * Index of refraction of the material base layer.
  132685. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132686. *
  132687. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  132688. *
  132689. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  132690. */
  132691. get indexOfRefraction(): number;
  132692. set indexOfRefraction(value: number);
  132693. /**
  132694. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  132695. */
  132696. get invertRefractionY(): boolean;
  132697. set invertRefractionY(value: boolean);
  132698. /**
  132699. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  132700. * Materials half opaque for instance using refraction could benefit from this control.
  132701. */
  132702. get linkRefractionWithTransparency(): boolean;
  132703. set linkRefractionWithTransparency(value: boolean);
  132704. /**
  132705. * If true, the light map contains occlusion information instead of lighting info.
  132706. */
  132707. useLightmapAsShadowmap: boolean;
  132708. /**
  132709. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  132710. */
  132711. useAlphaFromAlbedoTexture: boolean;
  132712. /**
  132713. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  132714. */
  132715. forceAlphaTest: boolean;
  132716. /**
  132717. * Defines the alpha limits in alpha test mode.
  132718. */
  132719. alphaCutOff: number;
  132720. /**
  132721. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  132722. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  132723. */
  132724. useSpecularOverAlpha: boolean;
  132725. /**
  132726. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  132727. */
  132728. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  132729. /**
  132730. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  132731. */
  132732. useRoughnessFromMetallicTextureAlpha: boolean;
  132733. /**
  132734. * Specifies if the metallic texture contains the roughness information in its green channel.
  132735. */
  132736. useRoughnessFromMetallicTextureGreen: boolean;
  132737. /**
  132738. * Specifies if the metallic texture contains the metallness information in its blue channel.
  132739. */
  132740. useMetallnessFromMetallicTextureBlue: boolean;
  132741. /**
  132742. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  132743. */
  132744. useAmbientOcclusionFromMetallicTextureRed: boolean;
  132745. /**
  132746. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  132747. */
  132748. useAmbientInGrayScale: boolean;
  132749. /**
  132750. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  132751. * The material will try to infer what glossiness each pixel should be.
  132752. */
  132753. useAutoMicroSurfaceFromReflectivityMap: boolean;
  132754. /**
  132755. * BJS is using an harcoded light falloff based on a manually sets up range.
  132756. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  132757. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  132758. */
  132759. get usePhysicalLightFalloff(): boolean;
  132760. /**
  132761. * BJS is using an harcoded light falloff based on a manually sets up range.
  132762. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  132763. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  132764. */
  132765. set usePhysicalLightFalloff(value: boolean);
  132766. /**
  132767. * In order to support the falloff compatibility with gltf, a special mode has been added
  132768. * to reproduce the gltf light falloff.
  132769. */
  132770. get useGLTFLightFalloff(): boolean;
  132771. /**
  132772. * In order to support the falloff compatibility with gltf, a special mode has been added
  132773. * to reproduce the gltf light falloff.
  132774. */
  132775. set useGLTFLightFalloff(value: boolean);
  132776. /**
  132777. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  132778. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  132779. */
  132780. useRadianceOverAlpha: boolean;
  132781. /**
  132782. * Allows using an object space normal map (instead of tangent space).
  132783. */
  132784. useObjectSpaceNormalMap: boolean;
  132785. /**
  132786. * Allows using the bump map in parallax mode.
  132787. */
  132788. useParallax: boolean;
  132789. /**
  132790. * Allows using the bump map in parallax occlusion mode.
  132791. */
  132792. useParallaxOcclusion: boolean;
  132793. /**
  132794. * Controls the scale bias of the parallax mode.
  132795. */
  132796. parallaxScaleBias: number;
  132797. /**
  132798. * If sets to true, disables all the lights affecting the material.
  132799. */
  132800. disableLighting: boolean;
  132801. /**
  132802. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  132803. */
  132804. forceIrradianceInFragment: boolean;
  132805. /**
  132806. * Number of Simultaneous lights allowed on the material.
  132807. */
  132808. maxSimultaneousLights: number;
  132809. /**
  132810. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  132811. */
  132812. invertNormalMapX: boolean;
  132813. /**
  132814. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  132815. */
  132816. invertNormalMapY: boolean;
  132817. /**
  132818. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  132819. */
  132820. twoSidedLighting: boolean;
  132821. /**
  132822. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  132823. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  132824. */
  132825. useAlphaFresnel: boolean;
  132826. /**
  132827. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  132828. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  132829. */
  132830. useLinearAlphaFresnel: boolean;
  132831. /**
  132832. * Let user defines the brdf lookup texture used for IBL.
  132833. * A default 8bit version is embedded but you could point at :
  132834. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  132835. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  132836. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  132837. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  132838. */
  132839. environmentBRDFTexture: Nullable<BaseTexture>;
  132840. /**
  132841. * Force normal to face away from face.
  132842. */
  132843. forceNormalForward: boolean;
  132844. /**
  132845. * Enables specular anti aliasing in the PBR shader.
  132846. * It will both interacts on the Geometry for analytical and IBL lighting.
  132847. * It also prefilter the roughness map based on the bump values.
  132848. */
  132849. enableSpecularAntiAliasing: boolean;
  132850. /**
  132851. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  132852. * makes the reflect vector face the model (under horizon).
  132853. */
  132854. useHorizonOcclusion: boolean;
  132855. /**
  132856. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  132857. * too much the area relying on ambient texture to define their ambient occlusion.
  132858. */
  132859. useRadianceOcclusion: boolean;
  132860. /**
  132861. * If set to true, no lighting calculations will be applied.
  132862. */
  132863. unlit: boolean;
  132864. /**
  132865. * Gets the image processing configuration used either in this material.
  132866. */
  132867. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  132868. /**
  132869. * Sets the Default image processing configuration used either in the this material.
  132870. *
  132871. * If sets to null, the scene one is in use.
  132872. */
  132873. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  132874. /**
  132875. * Gets wether the color curves effect is enabled.
  132876. */
  132877. get cameraColorCurvesEnabled(): boolean;
  132878. /**
  132879. * Sets wether the color curves effect is enabled.
  132880. */
  132881. set cameraColorCurvesEnabled(value: boolean);
  132882. /**
  132883. * Gets wether the color grading effect is enabled.
  132884. */
  132885. get cameraColorGradingEnabled(): boolean;
  132886. /**
  132887. * Gets wether the color grading effect is enabled.
  132888. */
  132889. set cameraColorGradingEnabled(value: boolean);
  132890. /**
  132891. * Gets wether tonemapping is enabled or not.
  132892. */
  132893. get cameraToneMappingEnabled(): boolean;
  132894. /**
  132895. * Sets wether tonemapping is enabled or not
  132896. */
  132897. set cameraToneMappingEnabled(value: boolean);
  132898. /**
  132899. * The camera exposure used on this material.
  132900. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  132901. * This corresponds to a photographic exposure.
  132902. */
  132903. get cameraExposure(): number;
  132904. /**
  132905. * The camera exposure used on this material.
  132906. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  132907. * This corresponds to a photographic exposure.
  132908. */
  132909. set cameraExposure(value: number);
  132910. /**
  132911. * Gets The camera contrast used on this material.
  132912. */
  132913. get cameraContrast(): number;
  132914. /**
  132915. * Sets The camera contrast used on this material.
  132916. */
  132917. set cameraContrast(value: number);
  132918. /**
  132919. * Gets the Color Grading 2D Lookup Texture.
  132920. */
  132921. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  132922. /**
  132923. * Sets the Color Grading 2D Lookup Texture.
  132924. */
  132925. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  132926. /**
  132927. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  132928. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  132929. * 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;
  132930. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  132931. */
  132932. get cameraColorCurves(): Nullable<ColorCurves>;
  132933. /**
  132934. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  132935. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  132936. * 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;
  132937. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  132938. */
  132939. set cameraColorCurves(value: Nullable<ColorCurves>);
  132940. /**
  132941. * Instantiates a new PBRMaterial instance.
  132942. *
  132943. * @param name The material name
  132944. * @param scene The scene the material will be use in.
  132945. */
  132946. constructor(name: string, scene: Scene);
  132947. /**
  132948. * Returns the name of this material class.
  132949. */
  132950. getClassName(): string;
  132951. /**
  132952. * Makes a duplicate of the current material.
  132953. * @param name - name to use for the new material.
  132954. */
  132955. clone(name: string): PBRMaterial;
  132956. /**
  132957. * Serializes this PBR Material.
  132958. * @returns - An object with the serialized material.
  132959. */
  132960. serialize(): any;
  132961. /**
  132962. * Parses a PBR Material from a serialized object.
  132963. * @param source - Serialized object.
  132964. * @param scene - BJS scene instance.
  132965. * @param rootUrl - url for the scene object
  132966. * @returns - PBRMaterial
  132967. */
  132968. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  132969. }
  132970. }
  132971. declare module BABYLON {
  132972. /**
  132973. * Direct draw surface info
  132974. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  132975. */
  132976. export interface DDSInfo {
  132977. /**
  132978. * Width of the texture
  132979. */
  132980. width: number;
  132981. /**
  132982. * Width of the texture
  132983. */
  132984. height: number;
  132985. /**
  132986. * Number of Mipmaps for the texture
  132987. * @see https://en.wikipedia.org/wiki/Mipmap
  132988. */
  132989. mipmapCount: number;
  132990. /**
  132991. * If the textures format is a known fourCC format
  132992. * @see https://www.fourcc.org/
  132993. */
  132994. isFourCC: boolean;
  132995. /**
  132996. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  132997. */
  132998. isRGB: boolean;
  132999. /**
  133000. * If the texture is a lumincance format
  133001. */
  133002. isLuminance: boolean;
  133003. /**
  133004. * If this is a cube texture
  133005. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  133006. */
  133007. isCube: boolean;
  133008. /**
  133009. * If the texture is a compressed format eg. FOURCC_DXT1
  133010. */
  133011. isCompressed: boolean;
  133012. /**
  133013. * The dxgiFormat of the texture
  133014. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  133015. */
  133016. dxgiFormat: number;
  133017. /**
  133018. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  133019. */
  133020. textureType: number;
  133021. /**
  133022. * Sphericle polynomial created for the dds texture
  133023. */
  133024. sphericalPolynomial?: SphericalPolynomial;
  133025. }
  133026. /**
  133027. * Class used to provide DDS decompression tools
  133028. */
  133029. export class DDSTools {
  133030. /**
  133031. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  133032. */
  133033. static StoreLODInAlphaChannel: boolean;
  133034. /**
  133035. * Gets DDS information from an array buffer
  133036. * @param data defines the array buffer view to read data from
  133037. * @returns the DDS information
  133038. */
  133039. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  133040. private static _FloatView;
  133041. private static _Int32View;
  133042. private static _ToHalfFloat;
  133043. private static _FromHalfFloat;
  133044. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  133045. private static _GetHalfFloatRGBAArrayBuffer;
  133046. private static _GetFloatRGBAArrayBuffer;
  133047. private static _GetFloatAsUIntRGBAArrayBuffer;
  133048. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  133049. private static _GetRGBAArrayBuffer;
  133050. private static _ExtractLongWordOrder;
  133051. private static _GetRGBArrayBuffer;
  133052. private static _GetLuminanceArrayBuffer;
  133053. /**
  133054. * Uploads DDS Levels to a Babylon Texture
  133055. * @hidden
  133056. */
  133057. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  133058. }
  133059. interface ThinEngine {
  133060. /**
  133061. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  133062. * @param rootUrl defines the url where the file to load is located
  133063. * @param scene defines the current scene
  133064. * @param lodScale defines scale to apply to the mip map selection
  133065. * @param lodOffset defines offset to apply to the mip map selection
  133066. * @param onLoad defines an optional callback raised when the texture is loaded
  133067. * @param onError defines an optional callback raised if there is an issue to load the texture
  133068. * @param format defines the format of the data
  133069. * @param forcedExtension defines the extension to use to pick the right loader
  133070. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  133071. * @returns the cube texture as an InternalTexture
  133072. */
  133073. 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;
  133074. }
  133075. }
  133076. declare module BABYLON {
  133077. /**
  133078. * Implementation of the DDS Texture Loader.
  133079. * @hidden
  133080. */
  133081. export class _DDSTextureLoader implements IInternalTextureLoader {
  133082. /**
  133083. * Defines wether the loader supports cascade loading the different faces.
  133084. */
  133085. readonly supportCascades: boolean;
  133086. /**
  133087. * This returns if the loader support the current file information.
  133088. * @param extension defines the file extension of the file being loaded
  133089. * @returns true if the loader can load the specified file
  133090. */
  133091. canLoad(extension: string): boolean;
  133092. /**
  133093. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  133094. * @param data contains the texture data
  133095. * @param texture defines the BabylonJS internal texture
  133096. * @param createPolynomials will be true if polynomials have been requested
  133097. * @param onLoad defines the callback to trigger once the texture is ready
  133098. * @param onError defines the callback to trigger in case of error
  133099. */
  133100. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  133101. /**
  133102. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  133103. * @param data contains the texture data
  133104. * @param texture defines the BabylonJS internal texture
  133105. * @param callback defines the method to call once ready to upload
  133106. */
  133107. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  133108. }
  133109. }
  133110. declare module BABYLON {
  133111. /**
  133112. * Implementation of the ENV Texture Loader.
  133113. * @hidden
  133114. */
  133115. export class _ENVTextureLoader implements IInternalTextureLoader {
  133116. /**
  133117. * Defines wether the loader supports cascade loading the different faces.
  133118. */
  133119. readonly supportCascades: boolean;
  133120. /**
  133121. * This returns if the loader support the current file information.
  133122. * @param extension defines the file extension of the file being loaded
  133123. * @returns true if the loader can load the specified file
  133124. */
  133125. canLoad(extension: string): boolean;
  133126. /**
  133127. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  133128. * @param data contains the texture data
  133129. * @param texture defines the BabylonJS internal texture
  133130. * @param createPolynomials will be true if polynomials have been requested
  133131. * @param onLoad defines the callback to trigger once the texture is ready
  133132. * @param onError defines the callback to trigger in case of error
  133133. */
  133134. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  133135. /**
  133136. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  133137. * @param data contains the texture data
  133138. * @param texture defines the BabylonJS internal texture
  133139. * @param callback defines the method to call once ready to upload
  133140. */
  133141. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  133142. }
  133143. }
  133144. declare module BABYLON {
  133145. /**
  133146. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  133147. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  133148. */
  133149. export class KhronosTextureContainer {
  133150. /** contents of the KTX container file */
  133151. data: ArrayBufferView;
  133152. private static HEADER_LEN;
  133153. private static COMPRESSED_2D;
  133154. private static COMPRESSED_3D;
  133155. private static TEX_2D;
  133156. private static TEX_3D;
  133157. /**
  133158. * Gets the openGL type
  133159. */
  133160. glType: number;
  133161. /**
  133162. * Gets the openGL type size
  133163. */
  133164. glTypeSize: number;
  133165. /**
  133166. * Gets the openGL format
  133167. */
  133168. glFormat: number;
  133169. /**
  133170. * Gets the openGL internal format
  133171. */
  133172. glInternalFormat: number;
  133173. /**
  133174. * Gets the base internal format
  133175. */
  133176. glBaseInternalFormat: number;
  133177. /**
  133178. * Gets image width in pixel
  133179. */
  133180. pixelWidth: number;
  133181. /**
  133182. * Gets image height in pixel
  133183. */
  133184. pixelHeight: number;
  133185. /**
  133186. * Gets image depth in pixels
  133187. */
  133188. pixelDepth: number;
  133189. /**
  133190. * Gets the number of array elements
  133191. */
  133192. numberOfArrayElements: number;
  133193. /**
  133194. * Gets the number of faces
  133195. */
  133196. numberOfFaces: number;
  133197. /**
  133198. * Gets the number of mipmap levels
  133199. */
  133200. numberOfMipmapLevels: number;
  133201. /**
  133202. * Gets the bytes of key value data
  133203. */
  133204. bytesOfKeyValueData: number;
  133205. /**
  133206. * Gets the load type
  133207. */
  133208. loadType: number;
  133209. /**
  133210. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  133211. */
  133212. isInvalid: boolean;
  133213. /**
  133214. * Creates a new KhronosTextureContainer
  133215. * @param data contents of the KTX container file
  133216. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  133217. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  133218. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  133219. */
  133220. constructor(
  133221. /** contents of the KTX container file */
  133222. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  133223. /**
  133224. * Uploads KTX content to a Babylon Texture.
  133225. * It is assumed that the texture has already been created & is currently bound
  133226. * @hidden
  133227. */
  133228. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  133229. private _upload2DCompressedLevels;
  133230. /**
  133231. * Checks if the given data starts with a KTX file identifier.
  133232. * @param data the data to check
  133233. * @returns true if the data is a KTX file or false otherwise
  133234. */
  133235. static IsValid(data: ArrayBufferView): boolean;
  133236. }
  133237. }
  133238. declare module BABYLON {
  133239. /**
  133240. * Class for loading KTX2 files
  133241. * !!! Experimental Extension Subject to Changes !!!
  133242. * @hidden
  133243. */
  133244. export class KhronosTextureContainer2 {
  133245. private static _ModulePromise;
  133246. private static _TranscodeFormat;
  133247. constructor(engine: ThinEngine);
  133248. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  133249. private _determineTranscodeFormat;
  133250. /**
  133251. * Checks if the given data starts with a KTX2 file identifier.
  133252. * @param data the data to check
  133253. * @returns true if the data is a KTX2 file or false otherwise
  133254. */
  133255. static IsValid(data: ArrayBufferView): boolean;
  133256. }
  133257. }
  133258. declare module BABYLON {
  133259. /**
  133260. * Implementation of the KTX Texture Loader.
  133261. * @hidden
  133262. */
  133263. export class _KTXTextureLoader implements IInternalTextureLoader {
  133264. /**
  133265. * Defines wether the loader supports cascade loading the different faces.
  133266. */
  133267. readonly supportCascades: boolean;
  133268. /**
  133269. * This returns if the loader support the current file information.
  133270. * @param extension defines the file extension of the file being loaded
  133271. * @returns true if the loader can load the specified file
  133272. */
  133273. canLoad(extension: string): boolean;
  133274. /**
  133275. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  133276. * @param data contains the texture data
  133277. * @param texture defines the BabylonJS internal texture
  133278. * @param createPolynomials will be true if polynomials have been requested
  133279. * @param onLoad defines the callback to trigger once the texture is ready
  133280. * @param onError defines the callback to trigger in case of error
  133281. */
  133282. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  133283. /**
  133284. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  133285. * @param data contains the texture data
  133286. * @param texture defines the BabylonJS internal texture
  133287. * @param callback defines the method to call once ready to upload
  133288. */
  133289. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  133290. }
  133291. }
  133292. declare module BABYLON {
  133293. /** @hidden */
  133294. export var _forceSceneHelpersToBundle: boolean;
  133295. interface Scene {
  133296. /**
  133297. * Creates a default light for the scene.
  133298. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  133299. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  133300. */
  133301. createDefaultLight(replace?: boolean): void;
  133302. /**
  133303. * Creates a default camera for the scene.
  133304. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  133305. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  133306. * @param replace has default false, when true replaces the active camera in the scene
  133307. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  133308. */
  133309. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  133310. /**
  133311. * Creates a default camera and a default light.
  133312. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  133313. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  133314. * @param replace has the default false, when true replaces the active camera/light in the scene
  133315. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  133316. */
  133317. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  133318. /**
  133319. * Creates a new sky box
  133320. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  133321. * @param environmentTexture defines the texture to use as environment texture
  133322. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  133323. * @param scale defines the overall scale of the skybox
  133324. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  133325. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  133326. * @returns a new mesh holding the sky box
  133327. */
  133328. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  133329. /**
  133330. * Creates a new environment
  133331. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  133332. * @param options defines the options you can use to configure the environment
  133333. * @returns the new EnvironmentHelper
  133334. */
  133335. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  133336. /**
  133337. * Creates a new VREXperienceHelper
  133338. * @see http://doc.babylonjs.com/how_to/webvr_helper
  133339. * @param webVROptions defines the options used to create the new VREXperienceHelper
  133340. * @returns a new VREXperienceHelper
  133341. */
  133342. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  133343. /**
  133344. * Creates a new WebXRDefaultExperience
  133345. * @see http://doc.babylonjs.com/how_to/webxr
  133346. * @param options experience options
  133347. * @returns a promise for a new WebXRDefaultExperience
  133348. */
  133349. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  133350. }
  133351. }
  133352. declare module BABYLON {
  133353. /**
  133354. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  133355. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  133356. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  133357. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  133358. */
  133359. export class VideoDome extends TransformNode {
  133360. /**
  133361. * Define the video source as a Monoscopic panoramic 360 video.
  133362. */
  133363. static readonly MODE_MONOSCOPIC: number;
  133364. /**
  133365. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  133366. */
  133367. static readonly MODE_TOPBOTTOM: number;
  133368. /**
  133369. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  133370. */
  133371. static readonly MODE_SIDEBYSIDE: number;
  133372. private _halfDome;
  133373. private _useDirectMapping;
  133374. /**
  133375. * The video texture being displayed on the sphere
  133376. */
  133377. protected _videoTexture: VideoTexture;
  133378. /**
  133379. * Gets the video texture being displayed on the sphere
  133380. */
  133381. get videoTexture(): VideoTexture;
  133382. /**
  133383. * The skybox material
  133384. */
  133385. protected _material: BackgroundMaterial;
  133386. /**
  133387. * The surface used for the skybox
  133388. */
  133389. protected _mesh: Mesh;
  133390. /**
  133391. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  133392. */
  133393. private _halfDomeMask;
  133394. /**
  133395. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  133396. * Also see the options.resolution property.
  133397. */
  133398. get fovMultiplier(): number;
  133399. set fovMultiplier(value: number);
  133400. private _videoMode;
  133401. /**
  133402. * Gets or set the current video mode for the video. It can be:
  133403. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  133404. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  133405. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  133406. */
  133407. get videoMode(): number;
  133408. set videoMode(value: number);
  133409. /**
  133410. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  133411. *
  133412. */
  133413. get halfDome(): boolean;
  133414. /**
  133415. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  133416. */
  133417. set halfDome(enabled: boolean);
  133418. /**
  133419. * Oberserver used in Stereoscopic VR Mode.
  133420. */
  133421. private _onBeforeCameraRenderObserver;
  133422. /**
  133423. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  133424. * @param name Element's name, child elements will append suffixes for their own names.
  133425. * @param urlsOrVideo defines the url(s) or the video element to use
  133426. * @param options An object containing optional or exposed sub element properties
  133427. */
  133428. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  133429. resolution?: number;
  133430. clickToPlay?: boolean;
  133431. autoPlay?: boolean;
  133432. loop?: boolean;
  133433. size?: number;
  133434. poster?: string;
  133435. faceForward?: boolean;
  133436. useDirectMapping?: boolean;
  133437. halfDomeMode?: boolean;
  133438. }, scene: Scene);
  133439. private _changeVideoMode;
  133440. /**
  133441. * Releases resources associated with this node.
  133442. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  133443. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  133444. */
  133445. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  133446. }
  133447. }
  133448. declare module BABYLON {
  133449. /**
  133450. * This class can be used to get instrumentation data from a Babylon engine
  133451. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  133452. */
  133453. export class EngineInstrumentation implements IDisposable {
  133454. /**
  133455. * Define the instrumented engine.
  133456. */
  133457. engine: Engine;
  133458. private _captureGPUFrameTime;
  133459. private _gpuFrameTimeToken;
  133460. private _gpuFrameTime;
  133461. private _captureShaderCompilationTime;
  133462. private _shaderCompilationTime;
  133463. private _onBeginFrameObserver;
  133464. private _onEndFrameObserver;
  133465. private _onBeforeShaderCompilationObserver;
  133466. private _onAfterShaderCompilationObserver;
  133467. /**
  133468. * Gets the perf counter used for GPU frame time
  133469. */
  133470. get gpuFrameTimeCounter(): PerfCounter;
  133471. /**
  133472. * Gets the GPU frame time capture status
  133473. */
  133474. get captureGPUFrameTime(): boolean;
  133475. /**
  133476. * Enable or disable the GPU frame time capture
  133477. */
  133478. set captureGPUFrameTime(value: boolean);
  133479. /**
  133480. * Gets the perf counter used for shader compilation time
  133481. */
  133482. get shaderCompilationTimeCounter(): PerfCounter;
  133483. /**
  133484. * Gets the shader compilation time capture status
  133485. */
  133486. get captureShaderCompilationTime(): boolean;
  133487. /**
  133488. * Enable or disable the shader compilation time capture
  133489. */
  133490. set captureShaderCompilationTime(value: boolean);
  133491. /**
  133492. * Instantiates a new engine instrumentation.
  133493. * This class can be used to get instrumentation data from a Babylon engine
  133494. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  133495. * @param engine Defines the engine to instrument
  133496. */
  133497. constructor(
  133498. /**
  133499. * Define the instrumented engine.
  133500. */
  133501. engine: Engine);
  133502. /**
  133503. * Dispose and release associated resources.
  133504. */
  133505. dispose(): void;
  133506. }
  133507. }
  133508. declare module BABYLON {
  133509. /**
  133510. * This class can be used to get instrumentation data from a Babylon engine
  133511. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  133512. */
  133513. export class SceneInstrumentation implements IDisposable {
  133514. /**
  133515. * Defines the scene to instrument
  133516. */
  133517. scene: Scene;
  133518. private _captureActiveMeshesEvaluationTime;
  133519. private _activeMeshesEvaluationTime;
  133520. private _captureRenderTargetsRenderTime;
  133521. private _renderTargetsRenderTime;
  133522. private _captureFrameTime;
  133523. private _frameTime;
  133524. private _captureRenderTime;
  133525. private _renderTime;
  133526. private _captureInterFrameTime;
  133527. private _interFrameTime;
  133528. private _captureParticlesRenderTime;
  133529. private _particlesRenderTime;
  133530. private _captureSpritesRenderTime;
  133531. private _spritesRenderTime;
  133532. private _capturePhysicsTime;
  133533. private _physicsTime;
  133534. private _captureAnimationsTime;
  133535. private _animationsTime;
  133536. private _captureCameraRenderTime;
  133537. private _cameraRenderTime;
  133538. private _onBeforeActiveMeshesEvaluationObserver;
  133539. private _onAfterActiveMeshesEvaluationObserver;
  133540. private _onBeforeRenderTargetsRenderObserver;
  133541. private _onAfterRenderTargetsRenderObserver;
  133542. private _onAfterRenderObserver;
  133543. private _onBeforeDrawPhaseObserver;
  133544. private _onAfterDrawPhaseObserver;
  133545. private _onBeforeAnimationsObserver;
  133546. private _onBeforeParticlesRenderingObserver;
  133547. private _onAfterParticlesRenderingObserver;
  133548. private _onBeforeSpritesRenderingObserver;
  133549. private _onAfterSpritesRenderingObserver;
  133550. private _onBeforePhysicsObserver;
  133551. private _onAfterPhysicsObserver;
  133552. private _onAfterAnimationsObserver;
  133553. private _onBeforeCameraRenderObserver;
  133554. private _onAfterCameraRenderObserver;
  133555. /**
  133556. * Gets the perf counter used for active meshes evaluation time
  133557. */
  133558. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  133559. /**
  133560. * Gets the active meshes evaluation time capture status
  133561. */
  133562. get captureActiveMeshesEvaluationTime(): boolean;
  133563. /**
  133564. * Enable or disable the active meshes evaluation time capture
  133565. */
  133566. set captureActiveMeshesEvaluationTime(value: boolean);
  133567. /**
  133568. * Gets the perf counter used for render targets render time
  133569. */
  133570. get renderTargetsRenderTimeCounter(): PerfCounter;
  133571. /**
  133572. * Gets the render targets render time capture status
  133573. */
  133574. get captureRenderTargetsRenderTime(): boolean;
  133575. /**
  133576. * Enable or disable the render targets render time capture
  133577. */
  133578. set captureRenderTargetsRenderTime(value: boolean);
  133579. /**
  133580. * Gets the perf counter used for particles render time
  133581. */
  133582. get particlesRenderTimeCounter(): PerfCounter;
  133583. /**
  133584. * Gets the particles render time capture status
  133585. */
  133586. get captureParticlesRenderTime(): boolean;
  133587. /**
  133588. * Enable or disable the particles render time capture
  133589. */
  133590. set captureParticlesRenderTime(value: boolean);
  133591. /**
  133592. * Gets the perf counter used for sprites render time
  133593. */
  133594. get spritesRenderTimeCounter(): PerfCounter;
  133595. /**
  133596. * Gets the sprites render time capture status
  133597. */
  133598. get captureSpritesRenderTime(): boolean;
  133599. /**
  133600. * Enable or disable the sprites render time capture
  133601. */
  133602. set captureSpritesRenderTime(value: boolean);
  133603. /**
  133604. * Gets the perf counter used for physics time
  133605. */
  133606. get physicsTimeCounter(): PerfCounter;
  133607. /**
  133608. * Gets the physics time capture status
  133609. */
  133610. get capturePhysicsTime(): boolean;
  133611. /**
  133612. * Enable or disable the physics time capture
  133613. */
  133614. set capturePhysicsTime(value: boolean);
  133615. /**
  133616. * Gets the perf counter used for animations time
  133617. */
  133618. get animationsTimeCounter(): PerfCounter;
  133619. /**
  133620. * Gets the animations time capture status
  133621. */
  133622. get captureAnimationsTime(): boolean;
  133623. /**
  133624. * Enable or disable the animations time capture
  133625. */
  133626. set captureAnimationsTime(value: boolean);
  133627. /**
  133628. * Gets the perf counter used for frame time capture
  133629. */
  133630. get frameTimeCounter(): PerfCounter;
  133631. /**
  133632. * Gets the frame time capture status
  133633. */
  133634. get captureFrameTime(): boolean;
  133635. /**
  133636. * Enable or disable the frame time capture
  133637. */
  133638. set captureFrameTime(value: boolean);
  133639. /**
  133640. * Gets the perf counter used for inter-frames time capture
  133641. */
  133642. get interFrameTimeCounter(): PerfCounter;
  133643. /**
  133644. * Gets the inter-frames time capture status
  133645. */
  133646. get captureInterFrameTime(): boolean;
  133647. /**
  133648. * Enable or disable the inter-frames time capture
  133649. */
  133650. set captureInterFrameTime(value: boolean);
  133651. /**
  133652. * Gets the perf counter used for render time capture
  133653. */
  133654. get renderTimeCounter(): PerfCounter;
  133655. /**
  133656. * Gets the render time capture status
  133657. */
  133658. get captureRenderTime(): boolean;
  133659. /**
  133660. * Enable or disable the render time capture
  133661. */
  133662. set captureRenderTime(value: boolean);
  133663. /**
  133664. * Gets the perf counter used for camera render time capture
  133665. */
  133666. get cameraRenderTimeCounter(): PerfCounter;
  133667. /**
  133668. * Gets the camera render time capture status
  133669. */
  133670. get captureCameraRenderTime(): boolean;
  133671. /**
  133672. * Enable or disable the camera render time capture
  133673. */
  133674. set captureCameraRenderTime(value: boolean);
  133675. /**
  133676. * Gets the perf counter used for draw calls
  133677. */
  133678. get drawCallsCounter(): PerfCounter;
  133679. /**
  133680. * Instantiates a new scene instrumentation.
  133681. * This class can be used to get instrumentation data from a Babylon engine
  133682. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  133683. * @param scene Defines the scene to instrument
  133684. */
  133685. constructor(
  133686. /**
  133687. * Defines the scene to instrument
  133688. */
  133689. scene: Scene);
  133690. /**
  133691. * Dispose and release associated resources.
  133692. */
  133693. dispose(): void;
  133694. }
  133695. }
  133696. declare module BABYLON {
  133697. /** @hidden */
  133698. export var glowMapGenerationPixelShader: {
  133699. name: string;
  133700. shader: string;
  133701. };
  133702. }
  133703. declare module BABYLON {
  133704. /** @hidden */
  133705. export var glowMapGenerationVertexShader: {
  133706. name: string;
  133707. shader: string;
  133708. };
  133709. }
  133710. declare module BABYLON {
  133711. /**
  133712. * Effect layer options. This helps customizing the behaviour
  133713. * of the effect layer.
  133714. */
  133715. export interface IEffectLayerOptions {
  133716. /**
  133717. * Multiplication factor apply to the canvas size to compute the render target size
  133718. * used to generated the objects (the smaller the faster).
  133719. */
  133720. mainTextureRatio: number;
  133721. /**
  133722. * Enforces a fixed size texture to ensure effect stability across devices.
  133723. */
  133724. mainTextureFixedSize?: number;
  133725. /**
  133726. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  133727. */
  133728. alphaBlendingMode: number;
  133729. /**
  133730. * The camera attached to the layer.
  133731. */
  133732. camera: Nullable<Camera>;
  133733. /**
  133734. * The rendering group to draw the layer in.
  133735. */
  133736. renderingGroupId: number;
  133737. }
  133738. /**
  133739. * The effect layer Helps adding post process effect blended with the main pass.
  133740. *
  133741. * This can be for instance use to generate glow or higlight effects on the scene.
  133742. *
  133743. * The effect layer class can not be used directly and is intented to inherited from to be
  133744. * customized per effects.
  133745. */
  133746. export abstract class EffectLayer {
  133747. private _vertexBuffers;
  133748. private _indexBuffer;
  133749. private _cachedDefines;
  133750. private _effectLayerMapGenerationEffect;
  133751. private _effectLayerOptions;
  133752. private _mergeEffect;
  133753. protected _scene: Scene;
  133754. protected _engine: Engine;
  133755. protected _maxSize: number;
  133756. protected _mainTextureDesiredSize: ISize;
  133757. protected _mainTexture: RenderTargetTexture;
  133758. protected _shouldRender: boolean;
  133759. protected _postProcesses: PostProcess[];
  133760. protected _textures: BaseTexture[];
  133761. protected _emissiveTextureAndColor: {
  133762. texture: Nullable<BaseTexture>;
  133763. color: Color4;
  133764. };
  133765. /**
  133766. * The name of the layer
  133767. */
  133768. name: string;
  133769. /**
  133770. * The clear color of the texture used to generate the glow map.
  133771. */
  133772. neutralColor: Color4;
  133773. /**
  133774. * Specifies whether the highlight layer is enabled or not.
  133775. */
  133776. isEnabled: boolean;
  133777. /**
  133778. * Gets the camera attached to the layer.
  133779. */
  133780. get camera(): Nullable<Camera>;
  133781. /**
  133782. * Gets the rendering group id the layer should render in.
  133783. */
  133784. get renderingGroupId(): number;
  133785. set renderingGroupId(renderingGroupId: number);
  133786. /**
  133787. * An event triggered when the effect layer has been disposed.
  133788. */
  133789. onDisposeObservable: Observable<EffectLayer>;
  133790. /**
  133791. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  133792. */
  133793. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  133794. /**
  133795. * An event triggered when the generated texture is being merged in the scene.
  133796. */
  133797. onBeforeComposeObservable: Observable<EffectLayer>;
  133798. /**
  133799. * An event triggered when the mesh is rendered into the effect render target.
  133800. */
  133801. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  133802. /**
  133803. * An event triggered after the mesh has been rendered into the effect render target.
  133804. */
  133805. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  133806. /**
  133807. * An event triggered when the generated texture has been merged in the scene.
  133808. */
  133809. onAfterComposeObservable: Observable<EffectLayer>;
  133810. /**
  133811. * An event triggered when the efffect layer changes its size.
  133812. */
  133813. onSizeChangedObservable: Observable<EffectLayer>;
  133814. /** @hidden */
  133815. static _SceneComponentInitialization: (scene: Scene) => void;
  133816. /**
  133817. * Instantiates a new effect Layer and references it in the scene.
  133818. * @param name The name of the layer
  133819. * @param scene The scene to use the layer in
  133820. */
  133821. constructor(
  133822. /** The Friendly of the effect in the scene */
  133823. name: string, scene: Scene);
  133824. /**
  133825. * Get the effect name of the layer.
  133826. * @return The effect name
  133827. */
  133828. abstract getEffectName(): string;
  133829. /**
  133830. * Checks for the readiness of the element composing the layer.
  133831. * @param subMesh the mesh to check for
  133832. * @param useInstances specify whether or not to use instances to render the mesh
  133833. * @return true if ready otherwise, false
  133834. */
  133835. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  133836. /**
  133837. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  133838. * @returns true if the effect requires stencil during the main canvas render pass.
  133839. */
  133840. abstract needStencil(): boolean;
  133841. /**
  133842. * Create the merge effect. This is the shader use to blit the information back
  133843. * to the main canvas at the end of the scene rendering.
  133844. * @returns The effect containing the shader used to merge the effect on the main canvas
  133845. */
  133846. protected abstract _createMergeEffect(): Effect;
  133847. /**
  133848. * Creates the render target textures and post processes used in the effect layer.
  133849. */
  133850. protected abstract _createTextureAndPostProcesses(): void;
  133851. /**
  133852. * Implementation specific of rendering the generating effect on the main canvas.
  133853. * @param effect The effect used to render through
  133854. */
  133855. protected abstract _internalRender(effect: Effect): void;
  133856. /**
  133857. * Sets the required values for both the emissive texture and and the main color.
  133858. */
  133859. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  133860. /**
  133861. * Free any resources and references associated to a mesh.
  133862. * Internal use
  133863. * @param mesh The mesh to free.
  133864. */
  133865. abstract _disposeMesh(mesh: Mesh): void;
  133866. /**
  133867. * Serializes this layer (Glow or Highlight for example)
  133868. * @returns a serialized layer object
  133869. */
  133870. abstract serialize?(): any;
  133871. /**
  133872. * Initializes the effect layer with the required options.
  133873. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  133874. */
  133875. protected _init(options: Partial<IEffectLayerOptions>): void;
  133876. /**
  133877. * Generates the index buffer of the full screen quad blending to the main canvas.
  133878. */
  133879. private _generateIndexBuffer;
  133880. /**
  133881. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  133882. */
  133883. private _generateVertexBuffer;
  133884. /**
  133885. * Sets the main texture desired size which is the closest power of two
  133886. * of the engine canvas size.
  133887. */
  133888. private _setMainTextureSize;
  133889. /**
  133890. * Creates the main texture for the effect layer.
  133891. */
  133892. protected _createMainTexture(): void;
  133893. /**
  133894. * Adds specific effects defines.
  133895. * @param defines The defines to add specifics to.
  133896. */
  133897. protected _addCustomEffectDefines(defines: string[]): void;
  133898. /**
  133899. * Checks for the readiness of the element composing the layer.
  133900. * @param subMesh the mesh to check for
  133901. * @param useInstances specify whether or not to use instances to render the mesh
  133902. * @param emissiveTexture the associated emissive texture used to generate the glow
  133903. * @return true if ready otherwise, false
  133904. */
  133905. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  133906. /**
  133907. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  133908. */
  133909. render(): void;
  133910. /**
  133911. * Determine if a given mesh will be used in the current effect.
  133912. * @param mesh mesh to test
  133913. * @returns true if the mesh will be used
  133914. */
  133915. hasMesh(mesh: AbstractMesh): boolean;
  133916. /**
  133917. * Returns true if the layer contains information to display, otherwise false.
  133918. * @returns true if the glow layer should be rendered
  133919. */
  133920. shouldRender(): boolean;
  133921. /**
  133922. * Returns true if the mesh should render, otherwise false.
  133923. * @param mesh The mesh to render
  133924. * @returns true if it should render otherwise false
  133925. */
  133926. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  133927. /**
  133928. * Returns true if the mesh can be rendered, otherwise false.
  133929. * @param mesh The mesh to render
  133930. * @param material The material used on the mesh
  133931. * @returns true if it can be rendered otherwise false
  133932. */
  133933. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  133934. /**
  133935. * Returns true if the mesh should render, otherwise false.
  133936. * @param mesh The mesh to render
  133937. * @returns true if it should render otherwise false
  133938. */
  133939. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  133940. /**
  133941. * Renders the submesh passed in parameter to the generation map.
  133942. */
  133943. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  133944. /**
  133945. * Defines whether the current material of the mesh should be use to render the effect.
  133946. * @param mesh defines the current mesh to render
  133947. */
  133948. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  133949. /**
  133950. * Rebuild the required buffers.
  133951. * @hidden Internal use only.
  133952. */
  133953. _rebuild(): void;
  133954. /**
  133955. * Dispose only the render target textures and post process.
  133956. */
  133957. private _disposeTextureAndPostProcesses;
  133958. /**
  133959. * Dispose the highlight layer and free resources.
  133960. */
  133961. dispose(): void;
  133962. /**
  133963. * Gets the class name of the effect layer
  133964. * @returns the string with the class name of the effect layer
  133965. */
  133966. getClassName(): string;
  133967. /**
  133968. * Creates an effect layer from parsed effect layer data
  133969. * @param parsedEffectLayer defines effect layer data
  133970. * @param scene defines the current scene
  133971. * @param rootUrl defines the root URL containing the effect layer information
  133972. * @returns a parsed effect Layer
  133973. */
  133974. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  133975. }
  133976. }
  133977. declare module BABYLON {
  133978. interface AbstractScene {
  133979. /**
  133980. * The list of effect layers (highlights/glow) added to the scene
  133981. * @see http://doc.babylonjs.com/how_to/highlight_layer
  133982. * @see http://doc.babylonjs.com/how_to/glow_layer
  133983. */
  133984. effectLayers: Array<EffectLayer>;
  133985. /**
  133986. * Removes the given effect layer from this scene.
  133987. * @param toRemove defines the effect layer to remove
  133988. * @returns the index of the removed effect layer
  133989. */
  133990. removeEffectLayer(toRemove: EffectLayer): number;
  133991. /**
  133992. * Adds the given effect layer to this scene
  133993. * @param newEffectLayer defines the effect layer to add
  133994. */
  133995. addEffectLayer(newEffectLayer: EffectLayer): void;
  133996. }
  133997. /**
  133998. * Defines the layer scene component responsible to manage any effect layers
  133999. * in a given scene.
  134000. */
  134001. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  134002. /**
  134003. * The component name helpfull to identify the component in the list of scene components.
  134004. */
  134005. readonly name: string;
  134006. /**
  134007. * The scene the component belongs to.
  134008. */
  134009. scene: Scene;
  134010. private _engine;
  134011. private _renderEffects;
  134012. private _needStencil;
  134013. private _previousStencilState;
  134014. /**
  134015. * Creates a new instance of the component for the given scene
  134016. * @param scene Defines the scene to register the component in
  134017. */
  134018. constructor(scene: Scene);
  134019. /**
  134020. * Registers the component in a given scene
  134021. */
  134022. register(): void;
  134023. /**
  134024. * Rebuilds the elements related to this component in case of
  134025. * context lost for instance.
  134026. */
  134027. rebuild(): void;
  134028. /**
  134029. * Serializes the component data to the specified json object
  134030. * @param serializationObject The object to serialize to
  134031. */
  134032. serialize(serializationObject: any): void;
  134033. /**
  134034. * Adds all the elements from the container to the scene
  134035. * @param container the container holding the elements
  134036. */
  134037. addFromContainer(container: AbstractScene): void;
  134038. /**
  134039. * Removes all the elements in the container from the scene
  134040. * @param container contains the elements to remove
  134041. * @param dispose if the removed element should be disposed (default: false)
  134042. */
  134043. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  134044. /**
  134045. * Disposes the component and the associated ressources.
  134046. */
  134047. dispose(): void;
  134048. private _isReadyForMesh;
  134049. private _renderMainTexture;
  134050. private _setStencil;
  134051. private _setStencilBack;
  134052. private _draw;
  134053. private _drawCamera;
  134054. private _drawRenderingGroup;
  134055. }
  134056. }
  134057. declare module BABYLON {
  134058. /** @hidden */
  134059. export var glowMapMergePixelShader: {
  134060. name: string;
  134061. shader: string;
  134062. };
  134063. }
  134064. declare module BABYLON {
  134065. /** @hidden */
  134066. export var glowMapMergeVertexShader: {
  134067. name: string;
  134068. shader: string;
  134069. };
  134070. }
  134071. declare module BABYLON {
  134072. interface AbstractScene {
  134073. /**
  134074. * Return a the first highlight layer of the scene with a given name.
  134075. * @param name The name of the highlight layer to look for.
  134076. * @return The highlight layer if found otherwise null.
  134077. */
  134078. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  134079. }
  134080. /**
  134081. * Glow layer options. This helps customizing the behaviour
  134082. * of the glow layer.
  134083. */
  134084. export interface IGlowLayerOptions {
  134085. /**
  134086. * Multiplication factor apply to the canvas size to compute the render target size
  134087. * used to generated the glowing objects (the smaller the faster).
  134088. */
  134089. mainTextureRatio: number;
  134090. /**
  134091. * Enforces a fixed size texture to ensure resize independant blur.
  134092. */
  134093. mainTextureFixedSize?: number;
  134094. /**
  134095. * How big is the kernel of the blur texture.
  134096. */
  134097. blurKernelSize: number;
  134098. /**
  134099. * The camera attached to the layer.
  134100. */
  134101. camera: Nullable<Camera>;
  134102. /**
  134103. * Enable MSAA by chosing the number of samples.
  134104. */
  134105. mainTextureSamples?: number;
  134106. /**
  134107. * The rendering group to draw the layer in.
  134108. */
  134109. renderingGroupId: number;
  134110. }
  134111. /**
  134112. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  134113. *
  134114. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  134115. *
  134116. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  134117. */
  134118. export class GlowLayer extends EffectLayer {
  134119. /**
  134120. * Effect Name of the layer.
  134121. */
  134122. static readonly EffectName: string;
  134123. /**
  134124. * The default blur kernel size used for the glow.
  134125. */
  134126. static DefaultBlurKernelSize: number;
  134127. /**
  134128. * The default texture size ratio used for the glow.
  134129. */
  134130. static DefaultTextureRatio: number;
  134131. /**
  134132. * Sets the kernel size of the blur.
  134133. */
  134134. set blurKernelSize(value: number);
  134135. /**
  134136. * Gets the kernel size of the blur.
  134137. */
  134138. get blurKernelSize(): number;
  134139. /**
  134140. * Sets the glow intensity.
  134141. */
  134142. set intensity(value: number);
  134143. /**
  134144. * Gets the glow intensity.
  134145. */
  134146. get intensity(): number;
  134147. private _options;
  134148. private _intensity;
  134149. private _horizontalBlurPostprocess1;
  134150. private _verticalBlurPostprocess1;
  134151. private _horizontalBlurPostprocess2;
  134152. private _verticalBlurPostprocess2;
  134153. private _blurTexture1;
  134154. private _blurTexture2;
  134155. private _postProcesses1;
  134156. private _postProcesses2;
  134157. private _includedOnlyMeshes;
  134158. private _excludedMeshes;
  134159. private _meshesUsingTheirOwnMaterials;
  134160. /**
  134161. * Callback used to let the user override the color selection on a per mesh basis
  134162. */
  134163. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  134164. /**
  134165. * Callback used to let the user override the texture selection on a per mesh basis
  134166. */
  134167. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  134168. /**
  134169. * Instantiates a new glow Layer and references it to the scene.
  134170. * @param name The name of the layer
  134171. * @param scene The scene to use the layer in
  134172. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  134173. */
  134174. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  134175. /**
  134176. * Get the effect name of the layer.
  134177. * @return The effect name
  134178. */
  134179. getEffectName(): string;
  134180. /**
  134181. * Create the merge effect. This is the shader use to blit the information back
  134182. * to the main canvas at the end of the scene rendering.
  134183. */
  134184. protected _createMergeEffect(): Effect;
  134185. /**
  134186. * Creates the render target textures and post processes used in the glow layer.
  134187. */
  134188. protected _createTextureAndPostProcesses(): void;
  134189. /**
  134190. * Checks for the readiness of the element composing the layer.
  134191. * @param subMesh the mesh to check for
  134192. * @param useInstances specify wether or not to use instances to render the mesh
  134193. * @param emissiveTexture the associated emissive texture used to generate the glow
  134194. * @return true if ready otherwise, false
  134195. */
  134196. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  134197. /**
  134198. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  134199. */
  134200. needStencil(): boolean;
  134201. /**
  134202. * Returns true if the mesh can be rendered, otherwise false.
  134203. * @param mesh The mesh to render
  134204. * @param material The material used on the mesh
  134205. * @returns true if it can be rendered otherwise false
  134206. */
  134207. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  134208. /**
  134209. * Implementation specific of rendering the generating effect on the main canvas.
  134210. * @param effect The effect used to render through
  134211. */
  134212. protected _internalRender(effect: Effect): void;
  134213. /**
  134214. * Sets the required values for both the emissive texture and and the main color.
  134215. */
  134216. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  134217. /**
  134218. * Returns true if the mesh should render, otherwise false.
  134219. * @param mesh The mesh to render
  134220. * @returns true if it should render otherwise false
  134221. */
  134222. protected _shouldRenderMesh(mesh: Mesh): boolean;
  134223. /**
  134224. * Adds specific effects defines.
  134225. * @param defines The defines to add specifics to.
  134226. */
  134227. protected _addCustomEffectDefines(defines: string[]): void;
  134228. /**
  134229. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  134230. * @param mesh The mesh to exclude from the glow layer
  134231. */
  134232. addExcludedMesh(mesh: Mesh): void;
  134233. /**
  134234. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  134235. * @param mesh The mesh to remove
  134236. */
  134237. removeExcludedMesh(mesh: Mesh): void;
  134238. /**
  134239. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  134240. * @param mesh The mesh to include in the glow layer
  134241. */
  134242. addIncludedOnlyMesh(mesh: Mesh): void;
  134243. /**
  134244. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  134245. * @param mesh The mesh to remove
  134246. */
  134247. removeIncludedOnlyMesh(mesh: Mesh): void;
  134248. /**
  134249. * Determine if a given mesh will be used in the glow layer
  134250. * @param mesh The mesh to test
  134251. * @returns true if the mesh will be highlighted by the current glow layer
  134252. */
  134253. hasMesh(mesh: AbstractMesh): boolean;
  134254. /**
  134255. * Defines whether the current material of the mesh should be use to render the effect.
  134256. * @param mesh defines the current mesh to render
  134257. */
  134258. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  134259. /**
  134260. * Add a mesh to be rendered through its own material and not with emissive only.
  134261. * @param mesh The mesh for which we need to use its material
  134262. */
  134263. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  134264. /**
  134265. * Remove a mesh from being rendered through its own material and not with emissive only.
  134266. * @param mesh The mesh for which we need to not use its material
  134267. */
  134268. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  134269. /**
  134270. * Free any resources and references associated to a mesh.
  134271. * Internal use
  134272. * @param mesh The mesh to free.
  134273. * @hidden
  134274. */
  134275. _disposeMesh(mesh: Mesh): void;
  134276. /**
  134277. * Gets the class name of the effect layer
  134278. * @returns the string with the class name of the effect layer
  134279. */
  134280. getClassName(): string;
  134281. /**
  134282. * Serializes this glow layer
  134283. * @returns a serialized glow layer object
  134284. */
  134285. serialize(): any;
  134286. /**
  134287. * Creates a Glow Layer from parsed glow layer data
  134288. * @param parsedGlowLayer defines glow layer data
  134289. * @param scene defines the current scene
  134290. * @param rootUrl defines the root URL containing the glow layer information
  134291. * @returns a parsed Glow Layer
  134292. */
  134293. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  134294. }
  134295. }
  134296. declare module BABYLON {
  134297. /** @hidden */
  134298. export var glowBlurPostProcessPixelShader: {
  134299. name: string;
  134300. shader: string;
  134301. };
  134302. }
  134303. declare module BABYLON {
  134304. interface AbstractScene {
  134305. /**
  134306. * Return a the first highlight layer of the scene with a given name.
  134307. * @param name The name of the highlight layer to look for.
  134308. * @return The highlight layer if found otherwise null.
  134309. */
  134310. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  134311. }
  134312. /**
  134313. * Highlight layer options. This helps customizing the behaviour
  134314. * of the highlight layer.
  134315. */
  134316. export interface IHighlightLayerOptions {
  134317. /**
  134318. * Multiplication factor apply to the canvas size to compute the render target size
  134319. * used to generated the glowing objects (the smaller the faster).
  134320. */
  134321. mainTextureRatio: number;
  134322. /**
  134323. * Enforces a fixed size texture to ensure resize independant blur.
  134324. */
  134325. mainTextureFixedSize?: number;
  134326. /**
  134327. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  134328. * of the picture to blur (the smaller the faster).
  134329. */
  134330. blurTextureSizeRatio: number;
  134331. /**
  134332. * How big in texel of the blur texture is the vertical blur.
  134333. */
  134334. blurVerticalSize: number;
  134335. /**
  134336. * How big in texel of the blur texture is the horizontal blur.
  134337. */
  134338. blurHorizontalSize: number;
  134339. /**
  134340. * Alpha blending mode used to apply the blur. Default is combine.
  134341. */
  134342. alphaBlendingMode: number;
  134343. /**
  134344. * The camera attached to the layer.
  134345. */
  134346. camera: Nullable<Camera>;
  134347. /**
  134348. * Should we display highlight as a solid stroke?
  134349. */
  134350. isStroke?: boolean;
  134351. /**
  134352. * The rendering group to draw the layer in.
  134353. */
  134354. renderingGroupId: number;
  134355. }
  134356. /**
  134357. * The highlight layer Helps adding a glow effect around a mesh.
  134358. *
  134359. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  134360. * glowy meshes to your scene.
  134361. *
  134362. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  134363. */
  134364. export class HighlightLayer extends EffectLayer {
  134365. name: string;
  134366. /**
  134367. * Effect Name of the highlight layer.
  134368. */
  134369. static readonly EffectName: string;
  134370. /**
  134371. * The neutral color used during the preparation of the glow effect.
  134372. * This is black by default as the blend operation is a blend operation.
  134373. */
  134374. static NeutralColor: Color4;
  134375. /**
  134376. * Stencil value used for glowing meshes.
  134377. */
  134378. static GlowingMeshStencilReference: number;
  134379. /**
  134380. * Stencil value used for the other meshes in the scene.
  134381. */
  134382. static NormalMeshStencilReference: number;
  134383. /**
  134384. * Specifies whether or not the inner glow is ACTIVE in the layer.
  134385. */
  134386. innerGlow: boolean;
  134387. /**
  134388. * Specifies whether or not the outer glow is ACTIVE in the layer.
  134389. */
  134390. outerGlow: boolean;
  134391. /**
  134392. * Specifies the horizontal size of the blur.
  134393. */
  134394. set blurHorizontalSize(value: number);
  134395. /**
  134396. * Specifies the vertical size of the blur.
  134397. */
  134398. set blurVerticalSize(value: number);
  134399. /**
  134400. * Gets the horizontal size of the blur.
  134401. */
  134402. get blurHorizontalSize(): number;
  134403. /**
  134404. * Gets the vertical size of the blur.
  134405. */
  134406. get blurVerticalSize(): number;
  134407. /**
  134408. * An event triggered when the highlight layer is being blurred.
  134409. */
  134410. onBeforeBlurObservable: Observable<HighlightLayer>;
  134411. /**
  134412. * An event triggered when the highlight layer has been blurred.
  134413. */
  134414. onAfterBlurObservable: Observable<HighlightLayer>;
  134415. private _instanceGlowingMeshStencilReference;
  134416. private _options;
  134417. private _downSamplePostprocess;
  134418. private _horizontalBlurPostprocess;
  134419. private _verticalBlurPostprocess;
  134420. private _blurTexture;
  134421. private _meshes;
  134422. private _excludedMeshes;
  134423. /**
  134424. * Instantiates a new highlight Layer and references it to the scene..
  134425. * @param name The name of the layer
  134426. * @param scene The scene to use the layer in
  134427. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  134428. */
  134429. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  134430. /**
  134431. * Get the effect name of the layer.
  134432. * @return The effect name
  134433. */
  134434. getEffectName(): string;
  134435. /**
  134436. * Create the merge effect. This is the shader use to blit the information back
  134437. * to the main canvas at the end of the scene rendering.
  134438. */
  134439. protected _createMergeEffect(): Effect;
  134440. /**
  134441. * Creates the render target textures and post processes used in the highlight layer.
  134442. */
  134443. protected _createTextureAndPostProcesses(): void;
  134444. /**
  134445. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  134446. */
  134447. needStencil(): boolean;
  134448. /**
  134449. * Checks for the readiness of the element composing the layer.
  134450. * @param subMesh the mesh to check for
  134451. * @param useInstances specify wether or not to use instances to render the mesh
  134452. * @param emissiveTexture the associated emissive texture used to generate the glow
  134453. * @return true if ready otherwise, false
  134454. */
  134455. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  134456. /**
  134457. * Implementation specific of rendering the generating effect on the main canvas.
  134458. * @param effect The effect used to render through
  134459. */
  134460. protected _internalRender(effect: Effect): void;
  134461. /**
  134462. * Returns true if the layer contains information to display, otherwise false.
  134463. */
  134464. shouldRender(): boolean;
  134465. /**
  134466. * Returns true if the mesh should render, otherwise false.
  134467. * @param mesh The mesh to render
  134468. * @returns true if it should render otherwise false
  134469. */
  134470. protected _shouldRenderMesh(mesh: Mesh): boolean;
  134471. /**
  134472. * Adds specific effects defines.
  134473. * @param defines The defines to add specifics to.
  134474. */
  134475. protected _addCustomEffectDefines(defines: string[]): void;
  134476. /**
  134477. * Sets the required values for both the emissive texture and and the main color.
  134478. */
  134479. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  134480. /**
  134481. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  134482. * @param mesh The mesh to exclude from the highlight layer
  134483. */
  134484. addExcludedMesh(mesh: Mesh): void;
  134485. /**
  134486. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  134487. * @param mesh The mesh to highlight
  134488. */
  134489. removeExcludedMesh(mesh: Mesh): void;
  134490. /**
  134491. * Determine if a given mesh will be highlighted by the current HighlightLayer
  134492. * @param mesh mesh to test
  134493. * @returns true if the mesh will be highlighted by the current HighlightLayer
  134494. */
  134495. hasMesh(mesh: AbstractMesh): boolean;
  134496. /**
  134497. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  134498. * @param mesh The mesh to highlight
  134499. * @param color The color of the highlight
  134500. * @param glowEmissiveOnly Extract the glow from the emissive texture
  134501. */
  134502. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  134503. /**
  134504. * Remove a mesh from the highlight layer in order to make it stop glowing.
  134505. * @param mesh The mesh to highlight
  134506. */
  134507. removeMesh(mesh: Mesh): void;
  134508. /**
  134509. * Remove all the meshes currently referenced in the highlight layer
  134510. */
  134511. removeAllMeshes(): void;
  134512. /**
  134513. * Force the stencil to the normal expected value for none glowing parts
  134514. */
  134515. private _defaultStencilReference;
  134516. /**
  134517. * Free any resources and references associated to a mesh.
  134518. * Internal use
  134519. * @param mesh The mesh to free.
  134520. * @hidden
  134521. */
  134522. _disposeMesh(mesh: Mesh): void;
  134523. /**
  134524. * Dispose the highlight layer and free resources.
  134525. */
  134526. dispose(): void;
  134527. /**
  134528. * Gets the class name of the effect layer
  134529. * @returns the string with the class name of the effect layer
  134530. */
  134531. getClassName(): string;
  134532. /**
  134533. * Serializes this Highlight layer
  134534. * @returns a serialized Highlight layer object
  134535. */
  134536. serialize(): any;
  134537. /**
  134538. * Creates a Highlight layer from parsed Highlight layer data
  134539. * @param parsedHightlightLayer defines the Highlight layer data
  134540. * @param scene defines the current scene
  134541. * @param rootUrl defines the root URL containing the Highlight layer information
  134542. * @returns a parsed Highlight layer
  134543. */
  134544. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  134545. }
  134546. }
  134547. declare module BABYLON {
  134548. interface AbstractScene {
  134549. /**
  134550. * The list of layers (background and foreground) of the scene
  134551. */
  134552. layers: Array<Layer>;
  134553. }
  134554. /**
  134555. * Defines the layer scene component responsible to manage any layers
  134556. * in a given scene.
  134557. */
  134558. export class LayerSceneComponent implements ISceneComponent {
  134559. /**
  134560. * The component name helpfull to identify the component in the list of scene components.
  134561. */
  134562. readonly name: string;
  134563. /**
  134564. * The scene the component belongs to.
  134565. */
  134566. scene: Scene;
  134567. private _engine;
  134568. /**
  134569. * Creates a new instance of the component for the given scene
  134570. * @param scene Defines the scene to register the component in
  134571. */
  134572. constructor(scene: Scene);
  134573. /**
  134574. * Registers the component in a given scene
  134575. */
  134576. register(): void;
  134577. /**
  134578. * Rebuilds the elements related to this component in case of
  134579. * context lost for instance.
  134580. */
  134581. rebuild(): void;
  134582. /**
  134583. * Disposes the component and the associated ressources.
  134584. */
  134585. dispose(): void;
  134586. private _draw;
  134587. private _drawCameraPredicate;
  134588. private _drawCameraBackground;
  134589. private _drawCameraForeground;
  134590. private _drawRenderTargetPredicate;
  134591. private _drawRenderTargetBackground;
  134592. private _drawRenderTargetForeground;
  134593. /**
  134594. * Adds all the elements from the container to the scene
  134595. * @param container the container holding the elements
  134596. */
  134597. addFromContainer(container: AbstractScene): void;
  134598. /**
  134599. * Removes all the elements in the container from the scene
  134600. * @param container contains the elements to remove
  134601. * @param dispose if the removed element should be disposed (default: false)
  134602. */
  134603. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  134604. }
  134605. }
  134606. declare module BABYLON {
  134607. /** @hidden */
  134608. export var layerPixelShader: {
  134609. name: string;
  134610. shader: string;
  134611. };
  134612. }
  134613. declare module BABYLON {
  134614. /** @hidden */
  134615. export var layerVertexShader: {
  134616. name: string;
  134617. shader: string;
  134618. };
  134619. }
  134620. declare module BABYLON {
  134621. /**
  134622. * This represents a full screen 2d layer.
  134623. * This can be useful to display a picture in the background of your scene for instance.
  134624. * @see https://www.babylonjs-playground.com/#08A2BS#1
  134625. */
  134626. export class Layer {
  134627. /**
  134628. * Define the name of the layer.
  134629. */
  134630. name: string;
  134631. /**
  134632. * Define the texture the layer should display.
  134633. */
  134634. texture: Nullable<Texture>;
  134635. /**
  134636. * Is the layer in background or foreground.
  134637. */
  134638. isBackground: boolean;
  134639. /**
  134640. * Define the color of the layer (instead of texture).
  134641. */
  134642. color: Color4;
  134643. /**
  134644. * Define the scale of the layer in order to zoom in out of the texture.
  134645. */
  134646. scale: Vector2;
  134647. /**
  134648. * Define an offset for the layer in order to shift the texture.
  134649. */
  134650. offset: Vector2;
  134651. /**
  134652. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  134653. */
  134654. alphaBlendingMode: number;
  134655. /**
  134656. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  134657. * Alpha test will not mix with the background color in case of transparency.
  134658. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  134659. */
  134660. alphaTest: boolean;
  134661. /**
  134662. * Define a mask to restrict the layer to only some of the scene cameras.
  134663. */
  134664. layerMask: number;
  134665. /**
  134666. * Define the list of render target the layer is visible into.
  134667. */
  134668. renderTargetTextures: RenderTargetTexture[];
  134669. /**
  134670. * Define if the layer is only used in renderTarget or if it also
  134671. * renders in the main frame buffer of the canvas.
  134672. */
  134673. renderOnlyInRenderTargetTextures: boolean;
  134674. private _scene;
  134675. private _vertexBuffers;
  134676. private _indexBuffer;
  134677. private _effect;
  134678. private _previousDefines;
  134679. /**
  134680. * An event triggered when the layer is disposed.
  134681. */
  134682. onDisposeObservable: Observable<Layer>;
  134683. private _onDisposeObserver;
  134684. /**
  134685. * Back compatibility with callback before the onDisposeObservable existed.
  134686. * The set callback will be triggered when the layer has been disposed.
  134687. */
  134688. set onDispose(callback: () => void);
  134689. /**
  134690. * An event triggered before rendering the scene
  134691. */
  134692. onBeforeRenderObservable: Observable<Layer>;
  134693. private _onBeforeRenderObserver;
  134694. /**
  134695. * Back compatibility with callback before the onBeforeRenderObservable existed.
  134696. * The set callback will be triggered just before rendering the layer.
  134697. */
  134698. set onBeforeRender(callback: () => void);
  134699. /**
  134700. * An event triggered after rendering the scene
  134701. */
  134702. onAfterRenderObservable: Observable<Layer>;
  134703. private _onAfterRenderObserver;
  134704. /**
  134705. * Back compatibility with callback before the onAfterRenderObservable existed.
  134706. * The set callback will be triggered just after rendering the layer.
  134707. */
  134708. set onAfterRender(callback: () => void);
  134709. /**
  134710. * Instantiates a new layer.
  134711. * This represents a full screen 2d layer.
  134712. * This can be useful to display a picture in the background of your scene for instance.
  134713. * @see https://www.babylonjs-playground.com/#08A2BS#1
  134714. * @param name Define the name of the layer in the scene
  134715. * @param imgUrl Define the url of the texture to display in the layer
  134716. * @param scene Define the scene the layer belongs to
  134717. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  134718. * @param color Defines a color for the layer
  134719. */
  134720. constructor(
  134721. /**
  134722. * Define the name of the layer.
  134723. */
  134724. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  134725. private _createIndexBuffer;
  134726. /** @hidden */
  134727. _rebuild(): void;
  134728. /**
  134729. * Renders the layer in the scene.
  134730. */
  134731. render(): void;
  134732. /**
  134733. * Disposes and releases the associated ressources.
  134734. */
  134735. dispose(): void;
  134736. }
  134737. }
  134738. declare module BABYLON {
  134739. /** @hidden */
  134740. export var lensFlarePixelShader: {
  134741. name: string;
  134742. shader: string;
  134743. };
  134744. }
  134745. declare module BABYLON {
  134746. /** @hidden */
  134747. export var lensFlareVertexShader: {
  134748. name: string;
  134749. shader: string;
  134750. };
  134751. }
  134752. declare module BABYLON {
  134753. /**
  134754. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  134755. * It is usually composed of several `lensFlare`.
  134756. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134757. */
  134758. export class LensFlareSystem {
  134759. /**
  134760. * Define the name of the lens flare system
  134761. */
  134762. name: string;
  134763. /**
  134764. * List of lens flares used in this system.
  134765. */
  134766. lensFlares: LensFlare[];
  134767. /**
  134768. * Define a limit from the border the lens flare can be visible.
  134769. */
  134770. borderLimit: number;
  134771. /**
  134772. * Define a viewport border we do not want to see the lens flare in.
  134773. */
  134774. viewportBorder: number;
  134775. /**
  134776. * Define a predicate which could limit the list of meshes able to occlude the effect.
  134777. */
  134778. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  134779. /**
  134780. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  134781. */
  134782. layerMask: number;
  134783. /**
  134784. * Define the id of the lens flare system in the scene.
  134785. * (equal to name by default)
  134786. */
  134787. id: string;
  134788. private _scene;
  134789. private _emitter;
  134790. private _vertexBuffers;
  134791. private _indexBuffer;
  134792. private _effect;
  134793. private _positionX;
  134794. private _positionY;
  134795. private _isEnabled;
  134796. /** @hidden */
  134797. static _SceneComponentInitialization: (scene: Scene) => void;
  134798. /**
  134799. * Instantiates a lens flare system.
  134800. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  134801. * It is usually composed of several `lensFlare`.
  134802. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134803. * @param name Define the name of the lens flare system in the scene
  134804. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  134805. * @param scene Define the scene the lens flare system belongs to
  134806. */
  134807. constructor(
  134808. /**
  134809. * Define the name of the lens flare system
  134810. */
  134811. name: string, emitter: any, scene: Scene);
  134812. /**
  134813. * Define if the lens flare system is enabled.
  134814. */
  134815. get isEnabled(): boolean;
  134816. set isEnabled(value: boolean);
  134817. /**
  134818. * Get the scene the effects belongs to.
  134819. * @returns the scene holding the lens flare system
  134820. */
  134821. getScene(): Scene;
  134822. /**
  134823. * Get the emitter of the lens flare system.
  134824. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  134825. * @returns the emitter of the lens flare system
  134826. */
  134827. getEmitter(): any;
  134828. /**
  134829. * Set the emitter of the lens flare system.
  134830. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  134831. * @param newEmitter Define the new emitter of the system
  134832. */
  134833. setEmitter(newEmitter: any): void;
  134834. /**
  134835. * Get the lens flare system emitter position.
  134836. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  134837. * @returns the position
  134838. */
  134839. getEmitterPosition(): Vector3;
  134840. /**
  134841. * @hidden
  134842. */
  134843. computeEffectivePosition(globalViewport: Viewport): boolean;
  134844. /** @hidden */
  134845. _isVisible(): boolean;
  134846. /**
  134847. * @hidden
  134848. */
  134849. render(): boolean;
  134850. /**
  134851. * Dispose and release the lens flare with its associated resources.
  134852. */
  134853. dispose(): void;
  134854. /**
  134855. * Parse a lens flare system from a JSON repressentation
  134856. * @param parsedLensFlareSystem Define the JSON to parse
  134857. * @param scene Define the scene the parsed system should be instantiated in
  134858. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  134859. * @returns the parsed system
  134860. */
  134861. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  134862. /**
  134863. * Serialize the current Lens Flare System into a JSON representation.
  134864. * @returns the serialized JSON
  134865. */
  134866. serialize(): any;
  134867. }
  134868. }
  134869. declare module BABYLON {
  134870. /**
  134871. * This represents one of the lens effect in a `lensFlareSystem`.
  134872. * It controls one of the indiviual texture used in the effect.
  134873. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134874. */
  134875. export class LensFlare {
  134876. /**
  134877. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  134878. */
  134879. size: number;
  134880. /**
  134881. * 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.
  134882. */
  134883. position: number;
  134884. /**
  134885. * Define the lens color.
  134886. */
  134887. color: Color3;
  134888. /**
  134889. * Define the lens texture.
  134890. */
  134891. texture: Nullable<Texture>;
  134892. /**
  134893. * Define the alpha mode to render this particular lens.
  134894. */
  134895. alphaMode: number;
  134896. private _system;
  134897. /**
  134898. * Creates a new Lens Flare.
  134899. * This represents one of the lens effect in a `lensFlareSystem`.
  134900. * It controls one of the indiviual texture used in the effect.
  134901. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134902. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  134903. * @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.
  134904. * @param color Define the lens color
  134905. * @param imgUrl Define the lens texture url
  134906. * @param system Define the `lensFlareSystem` this flare is part of
  134907. * @returns The newly created Lens Flare
  134908. */
  134909. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  134910. /**
  134911. * Instantiates a new Lens Flare.
  134912. * This represents one of the lens effect in a `lensFlareSystem`.
  134913. * It controls one of the indiviual texture used in the effect.
  134914. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134915. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  134916. * @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.
  134917. * @param color Define the lens color
  134918. * @param imgUrl Define the lens texture url
  134919. * @param system Define the `lensFlareSystem` this flare is part of
  134920. */
  134921. constructor(
  134922. /**
  134923. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  134924. */
  134925. size: number,
  134926. /**
  134927. * 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.
  134928. */
  134929. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  134930. /**
  134931. * Dispose and release the lens flare with its associated resources.
  134932. */
  134933. dispose(): void;
  134934. }
  134935. }
  134936. declare module BABYLON {
  134937. interface AbstractScene {
  134938. /**
  134939. * The list of lens flare system added to the scene
  134940. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134941. */
  134942. lensFlareSystems: Array<LensFlareSystem>;
  134943. /**
  134944. * Removes the given lens flare system from this scene.
  134945. * @param toRemove The lens flare system to remove
  134946. * @returns The index of the removed lens flare system
  134947. */
  134948. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  134949. /**
  134950. * Adds the given lens flare system to this scene
  134951. * @param newLensFlareSystem The lens flare system to add
  134952. */
  134953. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  134954. /**
  134955. * Gets a lens flare system using its name
  134956. * @param name defines the name to look for
  134957. * @returns the lens flare system or null if not found
  134958. */
  134959. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  134960. /**
  134961. * Gets a lens flare system using its id
  134962. * @param id defines the id to look for
  134963. * @returns the lens flare system or null if not found
  134964. */
  134965. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  134966. }
  134967. /**
  134968. * Defines the lens flare scene component responsible to manage any lens flares
  134969. * in a given scene.
  134970. */
  134971. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  134972. /**
  134973. * The component name helpfull to identify the component in the list of scene components.
  134974. */
  134975. readonly name: string;
  134976. /**
  134977. * The scene the component belongs to.
  134978. */
  134979. scene: Scene;
  134980. /**
  134981. * Creates a new instance of the component for the given scene
  134982. * @param scene Defines the scene to register the component in
  134983. */
  134984. constructor(scene: Scene);
  134985. /**
  134986. * Registers the component in a given scene
  134987. */
  134988. register(): void;
  134989. /**
  134990. * Rebuilds the elements related to this component in case of
  134991. * context lost for instance.
  134992. */
  134993. rebuild(): void;
  134994. /**
  134995. * Adds all the elements from the container to the scene
  134996. * @param container the container holding the elements
  134997. */
  134998. addFromContainer(container: AbstractScene): void;
  134999. /**
  135000. * Removes all the elements in the container from the scene
  135001. * @param container contains the elements to remove
  135002. * @param dispose if the removed element should be disposed (default: false)
  135003. */
  135004. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135005. /**
  135006. * Serializes the component data to the specified json object
  135007. * @param serializationObject The object to serialize to
  135008. */
  135009. serialize(serializationObject: any): void;
  135010. /**
  135011. * Disposes the component and the associated ressources.
  135012. */
  135013. dispose(): void;
  135014. private _draw;
  135015. }
  135016. }
  135017. declare module BABYLON {
  135018. /** @hidden */
  135019. export var depthPixelShader: {
  135020. name: string;
  135021. shader: string;
  135022. };
  135023. }
  135024. declare module BABYLON {
  135025. /** @hidden */
  135026. export var depthVertexShader: {
  135027. name: string;
  135028. shader: string;
  135029. };
  135030. }
  135031. declare module BABYLON {
  135032. /**
  135033. * This represents a depth renderer in Babylon.
  135034. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  135035. */
  135036. export class DepthRenderer {
  135037. private _scene;
  135038. private _depthMap;
  135039. private _effect;
  135040. private readonly _storeNonLinearDepth;
  135041. private readonly _clearColor;
  135042. /** Get if the depth renderer is using packed depth or not */
  135043. readonly isPacked: boolean;
  135044. private _cachedDefines;
  135045. private _camera;
  135046. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  135047. enabled: boolean;
  135048. /**
  135049. * Specifiess that the depth renderer will only be used within
  135050. * the camera it is created for.
  135051. * This can help forcing its rendering during the camera processing.
  135052. */
  135053. useOnlyInActiveCamera: boolean;
  135054. /** @hidden */
  135055. static _SceneComponentInitialization: (scene: Scene) => void;
  135056. /**
  135057. * Instantiates a depth renderer
  135058. * @param scene The scene the renderer belongs to
  135059. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  135060. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  135061. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  135062. */
  135063. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  135064. /**
  135065. * Creates the depth rendering effect and checks if the effect is ready.
  135066. * @param subMesh The submesh to be used to render the depth map of
  135067. * @param useInstances If multiple world instances should be used
  135068. * @returns if the depth renderer is ready to render the depth map
  135069. */
  135070. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135071. /**
  135072. * Gets the texture which the depth map will be written to.
  135073. * @returns The depth map texture
  135074. */
  135075. getDepthMap(): RenderTargetTexture;
  135076. /**
  135077. * Disposes of the depth renderer.
  135078. */
  135079. dispose(): void;
  135080. }
  135081. }
  135082. declare module BABYLON {
  135083. /** @hidden */
  135084. export var minmaxReduxPixelShader: {
  135085. name: string;
  135086. shader: string;
  135087. };
  135088. }
  135089. declare module BABYLON {
  135090. /**
  135091. * This class computes a min/max reduction from a texture: it means it computes the minimum
  135092. * and maximum values from all values of the texture.
  135093. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  135094. * The source values are read from the red channel of the texture.
  135095. */
  135096. export class MinMaxReducer {
  135097. /**
  135098. * Observable triggered when the computation has been performed
  135099. */
  135100. onAfterReductionPerformed: Observable<{
  135101. min: number;
  135102. max: number;
  135103. }>;
  135104. protected _camera: Camera;
  135105. protected _sourceTexture: Nullable<RenderTargetTexture>;
  135106. protected _reductionSteps: Nullable<Array<PostProcess>>;
  135107. protected _postProcessManager: PostProcessManager;
  135108. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  135109. protected _forceFullscreenViewport: boolean;
  135110. /**
  135111. * Creates a min/max reducer
  135112. * @param camera The camera to use for the post processes
  135113. */
  135114. constructor(camera: Camera);
  135115. /**
  135116. * Gets the texture used to read the values from.
  135117. */
  135118. get sourceTexture(): Nullable<RenderTargetTexture>;
  135119. /**
  135120. * Sets the source texture to read the values from.
  135121. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  135122. * because in such textures '1' value must not be taken into account to compute the maximum
  135123. * as this value is used to clear the texture.
  135124. * Note that the computation is not activated by calling this function, you must call activate() for that!
  135125. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  135126. * @param depthRedux Indicates if the texture is a depth texture or not
  135127. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  135128. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  135129. */
  135130. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  135131. /**
  135132. * Defines the refresh rate of the computation.
  135133. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  135134. */
  135135. get refreshRate(): number;
  135136. set refreshRate(value: number);
  135137. protected _activated: boolean;
  135138. /**
  135139. * Gets the activation status of the reducer
  135140. */
  135141. get activated(): boolean;
  135142. /**
  135143. * Activates the reduction computation.
  135144. * When activated, the observers registered in onAfterReductionPerformed are
  135145. * called after the compuation is performed
  135146. */
  135147. activate(): void;
  135148. /**
  135149. * Deactivates the reduction computation.
  135150. */
  135151. deactivate(): void;
  135152. /**
  135153. * Disposes the min/max reducer
  135154. * @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.
  135155. */
  135156. dispose(disposeAll?: boolean): void;
  135157. }
  135158. }
  135159. declare module BABYLON {
  135160. /**
  135161. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  135162. */
  135163. export class DepthReducer extends MinMaxReducer {
  135164. private _depthRenderer;
  135165. private _depthRendererId;
  135166. /**
  135167. * Gets the depth renderer used for the computation.
  135168. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  135169. */
  135170. get depthRenderer(): Nullable<DepthRenderer>;
  135171. /**
  135172. * Creates a depth reducer
  135173. * @param camera The camera used to render the depth texture
  135174. */
  135175. constructor(camera: Camera);
  135176. /**
  135177. * Sets the depth renderer to use to generate the depth map
  135178. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  135179. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  135180. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  135181. */
  135182. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  135183. /** @hidden */
  135184. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  135185. /**
  135186. * Activates the reduction computation.
  135187. * When activated, the observers registered in onAfterReductionPerformed are
  135188. * called after the compuation is performed
  135189. */
  135190. activate(): void;
  135191. /**
  135192. * Deactivates the reduction computation.
  135193. */
  135194. deactivate(): void;
  135195. /**
  135196. * Disposes the depth reducer
  135197. * @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.
  135198. */
  135199. dispose(disposeAll?: boolean): void;
  135200. }
  135201. }
  135202. declare module BABYLON {
  135203. /**
  135204. * A CSM implementation allowing casting shadows on large scenes.
  135205. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  135206. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  135207. */
  135208. export class CascadedShadowGenerator extends ShadowGenerator {
  135209. private static readonly frustumCornersNDCSpace;
  135210. /**
  135211. * Name of the CSM class
  135212. */
  135213. static CLASSNAME: string;
  135214. /**
  135215. * Defines the default number of cascades used by the CSM.
  135216. */
  135217. static readonly DEFAULT_CASCADES_COUNT: number;
  135218. /**
  135219. * Defines the minimum number of cascades used by the CSM.
  135220. */
  135221. static readonly MIN_CASCADES_COUNT: number;
  135222. /**
  135223. * Defines the maximum number of cascades used by the CSM.
  135224. */
  135225. static readonly MAX_CASCADES_COUNT: number;
  135226. protected _validateFilter(filter: number): number;
  135227. /**
  135228. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  135229. */
  135230. penumbraDarkness: number;
  135231. private _numCascades;
  135232. /**
  135233. * Gets or set the number of cascades used by the CSM.
  135234. */
  135235. get numCascades(): number;
  135236. set numCascades(value: number);
  135237. /**
  135238. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  135239. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  135240. */
  135241. stabilizeCascades: boolean;
  135242. private _freezeShadowCastersBoundingInfo;
  135243. private _freezeShadowCastersBoundingInfoObservable;
  135244. /**
  135245. * Enables or disables the shadow casters bounding info computation.
  135246. * If your shadow casters don't move, you can disable this feature.
  135247. * If it is enabled, the bounding box computation is done every frame.
  135248. */
  135249. get freezeShadowCastersBoundingInfo(): boolean;
  135250. set freezeShadowCastersBoundingInfo(freeze: boolean);
  135251. private _scbiMin;
  135252. private _scbiMax;
  135253. protected _computeShadowCastersBoundingInfo(): void;
  135254. protected _shadowCastersBoundingInfo: BoundingInfo;
  135255. /**
  135256. * Gets or sets the shadow casters bounding info.
  135257. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  135258. * so that the system won't overwrite the bounds you provide
  135259. */
  135260. get shadowCastersBoundingInfo(): BoundingInfo;
  135261. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  135262. protected _breaksAreDirty: boolean;
  135263. protected _minDistance: number;
  135264. protected _maxDistance: number;
  135265. /**
  135266. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  135267. *
  135268. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  135269. * If you don't know these values, simply leave them to their defaults and don't call this function.
  135270. * @param min minimal distance for the breaks (default to 0.)
  135271. * @param max maximal distance for the breaks (default to 1.)
  135272. */
  135273. setMinMaxDistance(min: number, max: number): void;
  135274. /** Gets the minimal distance used in the cascade break computation */
  135275. get minDistance(): number;
  135276. /** Gets the maximal distance used in the cascade break computation */
  135277. get maxDistance(): number;
  135278. /**
  135279. * Gets the class name of that object
  135280. * @returns "CascadedShadowGenerator"
  135281. */
  135282. getClassName(): string;
  135283. private _cascadeMinExtents;
  135284. private _cascadeMaxExtents;
  135285. /**
  135286. * Gets a cascade minimum extents
  135287. * @param cascadeIndex index of the cascade
  135288. * @returns the minimum cascade extents
  135289. */
  135290. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  135291. /**
  135292. * Gets a cascade maximum extents
  135293. * @param cascadeIndex index of the cascade
  135294. * @returns the maximum cascade extents
  135295. */
  135296. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  135297. private _cascades;
  135298. private _currentLayer;
  135299. private _viewSpaceFrustumsZ;
  135300. private _viewMatrices;
  135301. private _projectionMatrices;
  135302. private _transformMatrices;
  135303. private _transformMatricesAsArray;
  135304. private _frustumLengths;
  135305. private _lightSizeUVCorrection;
  135306. private _depthCorrection;
  135307. private _frustumCornersWorldSpace;
  135308. private _frustumCenter;
  135309. private _shadowCameraPos;
  135310. private _shadowMaxZ;
  135311. /**
  135312. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  135313. * It defaults to camera.maxZ
  135314. */
  135315. get shadowMaxZ(): number;
  135316. /**
  135317. * Sets the shadow max z distance.
  135318. */
  135319. set shadowMaxZ(value: number);
  135320. protected _debug: boolean;
  135321. /**
  135322. * Gets or sets the debug flag.
  135323. * When enabled, the cascades are materialized by different colors on the screen.
  135324. */
  135325. get debug(): boolean;
  135326. set debug(dbg: boolean);
  135327. private _depthClamp;
  135328. /**
  135329. * Gets or sets the depth clamping value.
  135330. *
  135331. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  135332. * to account for the shadow casters far away.
  135333. *
  135334. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  135335. */
  135336. get depthClamp(): boolean;
  135337. set depthClamp(value: boolean);
  135338. private _cascadeBlendPercentage;
  135339. /**
  135340. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  135341. * It defaults to 0.1 (10% blending).
  135342. */
  135343. get cascadeBlendPercentage(): number;
  135344. set cascadeBlendPercentage(value: number);
  135345. private _lambda;
  135346. /**
  135347. * Gets or set the lambda parameter.
  135348. * This parameter is used to split the camera frustum and create the cascades.
  135349. * 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.
  135350. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  135351. */
  135352. get lambda(): number;
  135353. set lambda(value: number);
  135354. /**
  135355. * Gets the view matrix corresponding to a given cascade
  135356. * @param cascadeNum cascade to retrieve the view matrix from
  135357. * @returns the cascade view matrix
  135358. */
  135359. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  135360. /**
  135361. * Gets the projection matrix corresponding to a given cascade
  135362. * @param cascadeNum cascade to retrieve the projection matrix from
  135363. * @returns the cascade projection matrix
  135364. */
  135365. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  135366. /**
  135367. * Gets the transformation matrix corresponding to a given cascade
  135368. * @param cascadeNum cascade to retrieve the transformation matrix from
  135369. * @returns the cascade transformation matrix
  135370. */
  135371. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  135372. private _depthRenderer;
  135373. /**
  135374. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  135375. *
  135376. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  135377. *
  135378. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  135379. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  135380. * @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
  135381. */
  135382. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  135383. private _depthReducer;
  135384. private _autoCalcDepthBounds;
  135385. /**
  135386. * Gets or sets the autoCalcDepthBounds property.
  135387. *
  135388. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  135389. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  135390. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  135391. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  135392. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  135393. */
  135394. get autoCalcDepthBounds(): boolean;
  135395. set autoCalcDepthBounds(value: boolean);
  135396. /**
  135397. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  135398. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  135399. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  135400. * for setting the refresh rate on the renderer yourself!
  135401. */
  135402. get autoCalcDepthBoundsRefreshRate(): number;
  135403. set autoCalcDepthBoundsRefreshRate(value: number);
  135404. /**
  135405. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  135406. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  135407. * you change the camera near/far planes!
  135408. */
  135409. splitFrustum(): void;
  135410. private _splitFrustum;
  135411. private _computeMatrices;
  135412. private _computeFrustumInWorldSpace;
  135413. private _computeCascadeFrustum;
  135414. /**
  135415. * Support test.
  135416. */
  135417. static get IsSupported(): boolean;
  135418. /** @hidden */
  135419. static _SceneComponentInitialization: (scene: Scene) => void;
  135420. /**
  135421. * Creates a Cascaded Shadow Generator object.
  135422. * A ShadowGenerator is the required tool to use the shadows.
  135423. * Each directional light casting shadows needs to use its own ShadowGenerator.
  135424. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  135425. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  135426. * @param light The directional light object generating the shadows.
  135427. * @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.
  135428. */
  135429. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  135430. protected _initializeGenerator(): void;
  135431. protected _createTargetRenderTexture(): void;
  135432. protected _initializeShadowMap(): void;
  135433. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  135434. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  135435. /**
  135436. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  135437. * @param defines Defines of the material we want to update
  135438. * @param lightIndex Index of the light in the enabled light list of the material
  135439. */
  135440. prepareDefines(defines: any, lightIndex: number): void;
  135441. /**
  135442. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  135443. * defined in the generator but impacting the effect).
  135444. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  135445. * @param effect The effect we are binfing the information for
  135446. */
  135447. bindShadowLight(lightIndex: string, effect: Effect): void;
  135448. /**
  135449. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  135450. * (eq to view projection * shadow projection matrices)
  135451. * @returns The transform matrix used to create the shadow map
  135452. */
  135453. getTransformMatrix(): Matrix;
  135454. /**
  135455. * Disposes the ShadowGenerator.
  135456. * Returns nothing.
  135457. */
  135458. dispose(): void;
  135459. /**
  135460. * Serializes the shadow generator setup to a json object.
  135461. * @returns The serialized JSON object
  135462. */
  135463. serialize(): any;
  135464. /**
  135465. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  135466. * @param parsedShadowGenerator The JSON object to parse
  135467. * @param scene The scene to create the shadow map for
  135468. * @returns The parsed shadow generator
  135469. */
  135470. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  135471. }
  135472. }
  135473. declare module BABYLON {
  135474. /**
  135475. * Defines the shadow generator component responsible to manage any shadow generators
  135476. * in a given scene.
  135477. */
  135478. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  135479. /**
  135480. * The component name helpfull to identify the component in the list of scene components.
  135481. */
  135482. readonly name: string;
  135483. /**
  135484. * The scene the component belongs to.
  135485. */
  135486. scene: Scene;
  135487. /**
  135488. * Creates a new instance of the component for the given scene
  135489. * @param scene Defines the scene to register the component in
  135490. */
  135491. constructor(scene: Scene);
  135492. /**
  135493. * Registers the component in a given scene
  135494. */
  135495. register(): void;
  135496. /**
  135497. * Rebuilds the elements related to this component in case of
  135498. * context lost for instance.
  135499. */
  135500. rebuild(): void;
  135501. /**
  135502. * Serializes the component data to the specified json object
  135503. * @param serializationObject The object to serialize to
  135504. */
  135505. serialize(serializationObject: any): void;
  135506. /**
  135507. * Adds all the elements from the container to the scene
  135508. * @param container the container holding the elements
  135509. */
  135510. addFromContainer(container: AbstractScene): void;
  135511. /**
  135512. * Removes all the elements in the container from the scene
  135513. * @param container contains the elements to remove
  135514. * @param dispose if the removed element should be disposed (default: false)
  135515. */
  135516. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135517. /**
  135518. * Rebuilds the elements related to this component in case of
  135519. * context lost for instance.
  135520. */
  135521. dispose(): void;
  135522. private _gatherRenderTargets;
  135523. }
  135524. }
  135525. declare module BABYLON {
  135526. /**
  135527. * A point light is a light defined by an unique point in world space.
  135528. * The light is emitted in every direction from this point.
  135529. * A good example of a point light is a standard light bulb.
  135530. * Documentation: https://doc.babylonjs.com/babylon101/lights
  135531. */
  135532. export class PointLight extends ShadowLight {
  135533. private _shadowAngle;
  135534. /**
  135535. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  135536. * This specifies what angle the shadow will use to be created.
  135537. *
  135538. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  135539. */
  135540. get shadowAngle(): number;
  135541. /**
  135542. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  135543. * This specifies what angle the shadow will use to be created.
  135544. *
  135545. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  135546. */
  135547. set shadowAngle(value: number);
  135548. /**
  135549. * Gets the direction if it has been set.
  135550. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  135551. */
  135552. get direction(): Vector3;
  135553. /**
  135554. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  135555. */
  135556. set direction(value: Vector3);
  135557. /**
  135558. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  135559. * A PointLight emits the light in every direction.
  135560. * It can cast shadows.
  135561. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  135562. * ```javascript
  135563. * var pointLight = new PointLight("pl", camera.position, scene);
  135564. * ```
  135565. * Documentation : https://doc.babylonjs.com/babylon101/lights
  135566. * @param name The light friendly name
  135567. * @param position The position of the point light in the scene
  135568. * @param scene The scene the lights belongs to
  135569. */
  135570. constructor(name: string, position: Vector3, scene: Scene);
  135571. /**
  135572. * Returns the string "PointLight"
  135573. * @returns the class name
  135574. */
  135575. getClassName(): string;
  135576. /**
  135577. * Returns the integer 0.
  135578. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  135579. */
  135580. getTypeID(): number;
  135581. /**
  135582. * Specifies wether or not the shadowmap should be a cube texture.
  135583. * @returns true if the shadowmap needs to be a cube texture.
  135584. */
  135585. needCube(): boolean;
  135586. /**
  135587. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  135588. * @param faceIndex The index of the face we are computed the direction to generate shadow
  135589. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  135590. */
  135591. getShadowDirection(faceIndex?: number): Vector3;
  135592. /**
  135593. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  135594. * - fov = PI / 2
  135595. * - aspect ratio : 1.0
  135596. * - z-near and far equal to the active camera minZ and maxZ.
  135597. * Returns the PointLight.
  135598. */
  135599. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  135600. protected _buildUniformLayout(): void;
  135601. /**
  135602. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  135603. * @param effect The effect to update
  135604. * @param lightIndex The index of the light in the effect to update
  135605. * @returns The point light
  135606. */
  135607. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  135608. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  135609. /**
  135610. * Prepares the list of defines specific to the light type.
  135611. * @param defines the list of defines
  135612. * @param lightIndex defines the index of the light for the effect
  135613. */
  135614. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  135615. }
  135616. }
  135617. declare module BABYLON {
  135618. /**
  135619. * Header information of HDR texture files.
  135620. */
  135621. export interface HDRInfo {
  135622. /**
  135623. * The height of the texture in pixels.
  135624. */
  135625. height: number;
  135626. /**
  135627. * The width of the texture in pixels.
  135628. */
  135629. width: number;
  135630. /**
  135631. * The index of the beginning of the data in the binary file.
  135632. */
  135633. dataPosition: number;
  135634. }
  135635. /**
  135636. * This groups tools to convert HDR texture to native colors array.
  135637. */
  135638. export class HDRTools {
  135639. private static Ldexp;
  135640. private static Rgbe2float;
  135641. private static readStringLine;
  135642. /**
  135643. * Reads header information from an RGBE texture stored in a native array.
  135644. * More information on this format are available here:
  135645. * https://en.wikipedia.org/wiki/RGBE_image_format
  135646. *
  135647. * @param uint8array The binary file stored in native array.
  135648. * @return The header information.
  135649. */
  135650. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  135651. /**
  135652. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  135653. * This RGBE texture needs to store the information as a panorama.
  135654. *
  135655. * More information on this format are available here:
  135656. * https://en.wikipedia.org/wiki/RGBE_image_format
  135657. *
  135658. * @param buffer The binary file stored in an array buffer.
  135659. * @param size The expected size of the extracted cubemap.
  135660. * @return The Cube Map information.
  135661. */
  135662. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  135663. /**
  135664. * Returns the pixels data extracted from an RGBE texture.
  135665. * This pixels will be stored left to right up to down in the R G B order in one array.
  135666. *
  135667. * More information on this format are available here:
  135668. * https://en.wikipedia.org/wiki/RGBE_image_format
  135669. *
  135670. * @param uint8array The binary file stored in an array buffer.
  135671. * @param hdrInfo The header information of the file.
  135672. * @return The pixels data in RGB right to left up to down order.
  135673. */
  135674. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  135675. private static RGBE_ReadPixels_RLE;
  135676. }
  135677. }
  135678. declare module BABYLON {
  135679. /**
  135680. * Effect Render Options
  135681. */
  135682. export interface IEffectRendererOptions {
  135683. /**
  135684. * Defines the vertices positions.
  135685. */
  135686. positions?: number[];
  135687. /**
  135688. * Defines the indices.
  135689. */
  135690. indices?: number[];
  135691. }
  135692. /**
  135693. * Helper class to render one or more effects.
  135694. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  135695. */
  135696. export class EffectRenderer {
  135697. private engine;
  135698. private static _DefaultOptions;
  135699. private _vertexBuffers;
  135700. private _indexBuffer;
  135701. private _fullscreenViewport;
  135702. /**
  135703. * Creates an effect renderer
  135704. * @param engine the engine to use for rendering
  135705. * @param options defines the options of the effect renderer
  135706. */
  135707. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  135708. /**
  135709. * Sets the current viewport in normalized coordinates 0-1
  135710. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  135711. */
  135712. setViewport(viewport?: Viewport): void;
  135713. /**
  135714. * Binds the embedded attributes buffer to the effect.
  135715. * @param effect Defines the effect to bind the attributes for
  135716. */
  135717. bindBuffers(effect: Effect): void;
  135718. /**
  135719. * Sets the current effect wrapper to use during draw.
  135720. * The effect needs to be ready before calling this api.
  135721. * This also sets the default full screen position attribute.
  135722. * @param effectWrapper Defines the effect to draw with
  135723. */
  135724. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  135725. /**
  135726. * Restores engine states
  135727. */
  135728. restoreStates(): void;
  135729. /**
  135730. * Draws a full screen quad.
  135731. */
  135732. draw(): void;
  135733. private isRenderTargetTexture;
  135734. /**
  135735. * renders one or more effects to a specified texture
  135736. * @param effectWrapper the effect to renderer
  135737. * @param outputTexture texture to draw to, if null it will render to the screen.
  135738. */
  135739. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  135740. /**
  135741. * Disposes of the effect renderer
  135742. */
  135743. dispose(): void;
  135744. }
  135745. /**
  135746. * Options to create an EffectWrapper
  135747. */
  135748. interface EffectWrapperCreationOptions {
  135749. /**
  135750. * Engine to use to create the effect
  135751. */
  135752. engine: ThinEngine;
  135753. /**
  135754. * Fragment shader for the effect
  135755. */
  135756. fragmentShader: string;
  135757. /**
  135758. * Use the shader store instead of direct source code
  135759. */
  135760. useShaderStore?: boolean;
  135761. /**
  135762. * Vertex shader for the effect
  135763. */
  135764. vertexShader?: string;
  135765. /**
  135766. * Attributes to use in the shader
  135767. */
  135768. attributeNames?: Array<string>;
  135769. /**
  135770. * Uniforms to use in the shader
  135771. */
  135772. uniformNames?: Array<string>;
  135773. /**
  135774. * Texture sampler names to use in the shader
  135775. */
  135776. samplerNames?: Array<string>;
  135777. /**
  135778. * Defines to use in the shader
  135779. */
  135780. defines?: Array<string>;
  135781. /**
  135782. * Callback when effect is compiled
  135783. */
  135784. onCompiled?: Nullable<(effect: Effect) => void>;
  135785. /**
  135786. * The friendly name of the effect displayed in Spector.
  135787. */
  135788. name?: string;
  135789. }
  135790. /**
  135791. * Wraps an effect to be used for rendering
  135792. */
  135793. export class EffectWrapper {
  135794. /**
  135795. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  135796. */
  135797. onApplyObservable: Observable<{}>;
  135798. /**
  135799. * The underlying effect
  135800. */
  135801. effect: Effect;
  135802. /**
  135803. * Creates an effect to be renderer
  135804. * @param creationOptions options to create the effect
  135805. */
  135806. constructor(creationOptions: EffectWrapperCreationOptions);
  135807. /**
  135808. * Disposes of the effect wrapper
  135809. */
  135810. dispose(): void;
  135811. }
  135812. }
  135813. declare module BABYLON {
  135814. /** @hidden */
  135815. export var hdrFilteringVertexShader: {
  135816. name: string;
  135817. shader: string;
  135818. };
  135819. }
  135820. declare module BABYLON {
  135821. /** @hidden */
  135822. export var hdrFilteringPixelShader: {
  135823. name: string;
  135824. shader: string;
  135825. };
  135826. }
  135827. declare module BABYLON {
  135828. /**
  135829. * Options for texture filtering
  135830. */
  135831. interface IHDRFilteringOptions {
  135832. /**
  135833. * Scales pixel intensity for the input HDR map.
  135834. */
  135835. hdrScale?: number;
  135836. /**
  135837. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  135838. */
  135839. quality?: number;
  135840. }
  135841. /**
  135842. * Filters HDR maps to get correct renderings of PBR reflections
  135843. */
  135844. export class HDRFiltering {
  135845. private _engine;
  135846. private _effectRenderer;
  135847. private _effectWrapper;
  135848. private _lodGenerationOffset;
  135849. private _lodGenerationScale;
  135850. /**
  135851. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  135852. * you care about baking speed.
  135853. */
  135854. quality: number;
  135855. /**
  135856. * Scales pixel intensity for the input HDR map.
  135857. */
  135858. hdrScale: number;
  135859. /**
  135860. * Instantiates HDR filter for reflection maps
  135861. *
  135862. * @param engine Thin engine
  135863. * @param options Options
  135864. */
  135865. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  135866. private _createRenderTarget;
  135867. private _prefilterInternal;
  135868. private _createEffect;
  135869. /**
  135870. * Get a value indicating if the filter is ready to be used
  135871. * @param texture Texture to filter
  135872. * @returns true if the filter is ready
  135873. */
  135874. isReady(texture: BaseTexture): boolean;
  135875. /**
  135876. * Prefilters a cube texture to have mipmap levels representing roughness values.
  135877. * Prefiltering will be invoked at the end of next rendering pass.
  135878. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  135879. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  135880. * @param texture Texture to filter
  135881. * @param onFinished Callback when filtering is done
  135882. * @return Promise called when prefiltering is done
  135883. */
  135884. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  135885. }
  135886. }
  135887. declare module BABYLON {
  135888. /**
  135889. * This represents a texture coming from an HDR input.
  135890. *
  135891. * The only supported format is currently panorama picture stored in RGBE format.
  135892. * Example of such files can be found on HDRLib: http://hdrlib.com/
  135893. */
  135894. export class HDRCubeTexture extends BaseTexture {
  135895. private static _facesMapping;
  135896. private _generateHarmonics;
  135897. private _noMipmap;
  135898. private _prefilterOnLoad;
  135899. private _textureMatrix;
  135900. private _size;
  135901. private _onLoad;
  135902. private _onError;
  135903. /**
  135904. * The texture URL.
  135905. */
  135906. url: string;
  135907. /**
  135908. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  135909. */
  135910. coordinatesMode: number;
  135911. protected _isBlocking: boolean;
  135912. /**
  135913. * Sets wether or not the texture is blocking during loading.
  135914. */
  135915. set isBlocking(value: boolean);
  135916. /**
  135917. * Gets wether or not the texture is blocking during loading.
  135918. */
  135919. get isBlocking(): boolean;
  135920. protected _rotationY: number;
  135921. /**
  135922. * Sets texture matrix rotation angle around Y axis in radians.
  135923. */
  135924. set rotationY(value: number);
  135925. /**
  135926. * Gets texture matrix rotation angle around Y axis radians.
  135927. */
  135928. get rotationY(): number;
  135929. /**
  135930. * Gets or sets the center of the bounding box associated with the cube texture
  135931. * It must define where the camera used to render the texture was set
  135932. */
  135933. boundingBoxPosition: Vector3;
  135934. private _boundingBoxSize;
  135935. /**
  135936. * Gets or sets the size of the bounding box associated with the cube texture
  135937. * When defined, the cubemap will switch to local mode
  135938. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  135939. * @example https://www.babylonjs-playground.com/#RNASML
  135940. */
  135941. set boundingBoxSize(value: Vector3);
  135942. get boundingBoxSize(): Vector3;
  135943. /**
  135944. * Instantiates an HDRTexture from the following parameters.
  135945. *
  135946. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  135947. * @param sceneOrEngine The scene or engine the texture will be used in
  135948. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  135949. * @param noMipmap Forces to not generate the mipmap if true
  135950. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  135951. * @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)
  135952. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  135953. */
  135954. 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>);
  135955. /**
  135956. * Get the current class name of the texture useful for serialization or dynamic coding.
  135957. * @returns "HDRCubeTexture"
  135958. */
  135959. getClassName(): string;
  135960. /**
  135961. * Occurs when the file is raw .hdr file.
  135962. */
  135963. private loadTexture;
  135964. clone(): HDRCubeTexture;
  135965. delayLoad(): void;
  135966. /**
  135967. * Get the texture reflection matrix used to rotate/transform the reflection.
  135968. * @returns the reflection matrix
  135969. */
  135970. getReflectionTextureMatrix(): Matrix;
  135971. /**
  135972. * Set the texture reflection matrix used to rotate/transform the reflection.
  135973. * @param value Define the reflection matrix to set
  135974. */
  135975. setReflectionTextureMatrix(value: Matrix): void;
  135976. /**
  135977. * Parses a JSON representation of an HDR Texture in order to create the texture
  135978. * @param parsedTexture Define the JSON representation
  135979. * @param scene Define the scene the texture should be created in
  135980. * @param rootUrl Define the root url in case we need to load relative dependencies
  135981. * @returns the newly created texture after parsing
  135982. */
  135983. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  135984. serialize(): any;
  135985. }
  135986. }
  135987. declare module BABYLON {
  135988. /**
  135989. * Class used to control physics engine
  135990. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  135991. */
  135992. export class PhysicsEngine implements IPhysicsEngine {
  135993. private _physicsPlugin;
  135994. /**
  135995. * Global value used to control the smallest number supported by the simulation
  135996. */
  135997. static Epsilon: number;
  135998. private _impostors;
  135999. private _joints;
  136000. private _subTimeStep;
  136001. /**
  136002. * Gets the gravity vector used by the simulation
  136003. */
  136004. gravity: Vector3;
  136005. /**
  136006. * Factory used to create the default physics plugin.
  136007. * @returns The default physics plugin
  136008. */
  136009. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  136010. /**
  136011. * Creates a new Physics Engine
  136012. * @param gravity defines the gravity vector used by the simulation
  136013. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  136014. */
  136015. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  136016. /**
  136017. * Sets the gravity vector used by the simulation
  136018. * @param gravity defines the gravity vector to use
  136019. */
  136020. setGravity(gravity: Vector3): void;
  136021. /**
  136022. * Set the time step of the physics engine.
  136023. * Default is 1/60.
  136024. * To slow it down, enter 1/600 for example.
  136025. * To speed it up, 1/30
  136026. * @param newTimeStep defines the new timestep to apply to this world.
  136027. */
  136028. setTimeStep(newTimeStep?: number): void;
  136029. /**
  136030. * Get the time step of the physics engine.
  136031. * @returns the current time step
  136032. */
  136033. getTimeStep(): number;
  136034. /**
  136035. * Set the sub time step of the physics engine.
  136036. * Default is 0 meaning there is no sub steps
  136037. * To increase physics resolution precision, set a small value (like 1 ms)
  136038. * @param subTimeStep defines the new sub timestep used for physics resolution.
  136039. */
  136040. setSubTimeStep(subTimeStep?: number): void;
  136041. /**
  136042. * Get the sub time step of the physics engine.
  136043. * @returns the current sub time step
  136044. */
  136045. getSubTimeStep(): number;
  136046. /**
  136047. * Release all resources
  136048. */
  136049. dispose(): void;
  136050. /**
  136051. * Gets the name of the current physics plugin
  136052. * @returns the name of the plugin
  136053. */
  136054. getPhysicsPluginName(): string;
  136055. /**
  136056. * Adding a new impostor for the impostor tracking.
  136057. * This will be done by the impostor itself.
  136058. * @param impostor the impostor to add
  136059. */
  136060. addImpostor(impostor: PhysicsImpostor): void;
  136061. /**
  136062. * Remove an impostor from the engine.
  136063. * This impostor and its mesh will not longer be updated by the physics engine.
  136064. * @param impostor the impostor to remove
  136065. */
  136066. removeImpostor(impostor: PhysicsImpostor): void;
  136067. /**
  136068. * Add a joint to the physics engine
  136069. * @param mainImpostor defines the main impostor to which the joint is added.
  136070. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  136071. * @param joint defines the joint that will connect both impostors.
  136072. */
  136073. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  136074. /**
  136075. * Removes a joint from the simulation
  136076. * @param mainImpostor defines the impostor used with the joint
  136077. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  136078. * @param joint defines the joint to remove
  136079. */
  136080. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  136081. /**
  136082. * Called by the scene. No need to call it.
  136083. * @param delta defines the timespam between frames
  136084. */
  136085. _step(delta: number): void;
  136086. /**
  136087. * Gets the current plugin used to run the simulation
  136088. * @returns current plugin
  136089. */
  136090. getPhysicsPlugin(): IPhysicsEnginePlugin;
  136091. /**
  136092. * Gets the list of physic impostors
  136093. * @returns an array of PhysicsImpostor
  136094. */
  136095. getImpostors(): Array<PhysicsImpostor>;
  136096. /**
  136097. * Gets the impostor for a physics enabled object
  136098. * @param object defines the object impersonated by the impostor
  136099. * @returns the PhysicsImpostor or null if not found
  136100. */
  136101. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  136102. /**
  136103. * Gets the impostor for a physics body object
  136104. * @param body defines physics body used by the impostor
  136105. * @returns the PhysicsImpostor or null if not found
  136106. */
  136107. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  136108. /**
  136109. * Does a raycast in the physics world
  136110. * @param from when should the ray start?
  136111. * @param to when should the ray end?
  136112. * @returns PhysicsRaycastResult
  136113. */
  136114. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  136115. }
  136116. }
  136117. declare module BABYLON {
  136118. /** @hidden */
  136119. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  136120. private _useDeltaForWorldStep;
  136121. world: any;
  136122. name: string;
  136123. private _physicsMaterials;
  136124. private _fixedTimeStep;
  136125. private _cannonRaycastResult;
  136126. private _raycastResult;
  136127. private _physicsBodysToRemoveAfterStep;
  136128. private _firstFrame;
  136129. BJSCANNON: any;
  136130. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  136131. setGravity(gravity: Vector3): void;
  136132. setTimeStep(timeStep: number): void;
  136133. getTimeStep(): number;
  136134. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  136135. private _removeMarkedPhysicsBodiesFromWorld;
  136136. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136137. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136138. generatePhysicsBody(impostor: PhysicsImpostor): void;
  136139. private _processChildMeshes;
  136140. removePhysicsBody(impostor: PhysicsImpostor): void;
  136141. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  136142. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  136143. private _addMaterial;
  136144. private _checkWithEpsilon;
  136145. private _createShape;
  136146. private _createHeightmap;
  136147. private _minus90X;
  136148. private _plus90X;
  136149. private _tmpPosition;
  136150. private _tmpDeltaPosition;
  136151. private _tmpUnityRotation;
  136152. private _updatePhysicsBodyTransformation;
  136153. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  136154. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  136155. isSupported(): boolean;
  136156. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136157. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136158. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136159. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136160. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  136161. getBodyMass(impostor: PhysicsImpostor): number;
  136162. getBodyFriction(impostor: PhysicsImpostor): number;
  136163. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  136164. getBodyRestitution(impostor: PhysicsImpostor): number;
  136165. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  136166. sleepBody(impostor: PhysicsImpostor): void;
  136167. wakeUpBody(impostor: PhysicsImpostor): void;
  136168. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  136169. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  136170. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  136171. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  136172. getRadius(impostor: PhysicsImpostor): number;
  136173. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  136174. dispose(): void;
  136175. private _extendNamespace;
  136176. /**
  136177. * Does a raycast in the physics world
  136178. * @param from when should the ray start?
  136179. * @param to when should the ray end?
  136180. * @returns PhysicsRaycastResult
  136181. */
  136182. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  136183. }
  136184. }
  136185. declare module BABYLON {
  136186. /** @hidden */
  136187. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  136188. private _useDeltaForWorldStep;
  136189. world: any;
  136190. name: string;
  136191. BJSOIMO: any;
  136192. private _raycastResult;
  136193. private _fixedTimeStep;
  136194. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  136195. setGravity(gravity: Vector3): void;
  136196. setTimeStep(timeStep: number): void;
  136197. getTimeStep(): number;
  136198. private _tmpImpostorsArray;
  136199. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  136200. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136201. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136202. generatePhysicsBody(impostor: PhysicsImpostor): void;
  136203. private _tmpPositionVector;
  136204. removePhysicsBody(impostor: PhysicsImpostor): void;
  136205. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  136206. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  136207. isSupported(): boolean;
  136208. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  136209. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  136210. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136211. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136212. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136213. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136214. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  136215. getBodyMass(impostor: PhysicsImpostor): number;
  136216. getBodyFriction(impostor: PhysicsImpostor): number;
  136217. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  136218. getBodyRestitution(impostor: PhysicsImpostor): number;
  136219. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  136220. sleepBody(impostor: PhysicsImpostor): void;
  136221. wakeUpBody(impostor: PhysicsImpostor): void;
  136222. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  136223. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  136224. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  136225. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  136226. getRadius(impostor: PhysicsImpostor): number;
  136227. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  136228. dispose(): void;
  136229. /**
  136230. * Does a raycast in the physics world
  136231. * @param from when should the ray start?
  136232. * @param to when should the ray end?
  136233. * @returns PhysicsRaycastResult
  136234. */
  136235. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  136236. }
  136237. }
  136238. declare module BABYLON {
  136239. /**
  136240. * Class containing static functions to help procedurally build meshes
  136241. */
  136242. export class RibbonBuilder {
  136243. /**
  136244. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  136245. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  136246. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  136247. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  136248. * * 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
  136249. * * 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
  136250. * * 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
  136251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136252. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136253. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136254. * * 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
  136255. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  136256. * * 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
  136257. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  136258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136259. * @param name defines the name of the mesh
  136260. * @param options defines the options used to create the mesh
  136261. * @param scene defines the hosting scene
  136262. * @returns the ribbon mesh
  136263. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  136264. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136265. */
  136266. static CreateRibbon(name: string, options: {
  136267. pathArray: Vector3[][];
  136268. closeArray?: boolean;
  136269. closePath?: boolean;
  136270. offset?: number;
  136271. updatable?: boolean;
  136272. sideOrientation?: number;
  136273. frontUVs?: Vector4;
  136274. backUVs?: Vector4;
  136275. instance?: Mesh;
  136276. invertUV?: boolean;
  136277. uvs?: Vector2[];
  136278. colors?: Color4[];
  136279. }, scene?: Nullable<Scene>): Mesh;
  136280. }
  136281. }
  136282. declare module BABYLON {
  136283. /**
  136284. * Class containing static functions to help procedurally build meshes
  136285. */
  136286. export class ShapeBuilder {
  136287. /**
  136288. * 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.
  136289. * * 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.
  136290. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136291. * * 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.
  136292. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  136293. * * 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
  136294. * * 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
  136295. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  136296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136297. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136298. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  136299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136300. * @param name defines the name of the mesh
  136301. * @param options defines the options used to create the mesh
  136302. * @param scene defines the hosting scene
  136303. * @returns the extruded shape mesh
  136304. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136305. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136306. */
  136307. static ExtrudeShape(name: string, options: {
  136308. shape: Vector3[];
  136309. path: Vector3[];
  136310. scale?: number;
  136311. rotation?: number;
  136312. cap?: number;
  136313. updatable?: boolean;
  136314. sideOrientation?: number;
  136315. frontUVs?: Vector4;
  136316. backUVs?: Vector4;
  136317. instance?: Mesh;
  136318. invertUV?: boolean;
  136319. }, scene?: Nullable<Scene>): Mesh;
  136320. /**
  136321. * Creates an custom extruded shape mesh.
  136322. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  136323. * * 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.
  136324. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136325. * * 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
  136326. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  136327. * * 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
  136328. * * It must returns a float value that will be the scale value applied to the shape on each path point
  136329. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  136330. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  136331. * * 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
  136332. * * 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
  136333. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  136334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136335. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136336. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136338. * @param name defines the name of the mesh
  136339. * @param options defines the options used to create the mesh
  136340. * @param scene defines the hosting scene
  136341. * @returns the custom extruded shape mesh
  136342. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  136343. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136344. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136345. */
  136346. static ExtrudeShapeCustom(name: string, options: {
  136347. shape: Vector3[];
  136348. path: Vector3[];
  136349. scaleFunction?: any;
  136350. rotationFunction?: any;
  136351. ribbonCloseArray?: boolean;
  136352. ribbonClosePath?: boolean;
  136353. cap?: number;
  136354. updatable?: boolean;
  136355. sideOrientation?: number;
  136356. frontUVs?: Vector4;
  136357. backUVs?: Vector4;
  136358. instance?: Mesh;
  136359. invertUV?: boolean;
  136360. }, scene?: Nullable<Scene>): Mesh;
  136361. private static _ExtrudeShapeGeneric;
  136362. }
  136363. }
  136364. declare module BABYLON {
  136365. /**
  136366. * AmmoJS Physics plugin
  136367. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  136368. * @see https://github.com/kripken/ammo.js/
  136369. */
  136370. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  136371. private _useDeltaForWorldStep;
  136372. /**
  136373. * Reference to the Ammo library
  136374. */
  136375. bjsAMMO: any;
  136376. /**
  136377. * Created ammoJS world which physics bodies are added to
  136378. */
  136379. world: any;
  136380. /**
  136381. * Name of the plugin
  136382. */
  136383. name: string;
  136384. private _timeStep;
  136385. private _fixedTimeStep;
  136386. private _maxSteps;
  136387. private _tmpQuaternion;
  136388. private _tmpAmmoTransform;
  136389. private _tmpAmmoQuaternion;
  136390. private _tmpAmmoConcreteContactResultCallback;
  136391. private _collisionConfiguration;
  136392. private _dispatcher;
  136393. private _overlappingPairCache;
  136394. private _solver;
  136395. private _softBodySolver;
  136396. private _tmpAmmoVectorA;
  136397. private _tmpAmmoVectorB;
  136398. private _tmpAmmoVectorC;
  136399. private _tmpAmmoVectorD;
  136400. private _tmpContactCallbackResult;
  136401. private _tmpAmmoVectorRCA;
  136402. private _tmpAmmoVectorRCB;
  136403. private _raycastResult;
  136404. private static readonly DISABLE_COLLISION_FLAG;
  136405. private static readonly KINEMATIC_FLAG;
  136406. private static readonly DISABLE_DEACTIVATION_FLAG;
  136407. /**
  136408. * Initializes the ammoJS plugin
  136409. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  136410. * @param ammoInjection can be used to inject your own ammo reference
  136411. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  136412. */
  136413. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  136414. /**
  136415. * Sets the gravity of the physics world (m/(s^2))
  136416. * @param gravity Gravity to set
  136417. */
  136418. setGravity(gravity: Vector3): void;
  136419. /**
  136420. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  136421. * @param timeStep timestep to use in seconds
  136422. */
  136423. setTimeStep(timeStep: number): void;
  136424. /**
  136425. * 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)
  136426. * @param fixedTimeStep fixedTimeStep to use in seconds
  136427. */
  136428. setFixedTimeStep(fixedTimeStep: number): void;
  136429. /**
  136430. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  136431. * @param maxSteps the maximum number of steps by the physics engine per frame
  136432. */
  136433. setMaxSteps(maxSteps: number): void;
  136434. /**
  136435. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  136436. * @returns the current timestep in seconds
  136437. */
  136438. getTimeStep(): number;
  136439. /**
  136440. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  136441. */
  136442. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  136443. private _isImpostorInContact;
  136444. private _isImpostorPairInContact;
  136445. private _stepSimulation;
  136446. /**
  136447. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  136448. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  136449. * After the step the babylon meshes are set to the position of the physics imposters
  136450. * @param delta amount of time to step forward
  136451. * @param impostors array of imposters to update before/after the step
  136452. */
  136453. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  136454. /**
  136455. * Update babylon mesh to match physics world object
  136456. * @param impostor imposter to match
  136457. */
  136458. private _afterSoftStep;
  136459. /**
  136460. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  136461. * @param impostor imposter to match
  136462. */
  136463. private _ropeStep;
  136464. /**
  136465. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  136466. * @param impostor imposter to match
  136467. */
  136468. private _softbodyOrClothStep;
  136469. private _tmpMatrix;
  136470. /**
  136471. * Applies an impulse on the imposter
  136472. * @param impostor imposter to apply impulse to
  136473. * @param force amount of force to be applied to the imposter
  136474. * @param contactPoint the location to apply the impulse on the imposter
  136475. */
  136476. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136477. /**
  136478. * Applies a force on the imposter
  136479. * @param impostor imposter to apply force
  136480. * @param force amount of force to be applied to the imposter
  136481. * @param contactPoint the location to apply the force on the imposter
  136482. */
  136483. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136484. /**
  136485. * Creates a physics body using the plugin
  136486. * @param impostor the imposter to create the physics body on
  136487. */
  136488. generatePhysicsBody(impostor: PhysicsImpostor): void;
  136489. /**
  136490. * Removes the physics body from the imposter and disposes of the body's memory
  136491. * @param impostor imposter to remove the physics body from
  136492. */
  136493. removePhysicsBody(impostor: PhysicsImpostor): void;
  136494. /**
  136495. * Generates a joint
  136496. * @param impostorJoint the imposter joint to create the joint with
  136497. */
  136498. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  136499. /**
  136500. * Removes a joint
  136501. * @param impostorJoint the imposter joint to remove the joint from
  136502. */
  136503. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  136504. private _addMeshVerts;
  136505. /**
  136506. * Initialise the soft body vertices to match its object's (mesh) vertices
  136507. * Softbody vertices (nodes) are in world space and to match this
  136508. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  136509. * @param impostor to create the softbody for
  136510. */
  136511. private _softVertexData;
  136512. /**
  136513. * Create an impostor's soft body
  136514. * @param impostor to create the softbody for
  136515. */
  136516. private _createSoftbody;
  136517. /**
  136518. * Create cloth for an impostor
  136519. * @param impostor to create the softbody for
  136520. */
  136521. private _createCloth;
  136522. /**
  136523. * Create rope for an impostor
  136524. * @param impostor to create the softbody for
  136525. */
  136526. private _createRope;
  136527. /**
  136528. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  136529. * @param impostor to create the custom physics shape for
  136530. */
  136531. private _createCustom;
  136532. private _addHullVerts;
  136533. private _createShape;
  136534. /**
  136535. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  136536. * @param impostor imposter containing the physics body and babylon object
  136537. */
  136538. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  136539. /**
  136540. * Sets the babylon object's position/rotation from the physics body's position/rotation
  136541. * @param impostor imposter containing the physics body and babylon object
  136542. * @param newPosition new position
  136543. * @param newRotation new rotation
  136544. */
  136545. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  136546. /**
  136547. * If this plugin is supported
  136548. * @returns true if its supported
  136549. */
  136550. isSupported(): boolean;
  136551. /**
  136552. * Sets the linear velocity of the physics body
  136553. * @param impostor imposter to set the velocity on
  136554. * @param velocity velocity to set
  136555. */
  136556. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136557. /**
  136558. * Sets the angular velocity of the physics body
  136559. * @param impostor imposter to set the velocity on
  136560. * @param velocity velocity to set
  136561. */
  136562. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136563. /**
  136564. * gets the linear velocity
  136565. * @param impostor imposter to get linear velocity from
  136566. * @returns linear velocity
  136567. */
  136568. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136569. /**
  136570. * gets the angular velocity
  136571. * @param impostor imposter to get angular velocity from
  136572. * @returns angular velocity
  136573. */
  136574. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136575. /**
  136576. * Sets the mass of physics body
  136577. * @param impostor imposter to set the mass on
  136578. * @param mass mass to set
  136579. */
  136580. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  136581. /**
  136582. * Gets the mass of the physics body
  136583. * @param impostor imposter to get the mass from
  136584. * @returns mass
  136585. */
  136586. getBodyMass(impostor: PhysicsImpostor): number;
  136587. /**
  136588. * Gets friction of the impostor
  136589. * @param impostor impostor to get friction from
  136590. * @returns friction value
  136591. */
  136592. getBodyFriction(impostor: PhysicsImpostor): number;
  136593. /**
  136594. * Sets friction of the impostor
  136595. * @param impostor impostor to set friction on
  136596. * @param friction friction value
  136597. */
  136598. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  136599. /**
  136600. * Gets restitution of the impostor
  136601. * @param impostor impostor to get restitution from
  136602. * @returns restitution value
  136603. */
  136604. getBodyRestitution(impostor: PhysicsImpostor): number;
  136605. /**
  136606. * Sets resitution of the impostor
  136607. * @param impostor impostor to set resitution on
  136608. * @param restitution resitution value
  136609. */
  136610. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  136611. /**
  136612. * Gets pressure inside the impostor
  136613. * @param impostor impostor to get pressure from
  136614. * @returns pressure value
  136615. */
  136616. getBodyPressure(impostor: PhysicsImpostor): number;
  136617. /**
  136618. * Sets pressure inside a soft body impostor
  136619. * Cloth and rope must remain 0 pressure
  136620. * @param impostor impostor to set pressure on
  136621. * @param pressure pressure value
  136622. */
  136623. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  136624. /**
  136625. * Gets stiffness of the impostor
  136626. * @param impostor impostor to get stiffness from
  136627. * @returns pressure value
  136628. */
  136629. getBodyStiffness(impostor: PhysicsImpostor): number;
  136630. /**
  136631. * Sets stiffness of the impostor
  136632. * @param impostor impostor to set stiffness on
  136633. * @param stiffness stiffness value from 0 to 1
  136634. */
  136635. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  136636. /**
  136637. * Gets velocityIterations of the impostor
  136638. * @param impostor impostor to get velocity iterations from
  136639. * @returns velocityIterations value
  136640. */
  136641. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  136642. /**
  136643. * Sets velocityIterations of the impostor
  136644. * @param impostor impostor to set velocity iterations on
  136645. * @param velocityIterations velocityIterations value
  136646. */
  136647. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  136648. /**
  136649. * Gets positionIterations of the impostor
  136650. * @param impostor impostor to get position iterations from
  136651. * @returns positionIterations value
  136652. */
  136653. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  136654. /**
  136655. * Sets positionIterations of the impostor
  136656. * @param impostor impostor to set position on
  136657. * @param positionIterations positionIterations value
  136658. */
  136659. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  136660. /**
  136661. * Append an anchor to a cloth object
  136662. * @param impostor is the cloth impostor to add anchor to
  136663. * @param otherImpostor is the rigid impostor to anchor to
  136664. * @param width ratio across width from 0 to 1
  136665. * @param height ratio up height from 0 to 1
  136666. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  136667. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  136668. */
  136669. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  136670. /**
  136671. * Append an hook to a rope object
  136672. * @param impostor is the rope impostor to add hook to
  136673. * @param otherImpostor is the rigid impostor to hook to
  136674. * @param length ratio along the rope from 0 to 1
  136675. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  136676. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  136677. */
  136678. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  136679. /**
  136680. * Sleeps the physics body and stops it from being active
  136681. * @param impostor impostor to sleep
  136682. */
  136683. sleepBody(impostor: PhysicsImpostor): void;
  136684. /**
  136685. * Activates the physics body
  136686. * @param impostor impostor to activate
  136687. */
  136688. wakeUpBody(impostor: PhysicsImpostor): void;
  136689. /**
  136690. * Updates the distance parameters of the joint
  136691. * @param joint joint to update
  136692. * @param maxDistance maximum distance of the joint
  136693. * @param minDistance minimum distance of the joint
  136694. */
  136695. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  136696. /**
  136697. * Sets a motor on the joint
  136698. * @param joint joint to set motor on
  136699. * @param speed speed of the motor
  136700. * @param maxForce maximum force of the motor
  136701. * @param motorIndex index of the motor
  136702. */
  136703. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  136704. /**
  136705. * Sets the motors limit
  136706. * @param joint joint to set limit on
  136707. * @param upperLimit upper limit
  136708. * @param lowerLimit lower limit
  136709. */
  136710. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  136711. /**
  136712. * Syncs the position and rotation of a mesh with the impostor
  136713. * @param mesh mesh to sync
  136714. * @param impostor impostor to update the mesh with
  136715. */
  136716. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  136717. /**
  136718. * Gets the radius of the impostor
  136719. * @param impostor impostor to get radius from
  136720. * @returns the radius
  136721. */
  136722. getRadius(impostor: PhysicsImpostor): number;
  136723. /**
  136724. * Gets the box size of the impostor
  136725. * @param impostor impostor to get box size from
  136726. * @param result the resulting box size
  136727. */
  136728. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  136729. /**
  136730. * Disposes of the impostor
  136731. */
  136732. dispose(): void;
  136733. /**
  136734. * Does a raycast in the physics world
  136735. * @param from when should the ray start?
  136736. * @param to when should the ray end?
  136737. * @returns PhysicsRaycastResult
  136738. */
  136739. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  136740. }
  136741. }
  136742. declare module BABYLON {
  136743. interface AbstractScene {
  136744. /**
  136745. * The list of reflection probes added to the scene
  136746. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  136747. */
  136748. reflectionProbes: Array<ReflectionProbe>;
  136749. /**
  136750. * Removes the given reflection probe from this scene.
  136751. * @param toRemove The reflection probe to remove
  136752. * @returns The index of the removed reflection probe
  136753. */
  136754. removeReflectionProbe(toRemove: ReflectionProbe): number;
  136755. /**
  136756. * Adds the given reflection probe to this scene.
  136757. * @param newReflectionProbe The reflection probe to add
  136758. */
  136759. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  136760. }
  136761. /**
  136762. * Class used to generate realtime reflection / refraction cube textures
  136763. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  136764. */
  136765. export class ReflectionProbe {
  136766. /** defines the name of the probe */
  136767. name: string;
  136768. private _scene;
  136769. private _renderTargetTexture;
  136770. private _projectionMatrix;
  136771. private _viewMatrix;
  136772. private _target;
  136773. private _add;
  136774. private _attachedMesh;
  136775. private _invertYAxis;
  136776. /** Gets or sets probe position (center of the cube map) */
  136777. position: Vector3;
  136778. /**
  136779. * Creates a new reflection probe
  136780. * @param name defines the name of the probe
  136781. * @param size defines the texture resolution (for each face)
  136782. * @param scene defines the hosting scene
  136783. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  136784. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  136785. */
  136786. constructor(
  136787. /** defines the name of the probe */
  136788. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  136789. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  136790. get samples(): number;
  136791. set samples(value: number);
  136792. /** Gets or sets the refresh rate to use (on every frame by default) */
  136793. get refreshRate(): number;
  136794. set refreshRate(value: number);
  136795. /**
  136796. * Gets the hosting scene
  136797. * @returns a Scene
  136798. */
  136799. getScene(): Scene;
  136800. /** Gets the internal CubeTexture used to render to */
  136801. get cubeTexture(): RenderTargetTexture;
  136802. /** Gets the list of meshes to render */
  136803. get renderList(): Nullable<AbstractMesh[]>;
  136804. /**
  136805. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  136806. * @param mesh defines the mesh to attach to
  136807. */
  136808. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  136809. /**
  136810. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  136811. * @param renderingGroupId The rendering group id corresponding to its index
  136812. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  136813. */
  136814. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  136815. /**
  136816. * Clean all associated resources
  136817. */
  136818. dispose(): void;
  136819. /**
  136820. * Converts the reflection probe information to a readable string for debug purpose.
  136821. * @param fullDetails Supports for multiple levels of logging within scene loading
  136822. * @returns the human readable reflection probe info
  136823. */
  136824. toString(fullDetails?: boolean): string;
  136825. /**
  136826. * Get the class name of the relfection probe.
  136827. * @returns "ReflectionProbe"
  136828. */
  136829. getClassName(): string;
  136830. /**
  136831. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  136832. * @returns The JSON representation of the texture
  136833. */
  136834. serialize(): any;
  136835. /**
  136836. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  136837. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  136838. * @param scene Define the scene the parsed reflection probe should be instantiated in
  136839. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  136840. * @returns The parsed reflection probe if successful
  136841. */
  136842. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  136843. }
  136844. }
  136845. declare module BABYLON {
  136846. /** @hidden */
  136847. export var _BabylonLoaderRegistered: boolean;
  136848. /**
  136849. * Helps setting up some configuration for the babylon file loader.
  136850. */
  136851. export class BabylonFileLoaderConfiguration {
  136852. /**
  136853. * The loader does not allow injecting custom physix engine into the plugins.
  136854. * Unfortunately in ES6, we need to manually inject them into the plugin.
  136855. * So you could set this variable to your engine import to make it work.
  136856. */
  136857. static LoaderInjectedPhysicsEngine: any;
  136858. }
  136859. }
  136860. declare module BABYLON {
  136861. /**
  136862. * The Physically based simple base material of BJS.
  136863. *
  136864. * This enables better naming and convention enforcements on top of the pbrMaterial.
  136865. * It is used as the base class for both the specGloss and metalRough conventions.
  136866. */
  136867. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  136868. /**
  136869. * Number of Simultaneous lights allowed on the material.
  136870. */
  136871. maxSimultaneousLights: number;
  136872. /**
  136873. * If sets to true, disables all the lights affecting the material.
  136874. */
  136875. disableLighting: boolean;
  136876. /**
  136877. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  136878. */
  136879. environmentTexture: BaseTexture;
  136880. /**
  136881. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  136882. */
  136883. invertNormalMapX: boolean;
  136884. /**
  136885. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  136886. */
  136887. invertNormalMapY: boolean;
  136888. /**
  136889. * Normal map used in the model.
  136890. */
  136891. normalTexture: BaseTexture;
  136892. /**
  136893. * Emissivie color used to self-illuminate the model.
  136894. */
  136895. emissiveColor: Color3;
  136896. /**
  136897. * Emissivie texture used to self-illuminate the model.
  136898. */
  136899. emissiveTexture: BaseTexture;
  136900. /**
  136901. * Occlusion Channel Strenght.
  136902. */
  136903. occlusionStrength: number;
  136904. /**
  136905. * Occlusion Texture of the material (adding extra occlusion effects).
  136906. */
  136907. occlusionTexture: BaseTexture;
  136908. /**
  136909. * Defines the alpha limits in alpha test mode.
  136910. */
  136911. alphaCutOff: number;
  136912. /**
  136913. * Gets the current double sided mode.
  136914. */
  136915. get doubleSided(): boolean;
  136916. /**
  136917. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  136918. */
  136919. set doubleSided(value: boolean);
  136920. /**
  136921. * Stores the pre-calculated light information of a mesh in a texture.
  136922. */
  136923. lightmapTexture: BaseTexture;
  136924. /**
  136925. * If true, the light map contains occlusion information instead of lighting info.
  136926. */
  136927. useLightmapAsShadowmap: boolean;
  136928. /**
  136929. * Instantiates a new PBRMaterial instance.
  136930. *
  136931. * @param name The material name
  136932. * @param scene The scene the material will be use in.
  136933. */
  136934. constructor(name: string, scene: Scene);
  136935. getClassName(): string;
  136936. }
  136937. }
  136938. declare module BABYLON {
  136939. /**
  136940. * The PBR material of BJS following the metal roughness convention.
  136941. *
  136942. * This fits to the PBR convention in the GLTF definition:
  136943. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  136944. */
  136945. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  136946. /**
  136947. * The base color has two different interpretations depending on the value of metalness.
  136948. * When the material is a metal, the base color is the specific measured reflectance value
  136949. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  136950. * of the material.
  136951. */
  136952. baseColor: Color3;
  136953. /**
  136954. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  136955. * well as opacity information in the alpha channel.
  136956. */
  136957. baseTexture: BaseTexture;
  136958. /**
  136959. * Specifies the metallic scalar value of the material.
  136960. * Can also be used to scale the metalness values of the metallic texture.
  136961. */
  136962. metallic: number;
  136963. /**
  136964. * Specifies the roughness scalar value of the material.
  136965. * Can also be used to scale the roughness values of the metallic texture.
  136966. */
  136967. roughness: number;
  136968. /**
  136969. * Texture containing both the metallic value in the B channel and the
  136970. * roughness value in the G channel to keep better precision.
  136971. */
  136972. metallicRoughnessTexture: BaseTexture;
  136973. /**
  136974. * Instantiates a new PBRMetalRoughnessMaterial instance.
  136975. *
  136976. * @param name The material name
  136977. * @param scene The scene the material will be use in.
  136978. */
  136979. constructor(name: string, scene: Scene);
  136980. /**
  136981. * Return the currrent class name of the material.
  136982. */
  136983. getClassName(): string;
  136984. /**
  136985. * Makes a duplicate of the current material.
  136986. * @param name - name to use for the new material.
  136987. */
  136988. clone(name: string): PBRMetallicRoughnessMaterial;
  136989. /**
  136990. * Serialize the material to a parsable JSON object.
  136991. */
  136992. serialize(): any;
  136993. /**
  136994. * Parses a JSON object correponding to the serialize function.
  136995. */
  136996. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  136997. }
  136998. }
  136999. declare module BABYLON {
  137000. /**
  137001. * The PBR material of BJS following the specular glossiness convention.
  137002. *
  137003. * This fits to the PBR convention in the GLTF definition:
  137004. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  137005. */
  137006. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  137007. /**
  137008. * Specifies the diffuse color of the material.
  137009. */
  137010. diffuseColor: Color3;
  137011. /**
  137012. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  137013. * channel.
  137014. */
  137015. diffuseTexture: BaseTexture;
  137016. /**
  137017. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  137018. */
  137019. specularColor: Color3;
  137020. /**
  137021. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  137022. */
  137023. glossiness: number;
  137024. /**
  137025. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  137026. */
  137027. specularGlossinessTexture: BaseTexture;
  137028. /**
  137029. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  137030. *
  137031. * @param name The material name
  137032. * @param scene The scene the material will be use in.
  137033. */
  137034. constructor(name: string, scene: Scene);
  137035. /**
  137036. * Return the currrent class name of the material.
  137037. */
  137038. getClassName(): string;
  137039. /**
  137040. * Makes a duplicate of the current material.
  137041. * @param name - name to use for the new material.
  137042. */
  137043. clone(name: string): PBRSpecularGlossinessMaterial;
  137044. /**
  137045. * Serialize the material to a parsable JSON object.
  137046. */
  137047. serialize(): any;
  137048. /**
  137049. * Parses a JSON object correponding to the serialize function.
  137050. */
  137051. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  137052. }
  137053. }
  137054. declare module BABYLON {
  137055. /**
  137056. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  137057. * It can help converting any input color in a desired output one. This can then be used to create effects
  137058. * from sepia, black and white to sixties or futuristic rendering...
  137059. *
  137060. * The only supported format is currently 3dl.
  137061. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  137062. */
  137063. export class ColorGradingTexture extends BaseTexture {
  137064. /**
  137065. * The texture URL.
  137066. */
  137067. url: string;
  137068. /**
  137069. * Empty line regex stored for GC.
  137070. */
  137071. private static _noneEmptyLineRegex;
  137072. private _textureMatrix;
  137073. private _onLoad;
  137074. /**
  137075. * Instantiates a ColorGradingTexture from the following parameters.
  137076. *
  137077. * @param url The location of the color gradind data (currently only supporting 3dl)
  137078. * @param sceneOrEngine The scene or engine the texture will be used in
  137079. * @param onLoad defines a callback triggered when the texture has been loaded
  137080. */
  137081. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  137082. /**
  137083. * Fires the onload event from the constructor if requested.
  137084. */
  137085. private _triggerOnLoad;
  137086. /**
  137087. * Returns the texture matrix used in most of the material.
  137088. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  137089. */
  137090. getTextureMatrix(): Matrix;
  137091. /**
  137092. * Occurs when the file being loaded is a .3dl LUT file.
  137093. */
  137094. private load3dlTexture;
  137095. /**
  137096. * Starts the loading process of the texture.
  137097. */
  137098. private loadTexture;
  137099. /**
  137100. * Clones the color gradind texture.
  137101. */
  137102. clone(): ColorGradingTexture;
  137103. /**
  137104. * Called during delayed load for textures.
  137105. */
  137106. delayLoad(): void;
  137107. /**
  137108. * Parses a color grading texture serialized by Babylon.
  137109. * @param parsedTexture The texture information being parsedTexture
  137110. * @param scene The scene to load the texture in
  137111. * @param rootUrl The root url of the data assets to load
  137112. * @return A color gradind texture
  137113. */
  137114. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  137115. /**
  137116. * Serializes the LUT texture to json format.
  137117. */
  137118. serialize(): any;
  137119. }
  137120. }
  137121. declare module BABYLON {
  137122. /**
  137123. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  137124. */
  137125. export class EquiRectangularCubeTexture extends BaseTexture {
  137126. /** The six faces of the cube. */
  137127. private static _FacesMapping;
  137128. private _noMipmap;
  137129. private _onLoad;
  137130. private _onError;
  137131. /** The size of the cubemap. */
  137132. private _size;
  137133. /** The buffer of the image. */
  137134. private _buffer;
  137135. /** The width of the input image. */
  137136. private _width;
  137137. /** The height of the input image. */
  137138. private _height;
  137139. /** The URL to the image. */
  137140. url: string;
  137141. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  137142. coordinatesMode: number;
  137143. /**
  137144. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  137145. * @param url The location of the image
  137146. * @param scene The scene the texture will be used in
  137147. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  137148. * @param noMipmap Forces to not generate the mipmap if true
  137149. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  137150. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  137151. * @param onLoad — defines a callback called when texture is loaded
  137152. * @param onError — defines a callback called if there is an error
  137153. */
  137154. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  137155. /**
  137156. * Load the image data, by putting the image on a canvas and extracting its buffer.
  137157. */
  137158. private loadImage;
  137159. /**
  137160. * Convert the image buffer into a cubemap and create a CubeTexture.
  137161. */
  137162. private loadTexture;
  137163. /**
  137164. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  137165. * @param buffer The ArrayBuffer that should be converted.
  137166. * @returns The buffer as Float32Array.
  137167. */
  137168. private getFloat32ArrayFromArrayBuffer;
  137169. /**
  137170. * Get the current class name of the texture useful for serialization or dynamic coding.
  137171. * @returns "EquiRectangularCubeTexture"
  137172. */
  137173. getClassName(): string;
  137174. /**
  137175. * Create a clone of the current EquiRectangularCubeTexture and return it.
  137176. * @returns A clone of the current EquiRectangularCubeTexture.
  137177. */
  137178. clone(): EquiRectangularCubeTexture;
  137179. }
  137180. }
  137181. declare module BABYLON {
  137182. /**
  137183. * Defines the options related to the creation of an HtmlElementTexture
  137184. */
  137185. export interface IHtmlElementTextureOptions {
  137186. /**
  137187. * Defines wether mip maps should be created or not.
  137188. */
  137189. generateMipMaps?: boolean;
  137190. /**
  137191. * Defines the sampling mode of the texture.
  137192. */
  137193. samplingMode?: number;
  137194. /**
  137195. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  137196. */
  137197. engine: Nullable<ThinEngine>;
  137198. /**
  137199. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  137200. */
  137201. scene: Nullable<Scene>;
  137202. }
  137203. /**
  137204. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  137205. * To be as efficient as possible depending on your constraints nothing aside the first upload
  137206. * is automatically managed.
  137207. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  137208. * in your application.
  137209. *
  137210. * As the update is not automatic, you need to call them manually.
  137211. */
  137212. export class HtmlElementTexture extends BaseTexture {
  137213. /**
  137214. * The texture URL.
  137215. */
  137216. element: HTMLVideoElement | HTMLCanvasElement;
  137217. private static readonly DefaultOptions;
  137218. private _textureMatrix;
  137219. private _isVideo;
  137220. private _generateMipMaps;
  137221. private _samplingMode;
  137222. /**
  137223. * Instantiates a HtmlElementTexture from the following parameters.
  137224. *
  137225. * @param name Defines the name of the texture
  137226. * @param element Defines the video or canvas the texture is filled with
  137227. * @param options Defines the other none mandatory texture creation options
  137228. */
  137229. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  137230. private _createInternalTexture;
  137231. /**
  137232. * Returns the texture matrix used in most of the material.
  137233. */
  137234. getTextureMatrix(): Matrix;
  137235. /**
  137236. * Updates the content of the texture.
  137237. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  137238. */
  137239. update(invertY?: Nullable<boolean>): void;
  137240. }
  137241. }
  137242. declare module BABYLON {
  137243. /**
  137244. * Based on jsTGALoader - Javascript loader for TGA file
  137245. * By Vincent Thibault
  137246. * @see http://blog.robrowser.com/javascript-tga-loader.html
  137247. */
  137248. export class TGATools {
  137249. private static _TYPE_INDEXED;
  137250. private static _TYPE_RGB;
  137251. private static _TYPE_GREY;
  137252. private static _TYPE_RLE_INDEXED;
  137253. private static _TYPE_RLE_RGB;
  137254. private static _TYPE_RLE_GREY;
  137255. private static _ORIGIN_MASK;
  137256. private static _ORIGIN_SHIFT;
  137257. private static _ORIGIN_BL;
  137258. private static _ORIGIN_BR;
  137259. private static _ORIGIN_UL;
  137260. private static _ORIGIN_UR;
  137261. /**
  137262. * Gets the header of a TGA file
  137263. * @param data defines the TGA data
  137264. * @returns the header
  137265. */
  137266. static GetTGAHeader(data: Uint8Array): any;
  137267. /**
  137268. * Uploads TGA content to a Babylon Texture
  137269. * @hidden
  137270. */
  137271. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  137272. /** @hidden */
  137273. 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;
  137274. /** @hidden */
  137275. 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;
  137276. /** @hidden */
  137277. 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;
  137278. /** @hidden */
  137279. 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;
  137280. /** @hidden */
  137281. 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;
  137282. /** @hidden */
  137283. 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;
  137284. }
  137285. }
  137286. declare module BABYLON {
  137287. /**
  137288. * Implementation of the TGA Texture Loader.
  137289. * @hidden
  137290. */
  137291. export class _TGATextureLoader implements IInternalTextureLoader {
  137292. /**
  137293. * Defines wether the loader supports cascade loading the different faces.
  137294. */
  137295. readonly supportCascades: boolean;
  137296. /**
  137297. * This returns if the loader support the current file information.
  137298. * @param extension defines the file extension of the file being loaded
  137299. * @returns true if the loader can load the specified file
  137300. */
  137301. canLoad(extension: string): boolean;
  137302. /**
  137303. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137304. * @param data contains the texture data
  137305. * @param texture defines the BabylonJS internal texture
  137306. * @param createPolynomials will be true if polynomials have been requested
  137307. * @param onLoad defines the callback to trigger once the texture is ready
  137308. * @param onError defines the callback to trigger in case of error
  137309. */
  137310. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137311. /**
  137312. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137313. * @param data contains the texture data
  137314. * @param texture defines the BabylonJS internal texture
  137315. * @param callback defines the method to call once ready to upload
  137316. */
  137317. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  137318. }
  137319. }
  137320. declare module BABYLON {
  137321. /**
  137322. * Info about the .basis files
  137323. */
  137324. class BasisFileInfo {
  137325. /**
  137326. * If the file has alpha
  137327. */
  137328. hasAlpha: boolean;
  137329. /**
  137330. * Info about each image of the basis file
  137331. */
  137332. images: Array<{
  137333. levels: Array<{
  137334. width: number;
  137335. height: number;
  137336. transcodedPixels: ArrayBufferView;
  137337. }>;
  137338. }>;
  137339. }
  137340. /**
  137341. * Result of transcoding a basis file
  137342. */
  137343. class TranscodeResult {
  137344. /**
  137345. * Info about the .basis file
  137346. */
  137347. fileInfo: BasisFileInfo;
  137348. /**
  137349. * Format to use when loading the file
  137350. */
  137351. format: number;
  137352. }
  137353. /**
  137354. * Configuration options for the Basis transcoder
  137355. */
  137356. export class BasisTranscodeConfiguration {
  137357. /**
  137358. * Supported compression formats used to determine the supported output format of the transcoder
  137359. */
  137360. supportedCompressionFormats?: {
  137361. /**
  137362. * etc1 compression format
  137363. */
  137364. etc1?: boolean;
  137365. /**
  137366. * s3tc compression format
  137367. */
  137368. s3tc?: boolean;
  137369. /**
  137370. * pvrtc compression format
  137371. */
  137372. pvrtc?: boolean;
  137373. /**
  137374. * etc2 compression format
  137375. */
  137376. etc2?: boolean;
  137377. };
  137378. /**
  137379. * If mipmap levels should be loaded for transcoded images (Default: true)
  137380. */
  137381. loadMipmapLevels?: boolean;
  137382. /**
  137383. * Index of a single image to load (Default: all images)
  137384. */
  137385. loadSingleImage?: number;
  137386. }
  137387. /**
  137388. * Used to load .Basis files
  137389. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  137390. */
  137391. export class BasisTools {
  137392. private static _IgnoreSupportedFormats;
  137393. /**
  137394. * URL to use when loading the basis transcoder
  137395. */
  137396. static JSModuleURL: string;
  137397. /**
  137398. * URL to use when loading the wasm module for the transcoder
  137399. */
  137400. static WasmModuleURL: string;
  137401. /**
  137402. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  137403. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  137404. * @returns internal format corresponding to the Basis format
  137405. */
  137406. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  137407. private static _WorkerPromise;
  137408. private static _Worker;
  137409. private static _actionId;
  137410. private static _CreateWorkerAsync;
  137411. /**
  137412. * Transcodes a loaded image file to compressed pixel data
  137413. * @param data image data to transcode
  137414. * @param config configuration options for the transcoding
  137415. * @returns a promise resulting in the transcoded image
  137416. */
  137417. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  137418. /**
  137419. * Loads a texture from the transcode result
  137420. * @param texture texture load to
  137421. * @param transcodeResult the result of transcoding the basis file to load from
  137422. */
  137423. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  137424. }
  137425. }
  137426. declare module BABYLON {
  137427. /**
  137428. * Loader for .basis file format
  137429. */
  137430. export class _BasisTextureLoader implements IInternalTextureLoader {
  137431. /**
  137432. * Defines whether the loader supports cascade loading the different faces.
  137433. */
  137434. readonly supportCascades: boolean;
  137435. /**
  137436. * This returns if the loader support the current file information.
  137437. * @param extension defines the file extension of the file being loaded
  137438. * @returns true if the loader can load the specified file
  137439. */
  137440. canLoad(extension: string): boolean;
  137441. /**
  137442. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137443. * @param data contains the texture data
  137444. * @param texture defines the BabylonJS internal texture
  137445. * @param createPolynomials will be true if polynomials have been requested
  137446. * @param onLoad defines the callback to trigger once the texture is ready
  137447. * @param onError defines the callback to trigger in case of error
  137448. */
  137449. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137450. /**
  137451. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137452. * @param data contains the texture data
  137453. * @param texture defines the BabylonJS internal texture
  137454. * @param callback defines the method to call once ready to upload
  137455. */
  137456. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  137457. }
  137458. }
  137459. declare module BABYLON {
  137460. /**
  137461. * Defines the basic options interface of a TexturePacker Frame
  137462. */
  137463. export interface ITexturePackerFrame {
  137464. /**
  137465. * The frame ID
  137466. */
  137467. id: number;
  137468. /**
  137469. * The frames Scale
  137470. */
  137471. scale: Vector2;
  137472. /**
  137473. * The Frames offset
  137474. */
  137475. offset: Vector2;
  137476. }
  137477. /**
  137478. * This is a support class for frame Data on texture packer sets.
  137479. */
  137480. export class TexturePackerFrame implements ITexturePackerFrame {
  137481. /**
  137482. * The frame ID
  137483. */
  137484. id: number;
  137485. /**
  137486. * The frames Scale
  137487. */
  137488. scale: Vector2;
  137489. /**
  137490. * The Frames offset
  137491. */
  137492. offset: Vector2;
  137493. /**
  137494. * Initializes a texture package frame.
  137495. * @param id The numerical frame identifier
  137496. * @param scale Scalar Vector2 for UV frame
  137497. * @param offset Vector2 for the frame position in UV units.
  137498. * @returns TexturePackerFrame
  137499. */
  137500. constructor(id: number, scale: Vector2, offset: Vector2);
  137501. }
  137502. }
  137503. declare module BABYLON {
  137504. /**
  137505. * Defines the basic options interface of a TexturePacker
  137506. */
  137507. export interface ITexturePackerOptions {
  137508. /**
  137509. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  137510. */
  137511. map?: string[];
  137512. /**
  137513. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  137514. */
  137515. uvsIn?: string;
  137516. /**
  137517. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  137518. */
  137519. uvsOut?: string;
  137520. /**
  137521. * number representing the layout style. Defaults to LAYOUT_STRIP
  137522. */
  137523. layout?: number;
  137524. /**
  137525. * number of columns if using custom column count layout(2). This defaults to 4.
  137526. */
  137527. colnum?: number;
  137528. /**
  137529. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  137530. */
  137531. updateInputMeshes?: boolean;
  137532. /**
  137533. * boolean flag to dispose all the source textures. Defaults to true.
  137534. */
  137535. disposeSources?: boolean;
  137536. /**
  137537. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  137538. */
  137539. fillBlanks?: boolean;
  137540. /**
  137541. * string value representing the context fill style color. Defaults to 'black'.
  137542. */
  137543. customFillColor?: string;
  137544. /**
  137545. * Width and Height Value of each Frame in the TexturePacker Sets
  137546. */
  137547. frameSize?: number;
  137548. /**
  137549. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  137550. */
  137551. paddingRatio?: number;
  137552. /**
  137553. * Number that declares the fill method for the padding gutter.
  137554. */
  137555. paddingMode?: number;
  137556. /**
  137557. * If in SUBUV_COLOR padding mode what color to use.
  137558. */
  137559. paddingColor?: Color3 | Color4;
  137560. }
  137561. /**
  137562. * Defines the basic interface of a TexturePacker JSON File
  137563. */
  137564. export interface ITexturePackerJSON {
  137565. /**
  137566. * The frame ID
  137567. */
  137568. name: string;
  137569. /**
  137570. * The base64 channel data
  137571. */
  137572. sets: any;
  137573. /**
  137574. * The options of the Packer
  137575. */
  137576. options: ITexturePackerOptions;
  137577. /**
  137578. * The frame data of the Packer
  137579. */
  137580. frames: Array<number>;
  137581. }
  137582. /**
  137583. * This is a support class that generates a series of packed texture sets.
  137584. * @see https://doc.babylonjs.com/babylon101/materials
  137585. */
  137586. export class TexturePacker {
  137587. /** Packer Layout Constant 0 */
  137588. static readonly LAYOUT_STRIP: number;
  137589. /** Packer Layout Constant 1 */
  137590. static readonly LAYOUT_POWER2: number;
  137591. /** Packer Layout Constant 2 */
  137592. static readonly LAYOUT_COLNUM: number;
  137593. /** Packer Layout Constant 0 */
  137594. static readonly SUBUV_WRAP: number;
  137595. /** Packer Layout Constant 1 */
  137596. static readonly SUBUV_EXTEND: number;
  137597. /** Packer Layout Constant 2 */
  137598. static readonly SUBUV_COLOR: number;
  137599. /** The Name of the Texture Package */
  137600. name: string;
  137601. /** The scene scope of the TexturePacker */
  137602. scene: Scene;
  137603. /** The Meshes to target */
  137604. meshes: AbstractMesh[];
  137605. /** Arguments passed with the Constructor */
  137606. options: ITexturePackerOptions;
  137607. /** The promise that is started upon initialization */
  137608. promise: Nullable<Promise<TexturePacker | string>>;
  137609. /** The Container object for the channel sets that are generated */
  137610. sets: object;
  137611. /** The Container array for the frames that are generated */
  137612. frames: TexturePackerFrame[];
  137613. /** The expected number of textures the system is parsing. */
  137614. private _expecting;
  137615. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  137616. private _paddingValue;
  137617. /**
  137618. * Initializes a texture package series from an array of meshes or a single mesh.
  137619. * @param name The name of the package
  137620. * @param meshes The target meshes to compose the package from
  137621. * @param options The arguments that texture packer should follow while building.
  137622. * @param scene The scene which the textures are scoped to.
  137623. * @returns TexturePacker
  137624. */
  137625. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  137626. /**
  137627. * Starts the package process
  137628. * @param resolve The promises resolution function
  137629. * @returns TexturePacker
  137630. */
  137631. private _createFrames;
  137632. /**
  137633. * Calculates the Size of the Channel Sets
  137634. * @returns Vector2
  137635. */
  137636. private _calculateSize;
  137637. /**
  137638. * Calculates the UV data for the frames.
  137639. * @param baseSize the base frameSize
  137640. * @param padding the base frame padding
  137641. * @param dtSize size of the Dynamic Texture for that channel
  137642. * @param dtUnits is 1/dtSize
  137643. * @param update flag to update the input meshes
  137644. */
  137645. private _calculateMeshUVFrames;
  137646. /**
  137647. * Calculates the frames Offset.
  137648. * @param index of the frame
  137649. * @returns Vector2
  137650. */
  137651. private _getFrameOffset;
  137652. /**
  137653. * Updates a Mesh to the frame data
  137654. * @param mesh that is the target
  137655. * @param frameID or the frame index
  137656. */
  137657. private _updateMeshUV;
  137658. /**
  137659. * Updates a Meshes materials to use the texture packer channels
  137660. * @param m is the mesh to target
  137661. * @param force all channels on the packer to be set.
  137662. */
  137663. private _updateTextureReferences;
  137664. /**
  137665. * Public method to set a Mesh to a frame
  137666. * @param m that is the target
  137667. * @param frameID or the frame index
  137668. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  137669. */
  137670. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  137671. /**
  137672. * Starts the async promise to compile the texture packer.
  137673. * @returns Promise<void>
  137674. */
  137675. processAsync(): Promise<void>;
  137676. /**
  137677. * Disposes all textures associated with this packer
  137678. */
  137679. dispose(): void;
  137680. /**
  137681. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  137682. * @param imageType is the image type to use.
  137683. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  137684. */
  137685. download(imageType?: string, quality?: number): void;
  137686. /**
  137687. * Public method to load a texturePacker JSON file.
  137688. * @param data of the JSON file in string format.
  137689. */
  137690. updateFromJSON(data: string): void;
  137691. }
  137692. }
  137693. declare module BABYLON {
  137694. /**
  137695. * 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.
  137696. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  137697. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  137698. */
  137699. export class CustomProceduralTexture extends ProceduralTexture {
  137700. private _animate;
  137701. private _time;
  137702. private _config;
  137703. private _texturePath;
  137704. /**
  137705. * Instantiates a new Custom Procedural Texture.
  137706. * 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.
  137707. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  137708. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  137709. * @param name Define the name of the texture
  137710. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  137711. * @param size Define the size of the texture to create
  137712. * @param scene Define the scene the texture belongs to
  137713. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  137714. * @param generateMipMaps Define if the texture should creates mip maps or not
  137715. */
  137716. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  137717. private _loadJson;
  137718. /**
  137719. * Is the texture ready to be used ? (rendered at least once)
  137720. * @returns true if ready, otherwise, false.
  137721. */
  137722. isReady(): boolean;
  137723. /**
  137724. * Render the texture to its associated render target.
  137725. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  137726. */
  137727. render(useCameraPostProcess?: boolean): void;
  137728. /**
  137729. * Update the list of dependant textures samplers in the shader.
  137730. */
  137731. updateTextures(): void;
  137732. /**
  137733. * Update the uniform values of the procedural texture in the shader.
  137734. */
  137735. updateShaderUniforms(): void;
  137736. /**
  137737. * Define if the texture animates or not.
  137738. */
  137739. get animate(): boolean;
  137740. set animate(value: boolean);
  137741. }
  137742. }
  137743. declare module BABYLON {
  137744. /** @hidden */
  137745. export var noisePixelShader: {
  137746. name: string;
  137747. shader: string;
  137748. };
  137749. }
  137750. declare module BABYLON {
  137751. /**
  137752. * Class used to generate noise procedural textures
  137753. */
  137754. export class NoiseProceduralTexture extends ProceduralTexture {
  137755. private _time;
  137756. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  137757. brightness: number;
  137758. /** Defines the number of octaves to process */
  137759. octaves: number;
  137760. /** Defines the level of persistence (0.8 by default) */
  137761. persistence: number;
  137762. /** Gets or sets animation speed factor (default is 1) */
  137763. animationSpeedFactor: number;
  137764. /**
  137765. * Creates a new NoiseProceduralTexture
  137766. * @param name defines the name fo the texture
  137767. * @param size defines the size of the texture (default is 256)
  137768. * @param scene defines the hosting scene
  137769. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  137770. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  137771. */
  137772. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  137773. private _updateShaderUniforms;
  137774. protected _getDefines(): string;
  137775. /** Generate the current state of the procedural texture */
  137776. render(useCameraPostProcess?: boolean): void;
  137777. /**
  137778. * Serializes this noise procedural texture
  137779. * @returns a serialized noise procedural texture object
  137780. */
  137781. serialize(): any;
  137782. /**
  137783. * Clone the texture.
  137784. * @returns the cloned texture
  137785. */
  137786. clone(): NoiseProceduralTexture;
  137787. /**
  137788. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  137789. * @param parsedTexture defines parsed texture data
  137790. * @param scene defines the current scene
  137791. * @param rootUrl defines the root URL containing noise procedural texture information
  137792. * @returns a parsed NoiseProceduralTexture
  137793. */
  137794. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  137795. }
  137796. }
  137797. declare module BABYLON {
  137798. /**
  137799. * Raw cube texture where the raw buffers are passed in
  137800. */
  137801. export class RawCubeTexture extends CubeTexture {
  137802. /**
  137803. * Creates a cube texture where the raw buffers are passed in.
  137804. * @param scene defines the scene the texture is attached to
  137805. * @param data defines the array of data to use to create each face
  137806. * @param size defines the size of the textures
  137807. * @param format defines the format of the data
  137808. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  137809. * @param generateMipMaps defines if the engine should generate the mip levels
  137810. * @param invertY defines if data must be stored with Y axis inverted
  137811. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  137812. * @param compression defines the compression used (null by default)
  137813. */
  137814. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  137815. /**
  137816. * Updates the raw cube texture.
  137817. * @param data defines the data to store
  137818. * @param format defines the data format
  137819. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  137820. * @param invertY defines if data must be stored with Y axis inverted
  137821. * @param compression defines the compression used (null by default)
  137822. * @param level defines which level of the texture to update
  137823. */
  137824. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  137825. /**
  137826. * Updates a raw cube texture with RGBD encoded data.
  137827. * @param data defines the array of data [mipmap][face] to use to create each face
  137828. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  137829. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  137830. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  137831. * @returns a promsie that resolves when the operation is complete
  137832. */
  137833. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  137834. /**
  137835. * Clones the raw cube texture.
  137836. * @return a new cube texture
  137837. */
  137838. clone(): CubeTexture;
  137839. /** @hidden */
  137840. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  137841. }
  137842. }
  137843. declare module BABYLON {
  137844. /**
  137845. * Class used to store 2D array textures containing user data
  137846. */
  137847. export class RawTexture2DArray extends Texture {
  137848. /** Gets or sets the texture format to use */
  137849. format: number;
  137850. /**
  137851. * Create a new RawTexture2DArray
  137852. * @param data defines the data of the texture
  137853. * @param width defines the width of the texture
  137854. * @param height defines the height of the texture
  137855. * @param depth defines the number of layers of the texture
  137856. * @param format defines the texture format to use
  137857. * @param scene defines the hosting scene
  137858. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  137859. * @param invertY defines if texture must be stored with Y axis inverted
  137860. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  137861. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  137862. */
  137863. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  137864. /** Gets or sets the texture format to use */
  137865. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  137866. /**
  137867. * Update the texture with new data
  137868. * @param data defines the data to store in the texture
  137869. */
  137870. update(data: ArrayBufferView): void;
  137871. }
  137872. }
  137873. declare module BABYLON {
  137874. /**
  137875. * Class used to store 3D textures containing user data
  137876. */
  137877. export class RawTexture3D extends Texture {
  137878. /** Gets or sets the texture format to use */
  137879. format: number;
  137880. /**
  137881. * Create a new RawTexture3D
  137882. * @param data defines the data of the texture
  137883. * @param width defines the width of the texture
  137884. * @param height defines the height of the texture
  137885. * @param depth defines the depth of the texture
  137886. * @param format defines the texture format to use
  137887. * @param scene defines the hosting scene
  137888. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  137889. * @param invertY defines if texture must be stored with Y axis inverted
  137890. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  137891. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  137892. */
  137893. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  137894. /** Gets or sets the texture format to use */
  137895. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  137896. /**
  137897. * Update the texture with new data
  137898. * @param data defines the data to store in the texture
  137899. */
  137900. update(data: ArrayBufferView): void;
  137901. }
  137902. }
  137903. declare module BABYLON {
  137904. /**
  137905. * Creates a refraction texture used by refraction channel of the standard material.
  137906. * It is like a mirror but to see through a material.
  137907. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  137908. */
  137909. export class RefractionTexture extends RenderTargetTexture {
  137910. /**
  137911. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  137912. * 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.
  137913. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  137914. */
  137915. refractionPlane: Plane;
  137916. /**
  137917. * Define how deep under the surface we should see.
  137918. */
  137919. depth: number;
  137920. /**
  137921. * Creates a refraction texture used by refraction channel of the standard material.
  137922. * It is like a mirror but to see through a material.
  137923. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  137924. * @param name Define the texture name
  137925. * @param size Define the size of the underlying texture
  137926. * @param scene Define the scene the refraction belongs to
  137927. * @param generateMipMaps Define if we need to generate mips level for the refraction
  137928. */
  137929. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  137930. /**
  137931. * Clone the refraction texture.
  137932. * @returns the cloned texture
  137933. */
  137934. clone(): RefractionTexture;
  137935. /**
  137936. * Serialize the texture to a JSON representation you could use in Parse later on
  137937. * @returns the serialized JSON representation
  137938. */
  137939. serialize(): any;
  137940. }
  137941. }
  137942. declare module BABYLON {
  137943. /**
  137944. * Block used to add support for vertex skinning (bones)
  137945. */
  137946. export class BonesBlock extends NodeMaterialBlock {
  137947. /**
  137948. * Creates a new BonesBlock
  137949. * @param name defines the block name
  137950. */
  137951. constructor(name: string);
  137952. /**
  137953. * Initialize the block and prepare the context for build
  137954. * @param state defines the state that will be used for the build
  137955. */
  137956. initialize(state: NodeMaterialBuildState): void;
  137957. /**
  137958. * Gets the current class name
  137959. * @returns the class name
  137960. */
  137961. getClassName(): string;
  137962. /**
  137963. * Gets the matrix indices input component
  137964. */
  137965. get matricesIndices(): NodeMaterialConnectionPoint;
  137966. /**
  137967. * Gets the matrix weights input component
  137968. */
  137969. get matricesWeights(): NodeMaterialConnectionPoint;
  137970. /**
  137971. * Gets the extra matrix indices input component
  137972. */
  137973. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  137974. /**
  137975. * Gets the extra matrix weights input component
  137976. */
  137977. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  137978. /**
  137979. * Gets the world input component
  137980. */
  137981. get world(): NodeMaterialConnectionPoint;
  137982. /**
  137983. * Gets the output component
  137984. */
  137985. get output(): NodeMaterialConnectionPoint;
  137986. autoConfigure(material: NodeMaterial): void;
  137987. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  137988. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  137989. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137990. protected _buildBlock(state: NodeMaterialBuildState): this;
  137991. }
  137992. }
  137993. declare module BABYLON {
  137994. /**
  137995. * Block used to add support for instances
  137996. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  137997. */
  137998. export class InstancesBlock extends NodeMaterialBlock {
  137999. /**
  138000. * Creates a new InstancesBlock
  138001. * @param name defines the block name
  138002. */
  138003. constructor(name: string);
  138004. /**
  138005. * Gets the current class name
  138006. * @returns the class name
  138007. */
  138008. getClassName(): string;
  138009. /**
  138010. * Gets the first world row input component
  138011. */
  138012. get world0(): NodeMaterialConnectionPoint;
  138013. /**
  138014. * Gets the second world row input component
  138015. */
  138016. get world1(): NodeMaterialConnectionPoint;
  138017. /**
  138018. * Gets the third world row input component
  138019. */
  138020. get world2(): NodeMaterialConnectionPoint;
  138021. /**
  138022. * Gets the forth world row input component
  138023. */
  138024. get world3(): NodeMaterialConnectionPoint;
  138025. /**
  138026. * Gets the world input component
  138027. */
  138028. get world(): NodeMaterialConnectionPoint;
  138029. /**
  138030. * Gets the output component
  138031. */
  138032. get output(): NodeMaterialConnectionPoint;
  138033. /**
  138034. * Gets the isntanceID component
  138035. */
  138036. get instanceID(): NodeMaterialConnectionPoint;
  138037. autoConfigure(material: NodeMaterial): void;
  138038. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  138039. protected _buildBlock(state: NodeMaterialBuildState): this;
  138040. }
  138041. }
  138042. declare module BABYLON {
  138043. /**
  138044. * Block used to add morph targets support to vertex shader
  138045. */
  138046. export class MorphTargetsBlock extends NodeMaterialBlock {
  138047. private _repeatableContentAnchor;
  138048. /**
  138049. * Create a new MorphTargetsBlock
  138050. * @param name defines the block name
  138051. */
  138052. constructor(name: string);
  138053. /**
  138054. * Gets the current class name
  138055. * @returns the class name
  138056. */
  138057. getClassName(): string;
  138058. /**
  138059. * Gets the position input component
  138060. */
  138061. get position(): NodeMaterialConnectionPoint;
  138062. /**
  138063. * Gets the normal input component
  138064. */
  138065. get normal(): NodeMaterialConnectionPoint;
  138066. /**
  138067. * Gets the tangent input component
  138068. */
  138069. get tangent(): NodeMaterialConnectionPoint;
  138070. /**
  138071. * Gets the tangent input component
  138072. */
  138073. get uv(): NodeMaterialConnectionPoint;
  138074. /**
  138075. * Gets the position output component
  138076. */
  138077. get positionOutput(): NodeMaterialConnectionPoint;
  138078. /**
  138079. * Gets the normal output component
  138080. */
  138081. get normalOutput(): NodeMaterialConnectionPoint;
  138082. /**
  138083. * Gets the tangent output component
  138084. */
  138085. get tangentOutput(): NodeMaterialConnectionPoint;
  138086. /**
  138087. * Gets the tangent output component
  138088. */
  138089. get uvOutput(): NodeMaterialConnectionPoint;
  138090. initialize(state: NodeMaterialBuildState): void;
  138091. autoConfigure(material: NodeMaterial): void;
  138092. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138093. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138094. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  138095. protected _buildBlock(state: NodeMaterialBuildState): this;
  138096. }
  138097. }
  138098. declare module BABYLON {
  138099. /**
  138100. * Block used to get data information from a light
  138101. */
  138102. export class LightInformationBlock extends NodeMaterialBlock {
  138103. private _lightDataUniformName;
  138104. private _lightColorUniformName;
  138105. private _lightTypeDefineName;
  138106. /**
  138107. * Gets or sets the light associated with this block
  138108. */
  138109. light: Nullable<Light>;
  138110. /**
  138111. * Creates a new LightInformationBlock
  138112. * @param name defines the block name
  138113. */
  138114. constructor(name: string);
  138115. /**
  138116. * Gets the current class name
  138117. * @returns the class name
  138118. */
  138119. getClassName(): string;
  138120. /**
  138121. * Gets the world position input component
  138122. */
  138123. get worldPosition(): NodeMaterialConnectionPoint;
  138124. /**
  138125. * Gets the direction output component
  138126. */
  138127. get direction(): NodeMaterialConnectionPoint;
  138128. /**
  138129. * Gets the direction output component
  138130. */
  138131. get color(): NodeMaterialConnectionPoint;
  138132. /**
  138133. * Gets the direction output component
  138134. */
  138135. get intensity(): NodeMaterialConnectionPoint;
  138136. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138137. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138138. protected _buildBlock(state: NodeMaterialBuildState): this;
  138139. serialize(): any;
  138140. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138141. }
  138142. }
  138143. declare module BABYLON {
  138144. /**
  138145. * Block used to add image processing support to fragment shader
  138146. */
  138147. export class ImageProcessingBlock extends NodeMaterialBlock {
  138148. /**
  138149. * Create a new ImageProcessingBlock
  138150. * @param name defines the block name
  138151. */
  138152. constructor(name: string);
  138153. /**
  138154. * Gets the current class name
  138155. * @returns the class name
  138156. */
  138157. getClassName(): string;
  138158. /**
  138159. * Gets the color input component
  138160. */
  138161. get color(): NodeMaterialConnectionPoint;
  138162. /**
  138163. * Gets the output component
  138164. */
  138165. get output(): NodeMaterialConnectionPoint;
  138166. /**
  138167. * Initialize the block and prepare the context for build
  138168. * @param state defines the state that will be used for the build
  138169. */
  138170. initialize(state: NodeMaterialBuildState): void;
  138171. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  138172. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138173. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138174. protected _buildBlock(state: NodeMaterialBuildState): this;
  138175. }
  138176. }
  138177. declare module BABYLON {
  138178. /**
  138179. * Block used to pertub normals based on a normal map
  138180. */
  138181. export class PerturbNormalBlock extends NodeMaterialBlock {
  138182. private _tangentSpaceParameterName;
  138183. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  138184. invertX: boolean;
  138185. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  138186. invertY: boolean;
  138187. /**
  138188. * Create a new PerturbNormalBlock
  138189. * @param name defines the block name
  138190. */
  138191. constructor(name: string);
  138192. /**
  138193. * Gets the current class name
  138194. * @returns the class name
  138195. */
  138196. getClassName(): string;
  138197. /**
  138198. * Gets the world position input component
  138199. */
  138200. get worldPosition(): NodeMaterialConnectionPoint;
  138201. /**
  138202. * Gets the world normal input component
  138203. */
  138204. get worldNormal(): NodeMaterialConnectionPoint;
  138205. /**
  138206. * Gets the world tangent input component
  138207. */
  138208. get worldTangent(): NodeMaterialConnectionPoint;
  138209. /**
  138210. * Gets the uv input component
  138211. */
  138212. get uv(): NodeMaterialConnectionPoint;
  138213. /**
  138214. * Gets the normal map color input component
  138215. */
  138216. get normalMapColor(): NodeMaterialConnectionPoint;
  138217. /**
  138218. * Gets the strength input component
  138219. */
  138220. get strength(): NodeMaterialConnectionPoint;
  138221. /**
  138222. * Gets the output component
  138223. */
  138224. get output(): NodeMaterialConnectionPoint;
  138225. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138226. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138227. autoConfigure(material: NodeMaterial): void;
  138228. protected _buildBlock(state: NodeMaterialBuildState): this;
  138229. protected _dumpPropertiesCode(): string;
  138230. serialize(): any;
  138231. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138232. }
  138233. }
  138234. declare module BABYLON {
  138235. /**
  138236. * Block used to discard a pixel if a value is smaller than a cutoff
  138237. */
  138238. export class DiscardBlock extends NodeMaterialBlock {
  138239. /**
  138240. * Create a new DiscardBlock
  138241. * @param name defines the block name
  138242. */
  138243. constructor(name: string);
  138244. /**
  138245. * Gets the current class name
  138246. * @returns the class name
  138247. */
  138248. getClassName(): string;
  138249. /**
  138250. * Gets the color input component
  138251. */
  138252. get value(): NodeMaterialConnectionPoint;
  138253. /**
  138254. * Gets the cutoff input component
  138255. */
  138256. get cutoff(): NodeMaterialConnectionPoint;
  138257. protected _buildBlock(state: NodeMaterialBuildState): this;
  138258. }
  138259. }
  138260. declare module BABYLON {
  138261. /**
  138262. * Block used to test if the fragment shader is front facing
  138263. */
  138264. export class FrontFacingBlock extends NodeMaterialBlock {
  138265. /**
  138266. * Creates a new FrontFacingBlock
  138267. * @param name defines the block name
  138268. */
  138269. constructor(name: string);
  138270. /**
  138271. * Gets the current class name
  138272. * @returns the class name
  138273. */
  138274. getClassName(): string;
  138275. /**
  138276. * Gets the output component
  138277. */
  138278. get output(): NodeMaterialConnectionPoint;
  138279. protected _buildBlock(state: NodeMaterialBuildState): this;
  138280. }
  138281. }
  138282. declare module BABYLON {
  138283. /**
  138284. * Block used to get the derivative value on x and y of a given input
  138285. */
  138286. export class DerivativeBlock extends NodeMaterialBlock {
  138287. /**
  138288. * Create a new DerivativeBlock
  138289. * @param name defines the block name
  138290. */
  138291. constructor(name: string);
  138292. /**
  138293. * Gets the current class name
  138294. * @returns the class name
  138295. */
  138296. getClassName(): string;
  138297. /**
  138298. * Gets the input component
  138299. */
  138300. get input(): NodeMaterialConnectionPoint;
  138301. /**
  138302. * Gets the derivative output on x
  138303. */
  138304. get dx(): NodeMaterialConnectionPoint;
  138305. /**
  138306. * Gets the derivative output on y
  138307. */
  138308. get dy(): NodeMaterialConnectionPoint;
  138309. protected _buildBlock(state: NodeMaterialBuildState): this;
  138310. }
  138311. }
  138312. declare module BABYLON {
  138313. /**
  138314. * Block used to make gl_FragCoord available
  138315. */
  138316. export class FragCoordBlock extends NodeMaterialBlock {
  138317. /**
  138318. * Creates a new FragCoordBlock
  138319. * @param name defines the block name
  138320. */
  138321. constructor(name: string);
  138322. /**
  138323. * Gets the current class name
  138324. * @returns the class name
  138325. */
  138326. getClassName(): string;
  138327. /**
  138328. * Gets the xy component
  138329. */
  138330. get xy(): NodeMaterialConnectionPoint;
  138331. /**
  138332. * Gets the xyz component
  138333. */
  138334. get xyz(): NodeMaterialConnectionPoint;
  138335. /**
  138336. * Gets the xyzw component
  138337. */
  138338. get xyzw(): NodeMaterialConnectionPoint;
  138339. /**
  138340. * Gets the x component
  138341. */
  138342. get x(): NodeMaterialConnectionPoint;
  138343. /**
  138344. * Gets the y component
  138345. */
  138346. get y(): NodeMaterialConnectionPoint;
  138347. /**
  138348. * Gets the z component
  138349. */
  138350. get z(): NodeMaterialConnectionPoint;
  138351. /**
  138352. * Gets the w component
  138353. */
  138354. get output(): NodeMaterialConnectionPoint;
  138355. protected writeOutputs(state: NodeMaterialBuildState): string;
  138356. protected _buildBlock(state: NodeMaterialBuildState): this;
  138357. }
  138358. }
  138359. declare module BABYLON {
  138360. /**
  138361. * Block used to get the screen sizes
  138362. */
  138363. export class ScreenSizeBlock extends NodeMaterialBlock {
  138364. private _varName;
  138365. private _scene;
  138366. /**
  138367. * Creates a new ScreenSizeBlock
  138368. * @param name defines the block name
  138369. */
  138370. constructor(name: string);
  138371. /**
  138372. * Gets the current class name
  138373. * @returns the class name
  138374. */
  138375. getClassName(): string;
  138376. /**
  138377. * Gets the xy component
  138378. */
  138379. get xy(): NodeMaterialConnectionPoint;
  138380. /**
  138381. * Gets the x component
  138382. */
  138383. get x(): NodeMaterialConnectionPoint;
  138384. /**
  138385. * Gets the y component
  138386. */
  138387. get y(): NodeMaterialConnectionPoint;
  138388. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138389. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  138390. protected _buildBlock(state: NodeMaterialBuildState): this;
  138391. }
  138392. }
  138393. declare module BABYLON {
  138394. /**
  138395. * Block used to add support for scene fog
  138396. */
  138397. export class FogBlock extends NodeMaterialBlock {
  138398. private _fogDistanceName;
  138399. private _fogParameters;
  138400. /**
  138401. * Create a new FogBlock
  138402. * @param name defines the block name
  138403. */
  138404. constructor(name: string);
  138405. /**
  138406. * Gets the current class name
  138407. * @returns the class name
  138408. */
  138409. getClassName(): string;
  138410. /**
  138411. * Gets the world position input component
  138412. */
  138413. get worldPosition(): NodeMaterialConnectionPoint;
  138414. /**
  138415. * Gets the view input component
  138416. */
  138417. get view(): NodeMaterialConnectionPoint;
  138418. /**
  138419. * Gets the color input component
  138420. */
  138421. get input(): NodeMaterialConnectionPoint;
  138422. /**
  138423. * Gets the fog color input component
  138424. */
  138425. get fogColor(): NodeMaterialConnectionPoint;
  138426. /**
  138427. * Gets the output component
  138428. */
  138429. get output(): NodeMaterialConnectionPoint;
  138430. autoConfigure(material: NodeMaterial): void;
  138431. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138432. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138433. protected _buildBlock(state: NodeMaterialBuildState): this;
  138434. }
  138435. }
  138436. declare module BABYLON {
  138437. /**
  138438. * Block used to add light in the fragment shader
  138439. */
  138440. export class LightBlock extends NodeMaterialBlock {
  138441. private _lightId;
  138442. /**
  138443. * Gets or sets the light associated with this block
  138444. */
  138445. light: Nullable<Light>;
  138446. /**
  138447. * Create a new LightBlock
  138448. * @param name defines the block name
  138449. */
  138450. constructor(name: string);
  138451. /**
  138452. * Gets the current class name
  138453. * @returns the class name
  138454. */
  138455. getClassName(): string;
  138456. /**
  138457. * Gets the world position input component
  138458. */
  138459. get worldPosition(): NodeMaterialConnectionPoint;
  138460. /**
  138461. * Gets the world normal input component
  138462. */
  138463. get worldNormal(): NodeMaterialConnectionPoint;
  138464. /**
  138465. * Gets the camera (or eye) position component
  138466. */
  138467. get cameraPosition(): NodeMaterialConnectionPoint;
  138468. /**
  138469. * Gets the glossiness component
  138470. */
  138471. get glossiness(): NodeMaterialConnectionPoint;
  138472. /**
  138473. * Gets the glossinness power component
  138474. */
  138475. get glossPower(): NodeMaterialConnectionPoint;
  138476. /**
  138477. * Gets the diffuse color component
  138478. */
  138479. get diffuseColor(): NodeMaterialConnectionPoint;
  138480. /**
  138481. * Gets the specular color component
  138482. */
  138483. get specularColor(): NodeMaterialConnectionPoint;
  138484. /**
  138485. * Gets the diffuse output component
  138486. */
  138487. get diffuseOutput(): NodeMaterialConnectionPoint;
  138488. /**
  138489. * Gets the specular output component
  138490. */
  138491. get specularOutput(): NodeMaterialConnectionPoint;
  138492. /**
  138493. * Gets the shadow output component
  138494. */
  138495. get shadow(): NodeMaterialConnectionPoint;
  138496. autoConfigure(material: NodeMaterial): void;
  138497. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138498. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  138499. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138500. private _injectVertexCode;
  138501. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  138502. serialize(): any;
  138503. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138504. }
  138505. }
  138506. declare module BABYLON {
  138507. /**
  138508. * Block used to read a reflection texture from a sampler
  138509. */
  138510. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  138511. /**
  138512. * Create a new ReflectionTextureBlock
  138513. * @param name defines the block name
  138514. */
  138515. constructor(name: string);
  138516. /**
  138517. * Gets the current class name
  138518. * @returns the class name
  138519. */
  138520. getClassName(): string;
  138521. /**
  138522. * Gets the world position input component
  138523. */
  138524. get position(): NodeMaterialConnectionPoint;
  138525. /**
  138526. * Gets the world position input component
  138527. */
  138528. get worldPosition(): NodeMaterialConnectionPoint;
  138529. /**
  138530. * Gets the world normal input component
  138531. */
  138532. get worldNormal(): NodeMaterialConnectionPoint;
  138533. /**
  138534. * Gets the world input component
  138535. */
  138536. get world(): NodeMaterialConnectionPoint;
  138537. /**
  138538. * Gets the camera (or eye) position component
  138539. */
  138540. get cameraPosition(): NodeMaterialConnectionPoint;
  138541. /**
  138542. * Gets the view input component
  138543. */
  138544. get view(): NodeMaterialConnectionPoint;
  138545. /**
  138546. * Gets the rgb output component
  138547. */
  138548. get rgb(): NodeMaterialConnectionPoint;
  138549. /**
  138550. * Gets the r output component
  138551. */
  138552. get r(): NodeMaterialConnectionPoint;
  138553. /**
  138554. * Gets the g output component
  138555. */
  138556. get g(): NodeMaterialConnectionPoint;
  138557. /**
  138558. * Gets the b output component
  138559. */
  138560. get b(): NodeMaterialConnectionPoint;
  138561. autoConfigure(material: NodeMaterial): void;
  138562. protected _buildBlock(state: NodeMaterialBuildState): this;
  138563. }
  138564. }
  138565. declare module BABYLON {
  138566. /**
  138567. * Block used to add 2 vectors
  138568. */
  138569. export class AddBlock extends NodeMaterialBlock {
  138570. /**
  138571. * Creates a new AddBlock
  138572. * @param name defines the block name
  138573. */
  138574. constructor(name: string);
  138575. /**
  138576. * Gets the current class name
  138577. * @returns the class name
  138578. */
  138579. getClassName(): string;
  138580. /**
  138581. * Gets the left operand input component
  138582. */
  138583. get left(): NodeMaterialConnectionPoint;
  138584. /**
  138585. * Gets the right operand input component
  138586. */
  138587. get right(): NodeMaterialConnectionPoint;
  138588. /**
  138589. * Gets the output component
  138590. */
  138591. get output(): NodeMaterialConnectionPoint;
  138592. protected _buildBlock(state: NodeMaterialBuildState): this;
  138593. }
  138594. }
  138595. declare module BABYLON {
  138596. /**
  138597. * Block used to scale a vector by a float
  138598. */
  138599. export class ScaleBlock extends NodeMaterialBlock {
  138600. /**
  138601. * Creates a new ScaleBlock
  138602. * @param name defines the block name
  138603. */
  138604. constructor(name: string);
  138605. /**
  138606. * Gets the current class name
  138607. * @returns the class name
  138608. */
  138609. getClassName(): string;
  138610. /**
  138611. * Gets the input component
  138612. */
  138613. get input(): NodeMaterialConnectionPoint;
  138614. /**
  138615. * Gets the factor input component
  138616. */
  138617. get factor(): NodeMaterialConnectionPoint;
  138618. /**
  138619. * Gets the output component
  138620. */
  138621. get output(): NodeMaterialConnectionPoint;
  138622. protected _buildBlock(state: NodeMaterialBuildState): this;
  138623. }
  138624. }
  138625. declare module BABYLON {
  138626. /**
  138627. * Block used to clamp a float
  138628. */
  138629. export class ClampBlock extends NodeMaterialBlock {
  138630. /** Gets or sets the minimum range */
  138631. minimum: number;
  138632. /** Gets or sets the maximum range */
  138633. maximum: number;
  138634. /**
  138635. * Creates a new ClampBlock
  138636. * @param name defines the block name
  138637. */
  138638. constructor(name: string);
  138639. /**
  138640. * Gets the current class name
  138641. * @returns the class name
  138642. */
  138643. getClassName(): string;
  138644. /**
  138645. * Gets the value input component
  138646. */
  138647. get value(): NodeMaterialConnectionPoint;
  138648. /**
  138649. * Gets the output component
  138650. */
  138651. get output(): NodeMaterialConnectionPoint;
  138652. protected _buildBlock(state: NodeMaterialBuildState): this;
  138653. protected _dumpPropertiesCode(): string;
  138654. serialize(): any;
  138655. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138656. }
  138657. }
  138658. declare module BABYLON {
  138659. /**
  138660. * Block used to apply a cross product between 2 vectors
  138661. */
  138662. export class CrossBlock extends NodeMaterialBlock {
  138663. /**
  138664. * Creates a new CrossBlock
  138665. * @param name defines the block name
  138666. */
  138667. constructor(name: string);
  138668. /**
  138669. * Gets the current class name
  138670. * @returns the class name
  138671. */
  138672. getClassName(): string;
  138673. /**
  138674. * Gets the left operand input component
  138675. */
  138676. get left(): NodeMaterialConnectionPoint;
  138677. /**
  138678. * Gets the right operand input component
  138679. */
  138680. get right(): NodeMaterialConnectionPoint;
  138681. /**
  138682. * Gets the output component
  138683. */
  138684. get output(): NodeMaterialConnectionPoint;
  138685. protected _buildBlock(state: NodeMaterialBuildState): this;
  138686. }
  138687. }
  138688. declare module BABYLON {
  138689. /**
  138690. * Block used to apply a dot product between 2 vectors
  138691. */
  138692. export class DotBlock extends NodeMaterialBlock {
  138693. /**
  138694. * Creates a new DotBlock
  138695. * @param name defines the block name
  138696. */
  138697. constructor(name: string);
  138698. /**
  138699. * Gets the current class name
  138700. * @returns the class name
  138701. */
  138702. getClassName(): string;
  138703. /**
  138704. * Gets the left operand input component
  138705. */
  138706. get left(): NodeMaterialConnectionPoint;
  138707. /**
  138708. * Gets the right operand input component
  138709. */
  138710. get right(): NodeMaterialConnectionPoint;
  138711. /**
  138712. * Gets the output component
  138713. */
  138714. get output(): NodeMaterialConnectionPoint;
  138715. protected _buildBlock(state: NodeMaterialBuildState): this;
  138716. }
  138717. }
  138718. declare module BABYLON {
  138719. /**
  138720. * Block used to normalize a vector
  138721. */
  138722. export class NormalizeBlock extends NodeMaterialBlock {
  138723. /**
  138724. * Creates a new NormalizeBlock
  138725. * @param name defines the block name
  138726. */
  138727. constructor(name: string);
  138728. /**
  138729. * Gets the current class name
  138730. * @returns the class name
  138731. */
  138732. getClassName(): string;
  138733. /**
  138734. * Gets the input component
  138735. */
  138736. get input(): NodeMaterialConnectionPoint;
  138737. /**
  138738. * Gets the output component
  138739. */
  138740. get output(): NodeMaterialConnectionPoint;
  138741. protected _buildBlock(state: NodeMaterialBuildState): this;
  138742. }
  138743. }
  138744. declare module BABYLON {
  138745. /**
  138746. * Operations supported by the Trigonometry block
  138747. */
  138748. export enum TrigonometryBlockOperations {
  138749. /** Cos */
  138750. Cos = 0,
  138751. /** Sin */
  138752. Sin = 1,
  138753. /** Abs */
  138754. Abs = 2,
  138755. /** Exp */
  138756. Exp = 3,
  138757. /** Exp2 */
  138758. Exp2 = 4,
  138759. /** Round */
  138760. Round = 5,
  138761. /** Floor */
  138762. Floor = 6,
  138763. /** Ceiling */
  138764. Ceiling = 7,
  138765. /** Square root */
  138766. Sqrt = 8,
  138767. /** Log */
  138768. Log = 9,
  138769. /** Tangent */
  138770. Tan = 10,
  138771. /** Arc tangent */
  138772. ArcTan = 11,
  138773. /** Arc cosinus */
  138774. ArcCos = 12,
  138775. /** Arc sinus */
  138776. ArcSin = 13,
  138777. /** Fraction */
  138778. Fract = 14,
  138779. /** Sign */
  138780. Sign = 15,
  138781. /** To radians (from degrees) */
  138782. Radians = 16,
  138783. /** To degrees (from radians) */
  138784. Degrees = 17
  138785. }
  138786. /**
  138787. * Block used to apply trigonometry operation to floats
  138788. */
  138789. export class TrigonometryBlock extends NodeMaterialBlock {
  138790. /**
  138791. * Gets or sets the operation applied by the block
  138792. */
  138793. operation: TrigonometryBlockOperations;
  138794. /**
  138795. * Creates a new TrigonometryBlock
  138796. * @param name defines the block name
  138797. */
  138798. constructor(name: string);
  138799. /**
  138800. * Gets the current class name
  138801. * @returns the class name
  138802. */
  138803. getClassName(): string;
  138804. /**
  138805. * Gets the input component
  138806. */
  138807. get input(): NodeMaterialConnectionPoint;
  138808. /**
  138809. * Gets the output component
  138810. */
  138811. get output(): NodeMaterialConnectionPoint;
  138812. protected _buildBlock(state: NodeMaterialBuildState): this;
  138813. serialize(): any;
  138814. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138815. protected _dumpPropertiesCode(): string;
  138816. }
  138817. }
  138818. declare module BABYLON {
  138819. /**
  138820. * Block used to create a Color3/4 out of individual inputs (one for each component)
  138821. */
  138822. export class ColorMergerBlock extends NodeMaterialBlock {
  138823. /**
  138824. * Create a new ColorMergerBlock
  138825. * @param name defines the block name
  138826. */
  138827. constructor(name: string);
  138828. /**
  138829. * Gets the current class name
  138830. * @returns the class name
  138831. */
  138832. getClassName(): string;
  138833. /**
  138834. * Gets the rgb component (input)
  138835. */
  138836. get rgbIn(): NodeMaterialConnectionPoint;
  138837. /**
  138838. * Gets the r component (input)
  138839. */
  138840. get r(): NodeMaterialConnectionPoint;
  138841. /**
  138842. * Gets the g component (input)
  138843. */
  138844. get g(): NodeMaterialConnectionPoint;
  138845. /**
  138846. * Gets the b component (input)
  138847. */
  138848. get b(): NodeMaterialConnectionPoint;
  138849. /**
  138850. * Gets the a component (input)
  138851. */
  138852. get a(): NodeMaterialConnectionPoint;
  138853. /**
  138854. * Gets the rgba component (output)
  138855. */
  138856. get rgba(): NodeMaterialConnectionPoint;
  138857. /**
  138858. * Gets the rgb component (output)
  138859. */
  138860. get rgbOut(): NodeMaterialConnectionPoint;
  138861. /**
  138862. * Gets the rgb component (output)
  138863. * @deprecated Please use rgbOut instead.
  138864. */
  138865. get rgb(): NodeMaterialConnectionPoint;
  138866. protected _buildBlock(state: NodeMaterialBuildState): this;
  138867. }
  138868. }
  138869. declare module BABYLON {
  138870. /**
  138871. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  138872. */
  138873. export class VectorSplitterBlock extends NodeMaterialBlock {
  138874. /**
  138875. * Create a new VectorSplitterBlock
  138876. * @param name defines the block name
  138877. */
  138878. constructor(name: string);
  138879. /**
  138880. * Gets the current class name
  138881. * @returns the class name
  138882. */
  138883. getClassName(): string;
  138884. /**
  138885. * Gets the xyzw component (input)
  138886. */
  138887. get xyzw(): NodeMaterialConnectionPoint;
  138888. /**
  138889. * Gets the xyz component (input)
  138890. */
  138891. get xyzIn(): NodeMaterialConnectionPoint;
  138892. /**
  138893. * Gets the xy component (input)
  138894. */
  138895. get xyIn(): NodeMaterialConnectionPoint;
  138896. /**
  138897. * Gets the xyz component (output)
  138898. */
  138899. get xyzOut(): NodeMaterialConnectionPoint;
  138900. /**
  138901. * Gets the xy component (output)
  138902. */
  138903. get xyOut(): NodeMaterialConnectionPoint;
  138904. /**
  138905. * Gets the x component (output)
  138906. */
  138907. get x(): NodeMaterialConnectionPoint;
  138908. /**
  138909. * Gets the y component (output)
  138910. */
  138911. get y(): NodeMaterialConnectionPoint;
  138912. /**
  138913. * Gets the z component (output)
  138914. */
  138915. get z(): NodeMaterialConnectionPoint;
  138916. /**
  138917. * Gets the w component (output)
  138918. */
  138919. get w(): NodeMaterialConnectionPoint;
  138920. protected _inputRename(name: string): string;
  138921. protected _outputRename(name: string): string;
  138922. protected _buildBlock(state: NodeMaterialBuildState): this;
  138923. }
  138924. }
  138925. declare module BABYLON {
  138926. /**
  138927. * Block used to lerp between 2 values
  138928. */
  138929. export class LerpBlock extends NodeMaterialBlock {
  138930. /**
  138931. * Creates a new LerpBlock
  138932. * @param name defines the block name
  138933. */
  138934. constructor(name: string);
  138935. /**
  138936. * Gets the current class name
  138937. * @returns the class name
  138938. */
  138939. getClassName(): string;
  138940. /**
  138941. * Gets the left operand input component
  138942. */
  138943. get left(): NodeMaterialConnectionPoint;
  138944. /**
  138945. * Gets the right operand input component
  138946. */
  138947. get right(): NodeMaterialConnectionPoint;
  138948. /**
  138949. * Gets the gradient operand input component
  138950. */
  138951. get gradient(): NodeMaterialConnectionPoint;
  138952. /**
  138953. * Gets the output component
  138954. */
  138955. get output(): NodeMaterialConnectionPoint;
  138956. protected _buildBlock(state: NodeMaterialBuildState): this;
  138957. }
  138958. }
  138959. declare module BABYLON {
  138960. /**
  138961. * Block used to divide 2 vectors
  138962. */
  138963. export class DivideBlock extends NodeMaterialBlock {
  138964. /**
  138965. * Creates a new DivideBlock
  138966. * @param name defines the block name
  138967. */
  138968. constructor(name: string);
  138969. /**
  138970. * Gets the current class name
  138971. * @returns the class name
  138972. */
  138973. getClassName(): string;
  138974. /**
  138975. * Gets the left operand input component
  138976. */
  138977. get left(): NodeMaterialConnectionPoint;
  138978. /**
  138979. * Gets the right operand input component
  138980. */
  138981. get right(): NodeMaterialConnectionPoint;
  138982. /**
  138983. * Gets the output component
  138984. */
  138985. get output(): NodeMaterialConnectionPoint;
  138986. protected _buildBlock(state: NodeMaterialBuildState): this;
  138987. }
  138988. }
  138989. declare module BABYLON {
  138990. /**
  138991. * Block used to subtract 2 vectors
  138992. */
  138993. export class SubtractBlock extends NodeMaterialBlock {
  138994. /**
  138995. * Creates a new SubtractBlock
  138996. * @param name defines the block name
  138997. */
  138998. constructor(name: string);
  138999. /**
  139000. * Gets the current class name
  139001. * @returns the class name
  139002. */
  139003. getClassName(): string;
  139004. /**
  139005. * Gets the left operand input component
  139006. */
  139007. get left(): NodeMaterialConnectionPoint;
  139008. /**
  139009. * Gets the right operand input component
  139010. */
  139011. get right(): NodeMaterialConnectionPoint;
  139012. /**
  139013. * Gets the output component
  139014. */
  139015. get output(): NodeMaterialConnectionPoint;
  139016. protected _buildBlock(state: NodeMaterialBuildState): this;
  139017. }
  139018. }
  139019. declare module BABYLON {
  139020. /**
  139021. * Block used to step a value
  139022. */
  139023. export class StepBlock extends NodeMaterialBlock {
  139024. /**
  139025. * Creates a new StepBlock
  139026. * @param name defines the block name
  139027. */
  139028. constructor(name: string);
  139029. /**
  139030. * Gets the current class name
  139031. * @returns the class name
  139032. */
  139033. getClassName(): string;
  139034. /**
  139035. * Gets the value operand input component
  139036. */
  139037. get value(): NodeMaterialConnectionPoint;
  139038. /**
  139039. * Gets the edge operand input component
  139040. */
  139041. get edge(): NodeMaterialConnectionPoint;
  139042. /**
  139043. * Gets the output component
  139044. */
  139045. get output(): NodeMaterialConnectionPoint;
  139046. protected _buildBlock(state: NodeMaterialBuildState): this;
  139047. }
  139048. }
  139049. declare module BABYLON {
  139050. /**
  139051. * Block used to get the opposite (1 - x) of a value
  139052. */
  139053. export class OneMinusBlock extends NodeMaterialBlock {
  139054. /**
  139055. * Creates a new OneMinusBlock
  139056. * @param name defines the block name
  139057. */
  139058. constructor(name: string);
  139059. /**
  139060. * Gets the current class name
  139061. * @returns the class name
  139062. */
  139063. getClassName(): string;
  139064. /**
  139065. * Gets the input component
  139066. */
  139067. get input(): NodeMaterialConnectionPoint;
  139068. /**
  139069. * Gets the output component
  139070. */
  139071. get output(): NodeMaterialConnectionPoint;
  139072. protected _buildBlock(state: NodeMaterialBuildState): this;
  139073. }
  139074. }
  139075. declare module BABYLON {
  139076. /**
  139077. * Block used to get the view direction
  139078. */
  139079. export class ViewDirectionBlock extends NodeMaterialBlock {
  139080. /**
  139081. * Creates a new ViewDirectionBlock
  139082. * @param name defines the block name
  139083. */
  139084. constructor(name: string);
  139085. /**
  139086. * Gets the current class name
  139087. * @returns the class name
  139088. */
  139089. getClassName(): string;
  139090. /**
  139091. * Gets the world position component
  139092. */
  139093. get worldPosition(): NodeMaterialConnectionPoint;
  139094. /**
  139095. * Gets the camera position component
  139096. */
  139097. get cameraPosition(): NodeMaterialConnectionPoint;
  139098. /**
  139099. * Gets the output component
  139100. */
  139101. get output(): NodeMaterialConnectionPoint;
  139102. autoConfigure(material: NodeMaterial): void;
  139103. protected _buildBlock(state: NodeMaterialBuildState): this;
  139104. }
  139105. }
  139106. declare module BABYLON {
  139107. /**
  139108. * Block used to compute fresnel value
  139109. */
  139110. export class FresnelBlock extends NodeMaterialBlock {
  139111. /**
  139112. * Create a new FresnelBlock
  139113. * @param name defines the block name
  139114. */
  139115. constructor(name: string);
  139116. /**
  139117. * Gets the current class name
  139118. * @returns the class name
  139119. */
  139120. getClassName(): string;
  139121. /**
  139122. * Gets the world normal input component
  139123. */
  139124. get worldNormal(): NodeMaterialConnectionPoint;
  139125. /**
  139126. * Gets the view direction input component
  139127. */
  139128. get viewDirection(): NodeMaterialConnectionPoint;
  139129. /**
  139130. * Gets the bias input component
  139131. */
  139132. get bias(): NodeMaterialConnectionPoint;
  139133. /**
  139134. * Gets the camera (or eye) position component
  139135. */
  139136. get power(): NodeMaterialConnectionPoint;
  139137. /**
  139138. * Gets the fresnel output component
  139139. */
  139140. get fresnel(): NodeMaterialConnectionPoint;
  139141. autoConfigure(material: NodeMaterial): void;
  139142. protected _buildBlock(state: NodeMaterialBuildState): this;
  139143. }
  139144. }
  139145. declare module BABYLON {
  139146. /**
  139147. * Block used to get the max of 2 values
  139148. */
  139149. export class MaxBlock extends NodeMaterialBlock {
  139150. /**
  139151. * Creates a new MaxBlock
  139152. * @param name defines the block name
  139153. */
  139154. constructor(name: string);
  139155. /**
  139156. * Gets the current class name
  139157. * @returns the class name
  139158. */
  139159. getClassName(): string;
  139160. /**
  139161. * Gets the left operand input component
  139162. */
  139163. get left(): NodeMaterialConnectionPoint;
  139164. /**
  139165. * Gets the right operand input component
  139166. */
  139167. get right(): NodeMaterialConnectionPoint;
  139168. /**
  139169. * Gets the output component
  139170. */
  139171. get output(): NodeMaterialConnectionPoint;
  139172. protected _buildBlock(state: NodeMaterialBuildState): this;
  139173. }
  139174. }
  139175. declare module BABYLON {
  139176. /**
  139177. * Block used to get the min of 2 values
  139178. */
  139179. export class MinBlock extends NodeMaterialBlock {
  139180. /**
  139181. * Creates a new MinBlock
  139182. * @param name defines the block name
  139183. */
  139184. constructor(name: string);
  139185. /**
  139186. * Gets the current class name
  139187. * @returns the class name
  139188. */
  139189. getClassName(): string;
  139190. /**
  139191. * Gets the left operand input component
  139192. */
  139193. get left(): NodeMaterialConnectionPoint;
  139194. /**
  139195. * Gets the right operand input component
  139196. */
  139197. get right(): NodeMaterialConnectionPoint;
  139198. /**
  139199. * Gets the output component
  139200. */
  139201. get output(): NodeMaterialConnectionPoint;
  139202. protected _buildBlock(state: NodeMaterialBuildState): this;
  139203. }
  139204. }
  139205. declare module BABYLON {
  139206. /**
  139207. * Block used to get the distance between 2 values
  139208. */
  139209. export class DistanceBlock extends NodeMaterialBlock {
  139210. /**
  139211. * Creates a new DistanceBlock
  139212. * @param name defines the block name
  139213. */
  139214. constructor(name: string);
  139215. /**
  139216. * Gets the current class name
  139217. * @returns the class name
  139218. */
  139219. getClassName(): string;
  139220. /**
  139221. * Gets the left operand input component
  139222. */
  139223. get left(): NodeMaterialConnectionPoint;
  139224. /**
  139225. * Gets the right operand input component
  139226. */
  139227. get right(): NodeMaterialConnectionPoint;
  139228. /**
  139229. * Gets the output component
  139230. */
  139231. get output(): NodeMaterialConnectionPoint;
  139232. protected _buildBlock(state: NodeMaterialBuildState): this;
  139233. }
  139234. }
  139235. declare module BABYLON {
  139236. /**
  139237. * Block used to get the length of a vector
  139238. */
  139239. export class LengthBlock extends NodeMaterialBlock {
  139240. /**
  139241. * Creates a new LengthBlock
  139242. * @param name defines the block name
  139243. */
  139244. constructor(name: string);
  139245. /**
  139246. * Gets the current class name
  139247. * @returns the class name
  139248. */
  139249. getClassName(): string;
  139250. /**
  139251. * Gets the value input component
  139252. */
  139253. get value(): NodeMaterialConnectionPoint;
  139254. /**
  139255. * Gets the output component
  139256. */
  139257. get output(): NodeMaterialConnectionPoint;
  139258. protected _buildBlock(state: NodeMaterialBuildState): this;
  139259. }
  139260. }
  139261. declare module BABYLON {
  139262. /**
  139263. * Block used to get negative version of a value (i.e. x * -1)
  139264. */
  139265. export class NegateBlock extends NodeMaterialBlock {
  139266. /**
  139267. * Creates a new NegateBlock
  139268. * @param name defines the block name
  139269. */
  139270. constructor(name: string);
  139271. /**
  139272. * Gets the current class name
  139273. * @returns the class name
  139274. */
  139275. getClassName(): string;
  139276. /**
  139277. * Gets the value input component
  139278. */
  139279. get value(): NodeMaterialConnectionPoint;
  139280. /**
  139281. * Gets the output component
  139282. */
  139283. get output(): NodeMaterialConnectionPoint;
  139284. protected _buildBlock(state: NodeMaterialBuildState): this;
  139285. }
  139286. }
  139287. declare module BABYLON {
  139288. /**
  139289. * Block used to get the value of the first parameter raised to the power of the second
  139290. */
  139291. export class PowBlock extends NodeMaterialBlock {
  139292. /**
  139293. * Creates a new PowBlock
  139294. * @param name defines the block name
  139295. */
  139296. constructor(name: string);
  139297. /**
  139298. * Gets the current class name
  139299. * @returns the class name
  139300. */
  139301. getClassName(): string;
  139302. /**
  139303. * Gets the value operand input component
  139304. */
  139305. get value(): NodeMaterialConnectionPoint;
  139306. /**
  139307. * Gets the power operand input component
  139308. */
  139309. get power(): NodeMaterialConnectionPoint;
  139310. /**
  139311. * Gets the output component
  139312. */
  139313. get output(): NodeMaterialConnectionPoint;
  139314. protected _buildBlock(state: NodeMaterialBuildState): this;
  139315. }
  139316. }
  139317. declare module BABYLON {
  139318. /**
  139319. * Block used to get a random number
  139320. */
  139321. export class RandomNumberBlock extends NodeMaterialBlock {
  139322. /**
  139323. * Creates a new RandomNumberBlock
  139324. * @param name defines the block name
  139325. */
  139326. constructor(name: string);
  139327. /**
  139328. * Gets the current class name
  139329. * @returns the class name
  139330. */
  139331. getClassName(): string;
  139332. /**
  139333. * Gets the seed input component
  139334. */
  139335. get seed(): NodeMaterialConnectionPoint;
  139336. /**
  139337. * Gets the output component
  139338. */
  139339. get output(): NodeMaterialConnectionPoint;
  139340. protected _buildBlock(state: NodeMaterialBuildState): this;
  139341. }
  139342. }
  139343. declare module BABYLON {
  139344. /**
  139345. * Block used to compute arc tangent of 2 values
  139346. */
  139347. export class ArcTan2Block extends NodeMaterialBlock {
  139348. /**
  139349. * Creates a new ArcTan2Block
  139350. * @param name defines the block name
  139351. */
  139352. constructor(name: string);
  139353. /**
  139354. * Gets the current class name
  139355. * @returns the class name
  139356. */
  139357. getClassName(): string;
  139358. /**
  139359. * Gets the x operand input component
  139360. */
  139361. get x(): NodeMaterialConnectionPoint;
  139362. /**
  139363. * Gets the y operand input component
  139364. */
  139365. get y(): NodeMaterialConnectionPoint;
  139366. /**
  139367. * Gets the output component
  139368. */
  139369. get output(): NodeMaterialConnectionPoint;
  139370. protected _buildBlock(state: NodeMaterialBuildState): this;
  139371. }
  139372. }
  139373. declare module BABYLON {
  139374. /**
  139375. * Block used to smooth step a value
  139376. */
  139377. export class SmoothStepBlock extends NodeMaterialBlock {
  139378. /**
  139379. * Creates a new SmoothStepBlock
  139380. * @param name defines the block name
  139381. */
  139382. constructor(name: string);
  139383. /**
  139384. * Gets the current class name
  139385. * @returns the class name
  139386. */
  139387. getClassName(): string;
  139388. /**
  139389. * Gets the value operand input component
  139390. */
  139391. get value(): NodeMaterialConnectionPoint;
  139392. /**
  139393. * Gets the first edge operand input component
  139394. */
  139395. get edge0(): NodeMaterialConnectionPoint;
  139396. /**
  139397. * Gets the second edge operand input component
  139398. */
  139399. get edge1(): NodeMaterialConnectionPoint;
  139400. /**
  139401. * Gets the output component
  139402. */
  139403. get output(): NodeMaterialConnectionPoint;
  139404. protected _buildBlock(state: NodeMaterialBuildState): this;
  139405. }
  139406. }
  139407. declare module BABYLON {
  139408. /**
  139409. * Block used to get the reciprocal (1 / x) of a value
  139410. */
  139411. export class ReciprocalBlock extends NodeMaterialBlock {
  139412. /**
  139413. * Creates a new ReciprocalBlock
  139414. * @param name defines the block name
  139415. */
  139416. constructor(name: string);
  139417. /**
  139418. * Gets the current class name
  139419. * @returns the class name
  139420. */
  139421. getClassName(): string;
  139422. /**
  139423. * Gets the input component
  139424. */
  139425. get input(): NodeMaterialConnectionPoint;
  139426. /**
  139427. * Gets the output component
  139428. */
  139429. get output(): NodeMaterialConnectionPoint;
  139430. protected _buildBlock(state: NodeMaterialBuildState): this;
  139431. }
  139432. }
  139433. declare module BABYLON {
  139434. /**
  139435. * Block used to replace a color by another one
  139436. */
  139437. export class ReplaceColorBlock extends NodeMaterialBlock {
  139438. /**
  139439. * Creates a new ReplaceColorBlock
  139440. * @param name defines the block name
  139441. */
  139442. constructor(name: string);
  139443. /**
  139444. * Gets the current class name
  139445. * @returns the class name
  139446. */
  139447. getClassName(): string;
  139448. /**
  139449. * Gets the value input component
  139450. */
  139451. get value(): NodeMaterialConnectionPoint;
  139452. /**
  139453. * Gets the reference input component
  139454. */
  139455. get reference(): NodeMaterialConnectionPoint;
  139456. /**
  139457. * Gets the distance input component
  139458. */
  139459. get distance(): NodeMaterialConnectionPoint;
  139460. /**
  139461. * Gets the replacement input component
  139462. */
  139463. get replacement(): NodeMaterialConnectionPoint;
  139464. /**
  139465. * Gets the output component
  139466. */
  139467. get output(): NodeMaterialConnectionPoint;
  139468. protected _buildBlock(state: NodeMaterialBuildState): this;
  139469. }
  139470. }
  139471. declare module BABYLON {
  139472. /**
  139473. * Block used to posterize a value
  139474. * @see https://en.wikipedia.org/wiki/Posterization
  139475. */
  139476. export class PosterizeBlock extends NodeMaterialBlock {
  139477. /**
  139478. * Creates a new PosterizeBlock
  139479. * @param name defines the block name
  139480. */
  139481. constructor(name: string);
  139482. /**
  139483. * Gets the current class name
  139484. * @returns the class name
  139485. */
  139486. getClassName(): string;
  139487. /**
  139488. * Gets the value input component
  139489. */
  139490. get value(): NodeMaterialConnectionPoint;
  139491. /**
  139492. * Gets the steps input component
  139493. */
  139494. get steps(): NodeMaterialConnectionPoint;
  139495. /**
  139496. * Gets the output component
  139497. */
  139498. get output(): NodeMaterialConnectionPoint;
  139499. protected _buildBlock(state: NodeMaterialBuildState): this;
  139500. }
  139501. }
  139502. declare module BABYLON {
  139503. /**
  139504. * Operations supported by the Wave block
  139505. */
  139506. export enum WaveBlockKind {
  139507. /** SawTooth */
  139508. SawTooth = 0,
  139509. /** Square */
  139510. Square = 1,
  139511. /** Triangle */
  139512. Triangle = 2
  139513. }
  139514. /**
  139515. * Block used to apply wave operation to floats
  139516. */
  139517. export class WaveBlock extends NodeMaterialBlock {
  139518. /**
  139519. * Gets or sets the kibnd of wave to be applied by the block
  139520. */
  139521. kind: WaveBlockKind;
  139522. /**
  139523. * Creates a new WaveBlock
  139524. * @param name defines the block name
  139525. */
  139526. constructor(name: string);
  139527. /**
  139528. * Gets the current class name
  139529. * @returns the class name
  139530. */
  139531. getClassName(): string;
  139532. /**
  139533. * Gets the input component
  139534. */
  139535. get input(): NodeMaterialConnectionPoint;
  139536. /**
  139537. * Gets the output component
  139538. */
  139539. get output(): NodeMaterialConnectionPoint;
  139540. protected _buildBlock(state: NodeMaterialBuildState): this;
  139541. serialize(): any;
  139542. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139543. }
  139544. }
  139545. declare module BABYLON {
  139546. /**
  139547. * Class used to store a color step for the GradientBlock
  139548. */
  139549. export class GradientBlockColorStep {
  139550. /**
  139551. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  139552. */
  139553. step: number;
  139554. /**
  139555. * Gets or sets the color associated with this step
  139556. */
  139557. color: Color3;
  139558. /**
  139559. * Creates a new GradientBlockColorStep
  139560. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  139561. * @param color defines the color associated with this step
  139562. */
  139563. constructor(
  139564. /**
  139565. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  139566. */
  139567. step: number,
  139568. /**
  139569. * Gets or sets the color associated with this step
  139570. */
  139571. color: Color3);
  139572. }
  139573. /**
  139574. * Block used to return a color from a gradient based on an input value between 0 and 1
  139575. */
  139576. export class GradientBlock extends NodeMaterialBlock {
  139577. /**
  139578. * Gets or sets the list of color steps
  139579. */
  139580. colorSteps: GradientBlockColorStep[];
  139581. /**
  139582. * Creates a new GradientBlock
  139583. * @param name defines the block name
  139584. */
  139585. constructor(name: string);
  139586. /**
  139587. * Gets the current class name
  139588. * @returns the class name
  139589. */
  139590. getClassName(): string;
  139591. /**
  139592. * Gets the gradient input component
  139593. */
  139594. get gradient(): NodeMaterialConnectionPoint;
  139595. /**
  139596. * Gets the output component
  139597. */
  139598. get output(): NodeMaterialConnectionPoint;
  139599. private _writeColorConstant;
  139600. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  139601. serialize(): any;
  139602. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139603. protected _dumpPropertiesCode(): string;
  139604. }
  139605. }
  139606. declare module BABYLON {
  139607. /**
  139608. * Block used to normalize lerp between 2 values
  139609. */
  139610. export class NLerpBlock extends NodeMaterialBlock {
  139611. /**
  139612. * Creates a new NLerpBlock
  139613. * @param name defines the block name
  139614. */
  139615. constructor(name: string);
  139616. /**
  139617. * Gets the current class name
  139618. * @returns the class name
  139619. */
  139620. getClassName(): string;
  139621. /**
  139622. * Gets the left operand input component
  139623. */
  139624. get left(): NodeMaterialConnectionPoint;
  139625. /**
  139626. * Gets the right operand input component
  139627. */
  139628. get right(): NodeMaterialConnectionPoint;
  139629. /**
  139630. * Gets the gradient operand input component
  139631. */
  139632. get gradient(): NodeMaterialConnectionPoint;
  139633. /**
  139634. * Gets the output component
  139635. */
  139636. get output(): NodeMaterialConnectionPoint;
  139637. protected _buildBlock(state: NodeMaterialBuildState): this;
  139638. }
  139639. }
  139640. declare module BABYLON {
  139641. /**
  139642. * block used to Generate a Worley Noise 3D Noise Pattern
  139643. */
  139644. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  139645. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  139646. manhattanDistance: boolean;
  139647. /**
  139648. * Creates a new WorleyNoise3DBlock
  139649. * @param name defines the block name
  139650. */
  139651. constructor(name: string);
  139652. /**
  139653. * Gets the current class name
  139654. * @returns the class name
  139655. */
  139656. getClassName(): string;
  139657. /**
  139658. * Gets the seed input component
  139659. */
  139660. get seed(): NodeMaterialConnectionPoint;
  139661. /**
  139662. * Gets the jitter input component
  139663. */
  139664. get jitter(): NodeMaterialConnectionPoint;
  139665. /**
  139666. * Gets the output component
  139667. */
  139668. get output(): NodeMaterialConnectionPoint;
  139669. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  139670. /**
  139671. * Exposes the properties to the UI?
  139672. */
  139673. protected _dumpPropertiesCode(): string;
  139674. /**
  139675. * Exposes the properties to the Seralize?
  139676. */
  139677. serialize(): any;
  139678. /**
  139679. * Exposes the properties to the deseralize?
  139680. */
  139681. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139682. }
  139683. }
  139684. declare module BABYLON {
  139685. /**
  139686. * block used to Generate a Simplex Perlin 3d Noise Pattern
  139687. */
  139688. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  139689. /**
  139690. * Creates a new SimplexPerlin3DBlock
  139691. * @param name defines the block name
  139692. */
  139693. constructor(name: string);
  139694. /**
  139695. * Gets the current class name
  139696. * @returns the class name
  139697. */
  139698. getClassName(): string;
  139699. /**
  139700. * Gets the seed operand input component
  139701. */
  139702. get seed(): NodeMaterialConnectionPoint;
  139703. /**
  139704. * Gets the output component
  139705. */
  139706. get output(): NodeMaterialConnectionPoint;
  139707. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  139708. }
  139709. }
  139710. declare module BABYLON {
  139711. /**
  139712. * Block used to blend normals
  139713. */
  139714. export class NormalBlendBlock extends NodeMaterialBlock {
  139715. /**
  139716. * Creates a new NormalBlendBlock
  139717. * @param name defines the block name
  139718. */
  139719. constructor(name: string);
  139720. /**
  139721. * Gets the current class name
  139722. * @returns the class name
  139723. */
  139724. getClassName(): string;
  139725. /**
  139726. * Gets the first input component
  139727. */
  139728. get normalMap0(): NodeMaterialConnectionPoint;
  139729. /**
  139730. * Gets the second input component
  139731. */
  139732. get normalMap1(): NodeMaterialConnectionPoint;
  139733. /**
  139734. * Gets the output component
  139735. */
  139736. get output(): NodeMaterialConnectionPoint;
  139737. protected _buildBlock(state: NodeMaterialBuildState): this;
  139738. }
  139739. }
  139740. declare module BABYLON {
  139741. /**
  139742. * Block used to rotate a 2d vector by a given angle
  139743. */
  139744. export class Rotate2dBlock extends NodeMaterialBlock {
  139745. /**
  139746. * Creates a new Rotate2dBlock
  139747. * @param name defines the block name
  139748. */
  139749. constructor(name: string);
  139750. /**
  139751. * Gets the current class name
  139752. * @returns the class name
  139753. */
  139754. getClassName(): string;
  139755. /**
  139756. * Gets the input vector
  139757. */
  139758. get input(): NodeMaterialConnectionPoint;
  139759. /**
  139760. * Gets the input angle
  139761. */
  139762. get angle(): NodeMaterialConnectionPoint;
  139763. /**
  139764. * Gets the output component
  139765. */
  139766. get output(): NodeMaterialConnectionPoint;
  139767. autoConfigure(material: NodeMaterial): void;
  139768. protected _buildBlock(state: NodeMaterialBuildState): this;
  139769. }
  139770. }
  139771. declare module BABYLON {
  139772. /**
  139773. * Block used to get the reflected vector from a direction and a normal
  139774. */
  139775. export class ReflectBlock extends NodeMaterialBlock {
  139776. /**
  139777. * Creates a new ReflectBlock
  139778. * @param name defines the block name
  139779. */
  139780. constructor(name: string);
  139781. /**
  139782. * Gets the current class name
  139783. * @returns the class name
  139784. */
  139785. getClassName(): string;
  139786. /**
  139787. * Gets the incident component
  139788. */
  139789. get incident(): NodeMaterialConnectionPoint;
  139790. /**
  139791. * Gets the normal component
  139792. */
  139793. get normal(): NodeMaterialConnectionPoint;
  139794. /**
  139795. * Gets the output component
  139796. */
  139797. get output(): NodeMaterialConnectionPoint;
  139798. protected _buildBlock(state: NodeMaterialBuildState): this;
  139799. }
  139800. }
  139801. declare module BABYLON {
  139802. /**
  139803. * Block used to get the refracted vector from a direction and a normal
  139804. */
  139805. export class RefractBlock extends NodeMaterialBlock {
  139806. /**
  139807. * Creates a new RefractBlock
  139808. * @param name defines the block name
  139809. */
  139810. constructor(name: string);
  139811. /**
  139812. * Gets the current class name
  139813. * @returns the class name
  139814. */
  139815. getClassName(): string;
  139816. /**
  139817. * Gets the incident component
  139818. */
  139819. get incident(): NodeMaterialConnectionPoint;
  139820. /**
  139821. * Gets the normal component
  139822. */
  139823. get normal(): NodeMaterialConnectionPoint;
  139824. /**
  139825. * Gets the index of refraction component
  139826. */
  139827. get ior(): NodeMaterialConnectionPoint;
  139828. /**
  139829. * Gets the output component
  139830. */
  139831. get output(): NodeMaterialConnectionPoint;
  139832. protected _buildBlock(state: NodeMaterialBuildState): this;
  139833. }
  139834. }
  139835. declare module BABYLON {
  139836. /**
  139837. * Block used to desaturate a color
  139838. */
  139839. export class DesaturateBlock extends NodeMaterialBlock {
  139840. /**
  139841. * Creates a new DesaturateBlock
  139842. * @param name defines the block name
  139843. */
  139844. constructor(name: string);
  139845. /**
  139846. * Gets the current class name
  139847. * @returns the class name
  139848. */
  139849. getClassName(): string;
  139850. /**
  139851. * Gets the color operand input component
  139852. */
  139853. get color(): NodeMaterialConnectionPoint;
  139854. /**
  139855. * Gets the level operand input component
  139856. */
  139857. get level(): NodeMaterialConnectionPoint;
  139858. /**
  139859. * Gets the output component
  139860. */
  139861. get output(): NodeMaterialConnectionPoint;
  139862. protected _buildBlock(state: NodeMaterialBuildState): this;
  139863. }
  139864. }
  139865. declare module BABYLON {
  139866. /**
  139867. * Block used to implement the ambient occlusion module of the PBR material
  139868. */
  139869. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  139870. /**
  139871. * Create a new AmbientOcclusionBlock
  139872. * @param name defines the block name
  139873. */
  139874. constructor(name: string);
  139875. /**
  139876. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  139877. */
  139878. useAmbientInGrayScale: boolean;
  139879. /**
  139880. * Initialize the block and prepare the context for build
  139881. * @param state defines the state that will be used for the build
  139882. */
  139883. initialize(state: NodeMaterialBuildState): void;
  139884. /**
  139885. * Gets the current class name
  139886. * @returns the class name
  139887. */
  139888. getClassName(): string;
  139889. /**
  139890. * Gets the texture input component
  139891. */
  139892. get texture(): NodeMaterialConnectionPoint;
  139893. /**
  139894. * Gets the texture intensity component
  139895. */
  139896. get intensity(): NodeMaterialConnectionPoint;
  139897. /**
  139898. * Gets the direct light intensity input component
  139899. */
  139900. get directLightIntensity(): NodeMaterialConnectionPoint;
  139901. /**
  139902. * Gets the ambient occlusion object output component
  139903. */
  139904. get ambientOcclusion(): NodeMaterialConnectionPoint;
  139905. /**
  139906. * Gets the main code of the block (fragment side)
  139907. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  139908. * @returns the shader code
  139909. */
  139910. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  139911. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139912. protected _buildBlock(state: NodeMaterialBuildState): this;
  139913. protected _dumpPropertiesCode(): string;
  139914. serialize(): any;
  139915. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139916. }
  139917. }
  139918. declare module BABYLON {
  139919. /**
  139920. * Block used to implement the reflection module of the PBR material
  139921. */
  139922. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  139923. /** @hidden */
  139924. _defineLODReflectionAlpha: string;
  139925. /** @hidden */
  139926. _defineLinearSpecularReflection: string;
  139927. private _vEnvironmentIrradianceName;
  139928. /** @hidden */
  139929. _vReflectionMicrosurfaceInfosName: string;
  139930. /** @hidden */
  139931. _vReflectionInfosName: string;
  139932. /** @hidden */
  139933. _vReflectionFilteringInfoName: string;
  139934. private _scene;
  139935. /**
  139936. * The three properties below are set by the main PBR block prior to calling methods of this class.
  139937. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  139938. * It's less burden on the user side in the editor part.
  139939. */
  139940. /** @hidden */
  139941. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  139942. /** @hidden */
  139943. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  139944. /** @hidden */
  139945. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  139946. /**
  139947. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  139948. * diffuse part of the IBL.
  139949. */
  139950. useSphericalHarmonics: boolean;
  139951. /**
  139952. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  139953. */
  139954. forceIrradianceInFragment: boolean;
  139955. /**
  139956. * Create a new ReflectionBlock
  139957. * @param name defines the block name
  139958. */
  139959. constructor(name: string);
  139960. /**
  139961. * Gets the current class name
  139962. * @returns the class name
  139963. */
  139964. getClassName(): string;
  139965. /**
  139966. * Gets the position input component
  139967. */
  139968. get position(): NodeMaterialConnectionPoint;
  139969. /**
  139970. * Gets the world position input component
  139971. */
  139972. get worldPosition(): NodeMaterialConnectionPoint;
  139973. /**
  139974. * Gets the world normal input component
  139975. */
  139976. get worldNormal(): NodeMaterialConnectionPoint;
  139977. /**
  139978. * Gets the world input component
  139979. */
  139980. get world(): NodeMaterialConnectionPoint;
  139981. /**
  139982. * Gets the camera (or eye) position component
  139983. */
  139984. get cameraPosition(): NodeMaterialConnectionPoint;
  139985. /**
  139986. * Gets the view input component
  139987. */
  139988. get view(): NodeMaterialConnectionPoint;
  139989. /**
  139990. * Gets the color input component
  139991. */
  139992. get color(): NodeMaterialConnectionPoint;
  139993. /**
  139994. * Gets the reflection object output component
  139995. */
  139996. get reflection(): NodeMaterialConnectionPoint;
  139997. /**
  139998. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  139999. */
  140000. get hasTexture(): boolean;
  140001. /**
  140002. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  140003. */
  140004. get reflectionColor(): string;
  140005. protected _getTexture(): Nullable<BaseTexture>;
  140006. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140007. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  140008. /**
  140009. * Gets the code to inject in the vertex shader
  140010. * @param state current state of the node material building
  140011. * @returns the shader code
  140012. */
  140013. handleVertexSide(state: NodeMaterialBuildState): string;
  140014. /**
  140015. * Gets the main code of the block (fragment side)
  140016. * @param state current state of the node material building
  140017. * @param normalVarName name of the existing variable corresponding to the normal
  140018. * @returns the shader code
  140019. */
  140020. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  140021. protected _buildBlock(state: NodeMaterialBuildState): this;
  140022. protected _dumpPropertiesCode(): string;
  140023. serialize(): any;
  140024. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140025. }
  140026. }
  140027. declare module BABYLON {
  140028. /**
  140029. * Block used to implement the sheen module of the PBR material
  140030. */
  140031. export class SheenBlock extends NodeMaterialBlock {
  140032. /**
  140033. * Create a new SheenBlock
  140034. * @param name defines the block name
  140035. */
  140036. constructor(name: string);
  140037. /**
  140038. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  140039. * It allows the strength of the sheen effect to not depend on the base color of the material,
  140040. * making it easier to setup and tweak the effect
  140041. */
  140042. albedoScaling: boolean;
  140043. /**
  140044. * Defines if the sheen is linked to the sheen color.
  140045. */
  140046. linkSheenWithAlbedo: boolean;
  140047. /**
  140048. * Initialize the block and prepare the context for build
  140049. * @param state defines the state that will be used for the build
  140050. */
  140051. initialize(state: NodeMaterialBuildState): void;
  140052. /**
  140053. * Gets the current class name
  140054. * @returns the class name
  140055. */
  140056. getClassName(): string;
  140057. /**
  140058. * Gets the intensity input component
  140059. */
  140060. get intensity(): NodeMaterialConnectionPoint;
  140061. /**
  140062. * Gets the color input component
  140063. */
  140064. get color(): NodeMaterialConnectionPoint;
  140065. /**
  140066. * Gets the roughness input component
  140067. */
  140068. get roughness(): NodeMaterialConnectionPoint;
  140069. /**
  140070. * Gets the sheen object output component
  140071. */
  140072. get sheen(): NodeMaterialConnectionPoint;
  140073. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140074. /**
  140075. * Gets the main code of the block (fragment side)
  140076. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  140077. * @returns the shader code
  140078. */
  140079. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  140080. protected _buildBlock(state: NodeMaterialBuildState): this;
  140081. protected _dumpPropertiesCode(): string;
  140082. serialize(): any;
  140083. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140084. }
  140085. }
  140086. declare module BABYLON {
  140087. /**
  140088. * Block used to implement the reflectivity module of the PBR material
  140089. */
  140090. export class ReflectivityBlock extends NodeMaterialBlock {
  140091. private _metallicReflectanceColor;
  140092. private _metallicF0Factor;
  140093. /** @hidden */
  140094. _vMetallicReflectanceFactorsName: string;
  140095. /**
  140096. * The property below is set by the main PBR block prior to calling methods of this class.
  140097. */
  140098. /** @hidden */
  140099. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  140100. /**
  140101. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  140102. */
  140103. useAmbientOcclusionFromMetallicTextureRed: boolean;
  140104. /**
  140105. * Specifies if the metallic texture contains the metallness information in its blue channel.
  140106. */
  140107. useMetallnessFromMetallicTextureBlue: boolean;
  140108. /**
  140109. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  140110. */
  140111. useRoughnessFromMetallicTextureAlpha: boolean;
  140112. /**
  140113. * Specifies if the metallic texture contains the roughness information in its green channel.
  140114. */
  140115. useRoughnessFromMetallicTextureGreen: boolean;
  140116. /**
  140117. * Create a new ReflectivityBlock
  140118. * @param name defines the block name
  140119. */
  140120. constructor(name: string);
  140121. /**
  140122. * Initialize the block and prepare the context for build
  140123. * @param state defines the state that will be used for the build
  140124. */
  140125. initialize(state: NodeMaterialBuildState): void;
  140126. /**
  140127. * Gets the current class name
  140128. * @returns the class name
  140129. */
  140130. getClassName(): string;
  140131. /**
  140132. * Gets the metallic input component
  140133. */
  140134. get metallic(): NodeMaterialConnectionPoint;
  140135. /**
  140136. * Gets the roughness input component
  140137. */
  140138. get roughness(): NodeMaterialConnectionPoint;
  140139. /**
  140140. * Gets the texture input component
  140141. */
  140142. get texture(): NodeMaterialConnectionPoint;
  140143. /**
  140144. * Gets the reflectivity object output component
  140145. */
  140146. get reflectivity(): NodeMaterialConnectionPoint;
  140147. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  140148. /**
  140149. * Gets the main code of the block (fragment side)
  140150. * @param state current state of the node material building
  140151. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  140152. * @returns the shader code
  140153. */
  140154. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  140155. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140156. protected _buildBlock(state: NodeMaterialBuildState): this;
  140157. protected _dumpPropertiesCode(): string;
  140158. serialize(): any;
  140159. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140160. }
  140161. }
  140162. declare module BABYLON {
  140163. /**
  140164. * Block used to implement the anisotropy module of the PBR material
  140165. */
  140166. export class AnisotropyBlock extends NodeMaterialBlock {
  140167. /**
  140168. * The two properties below are set by the main PBR block prior to calling methods of this class.
  140169. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  140170. * It's less burden on the user side in the editor part.
  140171. */
  140172. /** @hidden */
  140173. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  140174. /** @hidden */
  140175. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  140176. /**
  140177. * Create a new AnisotropyBlock
  140178. * @param name defines the block name
  140179. */
  140180. constructor(name: string);
  140181. /**
  140182. * Initialize the block and prepare the context for build
  140183. * @param state defines the state that will be used for the build
  140184. */
  140185. initialize(state: NodeMaterialBuildState): void;
  140186. /**
  140187. * Gets the current class name
  140188. * @returns the class name
  140189. */
  140190. getClassName(): string;
  140191. /**
  140192. * Gets the intensity input component
  140193. */
  140194. get intensity(): NodeMaterialConnectionPoint;
  140195. /**
  140196. * Gets the direction input component
  140197. */
  140198. get direction(): NodeMaterialConnectionPoint;
  140199. /**
  140200. * Gets the texture input component
  140201. */
  140202. get texture(): NodeMaterialConnectionPoint;
  140203. /**
  140204. * Gets the uv input component
  140205. */
  140206. get uv(): NodeMaterialConnectionPoint;
  140207. /**
  140208. * Gets the worldTangent input component
  140209. */
  140210. get worldTangent(): NodeMaterialConnectionPoint;
  140211. /**
  140212. * Gets the anisotropy object output component
  140213. */
  140214. get anisotropy(): NodeMaterialConnectionPoint;
  140215. private _generateTBNSpace;
  140216. /**
  140217. * Gets the main code of the block (fragment side)
  140218. * @param state current state of the node material building
  140219. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  140220. * @returns the shader code
  140221. */
  140222. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  140223. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140224. protected _buildBlock(state: NodeMaterialBuildState): this;
  140225. }
  140226. }
  140227. declare module BABYLON {
  140228. /**
  140229. * Block used to implement the clear coat module of the PBR material
  140230. */
  140231. export class ClearCoatBlock extends NodeMaterialBlock {
  140232. private _scene;
  140233. /**
  140234. * Create a new ClearCoatBlock
  140235. * @param name defines the block name
  140236. */
  140237. constructor(name: string);
  140238. /**
  140239. * Initialize the block and prepare the context for build
  140240. * @param state defines the state that will be used for the build
  140241. */
  140242. initialize(state: NodeMaterialBuildState): void;
  140243. /**
  140244. * Gets the current class name
  140245. * @returns the class name
  140246. */
  140247. getClassName(): string;
  140248. /**
  140249. * Gets the intensity input component
  140250. */
  140251. get intensity(): NodeMaterialConnectionPoint;
  140252. /**
  140253. * Gets the roughness input component
  140254. */
  140255. get roughness(): NodeMaterialConnectionPoint;
  140256. /**
  140257. * Gets the ior input component
  140258. */
  140259. get ior(): NodeMaterialConnectionPoint;
  140260. /**
  140261. * Gets the texture input component
  140262. */
  140263. get texture(): NodeMaterialConnectionPoint;
  140264. /**
  140265. * Gets the bump texture input component
  140266. */
  140267. get bumpTexture(): NodeMaterialConnectionPoint;
  140268. /**
  140269. * Gets the uv input component
  140270. */
  140271. get uv(): NodeMaterialConnectionPoint;
  140272. /**
  140273. * Gets the tint color input component
  140274. */
  140275. get tintColor(): NodeMaterialConnectionPoint;
  140276. /**
  140277. * Gets the tint "at distance" input component
  140278. */
  140279. get tintAtDistance(): NodeMaterialConnectionPoint;
  140280. /**
  140281. * Gets the tint thickness input component
  140282. */
  140283. get tintThickness(): NodeMaterialConnectionPoint;
  140284. /**
  140285. * Gets the world tangent input component
  140286. */
  140287. get worldTangent(): NodeMaterialConnectionPoint;
  140288. /**
  140289. * Gets the clear coat object output component
  140290. */
  140291. get clearcoat(): NodeMaterialConnectionPoint;
  140292. autoConfigure(material: NodeMaterial): void;
  140293. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140294. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  140295. private _generateTBNSpace;
  140296. /**
  140297. * Gets the main code of the block (fragment side)
  140298. * @param state current state of the node material building
  140299. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  140300. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  140301. * @param worldPosVarName name of the variable holding the world position
  140302. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  140303. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  140304. * @param worldNormalVarName name of the variable holding the world normal
  140305. * @returns the shader code
  140306. */
  140307. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  140308. protected _buildBlock(state: NodeMaterialBuildState): this;
  140309. }
  140310. }
  140311. declare module BABYLON {
  140312. /**
  140313. * Block used to implement the sub surface module of the PBR material
  140314. */
  140315. export class SubSurfaceBlock extends NodeMaterialBlock {
  140316. /**
  140317. * Create a new SubSurfaceBlock
  140318. * @param name defines the block name
  140319. */
  140320. constructor(name: string);
  140321. /**
  140322. * Stores the intensity of the different subsurface effects in the thickness texture.
  140323. * * the green channel is the translucency intensity.
  140324. * * the blue channel is the scattering intensity.
  140325. * * the alpha channel is the refraction intensity.
  140326. */
  140327. useMaskFromThicknessTexture: boolean;
  140328. /**
  140329. * Initialize the block and prepare the context for build
  140330. * @param state defines the state that will be used for the build
  140331. */
  140332. initialize(state: NodeMaterialBuildState): void;
  140333. /**
  140334. * Gets the current class name
  140335. * @returns the class name
  140336. */
  140337. getClassName(): string;
  140338. /**
  140339. * Gets the min thickness input component
  140340. */
  140341. get minThickness(): NodeMaterialConnectionPoint;
  140342. /**
  140343. * Gets the max thickness input component
  140344. */
  140345. get maxThickness(): NodeMaterialConnectionPoint;
  140346. /**
  140347. * Gets the thickness texture component
  140348. */
  140349. get thicknessTexture(): NodeMaterialConnectionPoint;
  140350. /**
  140351. * Gets the tint color input component
  140352. */
  140353. get tintColor(): NodeMaterialConnectionPoint;
  140354. /**
  140355. * Gets the translucency intensity input component
  140356. */
  140357. get translucencyIntensity(): NodeMaterialConnectionPoint;
  140358. /**
  140359. * Gets the translucency diffusion distance input component
  140360. */
  140361. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  140362. /**
  140363. * Gets the refraction object parameters
  140364. */
  140365. get refraction(): NodeMaterialConnectionPoint;
  140366. /**
  140367. * Gets the sub surface object output component
  140368. */
  140369. get subsurface(): NodeMaterialConnectionPoint;
  140370. autoConfigure(material: NodeMaterial): void;
  140371. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140372. /**
  140373. * Gets the main code of the block (fragment side)
  140374. * @param state current state of the node material building
  140375. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  140376. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  140377. * @param worldPosVarName name of the variable holding the world position
  140378. * @returns the shader code
  140379. */
  140380. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  140381. protected _buildBlock(state: NodeMaterialBuildState): this;
  140382. }
  140383. }
  140384. declare module BABYLON {
  140385. /**
  140386. * Block used to implement the PBR metallic/roughness model
  140387. */
  140388. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  140389. /**
  140390. * Gets or sets the light associated with this block
  140391. */
  140392. light: Nullable<Light>;
  140393. private _lightId;
  140394. private _scene;
  140395. private _environmentBRDFTexture;
  140396. private _environmentBrdfSamplerName;
  140397. private _vNormalWName;
  140398. private _invertNormalName;
  140399. /**
  140400. * Create a new ReflectionBlock
  140401. * @param name defines the block name
  140402. */
  140403. constructor(name: string);
  140404. /**
  140405. * Intensity of the direct lights e.g. the four lights available in your scene.
  140406. * This impacts both the direct diffuse and specular highlights.
  140407. */
  140408. directIntensity: number;
  140409. /**
  140410. * Intensity of the environment e.g. how much the environment will light the object
  140411. * either through harmonics for rough material or through the refelction for shiny ones.
  140412. */
  140413. environmentIntensity: number;
  140414. /**
  140415. * This is a special control allowing the reduction of the specular highlights coming from the
  140416. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  140417. */
  140418. specularIntensity: number;
  140419. /**
  140420. * Defines the falloff type used in this material.
  140421. * It by default is Physical.
  140422. */
  140423. lightFalloff: number;
  140424. /**
  140425. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  140426. */
  140427. useAlphaFromAlbedoTexture: boolean;
  140428. /**
  140429. * Specifies that alpha test should be used
  140430. */
  140431. useAlphaTest: boolean;
  140432. /**
  140433. * Defines the alpha limits in alpha test mode.
  140434. */
  140435. alphaTestCutoff: number;
  140436. /**
  140437. * Specifies that alpha blending should be used
  140438. */
  140439. useAlphaBlending: boolean;
  140440. /**
  140441. * Defines if the alpha value should be determined via the rgb values.
  140442. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  140443. */
  140444. opacityRGB: boolean;
  140445. /**
  140446. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  140447. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  140448. */
  140449. useRadianceOverAlpha: boolean;
  140450. /**
  140451. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  140452. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  140453. */
  140454. useSpecularOverAlpha: boolean;
  140455. /**
  140456. * Enables specular anti aliasing in the PBR shader.
  140457. * It will both interacts on the Geometry for analytical and IBL lighting.
  140458. * It also prefilter the roughness map based on the bump values.
  140459. */
  140460. enableSpecularAntiAliasing: boolean;
  140461. /**
  140462. * Enables realtime filtering on the texture.
  140463. */
  140464. realTimeFiltering: boolean;
  140465. /**
  140466. * Quality switch for realtime filtering
  140467. */
  140468. realTimeFilteringQuality: number;
  140469. /**
  140470. * Defines if the material uses energy conservation.
  140471. */
  140472. useEnergyConservation: boolean;
  140473. /**
  140474. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  140475. * too much the area relying on ambient texture to define their ambient occlusion.
  140476. */
  140477. useRadianceOcclusion: boolean;
  140478. /**
  140479. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  140480. * makes the reflect vector face the model (under horizon).
  140481. */
  140482. useHorizonOcclusion: boolean;
  140483. /**
  140484. * If set to true, no lighting calculations will be applied.
  140485. */
  140486. unlit: boolean;
  140487. /**
  140488. * Force normal to face away from face.
  140489. */
  140490. forceNormalForward: boolean;
  140491. /**
  140492. * Defines the material debug mode.
  140493. * It helps seeing only some components of the material while troubleshooting.
  140494. */
  140495. debugMode: number;
  140496. /**
  140497. * Specify from where on screen the debug mode should start.
  140498. * The value goes from -1 (full screen) to 1 (not visible)
  140499. * It helps with side by side comparison against the final render
  140500. * This defaults to 0
  140501. */
  140502. debugLimit: number;
  140503. /**
  140504. * As the default viewing range might not be enough (if the ambient is really small for instance)
  140505. * You can use the factor to better multiply the final value.
  140506. */
  140507. debugFactor: number;
  140508. /**
  140509. * Initialize the block and prepare the context for build
  140510. * @param state defines the state that will be used for the build
  140511. */
  140512. initialize(state: NodeMaterialBuildState): void;
  140513. /**
  140514. * Gets the current class name
  140515. * @returns the class name
  140516. */
  140517. getClassName(): string;
  140518. /**
  140519. * Gets the world position input component
  140520. */
  140521. get worldPosition(): NodeMaterialConnectionPoint;
  140522. /**
  140523. * Gets the world normal input component
  140524. */
  140525. get worldNormal(): NodeMaterialConnectionPoint;
  140526. /**
  140527. * Gets the perturbed normal input component
  140528. */
  140529. get perturbedNormal(): NodeMaterialConnectionPoint;
  140530. /**
  140531. * Gets the camera position input component
  140532. */
  140533. get cameraPosition(): NodeMaterialConnectionPoint;
  140534. /**
  140535. * Gets the base color input component
  140536. */
  140537. get baseColor(): NodeMaterialConnectionPoint;
  140538. /**
  140539. * Gets the opacity texture input component
  140540. */
  140541. get opacityTexture(): NodeMaterialConnectionPoint;
  140542. /**
  140543. * Gets the ambient color input component
  140544. */
  140545. get ambientColor(): NodeMaterialConnectionPoint;
  140546. /**
  140547. * Gets the reflectivity object parameters
  140548. */
  140549. get reflectivity(): NodeMaterialConnectionPoint;
  140550. /**
  140551. * Gets the ambient occlusion object parameters
  140552. */
  140553. get ambientOcclusion(): NodeMaterialConnectionPoint;
  140554. /**
  140555. * Gets the reflection object parameters
  140556. */
  140557. get reflection(): NodeMaterialConnectionPoint;
  140558. /**
  140559. * Gets the sheen object parameters
  140560. */
  140561. get sheen(): NodeMaterialConnectionPoint;
  140562. /**
  140563. * Gets the clear coat object parameters
  140564. */
  140565. get clearcoat(): NodeMaterialConnectionPoint;
  140566. /**
  140567. * Gets the sub surface object parameters
  140568. */
  140569. get subsurface(): NodeMaterialConnectionPoint;
  140570. /**
  140571. * Gets the anisotropy object parameters
  140572. */
  140573. get anisotropy(): NodeMaterialConnectionPoint;
  140574. /**
  140575. * Gets the ambient output component
  140576. */
  140577. get ambient(): NodeMaterialConnectionPoint;
  140578. /**
  140579. * Gets the diffuse output component
  140580. */
  140581. get diffuse(): NodeMaterialConnectionPoint;
  140582. /**
  140583. * Gets the specular output component
  140584. */
  140585. get specular(): NodeMaterialConnectionPoint;
  140586. /**
  140587. * Gets the sheen output component
  140588. */
  140589. get sheenDir(): NodeMaterialConnectionPoint;
  140590. /**
  140591. * Gets the clear coat output component
  140592. */
  140593. get clearcoatDir(): NodeMaterialConnectionPoint;
  140594. /**
  140595. * Gets the indirect diffuse output component
  140596. */
  140597. get diffuseIndirect(): NodeMaterialConnectionPoint;
  140598. /**
  140599. * Gets the indirect specular output component
  140600. */
  140601. get specularIndirect(): NodeMaterialConnectionPoint;
  140602. /**
  140603. * Gets the indirect sheen output component
  140604. */
  140605. get sheenIndirect(): NodeMaterialConnectionPoint;
  140606. /**
  140607. * Gets the indirect clear coat output component
  140608. */
  140609. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  140610. /**
  140611. * Gets the refraction output component
  140612. */
  140613. get refraction(): NodeMaterialConnectionPoint;
  140614. /**
  140615. * Gets the global lighting output component
  140616. */
  140617. get lighting(): NodeMaterialConnectionPoint;
  140618. /**
  140619. * Gets the shadow output component
  140620. */
  140621. get shadow(): NodeMaterialConnectionPoint;
  140622. /**
  140623. * Gets the alpha output component
  140624. */
  140625. get alpha(): NodeMaterialConnectionPoint;
  140626. autoConfigure(material: NodeMaterial): void;
  140627. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140628. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  140629. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140630. private _injectVertexCode;
  140631. /**
  140632. * Gets the code corresponding to the albedo/opacity module
  140633. * @returns the shader code
  140634. */
  140635. getAlbedoOpacityCode(): string;
  140636. protected _buildBlock(state: NodeMaterialBuildState): this;
  140637. protected _dumpPropertiesCode(): string;
  140638. serialize(): any;
  140639. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140640. }
  140641. }
  140642. declare module BABYLON {
  140643. /**
  140644. * Block used to compute value of one parameter modulo another
  140645. */
  140646. export class ModBlock extends NodeMaterialBlock {
  140647. /**
  140648. * Creates a new ModBlock
  140649. * @param name defines the block name
  140650. */
  140651. constructor(name: string);
  140652. /**
  140653. * Gets the current class name
  140654. * @returns the class name
  140655. */
  140656. getClassName(): string;
  140657. /**
  140658. * Gets the left operand input component
  140659. */
  140660. get left(): NodeMaterialConnectionPoint;
  140661. /**
  140662. * Gets the right operand input component
  140663. */
  140664. get right(): NodeMaterialConnectionPoint;
  140665. /**
  140666. * Gets the output component
  140667. */
  140668. get output(): NodeMaterialConnectionPoint;
  140669. protected _buildBlock(state: NodeMaterialBuildState): this;
  140670. }
  140671. }
  140672. declare module BABYLON {
  140673. /**
  140674. * Helper class to push actions to a pool of workers.
  140675. */
  140676. export class WorkerPool implements IDisposable {
  140677. private _workerInfos;
  140678. private _pendingActions;
  140679. /**
  140680. * Constructor
  140681. * @param workers Array of workers to use for actions
  140682. */
  140683. constructor(workers: Array<Worker>);
  140684. /**
  140685. * Terminates all workers and clears any pending actions.
  140686. */
  140687. dispose(): void;
  140688. /**
  140689. * Pushes an action to the worker pool. If all the workers are active, the action will be
  140690. * pended until a worker has completed its action.
  140691. * @param action The action to perform. Call onComplete when the action is complete.
  140692. */
  140693. push(action: (worker: Worker, onComplete: () => void) => void): void;
  140694. private _execute;
  140695. }
  140696. }
  140697. declare module BABYLON {
  140698. /**
  140699. * Configuration for Draco compression
  140700. */
  140701. export interface IDracoCompressionConfiguration {
  140702. /**
  140703. * Configuration for the decoder.
  140704. */
  140705. decoder: {
  140706. /**
  140707. * The url to the WebAssembly module.
  140708. */
  140709. wasmUrl?: string;
  140710. /**
  140711. * The url to the WebAssembly binary.
  140712. */
  140713. wasmBinaryUrl?: string;
  140714. /**
  140715. * The url to the fallback JavaScript module.
  140716. */
  140717. fallbackUrl?: string;
  140718. };
  140719. }
  140720. /**
  140721. * Draco compression (https://google.github.io/draco/)
  140722. *
  140723. * This class wraps the Draco module.
  140724. *
  140725. * **Encoder**
  140726. *
  140727. * The encoder is not currently implemented.
  140728. *
  140729. * **Decoder**
  140730. *
  140731. * 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.
  140732. *
  140733. * To update the configuration, use the following code:
  140734. * ```javascript
  140735. * DracoCompression.Configuration = {
  140736. * decoder: {
  140737. * wasmUrl: "<url to the WebAssembly library>",
  140738. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  140739. * fallbackUrl: "<url to the fallback JavaScript library>",
  140740. * }
  140741. * };
  140742. * ```
  140743. *
  140744. * 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.
  140745. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  140746. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  140747. *
  140748. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  140749. * ```javascript
  140750. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  140751. * ```
  140752. *
  140753. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  140754. */
  140755. export class DracoCompression implements IDisposable {
  140756. private _workerPoolPromise?;
  140757. private _decoderModulePromise?;
  140758. /**
  140759. * The configuration. Defaults to the following urls:
  140760. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  140761. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  140762. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  140763. */
  140764. static Configuration: IDracoCompressionConfiguration;
  140765. /**
  140766. * Returns true if the decoder configuration is available.
  140767. */
  140768. static get DecoderAvailable(): boolean;
  140769. /**
  140770. * Default number of workers to create when creating the draco compression object.
  140771. */
  140772. static DefaultNumWorkers: number;
  140773. private static GetDefaultNumWorkers;
  140774. private static _Default;
  140775. /**
  140776. * Default instance for the draco compression object.
  140777. */
  140778. static get Default(): DracoCompression;
  140779. /**
  140780. * Constructor
  140781. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  140782. */
  140783. constructor(numWorkers?: number);
  140784. /**
  140785. * Stop all async operations and release resources.
  140786. */
  140787. dispose(): void;
  140788. /**
  140789. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  140790. * @returns a promise that resolves when ready
  140791. */
  140792. whenReadyAsync(): Promise<void>;
  140793. /**
  140794. * Decode Draco compressed mesh data to vertex data.
  140795. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  140796. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  140797. * @returns A promise that resolves with the decoded vertex data
  140798. */
  140799. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  140800. [kind: string]: number;
  140801. }): Promise<VertexData>;
  140802. }
  140803. }
  140804. declare module BABYLON {
  140805. /**
  140806. * Class for building Constructive Solid Geometry
  140807. */
  140808. export class CSG {
  140809. private polygons;
  140810. /**
  140811. * The world matrix
  140812. */
  140813. matrix: Matrix;
  140814. /**
  140815. * Stores the position
  140816. */
  140817. position: Vector3;
  140818. /**
  140819. * Stores the rotation
  140820. */
  140821. rotation: Vector3;
  140822. /**
  140823. * Stores the rotation quaternion
  140824. */
  140825. rotationQuaternion: Nullable<Quaternion>;
  140826. /**
  140827. * Stores the scaling vector
  140828. */
  140829. scaling: Vector3;
  140830. /**
  140831. * Convert the Mesh to CSG
  140832. * @param mesh The Mesh to convert to CSG
  140833. * @returns A new CSG from the Mesh
  140834. */
  140835. static FromMesh(mesh: Mesh): CSG;
  140836. /**
  140837. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  140838. * @param polygons Polygons used to construct a CSG solid
  140839. */
  140840. private static FromPolygons;
  140841. /**
  140842. * Clones, or makes a deep copy, of the CSG
  140843. * @returns A new CSG
  140844. */
  140845. clone(): CSG;
  140846. /**
  140847. * Unions this CSG with another CSG
  140848. * @param csg The CSG to union against this CSG
  140849. * @returns The unioned CSG
  140850. */
  140851. union(csg: CSG): CSG;
  140852. /**
  140853. * Unions this CSG with another CSG in place
  140854. * @param csg The CSG to union against this CSG
  140855. */
  140856. unionInPlace(csg: CSG): void;
  140857. /**
  140858. * Subtracts this CSG with another CSG
  140859. * @param csg The CSG to subtract against this CSG
  140860. * @returns A new CSG
  140861. */
  140862. subtract(csg: CSG): CSG;
  140863. /**
  140864. * Subtracts this CSG with another CSG in place
  140865. * @param csg The CSG to subtact against this CSG
  140866. */
  140867. subtractInPlace(csg: CSG): void;
  140868. /**
  140869. * Intersect this CSG with another CSG
  140870. * @param csg The CSG to intersect against this CSG
  140871. * @returns A new CSG
  140872. */
  140873. intersect(csg: CSG): CSG;
  140874. /**
  140875. * Intersects this CSG with another CSG in place
  140876. * @param csg The CSG to intersect against this CSG
  140877. */
  140878. intersectInPlace(csg: CSG): void;
  140879. /**
  140880. * Return a new CSG solid with solid and empty space switched. This solid is
  140881. * not modified.
  140882. * @returns A new CSG solid with solid and empty space switched
  140883. */
  140884. inverse(): CSG;
  140885. /**
  140886. * Inverses the CSG in place
  140887. */
  140888. inverseInPlace(): void;
  140889. /**
  140890. * This is used to keep meshes transformations so they can be restored
  140891. * when we build back a Babylon Mesh
  140892. * NB : All CSG operations are performed in world coordinates
  140893. * @param csg The CSG to copy the transform attributes from
  140894. * @returns This CSG
  140895. */
  140896. copyTransformAttributes(csg: CSG): CSG;
  140897. /**
  140898. * Build Raw mesh from CSG
  140899. * Coordinates here are in world space
  140900. * @param name The name of the mesh geometry
  140901. * @param scene The Scene
  140902. * @param keepSubMeshes Specifies if the submeshes should be kept
  140903. * @returns A new Mesh
  140904. */
  140905. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  140906. /**
  140907. * Build Mesh from CSG taking material and transforms into account
  140908. * @param name The name of the Mesh
  140909. * @param material The material of the Mesh
  140910. * @param scene The Scene
  140911. * @param keepSubMeshes Specifies if submeshes should be kept
  140912. * @returns The new Mesh
  140913. */
  140914. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  140915. }
  140916. }
  140917. declare module BABYLON {
  140918. /**
  140919. * Class used to create a trail following a mesh
  140920. */
  140921. export class TrailMesh extends Mesh {
  140922. private _generator;
  140923. private _autoStart;
  140924. private _running;
  140925. private _diameter;
  140926. private _length;
  140927. private _sectionPolygonPointsCount;
  140928. private _sectionVectors;
  140929. private _sectionNormalVectors;
  140930. private _beforeRenderObserver;
  140931. /**
  140932. * @constructor
  140933. * @param name The value used by scene.getMeshByName() to do a lookup.
  140934. * @param generator The mesh or transform node to generate a trail.
  140935. * @param scene The scene to add this mesh to.
  140936. * @param diameter Diameter of trailing mesh. Default is 1.
  140937. * @param length Length of trailing mesh. Default is 60.
  140938. * @param autoStart Automatically start trailing mesh. Default true.
  140939. */
  140940. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  140941. /**
  140942. * "TrailMesh"
  140943. * @returns "TrailMesh"
  140944. */
  140945. getClassName(): string;
  140946. private _createMesh;
  140947. /**
  140948. * Start trailing mesh.
  140949. */
  140950. start(): void;
  140951. /**
  140952. * Stop trailing mesh.
  140953. */
  140954. stop(): void;
  140955. /**
  140956. * Update trailing mesh geometry.
  140957. */
  140958. update(): void;
  140959. /**
  140960. * Returns a new TrailMesh object.
  140961. * @param name is a string, the name given to the new mesh
  140962. * @param newGenerator use new generator object for cloned trail mesh
  140963. * @returns a new mesh
  140964. */
  140965. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  140966. /**
  140967. * Serializes this trail mesh
  140968. * @param serializationObject object to write serialization to
  140969. */
  140970. serialize(serializationObject: any): void;
  140971. /**
  140972. * Parses a serialized trail mesh
  140973. * @param parsedMesh the serialized mesh
  140974. * @param scene the scene to create the trail mesh in
  140975. * @returns the created trail mesh
  140976. */
  140977. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  140978. }
  140979. }
  140980. declare module BABYLON {
  140981. /**
  140982. * Class containing static functions to help procedurally build meshes
  140983. */
  140984. export class TiledBoxBuilder {
  140985. /**
  140986. * Creates a box mesh
  140987. * 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)
  140988. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  140989. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140990. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140992. * @param name defines the name of the mesh
  140993. * @param options defines the options used to create the mesh
  140994. * @param scene defines the hosting scene
  140995. * @returns the box mesh
  140996. */
  140997. static CreateTiledBox(name: string, options: {
  140998. pattern?: number;
  140999. width?: number;
  141000. height?: number;
  141001. depth?: number;
  141002. tileSize?: number;
  141003. tileWidth?: number;
  141004. tileHeight?: number;
  141005. alignHorizontal?: number;
  141006. alignVertical?: number;
  141007. faceUV?: Vector4[];
  141008. faceColors?: Color4[];
  141009. sideOrientation?: number;
  141010. updatable?: boolean;
  141011. }, scene?: Nullable<Scene>): Mesh;
  141012. }
  141013. }
  141014. declare module BABYLON {
  141015. /**
  141016. * Class containing static functions to help procedurally build meshes
  141017. */
  141018. export class TorusKnotBuilder {
  141019. /**
  141020. * Creates a torus knot mesh
  141021. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  141022. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  141023. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  141024. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  141025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141026. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141028. * @param name defines the name of the mesh
  141029. * @param options defines the options used to create the mesh
  141030. * @param scene defines the hosting scene
  141031. * @returns the torus knot mesh
  141032. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  141033. */
  141034. static CreateTorusKnot(name: string, options: {
  141035. radius?: number;
  141036. tube?: number;
  141037. radialSegments?: number;
  141038. tubularSegments?: number;
  141039. p?: number;
  141040. q?: number;
  141041. updatable?: boolean;
  141042. sideOrientation?: number;
  141043. frontUVs?: Vector4;
  141044. backUVs?: Vector4;
  141045. }, scene: any): Mesh;
  141046. }
  141047. }
  141048. declare module BABYLON {
  141049. /**
  141050. * Polygon
  141051. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  141052. */
  141053. export class Polygon {
  141054. /**
  141055. * Creates a rectangle
  141056. * @param xmin bottom X coord
  141057. * @param ymin bottom Y coord
  141058. * @param xmax top X coord
  141059. * @param ymax top Y coord
  141060. * @returns points that make the resulting rectation
  141061. */
  141062. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  141063. /**
  141064. * Creates a circle
  141065. * @param radius radius of circle
  141066. * @param cx scale in x
  141067. * @param cy scale in y
  141068. * @param numberOfSides number of sides that make up the circle
  141069. * @returns points that make the resulting circle
  141070. */
  141071. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  141072. /**
  141073. * Creates a polygon from input string
  141074. * @param input Input polygon data
  141075. * @returns the parsed points
  141076. */
  141077. static Parse(input: string): Vector2[];
  141078. /**
  141079. * Starts building a polygon from x and y coordinates
  141080. * @param x x coordinate
  141081. * @param y y coordinate
  141082. * @returns the started path2
  141083. */
  141084. static StartingAt(x: number, y: number): Path2;
  141085. }
  141086. /**
  141087. * Builds a polygon
  141088. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  141089. */
  141090. export class PolygonMeshBuilder {
  141091. private _points;
  141092. private _outlinepoints;
  141093. private _holes;
  141094. private _name;
  141095. private _scene;
  141096. private _epoints;
  141097. private _eholes;
  141098. private _addToepoint;
  141099. /**
  141100. * Babylon reference to the earcut plugin.
  141101. */
  141102. bjsEarcut: any;
  141103. /**
  141104. * Creates a PolygonMeshBuilder
  141105. * @param name name of the builder
  141106. * @param contours Path of the polygon
  141107. * @param scene scene to add to when creating the mesh
  141108. * @param earcutInjection can be used to inject your own earcut reference
  141109. */
  141110. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  141111. /**
  141112. * Adds a whole within the polygon
  141113. * @param hole Array of points defining the hole
  141114. * @returns this
  141115. */
  141116. addHole(hole: Vector2[]): PolygonMeshBuilder;
  141117. /**
  141118. * Creates the polygon
  141119. * @param updatable If the mesh should be updatable
  141120. * @param depth The depth of the mesh created
  141121. * @returns the created mesh
  141122. */
  141123. build(updatable?: boolean, depth?: number): Mesh;
  141124. /**
  141125. * Creates the polygon
  141126. * @param depth The depth of the mesh created
  141127. * @returns the created VertexData
  141128. */
  141129. buildVertexData(depth?: number): VertexData;
  141130. /**
  141131. * Adds a side to the polygon
  141132. * @param positions points that make the polygon
  141133. * @param normals normals of the polygon
  141134. * @param uvs uvs of the polygon
  141135. * @param indices indices of the polygon
  141136. * @param bounds bounds of the polygon
  141137. * @param points points of the polygon
  141138. * @param depth depth of the polygon
  141139. * @param flip flip of the polygon
  141140. */
  141141. private addSide;
  141142. }
  141143. }
  141144. declare module BABYLON {
  141145. /**
  141146. * Class containing static functions to help procedurally build meshes
  141147. */
  141148. export class PolygonBuilder {
  141149. /**
  141150. * Creates a polygon mesh
  141151. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  141152. * * 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
  141153. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  141154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141155. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  141156. * * Remember you can only change the shape positions, not their number when updating a polygon
  141157. * @param name defines the name of the mesh
  141158. * @param options defines the options used to create the mesh
  141159. * @param scene defines the hosting scene
  141160. * @param earcutInjection can be used to inject your own earcut reference
  141161. * @returns the polygon mesh
  141162. */
  141163. static CreatePolygon(name: string, options: {
  141164. shape: Vector3[];
  141165. holes?: Vector3[][];
  141166. depth?: number;
  141167. faceUV?: Vector4[];
  141168. faceColors?: Color4[];
  141169. updatable?: boolean;
  141170. sideOrientation?: number;
  141171. frontUVs?: Vector4;
  141172. backUVs?: Vector4;
  141173. wrap?: boolean;
  141174. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  141175. /**
  141176. * Creates an extruded polygon mesh, with depth in the Y direction.
  141177. * * 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)
  141178. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  141179. * @param name defines the name of the mesh
  141180. * @param options defines the options used to create the mesh
  141181. * @param scene defines the hosting scene
  141182. * @param earcutInjection can be used to inject your own earcut reference
  141183. * @returns the polygon mesh
  141184. */
  141185. static ExtrudePolygon(name: string, options: {
  141186. shape: Vector3[];
  141187. holes?: Vector3[][];
  141188. depth?: number;
  141189. faceUV?: Vector4[];
  141190. faceColors?: Color4[];
  141191. updatable?: boolean;
  141192. sideOrientation?: number;
  141193. frontUVs?: Vector4;
  141194. backUVs?: Vector4;
  141195. wrap?: boolean;
  141196. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  141197. }
  141198. }
  141199. declare module BABYLON {
  141200. /**
  141201. * Class containing static functions to help procedurally build meshes
  141202. */
  141203. export class LatheBuilder {
  141204. /**
  141205. * Creates lathe mesh.
  141206. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  141207. * * 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
  141208. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  141209. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  141210. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  141211. * * 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
  141212. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  141213. * * 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
  141214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141215. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141216. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141218. * @param name defines the name of the mesh
  141219. * @param options defines the options used to create the mesh
  141220. * @param scene defines the hosting scene
  141221. * @returns the lathe mesh
  141222. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  141223. */
  141224. static CreateLathe(name: string, options: {
  141225. shape: Vector3[];
  141226. radius?: number;
  141227. tessellation?: number;
  141228. clip?: number;
  141229. arc?: number;
  141230. closed?: boolean;
  141231. updatable?: boolean;
  141232. sideOrientation?: number;
  141233. frontUVs?: Vector4;
  141234. backUVs?: Vector4;
  141235. cap?: number;
  141236. invertUV?: boolean;
  141237. }, scene?: Nullable<Scene>): Mesh;
  141238. }
  141239. }
  141240. declare module BABYLON {
  141241. /**
  141242. * Class containing static functions to help procedurally build meshes
  141243. */
  141244. export class TiledPlaneBuilder {
  141245. /**
  141246. * Creates a tiled plane mesh
  141247. * * The parameter `pattern` will, depending on value, do nothing or
  141248. * * * flip (reflect about central vertical) alternate tiles across and up
  141249. * * * flip every tile on alternate rows
  141250. * * * rotate (180 degs) alternate tiles across and up
  141251. * * * rotate every tile on alternate rows
  141252. * * * flip and rotate alternate tiles across and up
  141253. * * * flip and rotate every tile on alternate rows
  141254. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  141255. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  141256. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141257. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  141258. * * 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)
  141259. * * 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)
  141260. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  141261. * @param name defines the name of the mesh
  141262. * @param options defines the options used to create the mesh
  141263. * @param scene defines the hosting scene
  141264. * @returns the box mesh
  141265. */
  141266. static CreateTiledPlane(name: string, options: {
  141267. pattern?: number;
  141268. tileSize?: number;
  141269. tileWidth?: number;
  141270. tileHeight?: number;
  141271. size?: number;
  141272. width?: number;
  141273. height?: number;
  141274. alignHorizontal?: number;
  141275. alignVertical?: number;
  141276. sideOrientation?: number;
  141277. frontUVs?: Vector4;
  141278. backUVs?: Vector4;
  141279. updatable?: boolean;
  141280. }, scene?: Nullable<Scene>): Mesh;
  141281. }
  141282. }
  141283. declare module BABYLON {
  141284. /**
  141285. * Class containing static functions to help procedurally build meshes
  141286. */
  141287. export class TubeBuilder {
  141288. /**
  141289. * Creates a tube mesh.
  141290. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  141291. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  141292. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  141293. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  141294. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  141295. * * 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)
  141296. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  141297. * * 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
  141298. * * 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
  141299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141300. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141301. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141303. * @param name defines the name of the mesh
  141304. * @param options defines the options used to create the mesh
  141305. * @param scene defines the hosting scene
  141306. * @returns the tube mesh
  141307. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141308. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  141309. */
  141310. static CreateTube(name: string, options: {
  141311. path: Vector3[];
  141312. radius?: number;
  141313. tessellation?: number;
  141314. radiusFunction?: {
  141315. (i: number, distance: number): number;
  141316. };
  141317. cap?: number;
  141318. arc?: number;
  141319. updatable?: boolean;
  141320. sideOrientation?: number;
  141321. frontUVs?: Vector4;
  141322. backUVs?: Vector4;
  141323. instance?: Mesh;
  141324. invertUV?: boolean;
  141325. }, scene?: Nullable<Scene>): Mesh;
  141326. }
  141327. }
  141328. declare module BABYLON {
  141329. /**
  141330. * Class containing static functions to help procedurally build meshes
  141331. */
  141332. export class IcoSphereBuilder {
  141333. /**
  141334. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  141335. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  141336. * * 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`)
  141337. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  141338. * * 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
  141339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141340. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141342. * @param name defines the name of the mesh
  141343. * @param options defines the options used to create the mesh
  141344. * @param scene defines the hosting scene
  141345. * @returns the icosahedron mesh
  141346. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  141347. */
  141348. static CreateIcoSphere(name: string, options: {
  141349. radius?: number;
  141350. radiusX?: number;
  141351. radiusY?: number;
  141352. radiusZ?: number;
  141353. flat?: boolean;
  141354. subdivisions?: number;
  141355. sideOrientation?: number;
  141356. frontUVs?: Vector4;
  141357. backUVs?: Vector4;
  141358. updatable?: boolean;
  141359. }, scene?: Nullable<Scene>): Mesh;
  141360. }
  141361. }
  141362. declare module BABYLON {
  141363. /**
  141364. * Class containing static functions to help procedurally build meshes
  141365. */
  141366. export class DecalBuilder {
  141367. /**
  141368. * Creates a decal mesh.
  141369. * 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
  141370. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  141371. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  141372. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  141373. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  141374. * @param name defines the name of the mesh
  141375. * @param sourceMesh defines the mesh where the decal must be applied
  141376. * @param options defines the options used to create the mesh
  141377. * @param scene defines the hosting scene
  141378. * @returns the decal mesh
  141379. * @see https://doc.babylonjs.com/how_to/decals
  141380. */
  141381. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  141382. position?: Vector3;
  141383. normal?: Vector3;
  141384. size?: Vector3;
  141385. angle?: number;
  141386. }): Mesh;
  141387. }
  141388. }
  141389. declare module BABYLON {
  141390. /**
  141391. * Class containing static functions to help procedurally build meshes
  141392. */
  141393. export class MeshBuilder {
  141394. /**
  141395. * Creates a box mesh
  141396. * * The parameter `size` sets the size (float) of each box side (default 1)
  141397. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  141398. * * 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)
  141399. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  141400. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141401. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141403. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  141404. * @param name defines the name of the mesh
  141405. * @param options defines the options used to create the mesh
  141406. * @param scene defines the hosting scene
  141407. * @returns the box mesh
  141408. */
  141409. static CreateBox(name: string, options: {
  141410. size?: number;
  141411. width?: number;
  141412. height?: number;
  141413. depth?: number;
  141414. faceUV?: Vector4[];
  141415. faceColors?: Color4[];
  141416. sideOrientation?: number;
  141417. frontUVs?: Vector4;
  141418. backUVs?: Vector4;
  141419. wrap?: boolean;
  141420. topBaseAt?: number;
  141421. bottomBaseAt?: number;
  141422. updatable?: boolean;
  141423. }, scene?: Nullable<Scene>): Mesh;
  141424. /**
  141425. * Creates a tiled box mesh
  141426. * * faceTiles sets the pattern, tile size and number of tiles for a face
  141427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141428. * @param name defines the name of the mesh
  141429. * @param options defines the options used to create the mesh
  141430. * @param scene defines the hosting scene
  141431. * @returns the tiled box mesh
  141432. */
  141433. static CreateTiledBox(name: string, options: {
  141434. pattern?: number;
  141435. size?: number;
  141436. width?: number;
  141437. height?: number;
  141438. depth: number;
  141439. tileSize?: number;
  141440. tileWidth?: number;
  141441. tileHeight?: number;
  141442. faceUV?: Vector4[];
  141443. faceColors?: Color4[];
  141444. alignHorizontal?: number;
  141445. alignVertical?: number;
  141446. sideOrientation?: number;
  141447. updatable?: boolean;
  141448. }, scene?: Nullable<Scene>): Mesh;
  141449. /**
  141450. * Creates a sphere mesh
  141451. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  141452. * * 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`)
  141453. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  141454. * * 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
  141455. * * 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)
  141456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141457. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141459. * @param name defines the name of the mesh
  141460. * @param options defines the options used to create the mesh
  141461. * @param scene defines the hosting scene
  141462. * @returns the sphere mesh
  141463. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  141464. */
  141465. static CreateSphere(name: string, options: {
  141466. segments?: number;
  141467. diameter?: number;
  141468. diameterX?: number;
  141469. diameterY?: number;
  141470. diameterZ?: number;
  141471. arc?: number;
  141472. slice?: number;
  141473. sideOrientation?: number;
  141474. frontUVs?: Vector4;
  141475. backUVs?: Vector4;
  141476. updatable?: boolean;
  141477. }, scene?: Nullable<Scene>): Mesh;
  141478. /**
  141479. * Creates a plane polygonal mesh. By default, this is a disc
  141480. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  141481. * * 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
  141482. * * 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
  141483. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141484. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141486. * @param name defines the name of the mesh
  141487. * @param options defines the options used to create the mesh
  141488. * @param scene defines the hosting scene
  141489. * @returns the plane polygonal mesh
  141490. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  141491. */
  141492. static CreateDisc(name: string, options: {
  141493. radius?: number;
  141494. tessellation?: number;
  141495. arc?: number;
  141496. updatable?: boolean;
  141497. sideOrientation?: number;
  141498. frontUVs?: Vector4;
  141499. backUVs?: Vector4;
  141500. }, scene?: Nullable<Scene>): Mesh;
  141501. /**
  141502. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  141503. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  141504. * * 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`)
  141505. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  141506. * * 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
  141507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141508. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141510. * @param name defines the name of the mesh
  141511. * @param options defines the options used to create the mesh
  141512. * @param scene defines the hosting scene
  141513. * @returns the icosahedron mesh
  141514. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  141515. */
  141516. static CreateIcoSphere(name: string, options: {
  141517. radius?: number;
  141518. radiusX?: number;
  141519. radiusY?: number;
  141520. radiusZ?: number;
  141521. flat?: boolean;
  141522. subdivisions?: number;
  141523. sideOrientation?: number;
  141524. frontUVs?: Vector4;
  141525. backUVs?: Vector4;
  141526. updatable?: boolean;
  141527. }, scene?: Nullable<Scene>): Mesh;
  141528. /**
  141529. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  141530. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  141531. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  141532. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  141533. * * 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
  141534. * * 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
  141535. * * 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
  141536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141537. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141538. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141539. * * 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
  141540. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  141541. * * 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
  141542. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  141543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141544. * @param name defines the name of the mesh
  141545. * @param options defines the options used to create the mesh
  141546. * @param scene defines the hosting scene
  141547. * @returns the ribbon mesh
  141548. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  141549. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141550. */
  141551. static CreateRibbon(name: string, options: {
  141552. pathArray: Vector3[][];
  141553. closeArray?: boolean;
  141554. closePath?: boolean;
  141555. offset?: number;
  141556. updatable?: boolean;
  141557. sideOrientation?: number;
  141558. frontUVs?: Vector4;
  141559. backUVs?: Vector4;
  141560. instance?: Mesh;
  141561. invertUV?: boolean;
  141562. uvs?: Vector2[];
  141563. colors?: Color4[];
  141564. }, scene?: Nullable<Scene>): Mesh;
  141565. /**
  141566. * Creates a cylinder or a cone mesh
  141567. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  141568. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  141569. * * 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.
  141570. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  141571. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  141572. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  141573. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  141574. * * 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).
  141575. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  141576. * * 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).
  141577. * * 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
  141578. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  141579. * * 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
  141580. * * 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.
  141581. * * If `enclose` is false, a ring surface is one element.
  141582. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  141583. * * 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
  141584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141585. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141587. * @param name defines the name of the mesh
  141588. * @param options defines the options used to create the mesh
  141589. * @param scene defines the hosting scene
  141590. * @returns the cylinder mesh
  141591. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  141592. */
  141593. static CreateCylinder(name: string, options: {
  141594. height?: number;
  141595. diameterTop?: number;
  141596. diameterBottom?: number;
  141597. diameter?: number;
  141598. tessellation?: number;
  141599. subdivisions?: number;
  141600. arc?: number;
  141601. faceColors?: Color4[];
  141602. faceUV?: Vector4[];
  141603. updatable?: boolean;
  141604. hasRings?: boolean;
  141605. enclose?: boolean;
  141606. cap?: number;
  141607. sideOrientation?: number;
  141608. frontUVs?: Vector4;
  141609. backUVs?: Vector4;
  141610. }, scene?: Nullable<Scene>): Mesh;
  141611. /**
  141612. * Creates a torus mesh
  141613. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  141614. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  141615. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  141616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141617. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141619. * @param name defines the name of the mesh
  141620. * @param options defines the options used to create the mesh
  141621. * @param scene defines the hosting scene
  141622. * @returns the torus mesh
  141623. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  141624. */
  141625. static CreateTorus(name: string, options: {
  141626. diameter?: number;
  141627. thickness?: number;
  141628. tessellation?: number;
  141629. updatable?: boolean;
  141630. sideOrientation?: number;
  141631. frontUVs?: Vector4;
  141632. backUVs?: Vector4;
  141633. }, scene?: Nullable<Scene>): Mesh;
  141634. /**
  141635. * Creates a torus knot mesh
  141636. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  141637. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  141638. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  141639. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  141640. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141641. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141643. * @param name defines the name of the mesh
  141644. * @param options defines the options used to create the mesh
  141645. * @param scene defines the hosting scene
  141646. * @returns the torus knot mesh
  141647. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  141648. */
  141649. static CreateTorusKnot(name: string, options: {
  141650. radius?: number;
  141651. tube?: number;
  141652. radialSegments?: number;
  141653. tubularSegments?: number;
  141654. p?: number;
  141655. q?: number;
  141656. updatable?: boolean;
  141657. sideOrientation?: number;
  141658. frontUVs?: Vector4;
  141659. backUVs?: Vector4;
  141660. }, scene?: Nullable<Scene>): Mesh;
  141661. /**
  141662. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  141663. * * 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
  141664. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  141665. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  141666. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  141667. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  141668. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  141669. * * 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
  141670. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  141671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141672. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  141673. * @param name defines the name of the new line system
  141674. * @param options defines the options used to create the line system
  141675. * @param scene defines the hosting scene
  141676. * @returns a new line system mesh
  141677. */
  141678. static CreateLineSystem(name: string, options: {
  141679. lines: Vector3[][];
  141680. updatable?: boolean;
  141681. instance?: Nullable<LinesMesh>;
  141682. colors?: Nullable<Color4[][]>;
  141683. useVertexAlpha?: boolean;
  141684. }, scene: Nullable<Scene>): LinesMesh;
  141685. /**
  141686. * Creates a line mesh
  141687. * 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
  141688. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  141689. * * The parameter `points` is an array successive Vector3
  141690. * * 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
  141691. * * The optional parameter `colors` is an array of successive Color4, one per line point
  141692. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  141693. * * When updating an instance, remember that only point positions can change, not the number of points
  141694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141695. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  141696. * @param name defines the name of the new line system
  141697. * @param options defines the options used to create the line system
  141698. * @param scene defines the hosting scene
  141699. * @returns a new line mesh
  141700. */
  141701. static CreateLines(name: string, options: {
  141702. points: Vector3[];
  141703. updatable?: boolean;
  141704. instance?: Nullable<LinesMesh>;
  141705. colors?: Color4[];
  141706. useVertexAlpha?: boolean;
  141707. }, scene?: Nullable<Scene>): LinesMesh;
  141708. /**
  141709. * Creates a dashed line mesh
  141710. * * 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
  141711. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  141712. * * The parameter `points` is an array successive Vector3
  141713. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  141714. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  141715. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  141716. * * 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
  141717. * * When updating an instance, remember that only point positions can change, not the number of points
  141718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141719. * @param name defines the name of the mesh
  141720. * @param options defines the options used to create the mesh
  141721. * @param scene defines the hosting scene
  141722. * @returns the dashed line mesh
  141723. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  141724. */
  141725. static CreateDashedLines(name: string, options: {
  141726. points: Vector3[];
  141727. dashSize?: number;
  141728. gapSize?: number;
  141729. dashNb?: number;
  141730. updatable?: boolean;
  141731. instance?: LinesMesh;
  141732. }, scene?: Nullable<Scene>): LinesMesh;
  141733. /**
  141734. * 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.
  141735. * * 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.
  141736. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  141737. * * 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.
  141738. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  141739. * * 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
  141740. * * 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
  141741. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  141742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141743. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141744. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  141745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141746. * @param name defines the name of the mesh
  141747. * @param options defines the options used to create the mesh
  141748. * @param scene defines the hosting scene
  141749. * @returns the extruded shape mesh
  141750. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141751. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  141752. */
  141753. static ExtrudeShape(name: string, options: {
  141754. shape: Vector3[];
  141755. path: Vector3[];
  141756. scale?: number;
  141757. rotation?: number;
  141758. cap?: number;
  141759. updatable?: boolean;
  141760. sideOrientation?: number;
  141761. frontUVs?: Vector4;
  141762. backUVs?: Vector4;
  141763. instance?: Mesh;
  141764. invertUV?: boolean;
  141765. }, scene?: Nullable<Scene>): Mesh;
  141766. /**
  141767. * Creates an custom extruded shape mesh.
  141768. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  141769. * * 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.
  141770. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  141771. * * 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
  141772. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  141773. * * 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
  141774. * * It must returns a float value that will be the scale value applied to the shape on each path point
  141775. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  141776. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  141777. * * 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
  141778. * * 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
  141779. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  141780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141781. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141782. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141784. * @param name defines the name of the mesh
  141785. * @param options defines the options used to create the mesh
  141786. * @param scene defines the hosting scene
  141787. * @returns the custom extruded shape mesh
  141788. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  141789. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141790. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  141791. */
  141792. static ExtrudeShapeCustom(name: string, options: {
  141793. shape: Vector3[];
  141794. path: Vector3[];
  141795. scaleFunction?: any;
  141796. rotationFunction?: any;
  141797. ribbonCloseArray?: boolean;
  141798. ribbonClosePath?: boolean;
  141799. cap?: number;
  141800. updatable?: boolean;
  141801. sideOrientation?: number;
  141802. frontUVs?: Vector4;
  141803. backUVs?: Vector4;
  141804. instance?: Mesh;
  141805. invertUV?: boolean;
  141806. }, scene?: Nullable<Scene>): Mesh;
  141807. /**
  141808. * Creates lathe mesh.
  141809. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  141810. * * 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
  141811. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  141812. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  141813. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  141814. * * 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
  141815. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  141816. * * 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
  141817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141818. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141819. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141821. * @param name defines the name of the mesh
  141822. * @param options defines the options used to create the mesh
  141823. * @param scene defines the hosting scene
  141824. * @returns the lathe mesh
  141825. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  141826. */
  141827. static CreateLathe(name: string, options: {
  141828. shape: Vector3[];
  141829. radius?: number;
  141830. tessellation?: number;
  141831. clip?: number;
  141832. arc?: number;
  141833. closed?: boolean;
  141834. updatable?: boolean;
  141835. sideOrientation?: number;
  141836. frontUVs?: Vector4;
  141837. backUVs?: Vector4;
  141838. cap?: number;
  141839. invertUV?: boolean;
  141840. }, scene?: Nullable<Scene>): Mesh;
  141841. /**
  141842. * Creates a tiled plane mesh
  141843. * * You can set a limited pattern arrangement with the tiles
  141844. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141845. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141847. * @param name defines the name of the mesh
  141848. * @param options defines the options used to create the mesh
  141849. * @param scene defines the hosting scene
  141850. * @returns the plane mesh
  141851. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  141852. */
  141853. static CreateTiledPlane(name: string, options: {
  141854. pattern?: number;
  141855. tileSize?: number;
  141856. tileWidth?: number;
  141857. tileHeight?: number;
  141858. size?: number;
  141859. width?: number;
  141860. height?: number;
  141861. alignHorizontal?: number;
  141862. alignVertical?: number;
  141863. sideOrientation?: number;
  141864. frontUVs?: Vector4;
  141865. backUVs?: Vector4;
  141866. updatable?: boolean;
  141867. }, scene?: Nullable<Scene>): Mesh;
  141868. /**
  141869. * Creates a plane mesh
  141870. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  141871. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  141872. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  141873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141874. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141876. * @param name defines the name of the mesh
  141877. * @param options defines the options used to create the mesh
  141878. * @param scene defines the hosting scene
  141879. * @returns the plane mesh
  141880. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  141881. */
  141882. static CreatePlane(name: string, options: {
  141883. size?: number;
  141884. width?: number;
  141885. height?: number;
  141886. sideOrientation?: number;
  141887. frontUVs?: Vector4;
  141888. backUVs?: Vector4;
  141889. updatable?: boolean;
  141890. sourcePlane?: Plane;
  141891. }, scene?: Nullable<Scene>): Mesh;
  141892. /**
  141893. * Creates a ground mesh
  141894. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  141895. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  141896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141897. * @param name defines the name of the mesh
  141898. * @param options defines the options used to create the mesh
  141899. * @param scene defines the hosting scene
  141900. * @returns the ground mesh
  141901. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  141902. */
  141903. static CreateGround(name: string, options: {
  141904. width?: number;
  141905. height?: number;
  141906. subdivisions?: number;
  141907. subdivisionsX?: number;
  141908. subdivisionsY?: number;
  141909. updatable?: boolean;
  141910. }, scene?: Nullable<Scene>): Mesh;
  141911. /**
  141912. * Creates a tiled ground mesh
  141913. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  141914. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  141915. * * 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
  141916. * * 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
  141917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141918. * @param name defines the name of the mesh
  141919. * @param options defines the options used to create the mesh
  141920. * @param scene defines the hosting scene
  141921. * @returns the tiled ground mesh
  141922. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  141923. */
  141924. static CreateTiledGround(name: string, options: {
  141925. xmin: number;
  141926. zmin: number;
  141927. xmax: number;
  141928. zmax: number;
  141929. subdivisions?: {
  141930. w: number;
  141931. h: number;
  141932. };
  141933. precision?: {
  141934. w: number;
  141935. h: number;
  141936. };
  141937. updatable?: boolean;
  141938. }, scene?: Nullable<Scene>): Mesh;
  141939. /**
  141940. * Creates a ground mesh from a height map
  141941. * * The parameter `url` sets the URL of the height map image resource.
  141942. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  141943. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  141944. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  141945. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  141946. * * 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.
  141947. * * 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).
  141948. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  141949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141950. * @param name defines the name of the mesh
  141951. * @param url defines the url to the height map
  141952. * @param options defines the options used to create the mesh
  141953. * @param scene defines the hosting scene
  141954. * @returns the ground mesh
  141955. * @see https://doc.babylonjs.com/babylon101/height_map
  141956. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  141957. */
  141958. static CreateGroundFromHeightMap(name: string, url: string, options: {
  141959. width?: number;
  141960. height?: number;
  141961. subdivisions?: number;
  141962. minHeight?: number;
  141963. maxHeight?: number;
  141964. colorFilter?: Color3;
  141965. alphaFilter?: number;
  141966. updatable?: boolean;
  141967. onReady?: (mesh: GroundMesh) => void;
  141968. }, scene?: Nullable<Scene>): GroundMesh;
  141969. /**
  141970. * Creates a polygon mesh
  141971. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  141972. * * 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
  141973. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  141974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141975. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  141976. * * Remember you can only change the shape positions, not their number when updating a polygon
  141977. * @param name defines the name of the mesh
  141978. * @param options defines the options used to create the mesh
  141979. * @param scene defines the hosting scene
  141980. * @param earcutInjection can be used to inject your own earcut reference
  141981. * @returns the polygon mesh
  141982. */
  141983. static CreatePolygon(name: string, options: {
  141984. shape: Vector3[];
  141985. holes?: Vector3[][];
  141986. depth?: number;
  141987. faceUV?: Vector4[];
  141988. faceColors?: Color4[];
  141989. updatable?: boolean;
  141990. sideOrientation?: number;
  141991. frontUVs?: Vector4;
  141992. backUVs?: Vector4;
  141993. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  141994. /**
  141995. * Creates an extruded polygon mesh, with depth in the Y direction.
  141996. * * 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)
  141997. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  141998. * @param name defines the name of the mesh
  141999. * @param options defines the options used to create the mesh
  142000. * @param scene defines the hosting scene
  142001. * @param earcutInjection can be used to inject your own earcut reference
  142002. * @returns the polygon mesh
  142003. */
  142004. static ExtrudePolygon(name: string, options: {
  142005. shape: Vector3[];
  142006. holes?: Vector3[][];
  142007. depth?: number;
  142008. faceUV?: Vector4[];
  142009. faceColors?: Color4[];
  142010. updatable?: boolean;
  142011. sideOrientation?: number;
  142012. frontUVs?: Vector4;
  142013. backUVs?: Vector4;
  142014. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142015. /**
  142016. * Creates a tube mesh.
  142017. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  142018. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  142019. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  142020. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  142021. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  142022. * * 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)
  142023. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  142024. * * 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
  142025. * * 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
  142026. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142027. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142028. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142030. * @param name defines the name of the mesh
  142031. * @param options defines the options used to create the mesh
  142032. * @param scene defines the hosting scene
  142033. * @returns the tube mesh
  142034. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142035. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  142036. */
  142037. static CreateTube(name: string, options: {
  142038. path: Vector3[];
  142039. radius?: number;
  142040. tessellation?: number;
  142041. radiusFunction?: {
  142042. (i: number, distance: number): number;
  142043. };
  142044. cap?: number;
  142045. arc?: number;
  142046. updatable?: boolean;
  142047. sideOrientation?: number;
  142048. frontUVs?: Vector4;
  142049. backUVs?: Vector4;
  142050. instance?: Mesh;
  142051. invertUV?: boolean;
  142052. }, scene?: Nullable<Scene>): Mesh;
  142053. /**
  142054. * Creates a polyhedron mesh
  142055. * * 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
  142056. * * The parameter `size` (positive float, default 1) sets the polygon size
  142057. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  142058. * * 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`
  142059. * * 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
  142060. * * 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)`)
  142061. * * 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
  142062. * * 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
  142063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142064. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142066. * @param name defines the name of the mesh
  142067. * @param options defines the options used to create the mesh
  142068. * @param scene defines the hosting scene
  142069. * @returns the polyhedron mesh
  142070. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  142071. */
  142072. static CreatePolyhedron(name: string, options: {
  142073. type?: number;
  142074. size?: number;
  142075. sizeX?: number;
  142076. sizeY?: number;
  142077. sizeZ?: number;
  142078. custom?: any;
  142079. faceUV?: Vector4[];
  142080. faceColors?: Color4[];
  142081. flat?: boolean;
  142082. updatable?: boolean;
  142083. sideOrientation?: number;
  142084. frontUVs?: Vector4;
  142085. backUVs?: Vector4;
  142086. }, scene?: Nullable<Scene>): Mesh;
  142087. /**
  142088. * Creates a decal mesh.
  142089. * 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
  142090. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  142091. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  142092. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  142093. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  142094. * @param name defines the name of the mesh
  142095. * @param sourceMesh defines the mesh where the decal must be applied
  142096. * @param options defines the options used to create the mesh
  142097. * @param scene defines the hosting scene
  142098. * @returns the decal mesh
  142099. * @see https://doc.babylonjs.com/how_to/decals
  142100. */
  142101. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  142102. position?: Vector3;
  142103. normal?: Vector3;
  142104. size?: Vector3;
  142105. angle?: number;
  142106. }): Mesh;
  142107. }
  142108. }
  142109. declare module BABYLON {
  142110. /**
  142111. * A simplifier interface for future simplification implementations
  142112. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142113. */
  142114. export interface ISimplifier {
  142115. /**
  142116. * Simplification of a given mesh according to the given settings.
  142117. * Since this requires computation, it is assumed that the function runs async.
  142118. * @param settings The settings of the simplification, including quality and distance
  142119. * @param successCallback A callback that will be called after the mesh was simplified.
  142120. * @param errorCallback in case of an error, this callback will be called. optional.
  142121. */
  142122. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  142123. }
  142124. /**
  142125. * Expected simplification settings.
  142126. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  142127. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142128. */
  142129. export interface ISimplificationSettings {
  142130. /**
  142131. * Gets or sets the expected quality
  142132. */
  142133. quality: number;
  142134. /**
  142135. * Gets or sets the distance when this optimized version should be used
  142136. */
  142137. distance: number;
  142138. /**
  142139. * Gets an already optimized mesh
  142140. */
  142141. optimizeMesh?: boolean;
  142142. }
  142143. /**
  142144. * Class used to specify simplification options
  142145. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142146. */
  142147. export class SimplificationSettings implements ISimplificationSettings {
  142148. /** expected quality */
  142149. quality: number;
  142150. /** distance when this optimized version should be used */
  142151. distance: number;
  142152. /** already optimized mesh */
  142153. optimizeMesh?: boolean | undefined;
  142154. /**
  142155. * Creates a SimplificationSettings
  142156. * @param quality expected quality
  142157. * @param distance distance when this optimized version should be used
  142158. * @param optimizeMesh already optimized mesh
  142159. */
  142160. constructor(
  142161. /** expected quality */
  142162. quality: number,
  142163. /** distance when this optimized version should be used */
  142164. distance: number,
  142165. /** already optimized mesh */
  142166. optimizeMesh?: boolean | undefined);
  142167. }
  142168. /**
  142169. * Interface used to define a simplification task
  142170. */
  142171. export interface ISimplificationTask {
  142172. /**
  142173. * Array of settings
  142174. */
  142175. settings: Array<ISimplificationSettings>;
  142176. /**
  142177. * Simplification type
  142178. */
  142179. simplificationType: SimplificationType;
  142180. /**
  142181. * Mesh to simplify
  142182. */
  142183. mesh: Mesh;
  142184. /**
  142185. * Callback called on success
  142186. */
  142187. successCallback?: () => void;
  142188. /**
  142189. * Defines if parallel processing can be used
  142190. */
  142191. parallelProcessing: boolean;
  142192. }
  142193. /**
  142194. * Queue used to order the simplification tasks
  142195. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142196. */
  142197. export class SimplificationQueue {
  142198. private _simplificationArray;
  142199. /**
  142200. * Gets a boolean indicating that the process is still running
  142201. */
  142202. running: boolean;
  142203. /**
  142204. * Creates a new queue
  142205. */
  142206. constructor();
  142207. /**
  142208. * Adds a new simplification task
  142209. * @param task defines a task to add
  142210. */
  142211. addTask(task: ISimplificationTask): void;
  142212. /**
  142213. * Execute next task
  142214. */
  142215. executeNext(): void;
  142216. /**
  142217. * Execute a simplification task
  142218. * @param task defines the task to run
  142219. */
  142220. runSimplification(task: ISimplificationTask): void;
  142221. private getSimplifier;
  142222. }
  142223. /**
  142224. * The implemented types of simplification
  142225. * At the moment only Quadratic Error Decimation is implemented
  142226. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142227. */
  142228. export enum SimplificationType {
  142229. /** Quadratic error decimation */
  142230. QUADRATIC = 0
  142231. }
  142232. /**
  142233. * An implementation of the Quadratic Error simplification algorithm.
  142234. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  142235. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  142236. * @author RaananW
  142237. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142238. */
  142239. export class QuadraticErrorSimplification implements ISimplifier {
  142240. private _mesh;
  142241. private triangles;
  142242. private vertices;
  142243. private references;
  142244. private _reconstructedMesh;
  142245. /** Gets or sets the number pf sync interations */
  142246. syncIterations: number;
  142247. /** Gets or sets the aggressiveness of the simplifier */
  142248. aggressiveness: number;
  142249. /** Gets or sets the number of allowed iterations for decimation */
  142250. decimationIterations: number;
  142251. /** Gets or sets the espilon to use for bounding box computation */
  142252. boundingBoxEpsilon: number;
  142253. /**
  142254. * Creates a new QuadraticErrorSimplification
  142255. * @param _mesh defines the target mesh
  142256. */
  142257. constructor(_mesh: Mesh);
  142258. /**
  142259. * Simplification of a given mesh according to the given settings.
  142260. * Since this requires computation, it is assumed that the function runs async.
  142261. * @param settings The settings of the simplification, including quality and distance
  142262. * @param successCallback A callback that will be called after the mesh was simplified.
  142263. */
  142264. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  142265. private runDecimation;
  142266. private initWithMesh;
  142267. private init;
  142268. private reconstructMesh;
  142269. private initDecimatedMesh;
  142270. private isFlipped;
  142271. private updateTriangles;
  142272. private identifyBorder;
  142273. private updateMesh;
  142274. private vertexError;
  142275. private calculateError;
  142276. }
  142277. }
  142278. declare module BABYLON {
  142279. interface Scene {
  142280. /** @hidden (Backing field) */
  142281. _simplificationQueue: SimplificationQueue;
  142282. /**
  142283. * Gets or sets the simplification queue attached to the scene
  142284. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142285. */
  142286. simplificationQueue: SimplificationQueue;
  142287. }
  142288. interface Mesh {
  142289. /**
  142290. * Simplify the mesh according to the given array of settings.
  142291. * Function will return immediately and will simplify async
  142292. * @param settings a collection of simplification settings
  142293. * @param parallelProcessing should all levels calculate parallel or one after the other
  142294. * @param simplificationType the type of simplification to run
  142295. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  142296. * @returns the current mesh
  142297. */
  142298. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  142299. }
  142300. /**
  142301. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  142302. * created in a scene
  142303. */
  142304. export class SimplicationQueueSceneComponent implements ISceneComponent {
  142305. /**
  142306. * The component name helpfull to identify the component in the list of scene components.
  142307. */
  142308. readonly name: string;
  142309. /**
  142310. * The scene the component belongs to.
  142311. */
  142312. scene: Scene;
  142313. /**
  142314. * Creates a new instance of the component for the given scene
  142315. * @param scene Defines the scene to register the component in
  142316. */
  142317. constructor(scene: Scene);
  142318. /**
  142319. * Registers the component in a given scene
  142320. */
  142321. register(): void;
  142322. /**
  142323. * Rebuilds the elements related to this component in case of
  142324. * context lost for instance.
  142325. */
  142326. rebuild(): void;
  142327. /**
  142328. * Disposes the component and the associated ressources
  142329. */
  142330. dispose(): void;
  142331. private _beforeCameraUpdate;
  142332. }
  142333. }
  142334. declare module BABYLON {
  142335. interface Mesh {
  142336. /**
  142337. * Creates a new thin instance
  142338. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  142339. * @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
  142340. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  142341. */
  142342. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  142343. /**
  142344. * Adds the transformation (matrix) of the current mesh as a thin instance
  142345. * @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
  142346. * @returns the thin instance index number
  142347. */
  142348. thinInstanceAddSelf(refresh: boolean): number;
  142349. /**
  142350. * Registers a custom attribute to be used with thin instances
  142351. * @param kind name of the attribute
  142352. * @param stride size in floats of the attribute
  142353. */
  142354. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  142355. /**
  142356. * Sets the matrix of a thin instance
  142357. * @param index index of the thin instance
  142358. * @param matrix matrix to set
  142359. * @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
  142360. */
  142361. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  142362. /**
  142363. * Sets the value of a custom attribute for a thin instance
  142364. * @param kind name of the attribute
  142365. * @param index index of the thin instance
  142366. * @param value value to set
  142367. * @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
  142368. */
  142369. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  142370. /**
  142371. * 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.
  142372. */
  142373. thinInstanceCount: number;
  142374. /**
  142375. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  142376. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  142377. * @param buffer buffer to set
  142378. * @param stride size in floats of each value of the buffer
  142379. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  142380. */
  142381. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  142382. /**
  142383. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  142384. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  142385. */
  142386. thinInstanceBufferUpdated(kind: string): void;
  142387. /**
  142388. * Refreshes the bounding info, taking into account all the thin instances defined
  142389. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  142390. */
  142391. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  142392. /** @hidden */
  142393. _thinInstanceInitializeUserStorage(): void;
  142394. /** @hidden */
  142395. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  142396. /** @hidden */
  142397. _userThinInstanceBuffersStorage: {
  142398. data: {
  142399. [key: string]: Float32Array;
  142400. };
  142401. sizes: {
  142402. [key: string]: number;
  142403. };
  142404. vertexBuffers: {
  142405. [key: string]: Nullable<VertexBuffer>;
  142406. };
  142407. strides: {
  142408. [key: string]: number;
  142409. };
  142410. };
  142411. }
  142412. }
  142413. declare module BABYLON {
  142414. /**
  142415. * Navigation plugin interface to add navigation constrained by a navigation mesh
  142416. */
  142417. export interface INavigationEnginePlugin {
  142418. /**
  142419. * plugin name
  142420. */
  142421. name: string;
  142422. /**
  142423. * Creates a navigation mesh
  142424. * @param meshes array of all the geometry used to compute the navigatio mesh
  142425. * @param parameters bunch of parameters used to filter geometry
  142426. */
  142427. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  142428. /**
  142429. * Create a navigation mesh debug mesh
  142430. * @param scene is where the mesh will be added
  142431. * @returns debug display mesh
  142432. */
  142433. createDebugNavMesh(scene: Scene): Mesh;
  142434. /**
  142435. * Get a navigation mesh constrained position, closest to the parameter position
  142436. * @param position world position
  142437. * @returns the closest point to position constrained by the navigation mesh
  142438. */
  142439. getClosestPoint(position: Vector3): Vector3;
  142440. /**
  142441. * Get a navigation mesh constrained position, closest to the parameter position
  142442. * @param position world position
  142443. * @param result output the closest point to position constrained by the navigation mesh
  142444. */
  142445. getClosestPointToRef(position: Vector3, result: Vector3): void;
  142446. /**
  142447. * Get a navigation mesh constrained position, within a particular radius
  142448. * @param position world position
  142449. * @param maxRadius the maximum distance to the constrained world position
  142450. * @returns the closest point to position constrained by the navigation mesh
  142451. */
  142452. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  142453. /**
  142454. * Get a navigation mesh constrained position, within a particular radius
  142455. * @param position world position
  142456. * @param maxRadius the maximum distance to the constrained world position
  142457. * @param result output the closest point to position constrained by the navigation mesh
  142458. */
  142459. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  142460. /**
  142461. * Compute the final position from a segment made of destination-position
  142462. * @param position world position
  142463. * @param destination world position
  142464. * @returns the resulting point along the navmesh
  142465. */
  142466. moveAlong(position: Vector3, destination: Vector3): Vector3;
  142467. /**
  142468. * Compute the final position from a segment made of destination-position
  142469. * @param position world position
  142470. * @param destination world position
  142471. * @param result output the resulting point along the navmesh
  142472. */
  142473. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  142474. /**
  142475. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  142476. * @param start world position
  142477. * @param end world position
  142478. * @returns array containing world position composing the path
  142479. */
  142480. computePath(start: Vector3, end: Vector3): Vector3[];
  142481. /**
  142482. * If this plugin is supported
  142483. * @returns true if plugin is supported
  142484. */
  142485. isSupported(): boolean;
  142486. /**
  142487. * Create a new Crowd so you can add agents
  142488. * @param maxAgents the maximum agent count in the crowd
  142489. * @param maxAgentRadius the maximum radius an agent can have
  142490. * @param scene to attach the crowd to
  142491. * @returns the crowd you can add agents to
  142492. */
  142493. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  142494. /**
  142495. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  142496. * The queries will try to find a solution within those bounds
  142497. * default is (1,1,1)
  142498. * @param extent x,y,z value that define the extent around the queries point of reference
  142499. */
  142500. setDefaultQueryExtent(extent: Vector3): void;
  142501. /**
  142502. * Get the Bounding box extent specified by setDefaultQueryExtent
  142503. * @returns the box extent values
  142504. */
  142505. getDefaultQueryExtent(): Vector3;
  142506. /**
  142507. * build the navmesh from a previously saved state using getNavmeshData
  142508. * @param data the Uint8Array returned by getNavmeshData
  142509. */
  142510. buildFromNavmeshData(data: Uint8Array): void;
  142511. /**
  142512. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  142513. * @returns data the Uint8Array that can be saved and reused
  142514. */
  142515. getNavmeshData(): Uint8Array;
  142516. /**
  142517. * Get the Bounding box extent result specified by setDefaultQueryExtent
  142518. * @param result output the box extent values
  142519. */
  142520. getDefaultQueryExtentToRef(result: Vector3): void;
  142521. /**
  142522. * Release all resources
  142523. */
  142524. dispose(): void;
  142525. }
  142526. /**
  142527. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  142528. */
  142529. export interface ICrowd {
  142530. /**
  142531. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  142532. * You can attach anything to that node. The node position is updated in the scene update tick.
  142533. * @param pos world position that will be constrained by the navigation mesh
  142534. * @param parameters agent parameters
  142535. * @param transform hooked to the agent that will be update by the scene
  142536. * @returns agent index
  142537. */
  142538. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  142539. /**
  142540. * Returns the agent position in world space
  142541. * @param index agent index returned by addAgent
  142542. * @returns world space position
  142543. */
  142544. getAgentPosition(index: number): Vector3;
  142545. /**
  142546. * Gets the agent position result in world space
  142547. * @param index agent index returned by addAgent
  142548. * @param result output world space position
  142549. */
  142550. getAgentPositionToRef(index: number, result: Vector3): void;
  142551. /**
  142552. * Gets the agent velocity in world space
  142553. * @param index agent index returned by addAgent
  142554. * @returns world space velocity
  142555. */
  142556. getAgentVelocity(index: number): Vector3;
  142557. /**
  142558. * Gets the agent velocity result in world space
  142559. * @param index agent index returned by addAgent
  142560. * @param result output world space velocity
  142561. */
  142562. getAgentVelocityToRef(index: number, result: Vector3): void;
  142563. /**
  142564. * remove a particular agent previously created
  142565. * @param index agent index returned by addAgent
  142566. */
  142567. removeAgent(index: number): void;
  142568. /**
  142569. * get the list of all agents attached to this crowd
  142570. * @returns list of agent indices
  142571. */
  142572. getAgents(): number[];
  142573. /**
  142574. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  142575. * @param deltaTime in seconds
  142576. */
  142577. update(deltaTime: number): void;
  142578. /**
  142579. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  142580. * @param index agent index returned by addAgent
  142581. * @param destination targeted world position
  142582. */
  142583. agentGoto(index: number, destination: Vector3): void;
  142584. /**
  142585. * Teleport the agent to a new position
  142586. * @param index agent index returned by addAgent
  142587. * @param destination targeted world position
  142588. */
  142589. agentTeleport(index: number, destination: Vector3): void;
  142590. /**
  142591. * Update agent parameters
  142592. * @param index agent index returned by addAgent
  142593. * @param parameters agent parameters
  142594. */
  142595. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  142596. /**
  142597. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  142598. * The queries will try to find a solution within those bounds
  142599. * default is (1,1,1)
  142600. * @param extent x,y,z value that define the extent around the queries point of reference
  142601. */
  142602. setDefaultQueryExtent(extent: Vector3): void;
  142603. /**
  142604. * Get the Bounding box extent specified by setDefaultQueryExtent
  142605. * @returns the box extent values
  142606. */
  142607. getDefaultQueryExtent(): Vector3;
  142608. /**
  142609. * Get the Bounding box extent result specified by setDefaultQueryExtent
  142610. * @param result output the box extent values
  142611. */
  142612. getDefaultQueryExtentToRef(result: Vector3): void;
  142613. /**
  142614. * Release all resources
  142615. */
  142616. dispose(): void;
  142617. }
  142618. /**
  142619. * Configures an agent
  142620. */
  142621. export interface IAgentParameters {
  142622. /**
  142623. * Agent radius. [Limit: >= 0]
  142624. */
  142625. radius: number;
  142626. /**
  142627. * Agent height. [Limit: > 0]
  142628. */
  142629. height: number;
  142630. /**
  142631. * Maximum allowed acceleration. [Limit: >= 0]
  142632. */
  142633. maxAcceleration: number;
  142634. /**
  142635. * Maximum allowed speed. [Limit: >= 0]
  142636. */
  142637. maxSpeed: number;
  142638. /**
  142639. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  142640. */
  142641. collisionQueryRange: number;
  142642. /**
  142643. * The path visibility optimization range. [Limit: > 0]
  142644. */
  142645. pathOptimizationRange: number;
  142646. /**
  142647. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  142648. */
  142649. separationWeight: number;
  142650. }
  142651. /**
  142652. * Configures the navigation mesh creation
  142653. */
  142654. export interface INavMeshParameters {
  142655. /**
  142656. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  142657. */
  142658. cs: number;
  142659. /**
  142660. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  142661. */
  142662. ch: number;
  142663. /**
  142664. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  142665. */
  142666. walkableSlopeAngle: number;
  142667. /**
  142668. * Minimum floor to 'ceiling' height that will still allow the floor area to
  142669. * be considered walkable. [Limit: >= 3] [Units: vx]
  142670. */
  142671. walkableHeight: number;
  142672. /**
  142673. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  142674. */
  142675. walkableClimb: number;
  142676. /**
  142677. * The distance to erode/shrink the walkable area of the heightfield away from
  142678. * obstructions. [Limit: >=0] [Units: vx]
  142679. */
  142680. walkableRadius: number;
  142681. /**
  142682. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  142683. */
  142684. maxEdgeLen: number;
  142685. /**
  142686. * The maximum distance a simplfied contour's border edges should deviate
  142687. * the original raw contour. [Limit: >=0] [Units: vx]
  142688. */
  142689. maxSimplificationError: number;
  142690. /**
  142691. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  142692. */
  142693. minRegionArea: number;
  142694. /**
  142695. * Any regions with a span count smaller than this value will, if possible,
  142696. * be merged with larger regions. [Limit: >=0] [Units: vx]
  142697. */
  142698. mergeRegionArea: number;
  142699. /**
  142700. * The maximum number of vertices allowed for polygons generated during the
  142701. * contour to polygon conversion process. [Limit: >= 3]
  142702. */
  142703. maxVertsPerPoly: number;
  142704. /**
  142705. * Sets the sampling distance to use when generating the detail mesh.
  142706. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  142707. */
  142708. detailSampleDist: number;
  142709. /**
  142710. * The maximum distance the detail mesh surface should deviate from heightfield
  142711. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  142712. */
  142713. detailSampleMaxError: number;
  142714. }
  142715. }
  142716. declare module BABYLON {
  142717. /**
  142718. * RecastJS navigation plugin
  142719. */
  142720. export class RecastJSPlugin implements INavigationEnginePlugin {
  142721. /**
  142722. * Reference to the Recast library
  142723. */
  142724. bjsRECAST: any;
  142725. /**
  142726. * plugin name
  142727. */
  142728. name: string;
  142729. /**
  142730. * the first navmesh created. We might extend this to support multiple navmeshes
  142731. */
  142732. navMesh: any;
  142733. /**
  142734. * Initializes the recastJS plugin
  142735. * @param recastInjection can be used to inject your own recast reference
  142736. */
  142737. constructor(recastInjection?: any);
  142738. /**
  142739. * Creates a navigation mesh
  142740. * @param meshes array of all the geometry used to compute the navigatio mesh
  142741. * @param parameters bunch of parameters used to filter geometry
  142742. */
  142743. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  142744. /**
  142745. * Create a navigation mesh debug mesh
  142746. * @param scene is where the mesh will be added
  142747. * @returns debug display mesh
  142748. */
  142749. createDebugNavMesh(scene: Scene): Mesh;
  142750. /**
  142751. * Get a navigation mesh constrained position, closest to the parameter position
  142752. * @param position world position
  142753. * @returns the closest point to position constrained by the navigation mesh
  142754. */
  142755. getClosestPoint(position: Vector3): Vector3;
  142756. /**
  142757. * Get a navigation mesh constrained position, closest to the parameter position
  142758. * @param position world position
  142759. * @param result output the closest point to position constrained by the navigation mesh
  142760. */
  142761. getClosestPointToRef(position: Vector3, result: Vector3): void;
  142762. /**
  142763. * Get a navigation mesh constrained position, within a particular radius
  142764. * @param position world position
  142765. * @param maxRadius the maximum distance to the constrained world position
  142766. * @returns the closest point to position constrained by the navigation mesh
  142767. */
  142768. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  142769. /**
  142770. * Get a navigation mesh constrained position, within a particular radius
  142771. * @param position world position
  142772. * @param maxRadius the maximum distance to the constrained world position
  142773. * @param result output the closest point to position constrained by the navigation mesh
  142774. */
  142775. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  142776. /**
  142777. * Compute the final position from a segment made of destination-position
  142778. * @param position world position
  142779. * @param destination world position
  142780. * @returns the resulting point along the navmesh
  142781. */
  142782. moveAlong(position: Vector3, destination: Vector3): Vector3;
  142783. /**
  142784. * Compute the final position from a segment made of destination-position
  142785. * @param position world position
  142786. * @param destination world position
  142787. * @param result output the resulting point along the navmesh
  142788. */
  142789. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  142790. /**
  142791. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  142792. * @param start world position
  142793. * @param end world position
  142794. * @returns array containing world position composing the path
  142795. */
  142796. computePath(start: Vector3, end: Vector3): Vector3[];
  142797. /**
  142798. * Create a new Crowd so you can add agents
  142799. * @param maxAgents the maximum agent count in the crowd
  142800. * @param maxAgentRadius the maximum radius an agent can have
  142801. * @param scene to attach the crowd to
  142802. * @returns the crowd you can add agents to
  142803. */
  142804. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  142805. /**
  142806. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  142807. * The queries will try to find a solution within those bounds
  142808. * default is (1,1,1)
  142809. * @param extent x,y,z value that define the extent around the queries point of reference
  142810. */
  142811. setDefaultQueryExtent(extent: Vector3): void;
  142812. /**
  142813. * Get the Bounding box extent specified by setDefaultQueryExtent
  142814. * @returns the box extent values
  142815. */
  142816. getDefaultQueryExtent(): Vector3;
  142817. /**
  142818. * build the navmesh from a previously saved state using getNavmeshData
  142819. * @param data the Uint8Array returned by getNavmeshData
  142820. */
  142821. buildFromNavmeshData(data: Uint8Array): void;
  142822. /**
  142823. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  142824. * @returns data the Uint8Array that can be saved and reused
  142825. */
  142826. getNavmeshData(): Uint8Array;
  142827. /**
  142828. * Get the Bounding box extent result specified by setDefaultQueryExtent
  142829. * @param result output the box extent values
  142830. */
  142831. getDefaultQueryExtentToRef(result: Vector3): void;
  142832. /**
  142833. * Disposes
  142834. */
  142835. dispose(): void;
  142836. /**
  142837. * If this plugin is supported
  142838. * @returns true if plugin is supported
  142839. */
  142840. isSupported(): boolean;
  142841. }
  142842. /**
  142843. * Recast detour crowd implementation
  142844. */
  142845. export class RecastJSCrowd implements ICrowd {
  142846. /**
  142847. * Recast/detour plugin
  142848. */
  142849. bjsRECASTPlugin: RecastJSPlugin;
  142850. /**
  142851. * Link to the detour crowd
  142852. */
  142853. recastCrowd: any;
  142854. /**
  142855. * One transform per agent
  142856. */
  142857. transforms: TransformNode[];
  142858. /**
  142859. * All agents created
  142860. */
  142861. agents: number[];
  142862. /**
  142863. * Link to the scene is kept to unregister the crowd from the scene
  142864. */
  142865. private _scene;
  142866. /**
  142867. * Observer for crowd updates
  142868. */
  142869. private _onBeforeAnimationsObserver;
  142870. /**
  142871. * Constructor
  142872. * @param plugin recastJS plugin
  142873. * @param maxAgents the maximum agent count in the crowd
  142874. * @param maxAgentRadius the maximum radius an agent can have
  142875. * @param scene to attach the crowd to
  142876. * @returns the crowd you can add agents to
  142877. */
  142878. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  142879. /**
  142880. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  142881. * You can attach anything to that node. The node position is updated in the scene update tick.
  142882. * @param pos world position that will be constrained by the navigation mesh
  142883. * @param parameters agent parameters
  142884. * @param transform hooked to the agent that will be update by the scene
  142885. * @returns agent index
  142886. */
  142887. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  142888. /**
  142889. * Returns the agent position in world space
  142890. * @param index agent index returned by addAgent
  142891. * @returns world space position
  142892. */
  142893. getAgentPosition(index: number): Vector3;
  142894. /**
  142895. * Returns the agent position result in world space
  142896. * @param index agent index returned by addAgent
  142897. * @param result output world space position
  142898. */
  142899. getAgentPositionToRef(index: number, result: Vector3): void;
  142900. /**
  142901. * Returns the agent velocity in world space
  142902. * @param index agent index returned by addAgent
  142903. * @returns world space velocity
  142904. */
  142905. getAgentVelocity(index: number): Vector3;
  142906. /**
  142907. * Returns the agent velocity result in world space
  142908. * @param index agent index returned by addAgent
  142909. * @param result output world space velocity
  142910. */
  142911. getAgentVelocityToRef(index: number, result: Vector3): void;
  142912. /**
  142913. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  142914. * @param index agent index returned by addAgent
  142915. * @param destination targeted world position
  142916. */
  142917. agentGoto(index: number, destination: Vector3): void;
  142918. /**
  142919. * Teleport the agent to a new position
  142920. * @param index agent index returned by addAgent
  142921. * @param destination targeted world position
  142922. */
  142923. agentTeleport(index: number, destination: Vector3): void;
  142924. /**
  142925. * Update agent parameters
  142926. * @param index agent index returned by addAgent
  142927. * @param parameters agent parameters
  142928. */
  142929. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  142930. /**
  142931. * remove a particular agent previously created
  142932. * @param index agent index returned by addAgent
  142933. */
  142934. removeAgent(index: number): void;
  142935. /**
  142936. * get the list of all agents attached to this crowd
  142937. * @returns list of agent indices
  142938. */
  142939. getAgents(): number[];
  142940. /**
  142941. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  142942. * @param deltaTime in seconds
  142943. */
  142944. update(deltaTime: number): void;
  142945. /**
  142946. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  142947. * The queries will try to find a solution within those bounds
  142948. * default is (1,1,1)
  142949. * @param extent x,y,z value that define the extent around the queries point of reference
  142950. */
  142951. setDefaultQueryExtent(extent: Vector3): void;
  142952. /**
  142953. * Get the Bounding box extent specified by setDefaultQueryExtent
  142954. * @returns the box extent values
  142955. */
  142956. getDefaultQueryExtent(): Vector3;
  142957. /**
  142958. * Get the Bounding box extent result specified by setDefaultQueryExtent
  142959. * @param result output the box extent values
  142960. */
  142961. getDefaultQueryExtentToRef(result: Vector3): void;
  142962. /**
  142963. * Release all resources
  142964. */
  142965. dispose(): void;
  142966. }
  142967. }
  142968. declare module BABYLON {
  142969. /**
  142970. * Class used to enable access to IndexedDB
  142971. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  142972. */
  142973. export class Database implements IOfflineProvider {
  142974. private _callbackManifestChecked;
  142975. private _currentSceneUrl;
  142976. private _db;
  142977. private _enableSceneOffline;
  142978. private _enableTexturesOffline;
  142979. private _manifestVersionFound;
  142980. private _mustUpdateRessources;
  142981. private _hasReachedQuota;
  142982. private _isSupported;
  142983. private _idbFactory;
  142984. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  142985. private static IsUASupportingBlobStorage;
  142986. /**
  142987. * Gets a boolean indicating if Database storate is enabled (off by default)
  142988. */
  142989. static IDBStorageEnabled: boolean;
  142990. /**
  142991. * Gets a boolean indicating if scene must be saved in the database
  142992. */
  142993. get enableSceneOffline(): boolean;
  142994. /**
  142995. * Gets a boolean indicating if textures must be saved in the database
  142996. */
  142997. get enableTexturesOffline(): boolean;
  142998. /**
  142999. * Creates a new Database
  143000. * @param urlToScene defines the url to load the scene
  143001. * @param callbackManifestChecked defines the callback to use when manifest is checked
  143002. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  143003. */
  143004. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  143005. private static _ParseURL;
  143006. private static _ReturnFullUrlLocation;
  143007. private _checkManifestFile;
  143008. /**
  143009. * Open the database and make it available
  143010. * @param successCallback defines the callback to call on success
  143011. * @param errorCallback defines the callback to call on error
  143012. */
  143013. open(successCallback: () => void, errorCallback: () => void): void;
  143014. /**
  143015. * Loads an image from the database
  143016. * @param url defines the url to load from
  143017. * @param image defines the target DOM image
  143018. */
  143019. loadImage(url: string, image: HTMLImageElement): void;
  143020. private _loadImageFromDBAsync;
  143021. private _saveImageIntoDBAsync;
  143022. private _checkVersionFromDB;
  143023. private _loadVersionFromDBAsync;
  143024. private _saveVersionIntoDBAsync;
  143025. /**
  143026. * Loads a file from database
  143027. * @param url defines the URL to load from
  143028. * @param sceneLoaded defines a callback to call on success
  143029. * @param progressCallBack defines a callback to call when progress changed
  143030. * @param errorCallback defines a callback to call on error
  143031. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  143032. */
  143033. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  143034. private _loadFileAsync;
  143035. private _saveFileAsync;
  143036. /**
  143037. * Validates if xhr data is correct
  143038. * @param xhr defines the request to validate
  143039. * @param dataType defines the expected data type
  143040. * @returns true if data is correct
  143041. */
  143042. private static _ValidateXHRData;
  143043. }
  143044. }
  143045. declare module BABYLON {
  143046. /** @hidden */
  143047. export var gpuUpdateParticlesPixelShader: {
  143048. name: string;
  143049. shader: string;
  143050. };
  143051. }
  143052. declare module BABYLON {
  143053. /** @hidden */
  143054. export var gpuUpdateParticlesVertexShader: {
  143055. name: string;
  143056. shader: string;
  143057. };
  143058. }
  143059. declare module BABYLON {
  143060. /** @hidden */
  143061. export var clipPlaneFragmentDeclaration2: {
  143062. name: string;
  143063. shader: string;
  143064. };
  143065. }
  143066. declare module BABYLON {
  143067. /** @hidden */
  143068. export var gpuRenderParticlesPixelShader: {
  143069. name: string;
  143070. shader: string;
  143071. };
  143072. }
  143073. declare module BABYLON {
  143074. /** @hidden */
  143075. export var clipPlaneVertexDeclaration2: {
  143076. name: string;
  143077. shader: string;
  143078. };
  143079. }
  143080. declare module BABYLON {
  143081. /** @hidden */
  143082. export var gpuRenderParticlesVertexShader: {
  143083. name: string;
  143084. shader: string;
  143085. };
  143086. }
  143087. declare module BABYLON {
  143088. /**
  143089. * This represents a GPU particle system in Babylon
  143090. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  143091. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  143092. */
  143093. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  143094. /**
  143095. * The layer mask we are rendering the particles through.
  143096. */
  143097. layerMask: number;
  143098. private _capacity;
  143099. private _activeCount;
  143100. private _currentActiveCount;
  143101. private _accumulatedCount;
  143102. private _renderEffect;
  143103. private _updateEffect;
  143104. private _buffer0;
  143105. private _buffer1;
  143106. private _spriteBuffer;
  143107. private _updateVAO;
  143108. private _renderVAO;
  143109. private _targetIndex;
  143110. private _sourceBuffer;
  143111. private _targetBuffer;
  143112. private _engine;
  143113. private _currentRenderId;
  143114. private _started;
  143115. private _stopped;
  143116. private _timeDelta;
  143117. private _randomTexture;
  143118. private _randomTexture2;
  143119. private _attributesStrideSize;
  143120. private _updateEffectOptions;
  143121. private _randomTextureSize;
  143122. private _actualFrame;
  143123. private _customEffect;
  143124. private readonly _rawTextureWidth;
  143125. /**
  143126. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  143127. */
  143128. static get IsSupported(): boolean;
  143129. /**
  143130. * An event triggered when the system is disposed.
  143131. */
  143132. onDisposeObservable: Observable<IParticleSystem>;
  143133. /**
  143134. * Gets the maximum number of particles active at the same time.
  143135. * @returns The max number of active particles.
  143136. */
  143137. getCapacity(): number;
  143138. /**
  143139. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  143140. * to override the particles.
  143141. */
  143142. forceDepthWrite: boolean;
  143143. /**
  143144. * Gets or set the number of active particles
  143145. */
  143146. get activeParticleCount(): number;
  143147. set activeParticleCount(value: number);
  143148. private _preWarmDone;
  143149. /**
  143150. * Specifies if the particles are updated in emitter local space or world space.
  143151. */
  143152. isLocal: boolean;
  143153. /**
  143154. * Is this system ready to be used/rendered
  143155. * @return true if the system is ready
  143156. */
  143157. isReady(): boolean;
  143158. /**
  143159. * Gets if the system has been started. (Note: this will still be true after stop is called)
  143160. * @returns True if it has been started, otherwise false.
  143161. */
  143162. isStarted(): boolean;
  143163. /**
  143164. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  143165. * @returns True if it has been stopped, otherwise false.
  143166. */
  143167. isStopped(): boolean;
  143168. /**
  143169. * Gets a boolean indicating that the system is stopping
  143170. * @returns true if the system is currently stopping
  143171. */
  143172. isStopping(): boolean;
  143173. /**
  143174. * Gets the number of particles active at the same time.
  143175. * @returns The number of active particles.
  143176. */
  143177. getActiveCount(): number;
  143178. /**
  143179. * Starts the particle system and begins to emit
  143180. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  143181. */
  143182. start(delay?: number): void;
  143183. /**
  143184. * Stops the particle system.
  143185. */
  143186. stop(): void;
  143187. /**
  143188. * Remove all active particles
  143189. */
  143190. reset(): void;
  143191. /**
  143192. * Returns the string "GPUParticleSystem"
  143193. * @returns a string containing the class name
  143194. */
  143195. getClassName(): string;
  143196. /**
  143197. * Gets the custom effect used to render the particles
  143198. * @param blendMode Blend mode for which the effect should be retrieved
  143199. * @returns The effect
  143200. */
  143201. getCustomEffect(blendMode?: number): Nullable<Effect>;
  143202. /**
  143203. * Sets the custom effect used to render the particles
  143204. * @param effect The effect to set
  143205. * @param blendMode Blend mode for which the effect should be set
  143206. */
  143207. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  143208. /** @hidden */
  143209. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  143210. /**
  143211. * Observable that will be called just before the particles are drawn
  143212. */
  143213. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  143214. /**
  143215. * Gets the name of the particle vertex shader
  143216. */
  143217. get vertexShaderName(): string;
  143218. private _colorGradientsTexture;
  143219. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  143220. /**
  143221. * Adds a new color gradient
  143222. * @param gradient defines the gradient to use (between 0 and 1)
  143223. * @param color1 defines the color to affect to the specified gradient
  143224. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  143225. * @returns the current particle system
  143226. */
  143227. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  143228. private _refreshColorGradient;
  143229. /** Force the system to rebuild all gradients that need to be resync */
  143230. forceRefreshGradients(): void;
  143231. /**
  143232. * Remove a specific color gradient
  143233. * @param gradient defines the gradient to remove
  143234. * @returns the current particle system
  143235. */
  143236. removeColorGradient(gradient: number): GPUParticleSystem;
  143237. private _angularSpeedGradientsTexture;
  143238. private _sizeGradientsTexture;
  143239. private _velocityGradientsTexture;
  143240. private _limitVelocityGradientsTexture;
  143241. private _dragGradientsTexture;
  143242. private _addFactorGradient;
  143243. /**
  143244. * Adds a new size gradient
  143245. * @param gradient defines the gradient to use (between 0 and 1)
  143246. * @param factor defines the size factor to affect to the specified gradient
  143247. * @returns the current particle system
  143248. */
  143249. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  143250. /**
  143251. * Remove a specific size gradient
  143252. * @param gradient defines the gradient to remove
  143253. * @returns the current particle system
  143254. */
  143255. removeSizeGradient(gradient: number): GPUParticleSystem;
  143256. private _refreshFactorGradient;
  143257. /**
  143258. * Adds a new angular speed gradient
  143259. * @param gradient defines the gradient to use (between 0 and 1)
  143260. * @param factor defines the angular speed to affect to the specified gradient
  143261. * @returns the current particle system
  143262. */
  143263. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  143264. /**
  143265. * Remove a specific angular speed gradient
  143266. * @param gradient defines the gradient to remove
  143267. * @returns the current particle system
  143268. */
  143269. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  143270. /**
  143271. * Adds a new velocity gradient
  143272. * @param gradient defines the gradient to use (between 0 and 1)
  143273. * @param factor defines the velocity to affect to the specified gradient
  143274. * @returns the current particle system
  143275. */
  143276. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  143277. /**
  143278. * Remove a specific velocity gradient
  143279. * @param gradient defines the gradient to remove
  143280. * @returns the current particle system
  143281. */
  143282. removeVelocityGradient(gradient: number): GPUParticleSystem;
  143283. /**
  143284. * Adds a new limit velocity gradient
  143285. * @param gradient defines the gradient to use (between 0 and 1)
  143286. * @param factor defines the limit velocity value to affect to the specified gradient
  143287. * @returns the current particle system
  143288. */
  143289. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  143290. /**
  143291. * Remove a specific limit velocity gradient
  143292. * @param gradient defines the gradient to remove
  143293. * @returns the current particle system
  143294. */
  143295. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  143296. /**
  143297. * Adds a new drag gradient
  143298. * @param gradient defines the gradient to use (between 0 and 1)
  143299. * @param factor defines the drag value to affect to the specified gradient
  143300. * @returns the current particle system
  143301. */
  143302. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  143303. /**
  143304. * Remove a specific drag gradient
  143305. * @param gradient defines the gradient to remove
  143306. * @returns the current particle system
  143307. */
  143308. removeDragGradient(gradient: number): GPUParticleSystem;
  143309. /**
  143310. * Not supported by GPUParticleSystem
  143311. * @param gradient defines the gradient to use (between 0 and 1)
  143312. * @param factor defines the emit rate value to affect to the specified gradient
  143313. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  143314. * @returns the current particle system
  143315. */
  143316. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  143317. /**
  143318. * Not supported by GPUParticleSystem
  143319. * @param gradient defines the gradient to remove
  143320. * @returns the current particle system
  143321. */
  143322. removeEmitRateGradient(gradient: number): IParticleSystem;
  143323. /**
  143324. * Not supported by GPUParticleSystem
  143325. * @param gradient defines the gradient to use (between 0 and 1)
  143326. * @param factor defines the start size value to affect to the specified gradient
  143327. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  143328. * @returns the current particle system
  143329. */
  143330. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  143331. /**
  143332. * Not supported by GPUParticleSystem
  143333. * @param gradient defines the gradient to remove
  143334. * @returns the current particle system
  143335. */
  143336. removeStartSizeGradient(gradient: number): IParticleSystem;
  143337. /**
  143338. * Not supported by GPUParticleSystem
  143339. * @param gradient defines the gradient to use (between 0 and 1)
  143340. * @param min defines the color remap minimal range
  143341. * @param max defines the color remap maximal range
  143342. * @returns the current particle system
  143343. */
  143344. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  143345. /**
  143346. * Not supported by GPUParticleSystem
  143347. * @param gradient defines the gradient to remove
  143348. * @returns the current particle system
  143349. */
  143350. removeColorRemapGradient(): IParticleSystem;
  143351. /**
  143352. * Not supported by GPUParticleSystem
  143353. * @param gradient defines the gradient to use (between 0 and 1)
  143354. * @param min defines the alpha remap minimal range
  143355. * @param max defines the alpha remap maximal range
  143356. * @returns the current particle system
  143357. */
  143358. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  143359. /**
  143360. * Not supported by GPUParticleSystem
  143361. * @param gradient defines the gradient to remove
  143362. * @returns the current particle system
  143363. */
  143364. removeAlphaRemapGradient(): IParticleSystem;
  143365. /**
  143366. * Not supported by GPUParticleSystem
  143367. * @param gradient defines the gradient to use (between 0 and 1)
  143368. * @param color defines the color to affect to the specified gradient
  143369. * @returns the current particle system
  143370. */
  143371. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  143372. /**
  143373. * Not supported by GPUParticleSystem
  143374. * @param gradient defines the gradient to remove
  143375. * @returns the current particle system
  143376. */
  143377. removeRampGradient(): IParticleSystem;
  143378. /**
  143379. * Not supported by GPUParticleSystem
  143380. * @returns the list of ramp gradients
  143381. */
  143382. getRampGradients(): Nullable<Array<Color3Gradient>>;
  143383. /**
  143384. * Not supported by GPUParticleSystem
  143385. * Gets or sets a boolean indicating that ramp gradients must be used
  143386. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  143387. */
  143388. get useRampGradients(): boolean;
  143389. set useRampGradients(value: boolean);
  143390. /**
  143391. * Not supported by GPUParticleSystem
  143392. * @param gradient defines the gradient to use (between 0 and 1)
  143393. * @param factor defines the life time factor to affect to the specified gradient
  143394. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  143395. * @returns the current particle system
  143396. */
  143397. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  143398. /**
  143399. * Not supported by GPUParticleSystem
  143400. * @param gradient defines the gradient to remove
  143401. * @returns the current particle system
  143402. */
  143403. removeLifeTimeGradient(gradient: number): IParticleSystem;
  143404. /**
  143405. * Instantiates a GPU particle system.
  143406. * 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.
  143407. * @param name The name of the particle system
  143408. * @param options The options used to create the system
  143409. * @param scene The scene the particle system belongs to
  143410. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  143411. * @param customEffect a custom effect used to change the way particles are rendered by default
  143412. */
  143413. constructor(name: string, options: Partial<{
  143414. capacity: number;
  143415. randomTextureSize: number;
  143416. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  143417. protected _reset(): void;
  143418. private _createUpdateVAO;
  143419. private _createRenderVAO;
  143420. private _initialize;
  143421. /** @hidden */
  143422. _recreateUpdateEffect(): void;
  143423. private _getEffect;
  143424. /**
  143425. * Fill the defines array according to the current settings of the particle system
  143426. * @param defines Array to be updated
  143427. * @param blendMode blend mode to take into account when updating the array
  143428. */
  143429. fillDefines(defines: Array<string>, blendMode?: number): void;
  143430. /**
  143431. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  143432. * @param uniforms Uniforms array to fill
  143433. * @param attributes Attributes array to fill
  143434. * @param samplers Samplers array to fill
  143435. */
  143436. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  143437. /** @hidden */
  143438. _recreateRenderEffect(): Effect;
  143439. /**
  143440. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  143441. * @param preWarm defines if we are in the pre-warmimg phase
  143442. */
  143443. animate(preWarm?: boolean): void;
  143444. private _createFactorGradientTexture;
  143445. private _createSizeGradientTexture;
  143446. private _createAngularSpeedGradientTexture;
  143447. private _createVelocityGradientTexture;
  143448. private _createLimitVelocityGradientTexture;
  143449. private _createDragGradientTexture;
  143450. private _createColorGradientTexture;
  143451. /**
  143452. * Renders the particle system in its current state
  143453. * @param preWarm defines if the system should only update the particles but not render them
  143454. * @returns the current number of particles
  143455. */
  143456. render(preWarm?: boolean): number;
  143457. /**
  143458. * Rebuilds the particle system
  143459. */
  143460. rebuild(): void;
  143461. private _releaseBuffers;
  143462. private _releaseVAOs;
  143463. /**
  143464. * Disposes the particle system and free the associated resources
  143465. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  143466. */
  143467. dispose(disposeTexture?: boolean): void;
  143468. /**
  143469. * Clones the particle system.
  143470. * @param name The name of the cloned object
  143471. * @param newEmitter The new emitter to use
  143472. * @returns the cloned particle system
  143473. */
  143474. clone(name: string, newEmitter: any): GPUParticleSystem;
  143475. /**
  143476. * Serializes the particle system to a JSON object
  143477. * @param serializeTexture defines if the texture must be serialized as well
  143478. * @returns the JSON object
  143479. */
  143480. serialize(serializeTexture?: boolean): any;
  143481. /**
  143482. * Parses a JSON object to create a GPU particle system.
  143483. * @param parsedParticleSystem The JSON object to parse
  143484. * @param scene The scene to create the particle system in
  143485. * @param rootUrl The root url to use to load external dependencies like texture
  143486. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  143487. * @returns the parsed GPU particle system
  143488. */
  143489. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  143490. }
  143491. }
  143492. declare module BABYLON {
  143493. /**
  143494. * Represents a set of particle systems working together to create a specific effect
  143495. */
  143496. export class ParticleSystemSet implements IDisposable {
  143497. /**
  143498. * Gets or sets base Assets URL
  143499. */
  143500. static BaseAssetsUrl: string;
  143501. private _emitterCreationOptions;
  143502. private _emitterNode;
  143503. /**
  143504. * Gets the particle system list
  143505. */
  143506. systems: IParticleSystem[];
  143507. /**
  143508. * Gets the emitter node used with this set
  143509. */
  143510. get emitterNode(): Nullable<TransformNode>;
  143511. /**
  143512. * Creates a new emitter mesh as a sphere
  143513. * @param options defines the options used to create the sphere
  143514. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  143515. * @param scene defines the hosting scene
  143516. */
  143517. setEmitterAsSphere(options: {
  143518. diameter: number;
  143519. segments: number;
  143520. color: Color3;
  143521. }, renderingGroupId: number, scene: Scene): void;
  143522. /**
  143523. * Starts all particle systems of the set
  143524. * @param emitter defines an optional mesh to use as emitter for the particle systems
  143525. */
  143526. start(emitter?: AbstractMesh): void;
  143527. /**
  143528. * Release all associated resources
  143529. */
  143530. dispose(): void;
  143531. /**
  143532. * Serialize the set into a JSON compatible object
  143533. * @param serializeTexture defines if the texture must be serialized as well
  143534. * @returns a JSON compatible representation of the set
  143535. */
  143536. serialize(serializeTexture?: boolean): any;
  143537. /**
  143538. * Parse a new ParticleSystemSet from a serialized source
  143539. * @param data defines a JSON compatible representation of the set
  143540. * @param scene defines the hosting scene
  143541. * @param gpu defines if we want GPU particles or CPU particles
  143542. * @returns a new ParticleSystemSet
  143543. */
  143544. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  143545. }
  143546. }
  143547. declare module BABYLON {
  143548. /**
  143549. * This class is made for on one-liner static method to help creating particle system set.
  143550. */
  143551. export class ParticleHelper {
  143552. /**
  143553. * Gets or sets base Assets URL
  143554. */
  143555. static BaseAssetsUrl: string;
  143556. /** Define the Url to load snippets */
  143557. static SnippetUrl: string;
  143558. /**
  143559. * Create a default particle system that you can tweak
  143560. * @param emitter defines the emitter to use
  143561. * @param capacity defines the system capacity (default is 500 particles)
  143562. * @param scene defines the hosting scene
  143563. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  143564. * @returns the new Particle system
  143565. */
  143566. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  143567. /**
  143568. * This is the main static method (one-liner) of this helper to create different particle systems
  143569. * @param type This string represents the type to the particle system to create
  143570. * @param scene The scene where the particle system should live
  143571. * @param gpu If the system will use gpu
  143572. * @returns the ParticleSystemSet created
  143573. */
  143574. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  143575. /**
  143576. * Static function used to export a particle system to a ParticleSystemSet variable.
  143577. * Please note that the emitter shape is not exported
  143578. * @param systems defines the particle systems to export
  143579. * @returns the created particle system set
  143580. */
  143581. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  143582. /**
  143583. * Creates a particle system from a snippet saved in a remote file
  143584. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  143585. * @param url defines the url to load from
  143586. * @param scene defines the hosting scene
  143587. * @param gpu If the system will use gpu
  143588. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  143589. * @returns a promise that will resolve to the new particle system
  143590. */
  143591. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  143592. /**
  143593. * Creates a particle system from a snippet saved by the particle system editor
  143594. * @param snippetId defines the snippet to load
  143595. * @param scene defines the hosting scene
  143596. * @param gpu If the system will use gpu
  143597. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  143598. * @returns a promise that will resolve to the new particle system
  143599. */
  143600. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  143601. }
  143602. }
  143603. declare module BABYLON {
  143604. interface Engine {
  143605. /**
  143606. * Create an effect to use with particle systems.
  143607. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  143608. * the particle system for which you want to create a custom effect in the last parameter
  143609. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  143610. * @param uniformsNames defines a list of attribute names
  143611. * @param samplers defines an array of string used to represent textures
  143612. * @param defines defines the string containing the defines to use to compile the shaders
  143613. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  143614. * @param onCompiled defines a function to call when the effect creation is successful
  143615. * @param onError defines a function to call when the effect creation has failed
  143616. * @param particleSystem the particle system you want to create the effect for
  143617. * @returns the new Effect
  143618. */
  143619. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  143620. }
  143621. interface Mesh {
  143622. /**
  143623. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  143624. * @returns an array of IParticleSystem
  143625. */
  143626. getEmittedParticleSystems(): IParticleSystem[];
  143627. /**
  143628. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  143629. * @returns an array of IParticleSystem
  143630. */
  143631. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  143632. }
  143633. }
  143634. declare module BABYLON {
  143635. /** Defines the 4 color options */
  143636. export enum PointColor {
  143637. /** color value */
  143638. Color = 2,
  143639. /** uv value */
  143640. UV = 1,
  143641. /** random value */
  143642. Random = 0,
  143643. /** stated value */
  143644. Stated = 3
  143645. }
  143646. /**
  143647. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  143648. * 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.
  143649. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  143650. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  143651. *
  143652. * Full documentation here : TO BE ENTERED
  143653. */
  143654. export class PointsCloudSystem implements IDisposable {
  143655. /**
  143656. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  143657. * Example : var p = SPS.particles[i];
  143658. */
  143659. particles: CloudPoint[];
  143660. /**
  143661. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  143662. */
  143663. nbParticles: number;
  143664. /**
  143665. * This a counter for your own usage. It's not set by any SPS functions.
  143666. */
  143667. counter: number;
  143668. /**
  143669. * The PCS name. This name is also given to the underlying mesh.
  143670. */
  143671. name: string;
  143672. /**
  143673. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  143674. */
  143675. mesh: Mesh;
  143676. /**
  143677. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  143678. * Please read :
  143679. */
  143680. vars: any;
  143681. /**
  143682. * @hidden
  143683. */
  143684. _size: number;
  143685. private _scene;
  143686. private _promises;
  143687. private _positions;
  143688. private _indices;
  143689. private _normals;
  143690. private _colors;
  143691. private _uvs;
  143692. private _indices32;
  143693. private _positions32;
  143694. private _colors32;
  143695. private _uvs32;
  143696. private _updatable;
  143697. private _isVisibilityBoxLocked;
  143698. private _alwaysVisible;
  143699. private _groups;
  143700. private _groupCounter;
  143701. private _computeParticleColor;
  143702. private _computeParticleTexture;
  143703. private _computeParticleRotation;
  143704. private _computeBoundingBox;
  143705. private _isReady;
  143706. /**
  143707. * Creates a PCS (Points Cloud System) object
  143708. * @param name (String) is the PCS name, this will be the underlying mesh name
  143709. * @param pointSize (number) is the size for each point
  143710. * @param scene (Scene) is the scene in which the PCS is added
  143711. * @param options defines the options of the PCS e.g.
  143712. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  143713. */
  143714. constructor(name: string, pointSize: number, scene: Scene, options?: {
  143715. updatable?: boolean;
  143716. });
  143717. /**
  143718. * Builds the PCS underlying mesh. Returns a standard Mesh.
  143719. * If no points were added to the PCS, the returned mesh is just a single point.
  143720. * @returns a promise for the created mesh
  143721. */
  143722. buildMeshAsync(): Promise<Mesh>;
  143723. /**
  143724. * @hidden
  143725. */
  143726. private _buildMesh;
  143727. private _addParticle;
  143728. private _randomUnitVector;
  143729. private _getColorIndicesForCoord;
  143730. private _setPointsColorOrUV;
  143731. private _colorFromTexture;
  143732. private _calculateDensity;
  143733. /**
  143734. * Adds points to the PCS in random positions within a unit sphere
  143735. * @param nb (positive integer) the number of particles to be created from this model
  143736. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  143737. * @returns the number of groups in the system
  143738. */
  143739. addPoints(nb: number, pointFunction?: any): number;
  143740. /**
  143741. * Adds points to the PCS from the surface of the model shape
  143742. * @param mesh is any Mesh object that will be used as a surface model for the points
  143743. * @param nb (positive integer) the number of particles to be created from this model
  143744. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  143745. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  143746. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  143747. * @returns the number of groups in the system
  143748. */
  143749. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  143750. /**
  143751. * Adds points to the PCS inside the model shape
  143752. * @param mesh is any Mesh object that will be used as a surface model for the points
  143753. * @param nb (positive integer) the number of particles to be created from this model
  143754. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  143755. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  143756. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  143757. * @returns the number of groups in the system
  143758. */
  143759. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  143760. /**
  143761. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  143762. * This method calls `updateParticle()` for each particle of the SPS.
  143763. * For an animated SPS, it is usually called within the render loop.
  143764. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  143765. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  143766. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  143767. * @returns the PCS.
  143768. */
  143769. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  143770. /**
  143771. * Disposes the PCS.
  143772. */
  143773. dispose(): void;
  143774. /**
  143775. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  143776. * doc :
  143777. * @returns the PCS.
  143778. */
  143779. refreshVisibleSize(): PointsCloudSystem;
  143780. /**
  143781. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  143782. * @param size the size (float) of the visibility box
  143783. * note : this doesn't lock the PCS mesh bounding box.
  143784. * doc :
  143785. */
  143786. setVisibilityBox(size: number): void;
  143787. /**
  143788. * Gets whether the PCS is always visible or not
  143789. * doc :
  143790. */
  143791. get isAlwaysVisible(): boolean;
  143792. /**
  143793. * Sets the PCS as always visible or not
  143794. * doc :
  143795. */
  143796. set isAlwaysVisible(val: boolean);
  143797. /**
  143798. * Tells to `setParticles()` to compute the particle rotations or not
  143799. * Default value : false. The PCS is faster when it's set to false
  143800. * Note : particle rotations are only applied to parent particles
  143801. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  143802. */
  143803. set computeParticleRotation(val: boolean);
  143804. /**
  143805. * Tells to `setParticles()` to compute the particle colors or not.
  143806. * Default value : true. The PCS is faster when it's set to false.
  143807. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  143808. */
  143809. set computeParticleColor(val: boolean);
  143810. set computeParticleTexture(val: boolean);
  143811. /**
  143812. * Gets if `setParticles()` computes the particle colors or not.
  143813. * Default value : false. The PCS is faster when it's set to false.
  143814. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  143815. */
  143816. get computeParticleColor(): boolean;
  143817. /**
  143818. * Gets if `setParticles()` computes the particle textures or not.
  143819. * Default value : false. The PCS is faster when it's set to false.
  143820. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  143821. */
  143822. get computeParticleTexture(): boolean;
  143823. /**
  143824. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  143825. */
  143826. set computeBoundingBox(val: boolean);
  143827. /**
  143828. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  143829. */
  143830. get computeBoundingBox(): boolean;
  143831. /**
  143832. * This function does nothing. It may be overwritten to set all the particle first values.
  143833. * The PCS doesn't call this function, you may have to call it by your own.
  143834. * doc :
  143835. */
  143836. initParticles(): void;
  143837. /**
  143838. * This function does nothing. It may be overwritten to recycle a particle
  143839. * The PCS doesn't call this function, you can to call it
  143840. * doc :
  143841. * @param particle The particle to recycle
  143842. * @returns the recycled particle
  143843. */
  143844. recycleParticle(particle: CloudPoint): CloudPoint;
  143845. /**
  143846. * Updates a particle : this function should be overwritten by the user.
  143847. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  143848. * doc :
  143849. * @example : just set a particle position or velocity and recycle conditions
  143850. * @param particle The particle to update
  143851. * @returns the updated particle
  143852. */
  143853. updateParticle(particle: CloudPoint): CloudPoint;
  143854. /**
  143855. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  143856. * This does nothing and may be overwritten by the user.
  143857. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  143858. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  143859. * @param update the boolean update value actually passed to setParticles()
  143860. */
  143861. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  143862. /**
  143863. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  143864. * This will be passed three parameters.
  143865. * This does nothing and may be overwritten by the user.
  143866. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  143867. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  143868. * @param update the boolean update value actually passed to setParticles()
  143869. */
  143870. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  143871. }
  143872. }
  143873. declare module BABYLON {
  143874. /**
  143875. * Represents one particle of a points cloud system.
  143876. */
  143877. export class CloudPoint {
  143878. /**
  143879. * particle global index
  143880. */
  143881. idx: number;
  143882. /**
  143883. * The color of the particle
  143884. */
  143885. color: Nullable<Color4>;
  143886. /**
  143887. * The world space position of the particle.
  143888. */
  143889. position: Vector3;
  143890. /**
  143891. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  143892. */
  143893. rotation: Vector3;
  143894. /**
  143895. * The world space rotation quaternion of the particle.
  143896. */
  143897. rotationQuaternion: Nullable<Quaternion>;
  143898. /**
  143899. * The uv of the particle.
  143900. */
  143901. uv: Nullable<Vector2>;
  143902. /**
  143903. * The current speed of the particle.
  143904. */
  143905. velocity: Vector3;
  143906. /**
  143907. * The pivot point in the particle local space.
  143908. */
  143909. pivot: Vector3;
  143910. /**
  143911. * Must the particle be translated from its pivot point in its local space ?
  143912. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  143913. * Default : false
  143914. */
  143915. translateFromPivot: boolean;
  143916. /**
  143917. * Index of this particle in the global "positions" array (Internal use)
  143918. * @hidden
  143919. */
  143920. _pos: number;
  143921. /**
  143922. * @hidden Index of this particle in the global "indices" array (Internal use)
  143923. */
  143924. _ind: number;
  143925. /**
  143926. * Group this particle belongs to
  143927. */
  143928. _group: PointsGroup;
  143929. /**
  143930. * Group id of this particle
  143931. */
  143932. groupId: number;
  143933. /**
  143934. * Index of the particle in its group id (Internal use)
  143935. */
  143936. idxInGroup: number;
  143937. /**
  143938. * @hidden Particle BoundingInfo object (Internal use)
  143939. */
  143940. _boundingInfo: BoundingInfo;
  143941. /**
  143942. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  143943. */
  143944. _pcs: PointsCloudSystem;
  143945. /**
  143946. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  143947. */
  143948. _stillInvisible: boolean;
  143949. /**
  143950. * @hidden Last computed particle rotation matrix
  143951. */
  143952. _rotationMatrix: number[];
  143953. /**
  143954. * Parent particle Id, if any.
  143955. * Default null.
  143956. */
  143957. parentId: Nullable<number>;
  143958. /**
  143959. * @hidden Internal global position in the PCS.
  143960. */
  143961. _globalPosition: Vector3;
  143962. /**
  143963. * Creates a Point Cloud object.
  143964. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  143965. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  143966. * @param group (PointsGroup) is the group the particle belongs to
  143967. * @param groupId (integer) is the group identifier in the PCS.
  143968. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  143969. * @param pcs defines the PCS it is associated to
  143970. */
  143971. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  143972. /**
  143973. * get point size
  143974. */
  143975. get size(): Vector3;
  143976. /**
  143977. * Set point size
  143978. */
  143979. set size(scale: Vector3);
  143980. /**
  143981. * Legacy support, changed quaternion to rotationQuaternion
  143982. */
  143983. get quaternion(): Nullable<Quaternion>;
  143984. /**
  143985. * Legacy support, changed quaternion to rotationQuaternion
  143986. */
  143987. set quaternion(q: Nullable<Quaternion>);
  143988. /**
  143989. * Returns a boolean. True if the particle intersects a mesh, else false
  143990. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  143991. * @param target is the object (point or mesh) what the intersection is computed against
  143992. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  143993. * @returns true if it intersects
  143994. */
  143995. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  143996. /**
  143997. * get the rotation matrix of the particle
  143998. * @hidden
  143999. */
  144000. getRotationMatrix(m: Matrix): void;
  144001. }
  144002. /**
  144003. * Represents a group of points in a points cloud system
  144004. * * PCS internal tool, don't use it manually.
  144005. */
  144006. export class PointsGroup {
  144007. /**
  144008. * The group id
  144009. * @hidden
  144010. */
  144011. groupID: number;
  144012. /**
  144013. * image data for group (internal use)
  144014. * @hidden
  144015. */
  144016. _groupImageData: Nullable<ArrayBufferView>;
  144017. /**
  144018. * Image Width (internal use)
  144019. * @hidden
  144020. */
  144021. _groupImgWidth: number;
  144022. /**
  144023. * Image Height (internal use)
  144024. * @hidden
  144025. */
  144026. _groupImgHeight: number;
  144027. /**
  144028. * Custom position function (internal use)
  144029. * @hidden
  144030. */
  144031. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  144032. /**
  144033. * density per facet for surface points
  144034. * @hidden
  144035. */
  144036. _groupDensity: number[];
  144037. /**
  144038. * Only when points are colored by texture carries pointer to texture list array
  144039. * @hidden
  144040. */
  144041. _textureNb: number;
  144042. /**
  144043. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  144044. * PCS internal tool, don't use it manually.
  144045. * @hidden
  144046. */
  144047. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  144048. }
  144049. }
  144050. declare module BABYLON {
  144051. interface Scene {
  144052. /** @hidden (Backing field) */
  144053. _physicsEngine: Nullable<IPhysicsEngine>;
  144054. /** @hidden */
  144055. _physicsTimeAccumulator: number;
  144056. /**
  144057. * Gets the current physics engine
  144058. * @returns a IPhysicsEngine or null if none attached
  144059. */
  144060. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  144061. /**
  144062. * Enables physics to the current scene
  144063. * @param gravity defines the scene's gravity for the physics engine
  144064. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  144065. * @return a boolean indicating if the physics engine was initialized
  144066. */
  144067. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  144068. /**
  144069. * Disables and disposes the physics engine associated with the scene
  144070. */
  144071. disablePhysicsEngine(): void;
  144072. /**
  144073. * Gets a boolean indicating if there is an active physics engine
  144074. * @returns a boolean indicating if there is an active physics engine
  144075. */
  144076. isPhysicsEnabled(): boolean;
  144077. /**
  144078. * Deletes a physics compound impostor
  144079. * @param compound defines the compound to delete
  144080. */
  144081. deleteCompoundImpostor(compound: any): void;
  144082. /**
  144083. * An event triggered when physic simulation is about to be run
  144084. */
  144085. onBeforePhysicsObservable: Observable<Scene>;
  144086. /**
  144087. * An event triggered when physic simulation has been done
  144088. */
  144089. onAfterPhysicsObservable: Observable<Scene>;
  144090. }
  144091. interface AbstractMesh {
  144092. /** @hidden */
  144093. _physicsImpostor: Nullable<PhysicsImpostor>;
  144094. /**
  144095. * Gets or sets impostor used for physic simulation
  144096. * @see http://doc.babylonjs.com/features/physics_engine
  144097. */
  144098. physicsImpostor: Nullable<PhysicsImpostor>;
  144099. /**
  144100. * Gets the current physics impostor
  144101. * @see http://doc.babylonjs.com/features/physics_engine
  144102. * @returns a physics impostor or null
  144103. */
  144104. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  144105. /** Apply a physic impulse to the mesh
  144106. * @param force defines the force to apply
  144107. * @param contactPoint defines where to apply the force
  144108. * @returns the current mesh
  144109. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  144110. */
  144111. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  144112. /**
  144113. * Creates a physic joint between two meshes
  144114. * @param otherMesh defines the other mesh to use
  144115. * @param pivot1 defines the pivot to use on this mesh
  144116. * @param pivot2 defines the pivot to use on the other mesh
  144117. * @param options defines additional options (can be plugin dependent)
  144118. * @returns the current mesh
  144119. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  144120. */
  144121. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  144122. /** @hidden */
  144123. _disposePhysicsObserver: Nullable<Observer<Node>>;
  144124. }
  144125. /**
  144126. * Defines the physics engine scene component responsible to manage a physics engine
  144127. */
  144128. export class PhysicsEngineSceneComponent implements ISceneComponent {
  144129. /**
  144130. * The component name helpful to identify the component in the list of scene components.
  144131. */
  144132. readonly name: string;
  144133. /**
  144134. * The scene the component belongs to.
  144135. */
  144136. scene: Scene;
  144137. /**
  144138. * Creates a new instance of the component for the given scene
  144139. * @param scene Defines the scene to register the component in
  144140. */
  144141. constructor(scene: Scene);
  144142. /**
  144143. * Registers the component in a given scene
  144144. */
  144145. register(): void;
  144146. /**
  144147. * Rebuilds the elements related to this component in case of
  144148. * context lost for instance.
  144149. */
  144150. rebuild(): void;
  144151. /**
  144152. * Disposes the component and the associated ressources
  144153. */
  144154. dispose(): void;
  144155. }
  144156. }
  144157. declare module BABYLON {
  144158. /**
  144159. * A helper for physics simulations
  144160. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144161. */
  144162. export class PhysicsHelper {
  144163. private _scene;
  144164. private _physicsEngine;
  144165. /**
  144166. * Initializes the Physics helper
  144167. * @param scene Babylon.js scene
  144168. */
  144169. constructor(scene: Scene);
  144170. /**
  144171. * Applies a radial explosion impulse
  144172. * @param origin the origin of the explosion
  144173. * @param radiusOrEventOptions the radius or the options of radial explosion
  144174. * @param strength the explosion strength
  144175. * @param falloff possible options: Constant & Linear. Defaults to Constant
  144176. * @returns A physics radial explosion event, or null
  144177. */
  144178. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  144179. /**
  144180. * Applies a radial explosion force
  144181. * @param origin the origin of the explosion
  144182. * @param radiusOrEventOptions the radius or the options of radial explosion
  144183. * @param strength the explosion strength
  144184. * @param falloff possible options: Constant & Linear. Defaults to Constant
  144185. * @returns A physics radial explosion event, or null
  144186. */
  144187. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  144188. /**
  144189. * Creates a gravitational field
  144190. * @param origin the origin of the explosion
  144191. * @param radiusOrEventOptions the radius or the options of radial explosion
  144192. * @param strength the explosion strength
  144193. * @param falloff possible options: Constant & Linear. Defaults to Constant
  144194. * @returns A physics gravitational field event, or null
  144195. */
  144196. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  144197. /**
  144198. * Creates a physics updraft event
  144199. * @param origin the origin of the updraft
  144200. * @param radiusOrEventOptions the radius or the options of the updraft
  144201. * @param strength the strength of the updraft
  144202. * @param height the height of the updraft
  144203. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  144204. * @returns A physics updraft event, or null
  144205. */
  144206. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  144207. /**
  144208. * Creates a physics vortex event
  144209. * @param origin the of the vortex
  144210. * @param radiusOrEventOptions the radius or the options of the vortex
  144211. * @param strength the strength of the vortex
  144212. * @param height the height of the vortex
  144213. * @returns a Physics vortex event, or null
  144214. * A physics vortex event or null
  144215. */
  144216. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  144217. }
  144218. /**
  144219. * Represents a physics radial explosion event
  144220. */
  144221. class PhysicsRadialExplosionEvent {
  144222. private _scene;
  144223. private _options;
  144224. private _sphere;
  144225. private _dataFetched;
  144226. /**
  144227. * Initializes a radial explosioin event
  144228. * @param _scene BabylonJS scene
  144229. * @param _options The options for the vortex event
  144230. */
  144231. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  144232. /**
  144233. * Returns the data related to the radial explosion event (sphere).
  144234. * @returns The radial explosion event data
  144235. */
  144236. getData(): PhysicsRadialExplosionEventData;
  144237. /**
  144238. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  144239. * @param impostor A physics imposter
  144240. * @param origin the origin of the explosion
  144241. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  144242. */
  144243. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  144244. /**
  144245. * Triggers affecterd impostors callbacks
  144246. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  144247. */
  144248. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  144249. /**
  144250. * Disposes the sphere.
  144251. * @param force Specifies if the sphere should be disposed by force
  144252. */
  144253. dispose(force?: boolean): void;
  144254. /*** Helpers ***/
  144255. private _prepareSphere;
  144256. private _intersectsWithSphere;
  144257. }
  144258. /**
  144259. * Represents a gravitational field event
  144260. */
  144261. class PhysicsGravitationalFieldEvent {
  144262. private _physicsHelper;
  144263. private _scene;
  144264. private _origin;
  144265. private _options;
  144266. private _tickCallback;
  144267. private _sphere;
  144268. private _dataFetched;
  144269. /**
  144270. * Initializes the physics gravitational field event
  144271. * @param _physicsHelper A physics helper
  144272. * @param _scene BabylonJS scene
  144273. * @param _origin The origin position of the gravitational field event
  144274. * @param _options The options for the vortex event
  144275. */
  144276. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  144277. /**
  144278. * Returns the data related to the gravitational field event (sphere).
  144279. * @returns A gravitational field event
  144280. */
  144281. getData(): PhysicsGravitationalFieldEventData;
  144282. /**
  144283. * Enables the gravitational field.
  144284. */
  144285. enable(): void;
  144286. /**
  144287. * Disables the gravitational field.
  144288. */
  144289. disable(): void;
  144290. /**
  144291. * Disposes the sphere.
  144292. * @param force The force to dispose from the gravitational field event
  144293. */
  144294. dispose(force?: boolean): void;
  144295. private _tick;
  144296. }
  144297. /**
  144298. * Represents a physics updraft event
  144299. */
  144300. class PhysicsUpdraftEvent {
  144301. private _scene;
  144302. private _origin;
  144303. private _options;
  144304. private _physicsEngine;
  144305. private _originTop;
  144306. private _originDirection;
  144307. private _tickCallback;
  144308. private _cylinder;
  144309. private _cylinderPosition;
  144310. private _dataFetched;
  144311. /**
  144312. * Initializes the physics updraft event
  144313. * @param _scene BabylonJS scene
  144314. * @param _origin The origin position of the updraft
  144315. * @param _options The options for the updraft event
  144316. */
  144317. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  144318. /**
  144319. * Returns the data related to the updraft event (cylinder).
  144320. * @returns A physics updraft event
  144321. */
  144322. getData(): PhysicsUpdraftEventData;
  144323. /**
  144324. * Enables the updraft.
  144325. */
  144326. enable(): void;
  144327. /**
  144328. * Disables the updraft.
  144329. */
  144330. disable(): void;
  144331. /**
  144332. * Disposes the cylinder.
  144333. * @param force Specifies if the updraft should be disposed by force
  144334. */
  144335. dispose(force?: boolean): void;
  144336. private getImpostorHitData;
  144337. private _tick;
  144338. /*** Helpers ***/
  144339. private _prepareCylinder;
  144340. private _intersectsWithCylinder;
  144341. }
  144342. /**
  144343. * Represents a physics vortex event
  144344. */
  144345. class PhysicsVortexEvent {
  144346. private _scene;
  144347. private _origin;
  144348. private _options;
  144349. private _physicsEngine;
  144350. private _originTop;
  144351. private _tickCallback;
  144352. private _cylinder;
  144353. private _cylinderPosition;
  144354. private _dataFetched;
  144355. /**
  144356. * Initializes the physics vortex event
  144357. * @param _scene The BabylonJS scene
  144358. * @param _origin The origin position of the vortex
  144359. * @param _options The options for the vortex event
  144360. */
  144361. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  144362. /**
  144363. * Returns the data related to the vortex event (cylinder).
  144364. * @returns The physics vortex event data
  144365. */
  144366. getData(): PhysicsVortexEventData;
  144367. /**
  144368. * Enables the vortex.
  144369. */
  144370. enable(): void;
  144371. /**
  144372. * Disables the cortex.
  144373. */
  144374. disable(): void;
  144375. /**
  144376. * Disposes the sphere.
  144377. * @param force
  144378. */
  144379. dispose(force?: boolean): void;
  144380. private getImpostorHitData;
  144381. private _tick;
  144382. /*** Helpers ***/
  144383. private _prepareCylinder;
  144384. private _intersectsWithCylinder;
  144385. }
  144386. /**
  144387. * Options fot the radial explosion event
  144388. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144389. */
  144390. export class PhysicsRadialExplosionEventOptions {
  144391. /**
  144392. * The radius of the sphere for the radial explosion.
  144393. */
  144394. radius: number;
  144395. /**
  144396. * The strenth of the explosion.
  144397. */
  144398. strength: number;
  144399. /**
  144400. * The strenght of the force in correspondence to the distance of the affected object
  144401. */
  144402. falloff: PhysicsRadialImpulseFalloff;
  144403. /**
  144404. * Sphere options for the radial explosion.
  144405. */
  144406. sphere: {
  144407. segments: number;
  144408. diameter: number;
  144409. };
  144410. /**
  144411. * Sphere options for the radial explosion.
  144412. */
  144413. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  144414. }
  144415. /**
  144416. * Options fot the updraft event
  144417. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144418. */
  144419. export class PhysicsUpdraftEventOptions {
  144420. /**
  144421. * The radius of the cylinder for the vortex
  144422. */
  144423. radius: number;
  144424. /**
  144425. * The strenth of the updraft.
  144426. */
  144427. strength: number;
  144428. /**
  144429. * The height of the cylinder for the updraft.
  144430. */
  144431. height: number;
  144432. /**
  144433. * The mode for the the updraft.
  144434. */
  144435. updraftMode: PhysicsUpdraftMode;
  144436. }
  144437. /**
  144438. * Options fot the vortex event
  144439. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144440. */
  144441. export class PhysicsVortexEventOptions {
  144442. /**
  144443. * The radius of the cylinder for the vortex
  144444. */
  144445. radius: number;
  144446. /**
  144447. * The strenth of the vortex.
  144448. */
  144449. strength: number;
  144450. /**
  144451. * The height of the cylinder for the vortex.
  144452. */
  144453. height: number;
  144454. /**
  144455. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  144456. */
  144457. centripetalForceThreshold: number;
  144458. /**
  144459. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  144460. */
  144461. centripetalForceMultiplier: number;
  144462. /**
  144463. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  144464. */
  144465. centrifugalForceMultiplier: number;
  144466. /**
  144467. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  144468. */
  144469. updraftForceMultiplier: number;
  144470. }
  144471. /**
  144472. * The strenght of the force in correspondence to the distance of the affected object
  144473. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144474. */
  144475. export enum PhysicsRadialImpulseFalloff {
  144476. /** Defines that impulse is constant in strength across it's whole radius */
  144477. Constant = 0,
  144478. /** Defines that impulse gets weaker if it's further from the origin */
  144479. Linear = 1
  144480. }
  144481. /**
  144482. * The strength of the force in correspondence to the distance of the affected object
  144483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144484. */
  144485. export enum PhysicsUpdraftMode {
  144486. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  144487. Center = 0,
  144488. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  144489. Perpendicular = 1
  144490. }
  144491. /**
  144492. * Interface for a physics hit data
  144493. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144494. */
  144495. export interface PhysicsHitData {
  144496. /**
  144497. * The force applied at the contact point
  144498. */
  144499. force: Vector3;
  144500. /**
  144501. * The contact point
  144502. */
  144503. contactPoint: Vector3;
  144504. /**
  144505. * The distance from the origin to the contact point
  144506. */
  144507. distanceFromOrigin: number;
  144508. }
  144509. /**
  144510. * Interface for radial explosion event data
  144511. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144512. */
  144513. export interface PhysicsRadialExplosionEventData {
  144514. /**
  144515. * A sphere used for the radial explosion event
  144516. */
  144517. sphere: Mesh;
  144518. }
  144519. /**
  144520. * Interface for gravitational field event data
  144521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144522. */
  144523. export interface PhysicsGravitationalFieldEventData {
  144524. /**
  144525. * A sphere mesh used for the gravitational field event
  144526. */
  144527. sphere: Mesh;
  144528. }
  144529. /**
  144530. * Interface for updraft event data
  144531. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144532. */
  144533. export interface PhysicsUpdraftEventData {
  144534. /**
  144535. * A cylinder used for the updraft event
  144536. */
  144537. cylinder: Mesh;
  144538. }
  144539. /**
  144540. * Interface for vortex event data
  144541. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144542. */
  144543. export interface PhysicsVortexEventData {
  144544. /**
  144545. * A cylinder used for the vortex event
  144546. */
  144547. cylinder: Mesh;
  144548. }
  144549. /**
  144550. * Interface for an affected physics impostor
  144551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144552. */
  144553. export interface PhysicsAffectedImpostorWithData {
  144554. /**
  144555. * The impostor affected by the effect
  144556. */
  144557. impostor: PhysicsImpostor;
  144558. /**
  144559. * The data about the hit/horce from the explosion
  144560. */
  144561. hitData: PhysicsHitData;
  144562. }
  144563. }
  144564. declare module BABYLON {
  144565. /** @hidden */
  144566. export var blackAndWhitePixelShader: {
  144567. name: string;
  144568. shader: string;
  144569. };
  144570. }
  144571. declare module BABYLON {
  144572. /**
  144573. * Post process used to render in black and white
  144574. */
  144575. export class BlackAndWhitePostProcess extends PostProcess {
  144576. /**
  144577. * Linear about to convert he result to black and white (default: 1)
  144578. */
  144579. degree: number;
  144580. /**
  144581. * Creates a black and white post process
  144582. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  144583. * @param name The name of the effect.
  144584. * @param options The required width/height ratio to downsize to before computing the render pass.
  144585. * @param camera The camera to apply the render pass to.
  144586. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144587. * @param engine The engine which the post process will be applied. (default: current engine)
  144588. * @param reusable If the post process can be reused on the same frame. (default: false)
  144589. */
  144590. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144591. }
  144592. }
  144593. declare module BABYLON {
  144594. /**
  144595. * This represents a set of one or more post processes in Babylon.
  144596. * A post process can be used to apply a shader to a texture after it is rendered.
  144597. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  144598. */
  144599. export class PostProcessRenderEffect {
  144600. private _postProcesses;
  144601. private _getPostProcesses;
  144602. private _singleInstance;
  144603. private _cameras;
  144604. private _indicesForCamera;
  144605. /**
  144606. * Name of the effect
  144607. * @hidden
  144608. */
  144609. _name: string;
  144610. /**
  144611. * Instantiates a post process render effect.
  144612. * A post process can be used to apply a shader to a texture after it is rendered.
  144613. * @param engine The engine the effect is tied to
  144614. * @param name The name of the effect
  144615. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  144616. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  144617. */
  144618. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  144619. /**
  144620. * Checks if all the post processes in the effect are supported.
  144621. */
  144622. get isSupported(): boolean;
  144623. /**
  144624. * Updates the current state of the effect
  144625. * @hidden
  144626. */
  144627. _update(): void;
  144628. /**
  144629. * Attaches the effect on cameras
  144630. * @param cameras The camera to attach to.
  144631. * @hidden
  144632. */
  144633. _attachCameras(cameras: Camera): void;
  144634. /**
  144635. * Attaches the effect on cameras
  144636. * @param cameras The camera to attach to.
  144637. * @hidden
  144638. */
  144639. _attachCameras(cameras: Camera[]): void;
  144640. /**
  144641. * Detaches the effect on cameras
  144642. * @param cameras The camera to detatch from.
  144643. * @hidden
  144644. */
  144645. _detachCameras(cameras: Camera): void;
  144646. /**
  144647. * Detatches the effect on cameras
  144648. * @param cameras The camera to detatch from.
  144649. * @hidden
  144650. */
  144651. _detachCameras(cameras: Camera[]): void;
  144652. /**
  144653. * Enables the effect on given cameras
  144654. * @param cameras The camera to enable.
  144655. * @hidden
  144656. */
  144657. _enable(cameras: Camera): void;
  144658. /**
  144659. * Enables the effect on given cameras
  144660. * @param cameras The camera to enable.
  144661. * @hidden
  144662. */
  144663. _enable(cameras: Nullable<Camera[]>): void;
  144664. /**
  144665. * Disables the effect on the given cameras
  144666. * @param cameras The camera to disable.
  144667. * @hidden
  144668. */
  144669. _disable(cameras: Camera): void;
  144670. /**
  144671. * Disables the effect on the given cameras
  144672. * @param cameras The camera to disable.
  144673. * @hidden
  144674. */
  144675. _disable(cameras: Nullable<Camera[]>): void;
  144676. /**
  144677. * Gets a list of the post processes contained in the effect.
  144678. * @param camera The camera to get the post processes on.
  144679. * @returns The list of the post processes in the effect.
  144680. */
  144681. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  144682. }
  144683. }
  144684. declare module BABYLON {
  144685. /** @hidden */
  144686. export var extractHighlightsPixelShader: {
  144687. name: string;
  144688. shader: string;
  144689. };
  144690. }
  144691. declare module BABYLON {
  144692. /**
  144693. * 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.
  144694. */
  144695. export class ExtractHighlightsPostProcess extends PostProcess {
  144696. /**
  144697. * The luminance threshold, pixels below this value will be set to black.
  144698. */
  144699. threshold: number;
  144700. /** @hidden */
  144701. _exposure: number;
  144702. /**
  144703. * Post process which has the input texture to be used when performing highlight extraction
  144704. * @hidden
  144705. */
  144706. _inputPostProcess: Nullable<PostProcess>;
  144707. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144708. }
  144709. }
  144710. declare module BABYLON {
  144711. /** @hidden */
  144712. export var bloomMergePixelShader: {
  144713. name: string;
  144714. shader: string;
  144715. };
  144716. }
  144717. declare module BABYLON {
  144718. /**
  144719. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  144720. */
  144721. export class BloomMergePostProcess extends PostProcess {
  144722. /** Weight of the bloom to be added to the original input. */
  144723. weight: number;
  144724. /**
  144725. * Creates a new instance of @see BloomMergePostProcess
  144726. * @param name The name of the effect.
  144727. * @param originalFromInput Post process which's input will be used for the merge.
  144728. * @param blurred Blurred highlights post process which's output will be used.
  144729. * @param weight Weight of the bloom to be added to the original input.
  144730. * @param options The required width/height ratio to downsize to before computing the render pass.
  144731. * @param camera The camera to apply the render pass to.
  144732. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144733. * @param engine The engine which the post process will be applied. (default: current engine)
  144734. * @param reusable If the post process can be reused on the same frame. (default: false)
  144735. * @param textureType Type of textures used when performing the post process. (default: 0)
  144736. * @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)
  144737. */
  144738. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  144739. /** Weight of the bloom to be added to the original input. */
  144740. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144741. }
  144742. }
  144743. declare module BABYLON {
  144744. /**
  144745. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  144746. */
  144747. export class BloomEffect extends PostProcessRenderEffect {
  144748. private bloomScale;
  144749. /**
  144750. * @hidden Internal
  144751. */
  144752. _effects: Array<PostProcess>;
  144753. /**
  144754. * @hidden Internal
  144755. */
  144756. _downscale: ExtractHighlightsPostProcess;
  144757. private _blurX;
  144758. private _blurY;
  144759. private _merge;
  144760. /**
  144761. * The luminance threshold to find bright areas of the image to bloom.
  144762. */
  144763. get threshold(): number;
  144764. set threshold(value: number);
  144765. /**
  144766. * The strength of the bloom.
  144767. */
  144768. get weight(): number;
  144769. set weight(value: number);
  144770. /**
  144771. * Specifies the size of the bloom blur kernel, relative to the final output size
  144772. */
  144773. get kernel(): number;
  144774. set kernel(value: number);
  144775. /**
  144776. * Creates a new instance of @see BloomEffect
  144777. * @param scene The scene the effect belongs to.
  144778. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  144779. * @param bloomKernel The size of the kernel to be used when applying the blur.
  144780. * @param bloomWeight The the strength of bloom.
  144781. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  144782. * @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)
  144783. */
  144784. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  144785. /**
  144786. * Disposes each of the internal effects for a given camera.
  144787. * @param camera The camera to dispose the effect on.
  144788. */
  144789. disposeEffects(camera: Camera): void;
  144790. /**
  144791. * @hidden Internal
  144792. */
  144793. _updateEffects(): void;
  144794. /**
  144795. * Internal
  144796. * @returns if all the contained post processes are ready.
  144797. * @hidden
  144798. */
  144799. _isReady(): boolean;
  144800. }
  144801. }
  144802. declare module BABYLON {
  144803. /** @hidden */
  144804. export var chromaticAberrationPixelShader: {
  144805. name: string;
  144806. shader: string;
  144807. };
  144808. }
  144809. declare module BABYLON {
  144810. /**
  144811. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  144812. */
  144813. export class ChromaticAberrationPostProcess extends PostProcess {
  144814. /**
  144815. * The amount of seperation of rgb channels (default: 30)
  144816. */
  144817. aberrationAmount: number;
  144818. /**
  144819. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  144820. */
  144821. radialIntensity: number;
  144822. /**
  144823. * 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))
  144824. */
  144825. direction: Vector2;
  144826. /**
  144827. * 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))
  144828. */
  144829. centerPosition: Vector2;
  144830. /**
  144831. * Creates a new instance ChromaticAberrationPostProcess
  144832. * @param name The name of the effect.
  144833. * @param screenWidth The width of the screen to apply the effect on.
  144834. * @param screenHeight The height of the screen to apply the effect on.
  144835. * @param options The required width/height ratio to downsize to before computing the render pass.
  144836. * @param camera The camera to apply the render pass to.
  144837. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144838. * @param engine The engine which the post process will be applied. (default: current engine)
  144839. * @param reusable If the post process can be reused on the same frame. (default: false)
  144840. * @param textureType Type of textures used when performing the post process. (default: 0)
  144841. * @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)
  144842. */
  144843. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144844. }
  144845. }
  144846. declare module BABYLON {
  144847. /** @hidden */
  144848. export var circleOfConfusionPixelShader: {
  144849. name: string;
  144850. shader: string;
  144851. };
  144852. }
  144853. declare module BABYLON {
  144854. /**
  144855. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  144856. */
  144857. export class CircleOfConfusionPostProcess extends PostProcess {
  144858. /**
  144859. * 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.
  144860. */
  144861. lensSize: number;
  144862. /**
  144863. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  144864. */
  144865. fStop: number;
  144866. /**
  144867. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  144868. */
  144869. focusDistance: number;
  144870. /**
  144871. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  144872. */
  144873. focalLength: number;
  144874. private _depthTexture;
  144875. /**
  144876. * Creates a new instance CircleOfConfusionPostProcess
  144877. * @param name The name of the effect.
  144878. * @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.
  144879. * @param options The required width/height ratio to downsize to before computing the render pass.
  144880. * @param camera The camera to apply the render pass to.
  144881. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144882. * @param engine The engine which the post process will be applied. (default: current engine)
  144883. * @param reusable If the post process can be reused on the same frame. (default: false)
  144884. * @param textureType Type of textures used when performing the post process. (default: 0)
  144885. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  144886. */
  144887. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144888. /**
  144889. * 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.
  144890. */
  144891. set depthTexture(value: RenderTargetTexture);
  144892. }
  144893. }
  144894. declare module BABYLON {
  144895. /** @hidden */
  144896. export var colorCorrectionPixelShader: {
  144897. name: string;
  144898. shader: string;
  144899. };
  144900. }
  144901. declare module BABYLON {
  144902. /**
  144903. *
  144904. * This post-process allows the modification of rendered colors by using
  144905. * a 'look-up table' (LUT). This effect is also called Color Grading.
  144906. *
  144907. * The object needs to be provided an url to a texture containing the color
  144908. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  144909. * Use an image editing software to tweak the LUT to match your needs.
  144910. *
  144911. * For an example of a color LUT, see here:
  144912. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  144913. * For explanations on color grading, see here:
  144914. * @see http://udn.epicgames.com/Three/ColorGrading.html
  144915. *
  144916. */
  144917. export class ColorCorrectionPostProcess extends PostProcess {
  144918. private _colorTableTexture;
  144919. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144920. }
  144921. }
  144922. declare module BABYLON {
  144923. /** @hidden */
  144924. export var convolutionPixelShader: {
  144925. name: string;
  144926. shader: string;
  144927. };
  144928. }
  144929. declare module BABYLON {
  144930. /**
  144931. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  144932. * input texture to perform effects such as edge detection or sharpening
  144933. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  144934. */
  144935. export class ConvolutionPostProcess extends PostProcess {
  144936. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  144937. kernel: number[];
  144938. /**
  144939. * Creates a new instance ConvolutionPostProcess
  144940. * @param name The name of the effect.
  144941. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  144942. * @param options The required width/height ratio to downsize to before computing the render pass.
  144943. * @param camera The camera to apply the render pass to.
  144944. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144945. * @param engine The engine which the post process will be applied. (default: current engine)
  144946. * @param reusable If the post process can be reused on the same frame. (default: false)
  144947. * @param textureType Type of textures used when performing the post process. (default: 0)
  144948. */
  144949. constructor(name: string,
  144950. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  144951. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  144952. /**
  144953. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144954. */
  144955. static EdgeDetect0Kernel: number[];
  144956. /**
  144957. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144958. */
  144959. static EdgeDetect1Kernel: number[];
  144960. /**
  144961. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144962. */
  144963. static EdgeDetect2Kernel: number[];
  144964. /**
  144965. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144966. */
  144967. static SharpenKernel: number[];
  144968. /**
  144969. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144970. */
  144971. static EmbossKernel: number[];
  144972. /**
  144973. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144974. */
  144975. static GaussianKernel: number[];
  144976. }
  144977. }
  144978. declare module BABYLON {
  144979. /**
  144980. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  144981. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  144982. * based on samples that have a large difference in distance than the center pixel.
  144983. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  144984. */
  144985. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  144986. direction: Vector2;
  144987. /**
  144988. * Creates a new instance CircleOfConfusionPostProcess
  144989. * @param name The name of the effect.
  144990. * @param scene The scene the effect belongs to.
  144991. * @param direction The direction the blur should be applied.
  144992. * @param kernel The size of the kernel used to blur.
  144993. * @param options The required width/height ratio to downsize to before computing the render pass.
  144994. * @param camera The camera to apply the render pass to.
  144995. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  144996. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  144997. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144998. * @param engine The engine which the post process will be applied. (default: current engine)
  144999. * @param reusable If the post process can be reused on the same frame. (default: false)
  145000. * @param textureType Type of textures used when performing the post process. (default: 0)
  145001. * @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)
  145002. */
  145003. 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);
  145004. }
  145005. }
  145006. declare module BABYLON {
  145007. /** @hidden */
  145008. export var depthOfFieldMergePixelShader: {
  145009. name: string;
  145010. shader: string;
  145011. };
  145012. }
  145013. declare module BABYLON {
  145014. /**
  145015. * Options to be set when merging outputs from the default pipeline.
  145016. */
  145017. export class DepthOfFieldMergePostProcessOptions {
  145018. /**
  145019. * The original image to merge on top of
  145020. */
  145021. originalFromInput: PostProcess;
  145022. /**
  145023. * Parameters to perform the merge of the depth of field effect
  145024. */
  145025. depthOfField?: {
  145026. circleOfConfusion: PostProcess;
  145027. blurSteps: Array<PostProcess>;
  145028. };
  145029. /**
  145030. * Parameters to perform the merge of bloom effect
  145031. */
  145032. bloom?: {
  145033. blurred: PostProcess;
  145034. weight: number;
  145035. };
  145036. }
  145037. /**
  145038. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  145039. */
  145040. export class DepthOfFieldMergePostProcess extends PostProcess {
  145041. private blurSteps;
  145042. /**
  145043. * Creates a new instance of DepthOfFieldMergePostProcess
  145044. * @param name The name of the effect.
  145045. * @param originalFromInput Post process which's input will be used for the merge.
  145046. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  145047. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  145048. * @param options The required width/height ratio to downsize to before computing the render pass.
  145049. * @param camera The camera to apply the render pass to.
  145050. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145051. * @param engine The engine which the post process will be applied. (default: current engine)
  145052. * @param reusable If the post process can be reused on the same frame. (default: false)
  145053. * @param textureType Type of textures used when performing the post process. (default: 0)
  145054. * @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)
  145055. */
  145056. 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);
  145057. /**
  145058. * Updates the effect with the current post process compile time values and recompiles the shader.
  145059. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  145060. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  145061. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  145062. * @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
  145063. * @param onCompiled Called when the shader has been compiled.
  145064. * @param onError Called if there is an error when compiling a shader.
  145065. */
  145066. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  145067. }
  145068. }
  145069. declare module BABYLON {
  145070. /**
  145071. * Specifies the level of max blur that should be applied when using the depth of field effect
  145072. */
  145073. export enum DepthOfFieldEffectBlurLevel {
  145074. /**
  145075. * Subtle blur
  145076. */
  145077. Low = 0,
  145078. /**
  145079. * Medium blur
  145080. */
  145081. Medium = 1,
  145082. /**
  145083. * Large blur
  145084. */
  145085. High = 2
  145086. }
  145087. /**
  145088. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  145089. */
  145090. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  145091. private _circleOfConfusion;
  145092. /**
  145093. * @hidden Internal, blurs from high to low
  145094. */
  145095. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  145096. private _depthOfFieldBlurY;
  145097. private _dofMerge;
  145098. /**
  145099. * @hidden Internal post processes in depth of field effect
  145100. */
  145101. _effects: Array<PostProcess>;
  145102. /**
  145103. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  145104. */
  145105. set focalLength(value: number);
  145106. get focalLength(): number;
  145107. /**
  145108. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  145109. */
  145110. set fStop(value: number);
  145111. get fStop(): number;
  145112. /**
  145113. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  145114. */
  145115. set focusDistance(value: number);
  145116. get focusDistance(): number;
  145117. /**
  145118. * 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.
  145119. */
  145120. set lensSize(value: number);
  145121. get lensSize(): number;
  145122. /**
  145123. * Creates a new instance DepthOfFieldEffect
  145124. * @param scene The scene the effect belongs to.
  145125. * @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.
  145126. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  145127. * @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)
  145128. */
  145129. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  145130. /**
  145131. * Get the current class name of the current effet
  145132. * @returns "DepthOfFieldEffect"
  145133. */
  145134. getClassName(): string;
  145135. /**
  145136. * 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.
  145137. */
  145138. set depthTexture(value: RenderTargetTexture);
  145139. /**
  145140. * Disposes each of the internal effects for a given camera.
  145141. * @param camera The camera to dispose the effect on.
  145142. */
  145143. disposeEffects(camera: Camera): void;
  145144. /**
  145145. * @hidden Internal
  145146. */
  145147. _updateEffects(): void;
  145148. /**
  145149. * Internal
  145150. * @returns if all the contained post processes are ready.
  145151. * @hidden
  145152. */
  145153. _isReady(): boolean;
  145154. }
  145155. }
  145156. declare module BABYLON {
  145157. /** @hidden */
  145158. export var displayPassPixelShader: {
  145159. name: string;
  145160. shader: string;
  145161. };
  145162. }
  145163. declare module BABYLON {
  145164. /**
  145165. * DisplayPassPostProcess which produces an output the same as it's input
  145166. */
  145167. export class DisplayPassPostProcess extends PostProcess {
  145168. /**
  145169. * Creates the DisplayPassPostProcess
  145170. * @param name The name of the effect.
  145171. * @param options The required width/height ratio to downsize to before computing the render pass.
  145172. * @param camera The camera to apply the render pass to.
  145173. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145174. * @param engine The engine which the post process will be applied. (default: current engine)
  145175. * @param reusable If the post process can be reused on the same frame. (default: false)
  145176. */
  145177. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  145178. }
  145179. }
  145180. declare module BABYLON {
  145181. /** @hidden */
  145182. export var filterPixelShader: {
  145183. name: string;
  145184. shader: string;
  145185. };
  145186. }
  145187. declare module BABYLON {
  145188. /**
  145189. * Applies a kernel filter to the image
  145190. */
  145191. export class FilterPostProcess extends PostProcess {
  145192. /** The matrix to be applied to the image */
  145193. kernelMatrix: Matrix;
  145194. /**
  145195. *
  145196. * @param name The name of the effect.
  145197. * @param kernelMatrix The matrix to be applied to the image
  145198. * @param options The required width/height ratio to downsize to before computing the render pass.
  145199. * @param camera The camera to apply the render pass to.
  145200. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145201. * @param engine The engine which the post process will be applied. (default: current engine)
  145202. * @param reusable If the post process can be reused on the same frame. (default: false)
  145203. */
  145204. constructor(name: string,
  145205. /** The matrix to be applied to the image */
  145206. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  145207. }
  145208. }
  145209. declare module BABYLON {
  145210. /** @hidden */
  145211. export var fxaaPixelShader: {
  145212. name: string;
  145213. shader: string;
  145214. };
  145215. }
  145216. declare module BABYLON {
  145217. /** @hidden */
  145218. export var fxaaVertexShader: {
  145219. name: string;
  145220. shader: string;
  145221. };
  145222. }
  145223. declare module BABYLON {
  145224. /**
  145225. * Fxaa post process
  145226. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  145227. */
  145228. export class FxaaPostProcess extends PostProcess {
  145229. /** @hidden */
  145230. texelWidth: number;
  145231. /** @hidden */
  145232. texelHeight: number;
  145233. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  145234. private _getDefines;
  145235. }
  145236. }
  145237. declare module BABYLON {
  145238. /** @hidden */
  145239. export var grainPixelShader: {
  145240. name: string;
  145241. shader: string;
  145242. };
  145243. }
  145244. declare module BABYLON {
  145245. /**
  145246. * The GrainPostProcess adds noise to the image at mid luminance levels
  145247. */
  145248. export class GrainPostProcess extends PostProcess {
  145249. /**
  145250. * The intensity of the grain added (default: 30)
  145251. */
  145252. intensity: number;
  145253. /**
  145254. * If the grain should be randomized on every frame
  145255. */
  145256. animated: boolean;
  145257. /**
  145258. * Creates a new instance of @see GrainPostProcess
  145259. * @param name The name of the effect.
  145260. * @param options The required width/height ratio to downsize to before computing the render pass.
  145261. * @param camera The camera to apply the render pass to.
  145262. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145263. * @param engine The engine which the post process will be applied. (default: current engine)
  145264. * @param reusable If the post process can be reused on the same frame. (default: false)
  145265. * @param textureType Type of textures used when performing the post process. (default: 0)
  145266. * @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)
  145267. */
  145268. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145269. }
  145270. }
  145271. declare module BABYLON {
  145272. /** @hidden */
  145273. export var highlightsPixelShader: {
  145274. name: string;
  145275. shader: string;
  145276. };
  145277. }
  145278. declare module BABYLON {
  145279. /**
  145280. * Extracts highlights from the image
  145281. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  145282. */
  145283. export class HighlightsPostProcess extends PostProcess {
  145284. /**
  145285. * Extracts highlights from the image
  145286. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  145287. * @param name The name of the effect.
  145288. * @param options The required width/height ratio to downsize to before computing the render pass.
  145289. * @param camera The camera to apply the render pass to.
  145290. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145291. * @param engine The engine which the post process will be applied. (default: current engine)
  145292. * @param reusable If the post process can be reused on the same frame. (default: false)
  145293. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  145294. */
  145295. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  145296. }
  145297. }
  145298. declare module BABYLON {
  145299. /** @hidden */
  145300. export var mrtFragmentDeclaration: {
  145301. name: string;
  145302. shader: string;
  145303. };
  145304. }
  145305. declare module BABYLON {
  145306. /** @hidden */
  145307. export var geometryPixelShader: {
  145308. name: string;
  145309. shader: string;
  145310. };
  145311. }
  145312. declare module BABYLON {
  145313. /** @hidden */
  145314. export var geometryVertexShader: {
  145315. name: string;
  145316. shader: string;
  145317. };
  145318. }
  145319. declare module BABYLON {
  145320. /** @hidden */
  145321. interface ISavedTransformationMatrix {
  145322. world: Matrix;
  145323. viewProjection: Matrix;
  145324. }
  145325. /**
  145326. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  145327. */
  145328. export class GeometryBufferRenderer {
  145329. /**
  145330. * Constant used to retrieve the position texture index in the G-Buffer textures array
  145331. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  145332. */
  145333. static readonly POSITION_TEXTURE_TYPE: number;
  145334. /**
  145335. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  145336. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  145337. */
  145338. static readonly VELOCITY_TEXTURE_TYPE: number;
  145339. /**
  145340. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  145341. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  145342. */
  145343. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  145344. /**
  145345. * Dictionary used to store the previous transformation matrices of each rendered mesh
  145346. * in order to compute objects velocities when enableVelocity is set to "true"
  145347. * @hidden
  145348. */
  145349. _previousTransformationMatrices: {
  145350. [index: number]: ISavedTransformationMatrix;
  145351. };
  145352. /**
  145353. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  145354. * in order to compute objects velocities when enableVelocity is set to "true"
  145355. * @hidden
  145356. */
  145357. _previousBonesTransformationMatrices: {
  145358. [index: number]: Float32Array;
  145359. };
  145360. /**
  145361. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  145362. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  145363. */
  145364. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  145365. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  145366. renderTransparentMeshes: boolean;
  145367. private _scene;
  145368. private _multiRenderTarget;
  145369. private _ratio;
  145370. private _enablePosition;
  145371. private _enableVelocity;
  145372. private _enableReflectivity;
  145373. private _positionIndex;
  145374. private _velocityIndex;
  145375. private _reflectivityIndex;
  145376. protected _effect: Effect;
  145377. protected _cachedDefines: string;
  145378. /**
  145379. * Set the render list (meshes to be rendered) used in the G buffer.
  145380. */
  145381. set renderList(meshes: Mesh[]);
  145382. /**
  145383. * Gets wether or not G buffer are supported by the running hardware.
  145384. * This requires draw buffer supports
  145385. */
  145386. get isSupported(): boolean;
  145387. /**
  145388. * Returns the index of the given texture type in the G-Buffer textures array
  145389. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  145390. * @returns the index of the given texture type in the G-Buffer textures array
  145391. */
  145392. getTextureIndex(textureType: number): number;
  145393. /**
  145394. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  145395. */
  145396. get enablePosition(): boolean;
  145397. /**
  145398. * Sets whether or not objects positions are enabled for the G buffer.
  145399. */
  145400. set enablePosition(enable: boolean);
  145401. /**
  145402. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  145403. */
  145404. get enableVelocity(): boolean;
  145405. /**
  145406. * Sets wether or not objects velocities are enabled for the G buffer.
  145407. */
  145408. set enableVelocity(enable: boolean);
  145409. /**
  145410. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  145411. */
  145412. get enableReflectivity(): boolean;
  145413. /**
  145414. * Sets wether or not objects roughness are enabled for the G buffer.
  145415. */
  145416. set enableReflectivity(enable: boolean);
  145417. /**
  145418. * Gets the scene associated with the buffer.
  145419. */
  145420. get scene(): Scene;
  145421. /**
  145422. * Gets the ratio used by the buffer during its creation.
  145423. * How big is the buffer related to the main canvas.
  145424. */
  145425. get ratio(): number;
  145426. /** @hidden */
  145427. static _SceneComponentInitialization: (scene: Scene) => void;
  145428. /**
  145429. * Creates a new G Buffer for the scene
  145430. * @param scene The scene the buffer belongs to
  145431. * @param ratio How big is the buffer related to the main canvas.
  145432. */
  145433. constructor(scene: Scene, ratio?: number);
  145434. /**
  145435. * Checks wether everything is ready to render a submesh to the G buffer.
  145436. * @param subMesh the submesh to check readiness for
  145437. * @param useInstances is the mesh drawn using instance or not
  145438. * @returns true if ready otherwise false
  145439. */
  145440. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  145441. /**
  145442. * Gets the current underlying G Buffer.
  145443. * @returns the buffer
  145444. */
  145445. getGBuffer(): MultiRenderTarget;
  145446. /**
  145447. * Gets the number of samples used to render the buffer (anti aliasing).
  145448. */
  145449. get samples(): number;
  145450. /**
  145451. * Sets the number of samples used to render the buffer (anti aliasing).
  145452. */
  145453. set samples(value: number);
  145454. /**
  145455. * Disposes the renderer and frees up associated resources.
  145456. */
  145457. dispose(): void;
  145458. protected _createRenderTargets(): void;
  145459. private _copyBonesTransformationMatrices;
  145460. }
  145461. }
  145462. declare module BABYLON {
  145463. interface Scene {
  145464. /** @hidden (Backing field) */
  145465. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  145466. /**
  145467. * Gets or Sets the current geometry buffer associated to the scene.
  145468. */
  145469. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  145470. /**
  145471. * Enables a GeometryBufferRender and associates it with the scene
  145472. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  145473. * @returns the GeometryBufferRenderer
  145474. */
  145475. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  145476. /**
  145477. * Disables the GeometryBufferRender associated with the scene
  145478. */
  145479. disableGeometryBufferRenderer(): void;
  145480. }
  145481. /**
  145482. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  145483. * in several rendering techniques.
  145484. */
  145485. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  145486. /**
  145487. * The component name helpful to identify the component in the list of scene components.
  145488. */
  145489. readonly name: string;
  145490. /**
  145491. * The scene the component belongs to.
  145492. */
  145493. scene: Scene;
  145494. /**
  145495. * Creates a new instance of the component for the given scene
  145496. * @param scene Defines the scene to register the component in
  145497. */
  145498. constructor(scene: Scene);
  145499. /**
  145500. * Registers the component in a given scene
  145501. */
  145502. register(): void;
  145503. /**
  145504. * Rebuilds the elements related to this component in case of
  145505. * context lost for instance.
  145506. */
  145507. rebuild(): void;
  145508. /**
  145509. * Disposes the component and the associated ressources
  145510. */
  145511. dispose(): void;
  145512. private _gatherRenderTargets;
  145513. }
  145514. }
  145515. declare module BABYLON {
  145516. /** @hidden */
  145517. export var motionBlurPixelShader: {
  145518. name: string;
  145519. shader: string;
  145520. };
  145521. }
  145522. declare module BABYLON {
  145523. /**
  145524. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  145525. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  145526. * As an example, all you have to do is to create the post-process:
  145527. * var mb = new BABYLON.MotionBlurPostProcess(
  145528. * 'mb', // The name of the effect.
  145529. * scene, // The scene containing the objects to blur according to their velocity.
  145530. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  145531. * camera // The camera to apply the render pass to.
  145532. * );
  145533. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  145534. */
  145535. export class MotionBlurPostProcess extends PostProcess {
  145536. /**
  145537. * Defines how much the image is blurred by the movement. Default value is equal to 1
  145538. */
  145539. motionStrength: number;
  145540. /**
  145541. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  145542. */
  145543. get motionBlurSamples(): number;
  145544. /**
  145545. * Sets the number of iterations to be used for motion blur quality
  145546. */
  145547. set motionBlurSamples(samples: number);
  145548. private _motionBlurSamples;
  145549. private _geometryBufferRenderer;
  145550. /**
  145551. * Creates a new instance MotionBlurPostProcess
  145552. * @param name The name of the effect.
  145553. * @param scene The scene containing the objects to blur according to their velocity.
  145554. * @param options The required width/height ratio to downsize to before computing the render pass.
  145555. * @param camera The camera to apply the render pass to.
  145556. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145557. * @param engine The engine which the post process will be applied. (default: current engine)
  145558. * @param reusable If the post process can be reused on the same frame. (default: false)
  145559. * @param textureType Type of textures used when performing the post process. (default: 0)
  145560. * @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)
  145561. */
  145562. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145563. /**
  145564. * Excludes the given skinned mesh from computing bones velocities.
  145565. * 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.
  145566. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  145567. */
  145568. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  145569. /**
  145570. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  145571. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  145572. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  145573. */
  145574. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  145575. /**
  145576. * Disposes the post process.
  145577. * @param camera The camera to dispose the post process on.
  145578. */
  145579. dispose(camera?: Camera): void;
  145580. }
  145581. }
  145582. declare module BABYLON {
  145583. /** @hidden */
  145584. export var refractionPixelShader: {
  145585. name: string;
  145586. shader: string;
  145587. };
  145588. }
  145589. declare module BABYLON {
  145590. /**
  145591. * Post process which applies a refractin texture
  145592. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  145593. */
  145594. export class RefractionPostProcess extends PostProcess {
  145595. /** the base color of the refraction (used to taint the rendering) */
  145596. color: Color3;
  145597. /** simulated refraction depth */
  145598. depth: number;
  145599. /** the coefficient of the base color (0 to remove base color tainting) */
  145600. colorLevel: number;
  145601. private _refTexture;
  145602. private _ownRefractionTexture;
  145603. /**
  145604. * Gets or sets the refraction texture
  145605. * Please note that you are responsible for disposing the texture if you set it manually
  145606. */
  145607. get refractionTexture(): Texture;
  145608. set refractionTexture(value: Texture);
  145609. /**
  145610. * Initializes the RefractionPostProcess
  145611. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  145612. * @param name The name of the effect.
  145613. * @param refractionTextureUrl Url of the refraction texture to use
  145614. * @param color the base color of the refraction (used to taint the rendering)
  145615. * @param depth simulated refraction depth
  145616. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  145617. * @param camera The camera to apply the render pass to.
  145618. * @param options The required width/height ratio to downsize to before computing the render pass.
  145619. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145620. * @param engine The engine which the post process will be applied. (default: current engine)
  145621. * @param reusable If the post process can be reused on the same frame. (default: false)
  145622. */
  145623. constructor(name: string, refractionTextureUrl: string,
  145624. /** the base color of the refraction (used to taint the rendering) */
  145625. color: Color3,
  145626. /** simulated refraction depth */
  145627. depth: number,
  145628. /** the coefficient of the base color (0 to remove base color tainting) */
  145629. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  145630. /**
  145631. * Disposes of the post process
  145632. * @param camera Camera to dispose post process on
  145633. */
  145634. dispose(camera: Camera): void;
  145635. }
  145636. }
  145637. declare module BABYLON {
  145638. /** @hidden */
  145639. export var sharpenPixelShader: {
  145640. name: string;
  145641. shader: string;
  145642. };
  145643. }
  145644. declare module BABYLON {
  145645. /**
  145646. * The SharpenPostProcess applies a sharpen kernel to every pixel
  145647. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  145648. */
  145649. export class SharpenPostProcess extends PostProcess {
  145650. /**
  145651. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  145652. */
  145653. colorAmount: number;
  145654. /**
  145655. * How much sharpness should be applied (default: 0.3)
  145656. */
  145657. edgeAmount: number;
  145658. /**
  145659. * Creates a new instance ConvolutionPostProcess
  145660. * @param name The name of the effect.
  145661. * @param options The required width/height ratio to downsize to before computing the render pass.
  145662. * @param camera The camera to apply the render pass to.
  145663. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145664. * @param engine The engine which the post process will be applied. (default: current engine)
  145665. * @param reusable If the post process can be reused on the same frame. (default: false)
  145666. * @param textureType Type of textures used when performing the post process. (default: 0)
  145667. * @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)
  145668. */
  145669. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145670. }
  145671. }
  145672. declare module BABYLON {
  145673. /**
  145674. * PostProcessRenderPipeline
  145675. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145676. */
  145677. export class PostProcessRenderPipeline {
  145678. private engine;
  145679. private _renderEffects;
  145680. private _renderEffectsForIsolatedPass;
  145681. /**
  145682. * List of inspectable custom properties (used by the Inspector)
  145683. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  145684. */
  145685. inspectableCustomProperties: IInspectable[];
  145686. /**
  145687. * @hidden
  145688. */
  145689. protected _cameras: Camera[];
  145690. /** @hidden */
  145691. _name: string;
  145692. /**
  145693. * Gets pipeline name
  145694. */
  145695. get name(): string;
  145696. /** Gets the list of attached cameras */
  145697. get cameras(): Camera[];
  145698. /**
  145699. * Initializes a PostProcessRenderPipeline
  145700. * @param engine engine to add the pipeline to
  145701. * @param name name of the pipeline
  145702. */
  145703. constructor(engine: Engine, name: string);
  145704. /**
  145705. * Gets the class name
  145706. * @returns "PostProcessRenderPipeline"
  145707. */
  145708. getClassName(): string;
  145709. /**
  145710. * If all the render effects in the pipeline are supported
  145711. */
  145712. get isSupported(): boolean;
  145713. /**
  145714. * Adds an effect to the pipeline
  145715. * @param renderEffect the effect to add
  145716. */
  145717. addEffect(renderEffect: PostProcessRenderEffect): void;
  145718. /** @hidden */
  145719. _rebuild(): void;
  145720. /** @hidden */
  145721. _enableEffect(renderEffectName: string, cameras: Camera): void;
  145722. /** @hidden */
  145723. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  145724. /** @hidden */
  145725. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  145726. /** @hidden */
  145727. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  145728. /** @hidden */
  145729. _attachCameras(cameras: Camera, unique: boolean): void;
  145730. /** @hidden */
  145731. _attachCameras(cameras: Camera[], unique: boolean): void;
  145732. /** @hidden */
  145733. _detachCameras(cameras: Camera): void;
  145734. /** @hidden */
  145735. _detachCameras(cameras: Nullable<Camera[]>): void;
  145736. /** @hidden */
  145737. _update(): void;
  145738. /** @hidden */
  145739. _reset(): void;
  145740. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  145741. /**
  145742. * Disposes of the pipeline
  145743. */
  145744. dispose(): void;
  145745. }
  145746. }
  145747. declare module BABYLON {
  145748. /**
  145749. * PostProcessRenderPipelineManager class
  145750. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145751. */
  145752. export class PostProcessRenderPipelineManager {
  145753. private _renderPipelines;
  145754. /**
  145755. * Initializes a PostProcessRenderPipelineManager
  145756. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145757. */
  145758. constructor();
  145759. /**
  145760. * Gets the list of supported render pipelines
  145761. */
  145762. get supportedPipelines(): PostProcessRenderPipeline[];
  145763. /**
  145764. * Adds a pipeline to the manager
  145765. * @param renderPipeline The pipeline to add
  145766. */
  145767. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  145768. /**
  145769. * Attaches a camera to the pipeline
  145770. * @param renderPipelineName The name of the pipeline to attach to
  145771. * @param cameras the camera to attach
  145772. * @param unique if the camera can be attached multiple times to the pipeline
  145773. */
  145774. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  145775. /**
  145776. * Detaches a camera from the pipeline
  145777. * @param renderPipelineName The name of the pipeline to detach from
  145778. * @param cameras the camera to detach
  145779. */
  145780. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  145781. /**
  145782. * Enables an effect by name on a pipeline
  145783. * @param renderPipelineName the name of the pipeline to enable the effect in
  145784. * @param renderEffectName the name of the effect to enable
  145785. * @param cameras the cameras that the effect should be enabled on
  145786. */
  145787. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  145788. /**
  145789. * Disables an effect by name on a pipeline
  145790. * @param renderPipelineName the name of the pipeline to disable the effect in
  145791. * @param renderEffectName the name of the effect to disable
  145792. * @param cameras the cameras that the effect should be disabled on
  145793. */
  145794. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  145795. /**
  145796. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  145797. */
  145798. update(): void;
  145799. /** @hidden */
  145800. _rebuild(): void;
  145801. /**
  145802. * Disposes of the manager and pipelines
  145803. */
  145804. dispose(): void;
  145805. }
  145806. }
  145807. declare module BABYLON {
  145808. interface Scene {
  145809. /** @hidden (Backing field) */
  145810. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  145811. /**
  145812. * Gets the postprocess render pipeline manager
  145813. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145814. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  145815. */
  145816. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  145817. }
  145818. /**
  145819. * Defines the Render Pipeline scene component responsible to rendering pipelines
  145820. */
  145821. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  145822. /**
  145823. * The component name helpfull to identify the component in the list of scene components.
  145824. */
  145825. readonly name: string;
  145826. /**
  145827. * The scene the component belongs to.
  145828. */
  145829. scene: Scene;
  145830. /**
  145831. * Creates a new instance of the component for the given scene
  145832. * @param scene Defines the scene to register the component in
  145833. */
  145834. constructor(scene: Scene);
  145835. /**
  145836. * Registers the component in a given scene
  145837. */
  145838. register(): void;
  145839. /**
  145840. * Rebuilds the elements related to this component in case of
  145841. * context lost for instance.
  145842. */
  145843. rebuild(): void;
  145844. /**
  145845. * Disposes the component and the associated ressources
  145846. */
  145847. dispose(): void;
  145848. private _gatherRenderTargets;
  145849. }
  145850. }
  145851. declare module BABYLON {
  145852. /**
  145853. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  145854. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  145855. */
  145856. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  145857. private _scene;
  145858. private _camerasToBeAttached;
  145859. /**
  145860. * ID of the sharpen post process,
  145861. */
  145862. private readonly SharpenPostProcessId;
  145863. /**
  145864. * @ignore
  145865. * ID of the image processing post process;
  145866. */
  145867. readonly ImageProcessingPostProcessId: string;
  145868. /**
  145869. * @ignore
  145870. * ID of the Fast Approximate Anti-Aliasing post process;
  145871. */
  145872. readonly FxaaPostProcessId: string;
  145873. /**
  145874. * ID of the chromatic aberration post process,
  145875. */
  145876. private readonly ChromaticAberrationPostProcessId;
  145877. /**
  145878. * ID of the grain post process
  145879. */
  145880. private readonly GrainPostProcessId;
  145881. /**
  145882. * Sharpen post process which will apply a sharpen convolution to enhance edges
  145883. */
  145884. sharpen: SharpenPostProcess;
  145885. private _sharpenEffect;
  145886. private bloom;
  145887. /**
  145888. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  145889. */
  145890. depthOfField: DepthOfFieldEffect;
  145891. /**
  145892. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  145893. */
  145894. fxaa: FxaaPostProcess;
  145895. /**
  145896. * Image post processing pass used to perform operations such as tone mapping or color grading.
  145897. */
  145898. imageProcessing: ImageProcessingPostProcess;
  145899. /**
  145900. * Chromatic aberration post process which will shift rgb colors in the image
  145901. */
  145902. chromaticAberration: ChromaticAberrationPostProcess;
  145903. private _chromaticAberrationEffect;
  145904. /**
  145905. * Grain post process which add noise to the image
  145906. */
  145907. grain: GrainPostProcess;
  145908. private _grainEffect;
  145909. /**
  145910. * Glow post process which adds a glow to emissive areas of the image
  145911. */
  145912. private _glowLayer;
  145913. /**
  145914. * Animations which can be used to tweak settings over a period of time
  145915. */
  145916. animations: Animation[];
  145917. private _imageProcessingConfigurationObserver;
  145918. private _sharpenEnabled;
  145919. private _bloomEnabled;
  145920. private _depthOfFieldEnabled;
  145921. private _depthOfFieldBlurLevel;
  145922. private _fxaaEnabled;
  145923. private _imageProcessingEnabled;
  145924. private _defaultPipelineTextureType;
  145925. private _bloomScale;
  145926. private _chromaticAberrationEnabled;
  145927. private _grainEnabled;
  145928. private _buildAllowed;
  145929. /**
  145930. * Gets active scene
  145931. */
  145932. get scene(): Scene;
  145933. /**
  145934. * Enable or disable the sharpen process from the pipeline
  145935. */
  145936. set sharpenEnabled(enabled: boolean);
  145937. get sharpenEnabled(): boolean;
  145938. private _resizeObserver;
  145939. private _hardwareScaleLevel;
  145940. private _bloomKernel;
  145941. /**
  145942. * Specifies the size of the bloom blur kernel, relative to the final output size
  145943. */
  145944. get bloomKernel(): number;
  145945. set bloomKernel(value: number);
  145946. /**
  145947. * Specifies the weight of the bloom in the final rendering
  145948. */
  145949. private _bloomWeight;
  145950. /**
  145951. * Specifies the luma threshold for the area that will be blurred by the bloom
  145952. */
  145953. private _bloomThreshold;
  145954. private _hdr;
  145955. /**
  145956. * The strength of the bloom.
  145957. */
  145958. set bloomWeight(value: number);
  145959. get bloomWeight(): number;
  145960. /**
  145961. * The strength of the bloom.
  145962. */
  145963. set bloomThreshold(value: number);
  145964. get bloomThreshold(): number;
  145965. /**
  145966. * The scale of the bloom, lower value will provide better performance.
  145967. */
  145968. set bloomScale(value: number);
  145969. get bloomScale(): number;
  145970. /**
  145971. * Enable or disable the bloom from the pipeline
  145972. */
  145973. set bloomEnabled(enabled: boolean);
  145974. get bloomEnabled(): boolean;
  145975. private _rebuildBloom;
  145976. /**
  145977. * If the depth of field is enabled.
  145978. */
  145979. get depthOfFieldEnabled(): boolean;
  145980. set depthOfFieldEnabled(enabled: boolean);
  145981. /**
  145982. * Blur level of the depth of field effect. (Higher blur will effect performance)
  145983. */
  145984. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  145985. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  145986. /**
  145987. * If the anti aliasing is enabled.
  145988. */
  145989. set fxaaEnabled(enabled: boolean);
  145990. get fxaaEnabled(): boolean;
  145991. private _samples;
  145992. /**
  145993. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  145994. */
  145995. set samples(sampleCount: number);
  145996. get samples(): number;
  145997. /**
  145998. * If image processing is enabled.
  145999. */
  146000. set imageProcessingEnabled(enabled: boolean);
  146001. get imageProcessingEnabled(): boolean;
  146002. /**
  146003. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  146004. */
  146005. set glowLayerEnabled(enabled: boolean);
  146006. get glowLayerEnabled(): boolean;
  146007. /**
  146008. * Gets the glow layer (or null if not defined)
  146009. */
  146010. get glowLayer(): Nullable<GlowLayer>;
  146011. /**
  146012. * Enable or disable the chromaticAberration process from the pipeline
  146013. */
  146014. set chromaticAberrationEnabled(enabled: boolean);
  146015. get chromaticAberrationEnabled(): boolean;
  146016. /**
  146017. * Enable or disable the grain process from the pipeline
  146018. */
  146019. set grainEnabled(enabled: boolean);
  146020. get grainEnabled(): boolean;
  146021. /**
  146022. * @constructor
  146023. * @param name - The rendering pipeline name (default: "")
  146024. * @param hdr - If high dynamic range textures should be used (default: true)
  146025. * @param scene - The scene linked to this pipeline (default: the last created scene)
  146026. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  146027. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  146028. */
  146029. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  146030. /**
  146031. * Get the class name
  146032. * @returns "DefaultRenderingPipeline"
  146033. */
  146034. getClassName(): string;
  146035. /**
  146036. * Force the compilation of the entire pipeline.
  146037. */
  146038. prepare(): void;
  146039. private _hasCleared;
  146040. private _prevPostProcess;
  146041. private _prevPrevPostProcess;
  146042. private _setAutoClearAndTextureSharing;
  146043. private _depthOfFieldSceneObserver;
  146044. private _buildPipeline;
  146045. private _disposePostProcesses;
  146046. /**
  146047. * Adds a camera to the pipeline
  146048. * @param camera the camera to be added
  146049. */
  146050. addCamera(camera: Camera): void;
  146051. /**
  146052. * Removes a camera from the pipeline
  146053. * @param camera the camera to remove
  146054. */
  146055. removeCamera(camera: Camera): void;
  146056. /**
  146057. * Dispose of the pipeline and stop all post processes
  146058. */
  146059. dispose(): void;
  146060. /**
  146061. * Serialize the rendering pipeline (Used when exporting)
  146062. * @returns the serialized object
  146063. */
  146064. serialize(): any;
  146065. /**
  146066. * Parse the serialized pipeline
  146067. * @param source Source pipeline.
  146068. * @param scene The scene to load the pipeline to.
  146069. * @param rootUrl The URL of the serialized pipeline.
  146070. * @returns An instantiated pipeline from the serialized object.
  146071. */
  146072. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  146073. }
  146074. }
  146075. declare module BABYLON {
  146076. /** @hidden */
  146077. export var lensHighlightsPixelShader: {
  146078. name: string;
  146079. shader: string;
  146080. };
  146081. }
  146082. declare module BABYLON {
  146083. /** @hidden */
  146084. export var depthOfFieldPixelShader: {
  146085. name: string;
  146086. shader: string;
  146087. };
  146088. }
  146089. declare module BABYLON {
  146090. /**
  146091. * BABYLON.JS Chromatic Aberration GLSL Shader
  146092. * Author: Olivier Guyot
  146093. * Separates very slightly R, G and B colors on the edges of the screen
  146094. * Inspired by Francois Tarlier & Martins Upitis
  146095. */
  146096. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  146097. /**
  146098. * @ignore
  146099. * The chromatic aberration PostProcess id in the pipeline
  146100. */
  146101. LensChromaticAberrationEffect: string;
  146102. /**
  146103. * @ignore
  146104. * The highlights enhancing PostProcess id in the pipeline
  146105. */
  146106. HighlightsEnhancingEffect: string;
  146107. /**
  146108. * @ignore
  146109. * The depth-of-field PostProcess id in the pipeline
  146110. */
  146111. LensDepthOfFieldEffect: string;
  146112. private _scene;
  146113. private _depthTexture;
  146114. private _grainTexture;
  146115. private _chromaticAberrationPostProcess;
  146116. private _highlightsPostProcess;
  146117. private _depthOfFieldPostProcess;
  146118. private _edgeBlur;
  146119. private _grainAmount;
  146120. private _chromaticAberration;
  146121. private _distortion;
  146122. private _highlightsGain;
  146123. private _highlightsThreshold;
  146124. private _dofDistance;
  146125. private _dofAperture;
  146126. private _dofDarken;
  146127. private _dofPentagon;
  146128. private _blurNoise;
  146129. /**
  146130. * @constructor
  146131. *
  146132. * Effect parameters are as follow:
  146133. * {
  146134. * chromatic_aberration: number; // from 0 to x (1 for realism)
  146135. * edge_blur: number; // from 0 to x (1 for realism)
  146136. * distortion: number; // from 0 to x (1 for realism)
  146137. * grain_amount: number; // from 0 to 1
  146138. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  146139. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  146140. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  146141. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  146142. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  146143. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  146144. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  146145. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  146146. * }
  146147. * Note: if an effect parameter is unset, effect is disabled
  146148. *
  146149. * @param name The rendering pipeline name
  146150. * @param parameters - An object containing all parameters (see above)
  146151. * @param scene The scene linked to this pipeline
  146152. * @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)
  146153. * @param cameras The array of cameras that the rendering pipeline will be attached to
  146154. */
  146155. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  146156. /**
  146157. * Get the class name
  146158. * @returns "LensRenderingPipeline"
  146159. */
  146160. getClassName(): string;
  146161. /**
  146162. * Gets associated scene
  146163. */
  146164. get scene(): Scene;
  146165. /**
  146166. * Gets or sets the edge blur
  146167. */
  146168. get edgeBlur(): number;
  146169. set edgeBlur(value: number);
  146170. /**
  146171. * Gets or sets the grain amount
  146172. */
  146173. get grainAmount(): number;
  146174. set grainAmount(value: number);
  146175. /**
  146176. * Gets or sets the chromatic aberration amount
  146177. */
  146178. get chromaticAberration(): number;
  146179. set chromaticAberration(value: number);
  146180. /**
  146181. * Gets or sets the depth of field aperture
  146182. */
  146183. get dofAperture(): number;
  146184. set dofAperture(value: number);
  146185. /**
  146186. * Gets or sets the edge distortion
  146187. */
  146188. get edgeDistortion(): number;
  146189. set edgeDistortion(value: number);
  146190. /**
  146191. * Gets or sets the depth of field distortion
  146192. */
  146193. get dofDistortion(): number;
  146194. set dofDistortion(value: number);
  146195. /**
  146196. * Gets or sets the darken out of focus amount
  146197. */
  146198. get darkenOutOfFocus(): number;
  146199. set darkenOutOfFocus(value: number);
  146200. /**
  146201. * Gets or sets a boolean indicating if blur noise is enabled
  146202. */
  146203. get blurNoise(): boolean;
  146204. set blurNoise(value: boolean);
  146205. /**
  146206. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  146207. */
  146208. get pentagonBokeh(): boolean;
  146209. set pentagonBokeh(value: boolean);
  146210. /**
  146211. * Gets or sets the highlight grain amount
  146212. */
  146213. get highlightsGain(): number;
  146214. set highlightsGain(value: number);
  146215. /**
  146216. * Gets or sets the highlight threshold
  146217. */
  146218. get highlightsThreshold(): number;
  146219. set highlightsThreshold(value: number);
  146220. /**
  146221. * Sets the amount of blur at the edges
  146222. * @param amount blur amount
  146223. */
  146224. setEdgeBlur(amount: number): void;
  146225. /**
  146226. * Sets edge blur to 0
  146227. */
  146228. disableEdgeBlur(): void;
  146229. /**
  146230. * Sets the amout of grain
  146231. * @param amount Amount of grain
  146232. */
  146233. setGrainAmount(amount: number): void;
  146234. /**
  146235. * Set grain amount to 0
  146236. */
  146237. disableGrain(): void;
  146238. /**
  146239. * Sets the chromatic aberration amount
  146240. * @param amount amount of chromatic aberration
  146241. */
  146242. setChromaticAberration(amount: number): void;
  146243. /**
  146244. * Sets chromatic aberration amount to 0
  146245. */
  146246. disableChromaticAberration(): void;
  146247. /**
  146248. * Sets the EdgeDistortion amount
  146249. * @param amount amount of EdgeDistortion
  146250. */
  146251. setEdgeDistortion(amount: number): void;
  146252. /**
  146253. * Sets edge distortion to 0
  146254. */
  146255. disableEdgeDistortion(): void;
  146256. /**
  146257. * Sets the FocusDistance amount
  146258. * @param amount amount of FocusDistance
  146259. */
  146260. setFocusDistance(amount: number): void;
  146261. /**
  146262. * Disables depth of field
  146263. */
  146264. disableDepthOfField(): void;
  146265. /**
  146266. * Sets the Aperture amount
  146267. * @param amount amount of Aperture
  146268. */
  146269. setAperture(amount: number): void;
  146270. /**
  146271. * Sets the DarkenOutOfFocus amount
  146272. * @param amount amount of DarkenOutOfFocus
  146273. */
  146274. setDarkenOutOfFocus(amount: number): void;
  146275. private _pentagonBokehIsEnabled;
  146276. /**
  146277. * Creates a pentagon bokeh effect
  146278. */
  146279. enablePentagonBokeh(): void;
  146280. /**
  146281. * Disables the pentagon bokeh effect
  146282. */
  146283. disablePentagonBokeh(): void;
  146284. /**
  146285. * Enables noise blur
  146286. */
  146287. enableNoiseBlur(): void;
  146288. /**
  146289. * Disables noise blur
  146290. */
  146291. disableNoiseBlur(): void;
  146292. /**
  146293. * Sets the HighlightsGain amount
  146294. * @param amount amount of HighlightsGain
  146295. */
  146296. setHighlightsGain(amount: number): void;
  146297. /**
  146298. * Sets the HighlightsThreshold amount
  146299. * @param amount amount of HighlightsThreshold
  146300. */
  146301. setHighlightsThreshold(amount: number): void;
  146302. /**
  146303. * Disables highlights
  146304. */
  146305. disableHighlights(): void;
  146306. /**
  146307. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  146308. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  146309. */
  146310. dispose(disableDepthRender?: boolean): void;
  146311. private _createChromaticAberrationPostProcess;
  146312. private _createHighlightsPostProcess;
  146313. private _createDepthOfFieldPostProcess;
  146314. private _createGrainTexture;
  146315. }
  146316. }
  146317. declare module BABYLON {
  146318. /** @hidden */
  146319. export var ssao2PixelShader: {
  146320. name: string;
  146321. shader: string;
  146322. };
  146323. }
  146324. declare module BABYLON {
  146325. /** @hidden */
  146326. export var ssaoCombinePixelShader: {
  146327. name: string;
  146328. shader: string;
  146329. };
  146330. }
  146331. declare module BABYLON {
  146332. /**
  146333. * Render pipeline to produce ssao effect
  146334. */
  146335. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  146336. /**
  146337. * @ignore
  146338. * The PassPostProcess id in the pipeline that contains the original scene color
  146339. */
  146340. SSAOOriginalSceneColorEffect: string;
  146341. /**
  146342. * @ignore
  146343. * The SSAO PostProcess id in the pipeline
  146344. */
  146345. SSAORenderEffect: string;
  146346. /**
  146347. * @ignore
  146348. * The horizontal blur PostProcess id in the pipeline
  146349. */
  146350. SSAOBlurHRenderEffect: string;
  146351. /**
  146352. * @ignore
  146353. * The vertical blur PostProcess id in the pipeline
  146354. */
  146355. SSAOBlurVRenderEffect: string;
  146356. /**
  146357. * @ignore
  146358. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  146359. */
  146360. SSAOCombineRenderEffect: string;
  146361. /**
  146362. * The output strength of the SSAO post-process. Default value is 1.0.
  146363. */
  146364. totalStrength: number;
  146365. /**
  146366. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  146367. */
  146368. maxZ: number;
  146369. /**
  146370. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  146371. */
  146372. minZAspect: number;
  146373. private _samples;
  146374. /**
  146375. * Number of samples used for the SSAO calculations. Default value is 8
  146376. */
  146377. set samples(n: number);
  146378. get samples(): number;
  146379. private _textureSamples;
  146380. /**
  146381. * Number of samples to use for antialiasing
  146382. */
  146383. set textureSamples(n: number);
  146384. get textureSamples(): number;
  146385. /**
  146386. * Ratio object used for SSAO ratio and blur ratio
  146387. */
  146388. private _ratio;
  146389. /**
  146390. * Dynamically generated sphere sampler.
  146391. */
  146392. private _sampleSphere;
  146393. /**
  146394. * Blur filter offsets
  146395. */
  146396. private _samplerOffsets;
  146397. private _expensiveBlur;
  146398. /**
  146399. * If bilateral blur should be used
  146400. */
  146401. set expensiveBlur(b: boolean);
  146402. get expensiveBlur(): boolean;
  146403. /**
  146404. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  146405. */
  146406. radius: number;
  146407. /**
  146408. * The base color of the SSAO post-process
  146409. * The final result is "base + ssao" between [0, 1]
  146410. */
  146411. base: number;
  146412. /**
  146413. * Support test.
  146414. */
  146415. static get IsSupported(): boolean;
  146416. private _scene;
  146417. private _depthTexture;
  146418. private _normalTexture;
  146419. private _randomTexture;
  146420. private _originalColorPostProcess;
  146421. private _ssaoPostProcess;
  146422. private _blurHPostProcess;
  146423. private _blurVPostProcess;
  146424. private _ssaoCombinePostProcess;
  146425. /**
  146426. * Gets active scene
  146427. */
  146428. get scene(): Scene;
  146429. /**
  146430. * @constructor
  146431. * @param name The rendering pipeline name
  146432. * @param scene The scene linked to this pipeline
  146433. * @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 }
  146434. * @param cameras The array of cameras that the rendering pipeline will be attached to
  146435. */
  146436. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  146437. /**
  146438. * Get the class name
  146439. * @returns "SSAO2RenderingPipeline"
  146440. */
  146441. getClassName(): string;
  146442. /**
  146443. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  146444. */
  146445. dispose(disableGeometryBufferRenderer?: boolean): void;
  146446. private _createBlurPostProcess;
  146447. /** @hidden */
  146448. _rebuild(): void;
  146449. private _bits;
  146450. private _radicalInverse_VdC;
  146451. private _hammersley;
  146452. private _hemisphereSample_uniform;
  146453. private _generateHemisphere;
  146454. private _createSSAOPostProcess;
  146455. private _createSSAOCombinePostProcess;
  146456. private _createRandomTexture;
  146457. /**
  146458. * Serialize the rendering pipeline (Used when exporting)
  146459. * @returns the serialized object
  146460. */
  146461. serialize(): any;
  146462. /**
  146463. * Parse the serialized pipeline
  146464. * @param source Source pipeline.
  146465. * @param scene The scene to load the pipeline to.
  146466. * @param rootUrl The URL of the serialized pipeline.
  146467. * @returns An instantiated pipeline from the serialized object.
  146468. */
  146469. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  146470. }
  146471. }
  146472. declare module BABYLON {
  146473. /** @hidden */
  146474. export var ssaoPixelShader: {
  146475. name: string;
  146476. shader: string;
  146477. };
  146478. }
  146479. declare module BABYLON {
  146480. /**
  146481. * Render pipeline to produce ssao effect
  146482. */
  146483. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  146484. /**
  146485. * @ignore
  146486. * The PassPostProcess id in the pipeline that contains the original scene color
  146487. */
  146488. SSAOOriginalSceneColorEffect: string;
  146489. /**
  146490. * @ignore
  146491. * The SSAO PostProcess id in the pipeline
  146492. */
  146493. SSAORenderEffect: string;
  146494. /**
  146495. * @ignore
  146496. * The horizontal blur PostProcess id in the pipeline
  146497. */
  146498. SSAOBlurHRenderEffect: string;
  146499. /**
  146500. * @ignore
  146501. * The vertical blur PostProcess id in the pipeline
  146502. */
  146503. SSAOBlurVRenderEffect: string;
  146504. /**
  146505. * @ignore
  146506. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  146507. */
  146508. SSAOCombineRenderEffect: string;
  146509. /**
  146510. * The output strength of the SSAO post-process. Default value is 1.0.
  146511. */
  146512. totalStrength: number;
  146513. /**
  146514. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  146515. */
  146516. radius: number;
  146517. /**
  146518. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  146519. * Must not be equal to fallOff and superior to fallOff.
  146520. * Default value is 0.0075
  146521. */
  146522. area: number;
  146523. /**
  146524. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  146525. * Must not be equal to area and inferior to area.
  146526. * Default value is 0.000001
  146527. */
  146528. fallOff: number;
  146529. /**
  146530. * The base color of the SSAO post-process
  146531. * The final result is "base + ssao" between [0, 1]
  146532. */
  146533. base: number;
  146534. private _scene;
  146535. private _depthTexture;
  146536. private _randomTexture;
  146537. private _originalColorPostProcess;
  146538. private _ssaoPostProcess;
  146539. private _blurHPostProcess;
  146540. private _blurVPostProcess;
  146541. private _ssaoCombinePostProcess;
  146542. private _firstUpdate;
  146543. /**
  146544. * Gets active scene
  146545. */
  146546. get scene(): Scene;
  146547. /**
  146548. * @constructor
  146549. * @param name - The rendering pipeline name
  146550. * @param scene - The scene linked to this pipeline
  146551. * @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 }
  146552. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  146553. */
  146554. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  146555. /**
  146556. * Get the class name
  146557. * @returns "SSAORenderingPipeline"
  146558. */
  146559. getClassName(): string;
  146560. /**
  146561. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  146562. */
  146563. dispose(disableDepthRender?: boolean): void;
  146564. private _createBlurPostProcess;
  146565. /** @hidden */
  146566. _rebuild(): void;
  146567. private _createSSAOPostProcess;
  146568. private _createSSAOCombinePostProcess;
  146569. private _createRandomTexture;
  146570. }
  146571. }
  146572. declare module BABYLON {
  146573. /** @hidden */
  146574. export var screenSpaceReflectionPixelShader: {
  146575. name: string;
  146576. shader: string;
  146577. };
  146578. }
  146579. declare module BABYLON {
  146580. /**
  146581. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  146582. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  146583. */
  146584. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  146585. /**
  146586. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  146587. */
  146588. threshold: number;
  146589. /**
  146590. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  146591. */
  146592. strength: number;
  146593. /**
  146594. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  146595. */
  146596. reflectionSpecularFalloffExponent: number;
  146597. /**
  146598. * 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]
  146599. */
  146600. step: number;
  146601. /**
  146602. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  146603. */
  146604. roughnessFactor: number;
  146605. private _geometryBufferRenderer;
  146606. private _enableSmoothReflections;
  146607. private _reflectionSamples;
  146608. private _smoothSteps;
  146609. /**
  146610. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  146611. * @param name The name of the effect.
  146612. * @param scene The scene containing the objects to calculate reflections.
  146613. * @param options The required width/height ratio to downsize to before computing the render pass.
  146614. * @param camera The camera to apply the render pass to.
  146615. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146616. * @param engine The engine which the post process will be applied. (default: current engine)
  146617. * @param reusable If the post process can be reused on the same frame. (default: false)
  146618. * @param textureType Type of textures used when performing the post process. (default: 0)
  146619. * @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)
  146620. */
  146621. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146622. /**
  146623. * Gets wether or not smoothing reflections is enabled.
  146624. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  146625. */
  146626. get enableSmoothReflections(): boolean;
  146627. /**
  146628. * Sets wether or not smoothing reflections is enabled.
  146629. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  146630. */
  146631. set enableSmoothReflections(enabled: boolean);
  146632. /**
  146633. * Gets the number of samples taken while computing reflections. More samples count is high,
  146634. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  146635. */
  146636. get reflectionSamples(): number;
  146637. /**
  146638. * Sets the number of samples taken while computing reflections. More samples count is high,
  146639. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  146640. */
  146641. set reflectionSamples(samples: number);
  146642. /**
  146643. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  146644. * more the post-process will require GPU power and can generate a drop in FPS.
  146645. * Default value (5.0) work pretty well in all cases but can be adjusted.
  146646. */
  146647. get smoothSteps(): number;
  146648. set smoothSteps(steps: number);
  146649. private _updateEffectDefines;
  146650. }
  146651. }
  146652. declare module BABYLON {
  146653. /** @hidden */
  146654. export var standardPixelShader: {
  146655. name: string;
  146656. shader: string;
  146657. };
  146658. }
  146659. declare module BABYLON {
  146660. /**
  146661. * Standard rendering pipeline
  146662. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  146663. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  146664. */
  146665. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  146666. /**
  146667. * Public members
  146668. */
  146669. /**
  146670. * Post-process which contains the original scene color before the pipeline applies all the effects
  146671. */
  146672. originalPostProcess: Nullable<PostProcess>;
  146673. /**
  146674. * Post-process used to down scale an image x4
  146675. */
  146676. downSampleX4PostProcess: Nullable<PostProcess>;
  146677. /**
  146678. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  146679. */
  146680. brightPassPostProcess: Nullable<PostProcess>;
  146681. /**
  146682. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  146683. */
  146684. blurHPostProcesses: PostProcess[];
  146685. /**
  146686. * Post-process array storing all the vertical blur post-processes used by the pipeline
  146687. */
  146688. blurVPostProcesses: PostProcess[];
  146689. /**
  146690. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  146691. */
  146692. textureAdderPostProcess: Nullable<PostProcess>;
  146693. /**
  146694. * Post-process used to create volumetric lighting effect
  146695. */
  146696. volumetricLightPostProcess: Nullable<PostProcess>;
  146697. /**
  146698. * Post-process used to smooth the previous volumetric light post-process on the X axis
  146699. */
  146700. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  146701. /**
  146702. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  146703. */
  146704. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  146705. /**
  146706. * Post-process used to merge the volumetric light effect and the real scene color
  146707. */
  146708. volumetricLightMergePostProces: Nullable<PostProcess>;
  146709. /**
  146710. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  146711. */
  146712. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  146713. /**
  146714. * Base post-process used to calculate the average luminance of the final image for HDR
  146715. */
  146716. luminancePostProcess: Nullable<PostProcess>;
  146717. /**
  146718. * Post-processes used to create down sample post-processes in order to get
  146719. * the average luminance of the final image for HDR
  146720. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  146721. */
  146722. luminanceDownSamplePostProcesses: PostProcess[];
  146723. /**
  146724. * Post-process used to create a HDR effect (light adaptation)
  146725. */
  146726. hdrPostProcess: Nullable<PostProcess>;
  146727. /**
  146728. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  146729. */
  146730. textureAdderFinalPostProcess: Nullable<PostProcess>;
  146731. /**
  146732. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  146733. */
  146734. lensFlareFinalPostProcess: Nullable<PostProcess>;
  146735. /**
  146736. * Post-process used to merge the final HDR post-process and the real scene color
  146737. */
  146738. hdrFinalPostProcess: Nullable<PostProcess>;
  146739. /**
  146740. * Post-process used to create a lens flare effect
  146741. */
  146742. lensFlarePostProcess: Nullable<PostProcess>;
  146743. /**
  146744. * Post-process that merges the result of the lens flare post-process and the real scene color
  146745. */
  146746. lensFlareComposePostProcess: Nullable<PostProcess>;
  146747. /**
  146748. * Post-process used to create a motion blur effect
  146749. */
  146750. motionBlurPostProcess: Nullable<PostProcess>;
  146751. /**
  146752. * Post-process used to create a depth of field effect
  146753. */
  146754. depthOfFieldPostProcess: Nullable<PostProcess>;
  146755. /**
  146756. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  146757. */
  146758. fxaaPostProcess: Nullable<FxaaPostProcess>;
  146759. /**
  146760. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  146761. */
  146762. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  146763. /**
  146764. * Represents the brightness threshold in order to configure the illuminated surfaces
  146765. */
  146766. brightThreshold: number;
  146767. /**
  146768. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  146769. */
  146770. blurWidth: number;
  146771. /**
  146772. * Sets if the blur for highlighted surfaces must be only horizontal
  146773. */
  146774. horizontalBlur: boolean;
  146775. /**
  146776. * Gets the overall exposure used by the pipeline
  146777. */
  146778. get exposure(): number;
  146779. /**
  146780. * Sets the overall exposure used by the pipeline
  146781. */
  146782. set exposure(value: number);
  146783. /**
  146784. * Texture used typically to simulate "dirty" on camera lens
  146785. */
  146786. lensTexture: Nullable<Texture>;
  146787. /**
  146788. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  146789. */
  146790. volumetricLightCoefficient: number;
  146791. /**
  146792. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  146793. */
  146794. volumetricLightPower: number;
  146795. /**
  146796. * Used the set the blur intensity to smooth the volumetric lights
  146797. */
  146798. volumetricLightBlurScale: number;
  146799. /**
  146800. * Light (spot or directional) used to generate the volumetric lights rays
  146801. * The source light must have a shadow generate so the pipeline can get its
  146802. * depth map
  146803. */
  146804. sourceLight: Nullable<SpotLight | DirectionalLight>;
  146805. /**
  146806. * For eye adaptation, represents the minimum luminance the eye can see
  146807. */
  146808. hdrMinimumLuminance: number;
  146809. /**
  146810. * For eye adaptation, represents the decrease luminance speed
  146811. */
  146812. hdrDecreaseRate: number;
  146813. /**
  146814. * For eye adaptation, represents the increase luminance speed
  146815. */
  146816. hdrIncreaseRate: number;
  146817. /**
  146818. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  146819. */
  146820. get hdrAutoExposure(): boolean;
  146821. /**
  146822. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  146823. */
  146824. set hdrAutoExposure(value: boolean);
  146825. /**
  146826. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  146827. */
  146828. lensColorTexture: Nullable<Texture>;
  146829. /**
  146830. * The overall strengh for the lens flare effect
  146831. */
  146832. lensFlareStrength: number;
  146833. /**
  146834. * Dispersion coefficient for lens flare ghosts
  146835. */
  146836. lensFlareGhostDispersal: number;
  146837. /**
  146838. * Main lens flare halo width
  146839. */
  146840. lensFlareHaloWidth: number;
  146841. /**
  146842. * Based on the lens distortion effect, defines how much the lens flare result
  146843. * is distorted
  146844. */
  146845. lensFlareDistortionStrength: number;
  146846. /**
  146847. * Configures the blur intensity used for for lens flare (halo)
  146848. */
  146849. lensFlareBlurWidth: number;
  146850. /**
  146851. * Lens star texture must be used to simulate rays on the flares and is available
  146852. * in the documentation
  146853. */
  146854. lensStarTexture: Nullable<Texture>;
  146855. /**
  146856. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  146857. * flare effect by taking account of the dirt texture
  146858. */
  146859. lensFlareDirtTexture: Nullable<Texture>;
  146860. /**
  146861. * Represents the focal length for the depth of field effect
  146862. */
  146863. depthOfFieldDistance: number;
  146864. /**
  146865. * Represents the blur intensity for the blurred part of the depth of field effect
  146866. */
  146867. depthOfFieldBlurWidth: number;
  146868. /**
  146869. * Gets how much the image is blurred by the movement while using the motion blur post-process
  146870. */
  146871. get motionStrength(): number;
  146872. /**
  146873. * Sets how much the image is blurred by the movement while using the motion blur post-process
  146874. */
  146875. set motionStrength(strength: number);
  146876. /**
  146877. * Gets wether or not the motion blur post-process is object based or screen based.
  146878. */
  146879. get objectBasedMotionBlur(): boolean;
  146880. /**
  146881. * Sets wether or not the motion blur post-process should be object based or screen based
  146882. */
  146883. set objectBasedMotionBlur(value: boolean);
  146884. /**
  146885. * List of animations for the pipeline (IAnimatable implementation)
  146886. */
  146887. animations: Animation[];
  146888. /**
  146889. * Private members
  146890. */
  146891. private _scene;
  146892. private _currentDepthOfFieldSource;
  146893. private _basePostProcess;
  146894. private _fixedExposure;
  146895. private _currentExposure;
  146896. private _hdrAutoExposure;
  146897. private _hdrCurrentLuminance;
  146898. private _motionStrength;
  146899. private _isObjectBasedMotionBlur;
  146900. private _floatTextureType;
  146901. private _camerasToBeAttached;
  146902. private _ratio;
  146903. private _bloomEnabled;
  146904. private _depthOfFieldEnabled;
  146905. private _vlsEnabled;
  146906. private _lensFlareEnabled;
  146907. private _hdrEnabled;
  146908. private _motionBlurEnabled;
  146909. private _fxaaEnabled;
  146910. private _screenSpaceReflectionsEnabled;
  146911. private _motionBlurSamples;
  146912. private _volumetricLightStepsCount;
  146913. private _samples;
  146914. /**
  146915. * @ignore
  146916. * Specifies if the bloom pipeline is enabled
  146917. */
  146918. get BloomEnabled(): boolean;
  146919. set BloomEnabled(enabled: boolean);
  146920. /**
  146921. * @ignore
  146922. * Specifies if the depth of field pipeline is enabed
  146923. */
  146924. get DepthOfFieldEnabled(): boolean;
  146925. set DepthOfFieldEnabled(enabled: boolean);
  146926. /**
  146927. * @ignore
  146928. * Specifies if the lens flare pipeline is enabed
  146929. */
  146930. get LensFlareEnabled(): boolean;
  146931. set LensFlareEnabled(enabled: boolean);
  146932. /**
  146933. * @ignore
  146934. * Specifies if the HDR pipeline is enabled
  146935. */
  146936. get HDREnabled(): boolean;
  146937. set HDREnabled(enabled: boolean);
  146938. /**
  146939. * @ignore
  146940. * Specifies if the volumetric lights scattering effect is enabled
  146941. */
  146942. get VLSEnabled(): boolean;
  146943. set VLSEnabled(enabled: boolean);
  146944. /**
  146945. * @ignore
  146946. * Specifies if the motion blur effect is enabled
  146947. */
  146948. get MotionBlurEnabled(): boolean;
  146949. set MotionBlurEnabled(enabled: boolean);
  146950. /**
  146951. * Specifies if anti-aliasing is enabled
  146952. */
  146953. get fxaaEnabled(): boolean;
  146954. set fxaaEnabled(enabled: boolean);
  146955. /**
  146956. * Specifies if screen space reflections are enabled.
  146957. */
  146958. get screenSpaceReflectionsEnabled(): boolean;
  146959. set screenSpaceReflectionsEnabled(enabled: boolean);
  146960. /**
  146961. * Specifies the number of steps used to calculate the volumetric lights
  146962. * Typically in interval [50, 200]
  146963. */
  146964. get volumetricLightStepsCount(): number;
  146965. set volumetricLightStepsCount(count: number);
  146966. /**
  146967. * Specifies the number of samples used for the motion blur effect
  146968. * Typically in interval [16, 64]
  146969. */
  146970. get motionBlurSamples(): number;
  146971. set motionBlurSamples(samples: number);
  146972. /**
  146973. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  146974. */
  146975. get samples(): number;
  146976. set samples(sampleCount: number);
  146977. /**
  146978. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  146979. * @constructor
  146980. * @param name The rendering pipeline name
  146981. * @param scene The scene linked to this pipeline
  146982. * @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)
  146983. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  146984. * @param cameras The array of cameras that the rendering pipeline will be attached to
  146985. */
  146986. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  146987. private _buildPipeline;
  146988. private _createDownSampleX4PostProcess;
  146989. private _createBrightPassPostProcess;
  146990. private _createBlurPostProcesses;
  146991. private _createTextureAdderPostProcess;
  146992. private _createVolumetricLightPostProcess;
  146993. private _createLuminancePostProcesses;
  146994. private _createHdrPostProcess;
  146995. private _createLensFlarePostProcess;
  146996. private _createDepthOfFieldPostProcess;
  146997. private _createMotionBlurPostProcess;
  146998. private _getDepthTexture;
  146999. private _disposePostProcesses;
  147000. /**
  147001. * Dispose of the pipeline and stop all post processes
  147002. */
  147003. dispose(): void;
  147004. /**
  147005. * Serialize the rendering pipeline (Used when exporting)
  147006. * @returns the serialized object
  147007. */
  147008. serialize(): any;
  147009. /**
  147010. * Parse the serialized pipeline
  147011. * @param source Source pipeline.
  147012. * @param scene The scene to load the pipeline to.
  147013. * @param rootUrl The URL of the serialized pipeline.
  147014. * @returns An instantiated pipeline from the serialized object.
  147015. */
  147016. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  147017. /**
  147018. * Luminance steps
  147019. */
  147020. static LuminanceSteps: number;
  147021. }
  147022. }
  147023. declare module BABYLON {
  147024. /** @hidden */
  147025. export var stereoscopicInterlacePixelShader: {
  147026. name: string;
  147027. shader: string;
  147028. };
  147029. }
  147030. declare module BABYLON {
  147031. /**
  147032. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  147033. */
  147034. export class StereoscopicInterlacePostProcessI extends PostProcess {
  147035. private _stepSize;
  147036. private _passedProcess;
  147037. /**
  147038. * Initializes a StereoscopicInterlacePostProcessI
  147039. * @param name The name of the effect.
  147040. * @param rigCameras The rig cameras to be appled to the post process
  147041. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  147042. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  147043. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147044. * @param engine The engine which the post process will be applied. (default: current engine)
  147045. * @param reusable If the post process can be reused on the same frame. (default: false)
  147046. */
  147047. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147048. }
  147049. /**
  147050. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  147051. */
  147052. export class StereoscopicInterlacePostProcess extends PostProcess {
  147053. private _stepSize;
  147054. private _passedProcess;
  147055. /**
  147056. * Initializes a StereoscopicInterlacePostProcess
  147057. * @param name The name of the effect.
  147058. * @param rigCameras The rig cameras to be appled to the post process
  147059. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  147060. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147061. * @param engine The engine which the post process will be applied. (default: current engine)
  147062. * @param reusable If the post process can be reused on the same frame. (default: false)
  147063. */
  147064. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147065. }
  147066. }
  147067. declare module BABYLON {
  147068. /** @hidden */
  147069. export var tonemapPixelShader: {
  147070. name: string;
  147071. shader: string;
  147072. };
  147073. }
  147074. declare module BABYLON {
  147075. /** Defines operator used for tonemapping */
  147076. export enum TonemappingOperator {
  147077. /** Hable */
  147078. Hable = 0,
  147079. /** Reinhard */
  147080. Reinhard = 1,
  147081. /** HejiDawson */
  147082. HejiDawson = 2,
  147083. /** Photographic */
  147084. Photographic = 3
  147085. }
  147086. /**
  147087. * Defines a post process to apply tone mapping
  147088. */
  147089. export class TonemapPostProcess extends PostProcess {
  147090. private _operator;
  147091. /** Defines the required exposure adjustement */
  147092. exposureAdjustment: number;
  147093. /**
  147094. * Creates a new TonemapPostProcess
  147095. * @param name defines the name of the postprocess
  147096. * @param _operator defines the operator to use
  147097. * @param exposureAdjustment defines the required exposure adjustement
  147098. * @param camera defines the camera to use (can be null)
  147099. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  147100. * @param engine defines the hosting engine (can be ignore if camera is set)
  147101. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  147102. */
  147103. constructor(name: string, _operator: TonemappingOperator,
  147104. /** Defines the required exposure adjustement */
  147105. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  147106. }
  147107. }
  147108. declare module BABYLON {
  147109. /** @hidden */
  147110. export var volumetricLightScatteringPixelShader: {
  147111. name: string;
  147112. shader: string;
  147113. };
  147114. }
  147115. declare module BABYLON {
  147116. /** @hidden */
  147117. export var volumetricLightScatteringPassVertexShader: {
  147118. name: string;
  147119. shader: string;
  147120. };
  147121. }
  147122. declare module BABYLON {
  147123. /** @hidden */
  147124. export var volumetricLightScatteringPassPixelShader: {
  147125. name: string;
  147126. shader: string;
  147127. };
  147128. }
  147129. declare module BABYLON {
  147130. /**
  147131. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  147132. */
  147133. export class VolumetricLightScatteringPostProcess extends PostProcess {
  147134. private _volumetricLightScatteringPass;
  147135. private _volumetricLightScatteringRTT;
  147136. private _viewPort;
  147137. private _screenCoordinates;
  147138. private _cachedDefines;
  147139. /**
  147140. * If not undefined, the mesh position is computed from the attached node position
  147141. */
  147142. attachedNode: {
  147143. position: Vector3;
  147144. };
  147145. /**
  147146. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  147147. */
  147148. customMeshPosition: Vector3;
  147149. /**
  147150. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  147151. */
  147152. useCustomMeshPosition: boolean;
  147153. /**
  147154. * If the post-process should inverse the light scattering direction
  147155. */
  147156. invert: boolean;
  147157. /**
  147158. * The internal mesh used by the post-process
  147159. */
  147160. mesh: Mesh;
  147161. /**
  147162. * @hidden
  147163. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  147164. */
  147165. get useDiffuseColor(): boolean;
  147166. set useDiffuseColor(useDiffuseColor: boolean);
  147167. /**
  147168. * Array containing the excluded meshes not rendered in the internal pass
  147169. */
  147170. excludedMeshes: AbstractMesh[];
  147171. /**
  147172. * Controls the overall intensity of the post-process
  147173. */
  147174. exposure: number;
  147175. /**
  147176. * Dissipates each sample's contribution in range [0, 1]
  147177. */
  147178. decay: number;
  147179. /**
  147180. * Controls the overall intensity of each sample
  147181. */
  147182. weight: number;
  147183. /**
  147184. * Controls the density of each sample
  147185. */
  147186. density: number;
  147187. /**
  147188. * @constructor
  147189. * @param name The post-process name
  147190. * @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)
  147191. * @param camera The camera that the post-process will be attached to
  147192. * @param mesh The mesh used to create the light scattering
  147193. * @param samples The post-process quality, default 100
  147194. * @param samplingModeThe post-process filtering mode
  147195. * @param engine The babylon engine
  147196. * @param reusable If the post-process is reusable
  147197. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  147198. */
  147199. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  147200. /**
  147201. * Returns the string "VolumetricLightScatteringPostProcess"
  147202. * @returns "VolumetricLightScatteringPostProcess"
  147203. */
  147204. getClassName(): string;
  147205. private _isReady;
  147206. /**
  147207. * Sets the new light position for light scattering effect
  147208. * @param position The new custom light position
  147209. */
  147210. setCustomMeshPosition(position: Vector3): void;
  147211. /**
  147212. * Returns the light position for light scattering effect
  147213. * @return Vector3 The custom light position
  147214. */
  147215. getCustomMeshPosition(): Vector3;
  147216. /**
  147217. * Disposes the internal assets and detaches the post-process from the camera
  147218. */
  147219. dispose(camera: Camera): void;
  147220. /**
  147221. * Returns the render target texture used by the post-process
  147222. * @return the render target texture used by the post-process
  147223. */
  147224. getPass(): RenderTargetTexture;
  147225. private _meshExcluded;
  147226. private _createPass;
  147227. private _updateMeshScreenCoordinates;
  147228. /**
  147229. * Creates a default mesh for the Volumeric Light Scattering post-process
  147230. * @param name The mesh name
  147231. * @param scene The scene where to create the mesh
  147232. * @return the default mesh
  147233. */
  147234. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  147235. }
  147236. }
  147237. declare module BABYLON {
  147238. interface Scene {
  147239. /** @hidden (Backing field) */
  147240. _boundingBoxRenderer: BoundingBoxRenderer;
  147241. /** @hidden (Backing field) */
  147242. _forceShowBoundingBoxes: boolean;
  147243. /**
  147244. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  147245. */
  147246. forceShowBoundingBoxes: boolean;
  147247. /**
  147248. * Gets the bounding box renderer associated with the scene
  147249. * @returns a BoundingBoxRenderer
  147250. */
  147251. getBoundingBoxRenderer(): BoundingBoxRenderer;
  147252. }
  147253. interface AbstractMesh {
  147254. /** @hidden (Backing field) */
  147255. _showBoundingBox: boolean;
  147256. /**
  147257. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  147258. */
  147259. showBoundingBox: boolean;
  147260. }
  147261. /**
  147262. * Component responsible of rendering the bounding box of the meshes in a scene.
  147263. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  147264. */
  147265. export class BoundingBoxRenderer implements ISceneComponent {
  147266. /**
  147267. * The component name helpfull to identify the component in the list of scene components.
  147268. */
  147269. readonly name: string;
  147270. /**
  147271. * The scene the component belongs to.
  147272. */
  147273. scene: Scene;
  147274. /**
  147275. * Color of the bounding box lines placed in front of an object
  147276. */
  147277. frontColor: Color3;
  147278. /**
  147279. * Color of the bounding box lines placed behind an object
  147280. */
  147281. backColor: Color3;
  147282. /**
  147283. * Defines if the renderer should show the back lines or not
  147284. */
  147285. showBackLines: boolean;
  147286. /**
  147287. * Observable raised before rendering a bounding box
  147288. */
  147289. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  147290. /**
  147291. * Observable raised after rendering a bounding box
  147292. */
  147293. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  147294. /**
  147295. * @hidden
  147296. */
  147297. renderList: SmartArray<BoundingBox>;
  147298. private _colorShader;
  147299. private _vertexBuffers;
  147300. private _indexBuffer;
  147301. private _fillIndexBuffer;
  147302. private _fillIndexData;
  147303. /**
  147304. * Instantiates a new bounding box renderer in a scene.
  147305. * @param scene the scene the renderer renders in
  147306. */
  147307. constructor(scene: Scene);
  147308. /**
  147309. * Registers the component in a given scene
  147310. */
  147311. register(): void;
  147312. private _evaluateSubMesh;
  147313. private _activeMesh;
  147314. private _prepareRessources;
  147315. private _createIndexBuffer;
  147316. /**
  147317. * Rebuilds the elements related to this component in case of
  147318. * context lost for instance.
  147319. */
  147320. rebuild(): void;
  147321. /**
  147322. * @hidden
  147323. */
  147324. reset(): void;
  147325. /**
  147326. * Render the bounding boxes of a specific rendering group
  147327. * @param renderingGroupId defines the rendering group to render
  147328. */
  147329. render(renderingGroupId: number): void;
  147330. /**
  147331. * In case of occlusion queries, we can render the occlusion bounding box through this method
  147332. * @param mesh Define the mesh to render the occlusion bounding box for
  147333. */
  147334. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  147335. /**
  147336. * Dispose and release the resources attached to this renderer.
  147337. */
  147338. dispose(): void;
  147339. }
  147340. }
  147341. declare module BABYLON {
  147342. interface Scene {
  147343. /** @hidden (Backing field) */
  147344. _depthRenderer: {
  147345. [id: string]: DepthRenderer;
  147346. };
  147347. /**
  147348. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  147349. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  147350. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  147351. * @returns the created depth renderer
  147352. */
  147353. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  147354. /**
  147355. * Disables a depth renderer for a given camera
  147356. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  147357. */
  147358. disableDepthRenderer(camera?: Nullable<Camera>): void;
  147359. }
  147360. /**
  147361. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  147362. * in several rendering techniques.
  147363. */
  147364. export class DepthRendererSceneComponent implements ISceneComponent {
  147365. /**
  147366. * The component name helpfull to identify the component in the list of scene components.
  147367. */
  147368. readonly name: string;
  147369. /**
  147370. * The scene the component belongs to.
  147371. */
  147372. scene: Scene;
  147373. /**
  147374. * Creates a new instance of the component for the given scene
  147375. * @param scene Defines the scene to register the component in
  147376. */
  147377. constructor(scene: Scene);
  147378. /**
  147379. * Registers the component in a given scene
  147380. */
  147381. register(): void;
  147382. /**
  147383. * Rebuilds the elements related to this component in case of
  147384. * context lost for instance.
  147385. */
  147386. rebuild(): void;
  147387. /**
  147388. * Disposes the component and the associated ressources
  147389. */
  147390. dispose(): void;
  147391. private _gatherRenderTargets;
  147392. private _gatherActiveCameraRenderTargets;
  147393. }
  147394. }
  147395. declare module BABYLON {
  147396. /** @hidden */
  147397. export var outlinePixelShader: {
  147398. name: string;
  147399. shader: string;
  147400. };
  147401. }
  147402. declare module BABYLON {
  147403. /** @hidden */
  147404. export var outlineVertexShader: {
  147405. name: string;
  147406. shader: string;
  147407. };
  147408. }
  147409. declare module BABYLON {
  147410. interface Scene {
  147411. /** @hidden */
  147412. _outlineRenderer: OutlineRenderer;
  147413. /**
  147414. * Gets the outline renderer associated with the scene
  147415. * @returns a OutlineRenderer
  147416. */
  147417. getOutlineRenderer(): OutlineRenderer;
  147418. }
  147419. interface AbstractMesh {
  147420. /** @hidden (Backing field) */
  147421. _renderOutline: boolean;
  147422. /**
  147423. * Gets or sets a boolean indicating if the outline must be rendered as well
  147424. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  147425. */
  147426. renderOutline: boolean;
  147427. /** @hidden (Backing field) */
  147428. _renderOverlay: boolean;
  147429. /**
  147430. * Gets or sets a boolean indicating if the overlay must be rendered as well
  147431. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  147432. */
  147433. renderOverlay: boolean;
  147434. }
  147435. /**
  147436. * This class is responsible to draw bothe outline/overlay of meshes.
  147437. * It should not be used directly but through the available method on mesh.
  147438. */
  147439. export class OutlineRenderer implements ISceneComponent {
  147440. /**
  147441. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  147442. */
  147443. private static _StencilReference;
  147444. /**
  147445. * The name of the component. Each component must have a unique name.
  147446. */
  147447. name: string;
  147448. /**
  147449. * The scene the component belongs to.
  147450. */
  147451. scene: Scene;
  147452. /**
  147453. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  147454. */
  147455. zOffset: number;
  147456. private _engine;
  147457. private _effect;
  147458. private _cachedDefines;
  147459. private _savedDepthWrite;
  147460. /**
  147461. * Instantiates a new outline renderer. (There could be only one per scene).
  147462. * @param scene Defines the scene it belongs to
  147463. */
  147464. constructor(scene: Scene);
  147465. /**
  147466. * Register the component to one instance of a scene.
  147467. */
  147468. register(): void;
  147469. /**
  147470. * Rebuilds the elements related to this component in case of
  147471. * context lost for instance.
  147472. */
  147473. rebuild(): void;
  147474. /**
  147475. * Disposes the component and the associated ressources.
  147476. */
  147477. dispose(): void;
  147478. /**
  147479. * Renders the outline in the canvas.
  147480. * @param subMesh Defines the sumesh to render
  147481. * @param batch Defines the batch of meshes in case of instances
  147482. * @param useOverlay Defines if the rendering is for the overlay or the outline
  147483. */
  147484. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  147485. /**
  147486. * Returns whether or not the outline renderer is ready for a given submesh.
  147487. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  147488. * @param subMesh Defines the submesh to check readyness for
  147489. * @param useInstances Defines wheter wee are trying to render instances or not
  147490. * @returns true if ready otherwise false
  147491. */
  147492. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  147493. private _beforeRenderingMesh;
  147494. private _afterRenderingMesh;
  147495. }
  147496. }
  147497. declare module BABYLON {
  147498. /**
  147499. * Defines the basic options interface of a Sprite Frame Source Size.
  147500. */
  147501. export interface ISpriteJSONSpriteSourceSize {
  147502. /**
  147503. * number of the original width of the Frame
  147504. */
  147505. w: number;
  147506. /**
  147507. * number of the original height of the Frame
  147508. */
  147509. h: number;
  147510. }
  147511. /**
  147512. * Defines the basic options interface of a Sprite Frame Data.
  147513. */
  147514. export interface ISpriteJSONSpriteFrameData {
  147515. /**
  147516. * number of the x offset of the Frame
  147517. */
  147518. x: number;
  147519. /**
  147520. * number of the y offset of the Frame
  147521. */
  147522. y: number;
  147523. /**
  147524. * number of the width of the Frame
  147525. */
  147526. w: number;
  147527. /**
  147528. * number of the height of the Frame
  147529. */
  147530. h: number;
  147531. }
  147532. /**
  147533. * Defines the basic options interface of a JSON Sprite.
  147534. */
  147535. export interface ISpriteJSONSprite {
  147536. /**
  147537. * string name of the Frame
  147538. */
  147539. filename: string;
  147540. /**
  147541. * ISpriteJSONSpriteFrame basic object of the frame data
  147542. */
  147543. frame: ISpriteJSONSpriteFrameData;
  147544. /**
  147545. * boolean to flag is the frame was rotated.
  147546. */
  147547. rotated: boolean;
  147548. /**
  147549. * boolean to flag is the frame was trimmed.
  147550. */
  147551. trimmed: boolean;
  147552. /**
  147553. * ISpriteJSONSpriteFrame basic object of the source data
  147554. */
  147555. spriteSourceSize: ISpriteJSONSpriteFrameData;
  147556. /**
  147557. * ISpriteJSONSpriteFrame basic object of the source data
  147558. */
  147559. sourceSize: ISpriteJSONSpriteSourceSize;
  147560. }
  147561. /**
  147562. * Defines the basic options interface of a JSON atlas.
  147563. */
  147564. export interface ISpriteJSONAtlas {
  147565. /**
  147566. * Array of objects that contain the frame data.
  147567. */
  147568. frames: Array<ISpriteJSONSprite>;
  147569. /**
  147570. * object basic object containing the sprite meta data.
  147571. */
  147572. meta?: object;
  147573. }
  147574. }
  147575. declare module BABYLON {
  147576. /** @hidden */
  147577. export var spriteMapPixelShader: {
  147578. name: string;
  147579. shader: string;
  147580. };
  147581. }
  147582. declare module BABYLON {
  147583. /** @hidden */
  147584. export var spriteMapVertexShader: {
  147585. name: string;
  147586. shader: string;
  147587. };
  147588. }
  147589. declare module BABYLON {
  147590. /**
  147591. * Defines the basic options interface of a SpriteMap
  147592. */
  147593. export interface ISpriteMapOptions {
  147594. /**
  147595. * Vector2 of the number of cells in the grid.
  147596. */
  147597. stageSize?: Vector2;
  147598. /**
  147599. * Vector2 of the size of the output plane in World Units.
  147600. */
  147601. outputSize?: Vector2;
  147602. /**
  147603. * Vector3 of the position of the output plane in World Units.
  147604. */
  147605. outputPosition?: Vector3;
  147606. /**
  147607. * Vector3 of the rotation of the output plane.
  147608. */
  147609. outputRotation?: Vector3;
  147610. /**
  147611. * number of layers that the system will reserve in resources.
  147612. */
  147613. layerCount?: number;
  147614. /**
  147615. * number of max animation frames a single cell will reserve in resources.
  147616. */
  147617. maxAnimationFrames?: number;
  147618. /**
  147619. * number cell index of the base tile when the system compiles.
  147620. */
  147621. baseTile?: number;
  147622. /**
  147623. * boolean flip the sprite after its been repositioned by the framing data.
  147624. */
  147625. flipU?: boolean;
  147626. /**
  147627. * Vector3 scalar of the global RGB values of the SpriteMap.
  147628. */
  147629. colorMultiply?: Vector3;
  147630. }
  147631. /**
  147632. * Defines the IDisposable interface in order to be cleanable from resources.
  147633. */
  147634. export interface ISpriteMap extends IDisposable {
  147635. /**
  147636. * String name of the SpriteMap.
  147637. */
  147638. name: string;
  147639. /**
  147640. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  147641. */
  147642. atlasJSON: ISpriteJSONAtlas;
  147643. /**
  147644. * Texture of the SpriteMap.
  147645. */
  147646. spriteSheet: Texture;
  147647. /**
  147648. * The parameters to initialize the SpriteMap with.
  147649. */
  147650. options: ISpriteMapOptions;
  147651. }
  147652. /**
  147653. * Class used to manage a grid restricted sprite deployment on an Output plane.
  147654. */
  147655. export class SpriteMap implements ISpriteMap {
  147656. /** The Name of the spriteMap */
  147657. name: string;
  147658. /** The JSON file with the frame and meta data */
  147659. atlasJSON: ISpriteJSONAtlas;
  147660. /** The systems Sprite Sheet Texture */
  147661. spriteSheet: Texture;
  147662. /** Arguments passed with the Constructor */
  147663. options: ISpriteMapOptions;
  147664. /** Public Sprite Storage array, parsed from atlasJSON */
  147665. sprites: Array<ISpriteJSONSprite>;
  147666. /** Returns the Number of Sprites in the System */
  147667. get spriteCount(): number;
  147668. /** Returns the Position of Output Plane*/
  147669. get position(): Vector3;
  147670. /** Returns the Position of Output Plane*/
  147671. set position(v: Vector3);
  147672. /** Returns the Rotation of Output Plane*/
  147673. get rotation(): Vector3;
  147674. /** Returns the Rotation of Output Plane*/
  147675. set rotation(v: Vector3);
  147676. /** Sets the AnimationMap*/
  147677. get animationMap(): RawTexture;
  147678. /** Sets the AnimationMap*/
  147679. set animationMap(v: RawTexture);
  147680. /** Scene that the SpriteMap was created in */
  147681. private _scene;
  147682. /** Texture Buffer of Float32 that holds tile frame data*/
  147683. private _frameMap;
  147684. /** Texture Buffers of Float32 that holds tileMap data*/
  147685. private _tileMaps;
  147686. /** Texture Buffer of Float32 that holds Animation Data*/
  147687. private _animationMap;
  147688. /** Custom ShaderMaterial Central to the System*/
  147689. private _material;
  147690. /** Custom ShaderMaterial Central to the System*/
  147691. private _output;
  147692. /** Systems Time Ticker*/
  147693. private _time;
  147694. /**
  147695. * Creates a new SpriteMap
  147696. * @param name defines the SpriteMaps Name
  147697. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  147698. * @param spriteSheet is the Texture that the Sprites are on.
  147699. * @param options a basic deployment configuration
  147700. * @param scene The Scene that the map is deployed on
  147701. */
  147702. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  147703. /**
  147704. * Returns tileID location
  147705. * @returns Vector2 the cell position ID
  147706. */
  147707. getTileID(): Vector2;
  147708. /**
  147709. * Gets the UV location of the mouse over the SpriteMap.
  147710. * @returns Vector2 the UV position of the mouse interaction
  147711. */
  147712. getMousePosition(): Vector2;
  147713. /**
  147714. * Creates the "frame" texture Buffer
  147715. * -------------------------------------
  147716. * Structure of frames
  147717. * "filename": "Falling-Water-2.png",
  147718. * "frame": {"x":69,"y":103,"w":24,"h":32},
  147719. * "rotated": true,
  147720. * "trimmed": true,
  147721. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  147722. * "sourceSize": {"w":32,"h":32}
  147723. * @returns RawTexture of the frameMap
  147724. */
  147725. private _createFrameBuffer;
  147726. /**
  147727. * Creates the tileMap texture Buffer
  147728. * @param buffer normally and array of numbers, or a false to generate from scratch
  147729. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  147730. * @returns RawTexture of the tileMap
  147731. */
  147732. private _createTileBuffer;
  147733. /**
  147734. * Modifies the data of the tileMaps
  147735. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  147736. * @param pos is the iVector2 Coordinates of the Tile
  147737. * @param tile The SpriteIndex of the new Tile
  147738. */
  147739. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  147740. /**
  147741. * Creates the animationMap texture Buffer
  147742. * @param buffer normally and array of numbers, or a false to generate from scratch
  147743. * @returns RawTexture of the animationMap
  147744. */
  147745. private _createTileAnimationBuffer;
  147746. /**
  147747. * Modifies the data of the animationMap
  147748. * @param cellID is the Index of the Sprite
  147749. * @param _frame is the target Animation frame
  147750. * @param toCell is the Target Index of the next frame of the animation
  147751. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  147752. * @param speed is a global scalar of the time variable on the map.
  147753. */
  147754. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  147755. /**
  147756. * Exports the .tilemaps file
  147757. */
  147758. saveTileMaps(): void;
  147759. /**
  147760. * Imports the .tilemaps file
  147761. * @param url of the .tilemaps file
  147762. */
  147763. loadTileMaps(url: string): void;
  147764. /**
  147765. * Release associated resources
  147766. */
  147767. dispose(): void;
  147768. }
  147769. }
  147770. declare module BABYLON {
  147771. /**
  147772. * Class used to manage multiple sprites of different sizes on the same spritesheet
  147773. * @see http://doc.babylonjs.com/babylon101/sprites
  147774. */
  147775. export class SpritePackedManager extends SpriteManager {
  147776. /** defines the packed manager's name */
  147777. name: string;
  147778. /**
  147779. * Creates a new sprite manager from a packed sprite sheet
  147780. * @param name defines the manager's name
  147781. * @param imgUrl defines the sprite sheet url
  147782. * @param capacity defines the maximum allowed number of sprites
  147783. * @param scene defines the hosting scene
  147784. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  147785. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  147786. * @param samplingMode defines the smapling mode to use with spritesheet
  147787. * @param fromPacked set to true; do not alter
  147788. */
  147789. constructor(
  147790. /** defines the packed manager's name */
  147791. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  147792. }
  147793. }
  147794. declare module BABYLON {
  147795. /**
  147796. * Defines the list of states available for a task inside a AssetsManager
  147797. */
  147798. export enum AssetTaskState {
  147799. /**
  147800. * Initialization
  147801. */
  147802. INIT = 0,
  147803. /**
  147804. * Running
  147805. */
  147806. RUNNING = 1,
  147807. /**
  147808. * Done
  147809. */
  147810. DONE = 2,
  147811. /**
  147812. * Error
  147813. */
  147814. ERROR = 3
  147815. }
  147816. /**
  147817. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  147818. */
  147819. export abstract class AbstractAssetTask {
  147820. /**
  147821. * Task name
  147822. */ name: string;
  147823. /**
  147824. * Callback called when the task is successful
  147825. */
  147826. onSuccess: (task: any) => void;
  147827. /**
  147828. * Callback called when the task is not successful
  147829. */
  147830. onError: (task: any, message?: string, exception?: any) => void;
  147831. /**
  147832. * Creates a new AssetsManager
  147833. * @param name defines the name of the task
  147834. */
  147835. constructor(
  147836. /**
  147837. * Task name
  147838. */ name: string);
  147839. private _isCompleted;
  147840. private _taskState;
  147841. private _errorObject;
  147842. /**
  147843. * Get if the task is completed
  147844. */
  147845. get isCompleted(): boolean;
  147846. /**
  147847. * Gets the current state of the task
  147848. */
  147849. get taskState(): AssetTaskState;
  147850. /**
  147851. * Gets the current error object (if task is in error)
  147852. */
  147853. get errorObject(): {
  147854. message?: string;
  147855. exception?: any;
  147856. };
  147857. /**
  147858. * Internal only
  147859. * @hidden
  147860. */
  147861. _setErrorObject(message?: string, exception?: any): void;
  147862. /**
  147863. * Execute the current task
  147864. * @param scene defines the scene where you want your assets to be loaded
  147865. * @param onSuccess is a callback called when the task is successfully executed
  147866. * @param onError is a callback called if an error occurs
  147867. */
  147868. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147869. /**
  147870. * Execute the current task
  147871. * @param scene defines the scene where you want your assets to be loaded
  147872. * @param onSuccess is a callback called when the task is successfully executed
  147873. * @param onError is a callback called if an error occurs
  147874. */
  147875. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147876. /**
  147877. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  147878. * This can be used with failed tasks that have the reason for failure fixed.
  147879. */
  147880. reset(): void;
  147881. private onErrorCallback;
  147882. private onDoneCallback;
  147883. }
  147884. /**
  147885. * Define the interface used by progress events raised during assets loading
  147886. */
  147887. export interface IAssetsProgressEvent {
  147888. /**
  147889. * Defines the number of remaining tasks to process
  147890. */
  147891. remainingCount: number;
  147892. /**
  147893. * Defines the total number of tasks
  147894. */
  147895. totalCount: number;
  147896. /**
  147897. * Defines the task that was just processed
  147898. */
  147899. task: AbstractAssetTask;
  147900. }
  147901. /**
  147902. * Class used to share progress information about assets loading
  147903. */
  147904. export class AssetsProgressEvent implements IAssetsProgressEvent {
  147905. /**
  147906. * Defines the number of remaining tasks to process
  147907. */
  147908. remainingCount: number;
  147909. /**
  147910. * Defines the total number of tasks
  147911. */
  147912. totalCount: number;
  147913. /**
  147914. * Defines the task that was just processed
  147915. */
  147916. task: AbstractAssetTask;
  147917. /**
  147918. * Creates a AssetsProgressEvent
  147919. * @param remainingCount defines the number of remaining tasks to process
  147920. * @param totalCount defines the total number of tasks
  147921. * @param task defines the task that was just processed
  147922. */
  147923. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  147924. }
  147925. /**
  147926. * Define a task used by AssetsManager to load meshes
  147927. */
  147928. export class MeshAssetTask extends AbstractAssetTask {
  147929. /**
  147930. * Defines the name of the task
  147931. */
  147932. name: string;
  147933. /**
  147934. * Defines the list of mesh's names you want to load
  147935. */
  147936. meshesNames: any;
  147937. /**
  147938. * Defines the root url to use as a base to load your meshes and associated resources
  147939. */
  147940. rootUrl: string;
  147941. /**
  147942. * Defines the filename or File of the scene to load from
  147943. */
  147944. sceneFilename: string | File;
  147945. /**
  147946. * Gets the list of loaded meshes
  147947. */
  147948. loadedMeshes: Array<AbstractMesh>;
  147949. /**
  147950. * Gets the list of loaded particle systems
  147951. */
  147952. loadedParticleSystems: Array<IParticleSystem>;
  147953. /**
  147954. * Gets the list of loaded skeletons
  147955. */
  147956. loadedSkeletons: Array<Skeleton>;
  147957. /**
  147958. * Gets the list of loaded animation groups
  147959. */
  147960. loadedAnimationGroups: Array<AnimationGroup>;
  147961. /**
  147962. * Callback called when the task is successful
  147963. */
  147964. onSuccess: (task: MeshAssetTask) => void;
  147965. /**
  147966. * Callback called when the task is successful
  147967. */
  147968. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  147969. /**
  147970. * Creates a new MeshAssetTask
  147971. * @param name defines the name of the task
  147972. * @param meshesNames defines the list of mesh's names you want to load
  147973. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  147974. * @param sceneFilename defines the filename or File of the scene to load from
  147975. */
  147976. constructor(
  147977. /**
  147978. * Defines the name of the task
  147979. */
  147980. name: string,
  147981. /**
  147982. * Defines the list of mesh's names you want to load
  147983. */
  147984. meshesNames: any,
  147985. /**
  147986. * Defines the root url to use as a base to load your meshes and associated resources
  147987. */
  147988. rootUrl: string,
  147989. /**
  147990. * Defines the filename or File of the scene to load from
  147991. */
  147992. sceneFilename: string | File);
  147993. /**
  147994. * Execute the current task
  147995. * @param scene defines the scene where you want your assets to be loaded
  147996. * @param onSuccess is a callback called when the task is successfully executed
  147997. * @param onError is a callback called if an error occurs
  147998. */
  147999. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148000. }
  148001. /**
  148002. * Define a task used by AssetsManager to load text content
  148003. */
  148004. export class TextFileAssetTask extends AbstractAssetTask {
  148005. /**
  148006. * Defines the name of the task
  148007. */
  148008. name: string;
  148009. /**
  148010. * Defines the location of the file to load
  148011. */
  148012. url: string;
  148013. /**
  148014. * Gets the loaded text string
  148015. */
  148016. text: string;
  148017. /**
  148018. * Callback called when the task is successful
  148019. */
  148020. onSuccess: (task: TextFileAssetTask) => void;
  148021. /**
  148022. * Callback called when the task is successful
  148023. */
  148024. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  148025. /**
  148026. * Creates a new TextFileAssetTask object
  148027. * @param name defines the name of the task
  148028. * @param url defines the location of the file to load
  148029. */
  148030. constructor(
  148031. /**
  148032. * Defines the name of the task
  148033. */
  148034. name: string,
  148035. /**
  148036. * Defines the location of the file to load
  148037. */
  148038. url: string);
  148039. /**
  148040. * Execute the current task
  148041. * @param scene defines the scene where you want your assets to be loaded
  148042. * @param onSuccess is a callback called when the task is successfully executed
  148043. * @param onError is a callback called if an error occurs
  148044. */
  148045. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148046. }
  148047. /**
  148048. * Define a task used by AssetsManager to load binary data
  148049. */
  148050. export class BinaryFileAssetTask extends AbstractAssetTask {
  148051. /**
  148052. * Defines the name of the task
  148053. */
  148054. name: string;
  148055. /**
  148056. * Defines the location of the file to load
  148057. */
  148058. url: string;
  148059. /**
  148060. * Gets the lodaded data (as an array buffer)
  148061. */
  148062. data: ArrayBuffer;
  148063. /**
  148064. * Callback called when the task is successful
  148065. */
  148066. onSuccess: (task: BinaryFileAssetTask) => void;
  148067. /**
  148068. * Callback called when the task is successful
  148069. */
  148070. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  148071. /**
  148072. * Creates a new BinaryFileAssetTask object
  148073. * @param name defines the name of the new task
  148074. * @param url defines the location of the file to load
  148075. */
  148076. constructor(
  148077. /**
  148078. * Defines the name of the task
  148079. */
  148080. name: string,
  148081. /**
  148082. * Defines the location of the file to load
  148083. */
  148084. url: string);
  148085. /**
  148086. * Execute the current task
  148087. * @param scene defines the scene where you want your assets to be loaded
  148088. * @param onSuccess is a callback called when the task is successfully executed
  148089. * @param onError is a callback called if an error occurs
  148090. */
  148091. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148092. }
  148093. /**
  148094. * Define a task used by AssetsManager to load images
  148095. */
  148096. export class ImageAssetTask extends AbstractAssetTask {
  148097. /**
  148098. * Defines the name of the task
  148099. */
  148100. name: string;
  148101. /**
  148102. * Defines the location of the image to load
  148103. */
  148104. url: string;
  148105. /**
  148106. * Gets the loaded images
  148107. */
  148108. image: HTMLImageElement;
  148109. /**
  148110. * Callback called when the task is successful
  148111. */
  148112. onSuccess: (task: ImageAssetTask) => void;
  148113. /**
  148114. * Callback called when the task is successful
  148115. */
  148116. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  148117. /**
  148118. * Creates a new ImageAssetTask
  148119. * @param name defines the name of the task
  148120. * @param url defines the location of the image to load
  148121. */
  148122. constructor(
  148123. /**
  148124. * Defines the name of the task
  148125. */
  148126. name: string,
  148127. /**
  148128. * Defines the location of the image to load
  148129. */
  148130. url: string);
  148131. /**
  148132. * Execute the current task
  148133. * @param scene defines the scene where you want your assets to be loaded
  148134. * @param onSuccess is a callback called when the task is successfully executed
  148135. * @param onError is a callback called if an error occurs
  148136. */
  148137. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148138. }
  148139. /**
  148140. * Defines the interface used by texture loading tasks
  148141. */
  148142. export interface ITextureAssetTask<TEX extends BaseTexture> {
  148143. /**
  148144. * Gets the loaded texture
  148145. */
  148146. texture: TEX;
  148147. }
  148148. /**
  148149. * Define a task used by AssetsManager to load 2D textures
  148150. */
  148151. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  148152. /**
  148153. * Defines the name of the task
  148154. */
  148155. name: string;
  148156. /**
  148157. * Defines the location of the file to load
  148158. */
  148159. url: string;
  148160. /**
  148161. * Defines if mipmap should not be generated (default is false)
  148162. */
  148163. noMipmap?: boolean | undefined;
  148164. /**
  148165. * Defines if texture must be inverted on Y axis (default is true)
  148166. */
  148167. invertY: boolean;
  148168. /**
  148169. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  148170. */
  148171. samplingMode: number;
  148172. /**
  148173. * Gets the loaded texture
  148174. */
  148175. texture: Texture;
  148176. /**
  148177. * Callback called when the task is successful
  148178. */
  148179. onSuccess: (task: TextureAssetTask) => void;
  148180. /**
  148181. * Callback called when the task is successful
  148182. */
  148183. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  148184. /**
  148185. * Creates a new TextureAssetTask object
  148186. * @param name defines the name of the task
  148187. * @param url defines the location of the file to load
  148188. * @param noMipmap defines if mipmap should not be generated (default is false)
  148189. * @param invertY defines if texture must be inverted on Y axis (default is true)
  148190. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  148191. */
  148192. constructor(
  148193. /**
  148194. * Defines the name of the task
  148195. */
  148196. name: string,
  148197. /**
  148198. * Defines the location of the file to load
  148199. */
  148200. url: string,
  148201. /**
  148202. * Defines if mipmap should not be generated (default is false)
  148203. */
  148204. noMipmap?: boolean | undefined,
  148205. /**
  148206. * Defines if texture must be inverted on Y axis (default is true)
  148207. */
  148208. invertY?: boolean,
  148209. /**
  148210. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  148211. */
  148212. samplingMode?: number);
  148213. /**
  148214. * Execute the current task
  148215. * @param scene defines the scene where you want your assets to be loaded
  148216. * @param onSuccess is a callback called when the task is successfully executed
  148217. * @param onError is a callback called if an error occurs
  148218. */
  148219. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148220. }
  148221. /**
  148222. * Define a task used by AssetsManager to load cube textures
  148223. */
  148224. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  148225. /**
  148226. * Defines the name of the task
  148227. */
  148228. name: string;
  148229. /**
  148230. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  148231. */
  148232. url: string;
  148233. /**
  148234. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  148235. */
  148236. extensions?: string[] | undefined;
  148237. /**
  148238. * Defines if mipmaps should not be generated (default is false)
  148239. */
  148240. noMipmap?: boolean | undefined;
  148241. /**
  148242. * Defines the explicit list of files (undefined by default)
  148243. */
  148244. files?: string[] | undefined;
  148245. /**
  148246. * Gets the loaded texture
  148247. */
  148248. texture: CubeTexture;
  148249. /**
  148250. * Callback called when the task is successful
  148251. */
  148252. onSuccess: (task: CubeTextureAssetTask) => void;
  148253. /**
  148254. * Callback called when the task is successful
  148255. */
  148256. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  148257. /**
  148258. * Creates a new CubeTextureAssetTask
  148259. * @param name defines the name of the task
  148260. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  148261. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  148262. * @param noMipmap defines if mipmaps should not be generated (default is false)
  148263. * @param files defines the explicit list of files (undefined by default)
  148264. */
  148265. constructor(
  148266. /**
  148267. * Defines the name of the task
  148268. */
  148269. name: string,
  148270. /**
  148271. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  148272. */
  148273. url: string,
  148274. /**
  148275. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  148276. */
  148277. extensions?: string[] | undefined,
  148278. /**
  148279. * Defines if mipmaps should not be generated (default is false)
  148280. */
  148281. noMipmap?: boolean | undefined,
  148282. /**
  148283. * Defines the explicit list of files (undefined by default)
  148284. */
  148285. files?: string[] | undefined);
  148286. /**
  148287. * Execute the current task
  148288. * @param scene defines the scene where you want your assets to be loaded
  148289. * @param onSuccess is a callback called when the task is successfully executed
  148290. * @param onError is a callback called if an error occurs
  148291. */
  148292. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148293. }
  148294. /**
  148295. * Define a task used by AssetsManager to load HDR cube textures
  148296. */
  148297. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  148298. /**
  148299. * Defines the name of the task
  148300. */
  148301. name: string;
  148302. /**
  148303. * Defines the location of the file to load
  148304. */
  148305. url: string;
  148306. /**
  148307. * Defines the desired size (the more it increases the longer the generation will be)
  148308. */
  148309. size: number;
  148310. /**
  148311. * Defines if mipmaps should not be generated (default is false)
  148312. */
  148313. noMipmap: boolean;
  148314. /**
  148315. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  148316. */
  148317. generateHarmonics: boolean;
  148318. /**
  148319. * 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)
  148320. */
  148321. gammaSpace: boolean;
  148322. /**
  148323. * Internal Use Only
  148324. */
  148325. reserved: boolean;
  148326. /**
  148327. * Gets the loaded texture
  148328. */
  148329. texture: HDRCubeTexture;
  148330. /**
  148331. * Callback called when the task is successful
  148332. */
  148333. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  148334. /**
  148335. * Callback called when the task is successful
  148336. */
  148337. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  148338. /**
  148339. * Creates a new HDRCubeTextureAssetTask object
  148340. * @param name defines the name of the task
  148341. * @param url defines the location of the file to load
  148342. * @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.
  148343. * @param noMipmap defines if mipmaps should not be generated (default is false)
  148344. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  148345. * @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)
  148346. * @param reserved Internal use only
  148347. */
  148348. constructor(
  148349. /**
  148350. * Defines the name of the task
  148351. */
  148352. name: string,
  148353. /**
  148354. * Defines the location of the file to load
  148355. */
  148356. url: string,
  148357. /**
  148358. * Defines the desired size (the more it increases the longer the generation will be)
  148359. */
  148360. size: number,
  148361. /**
  148362. * Defines if mipmaps should not be generated (default is false)
  148363. */
  148364. noMipmap?: boolean,
  148365. /**
  148366. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  148367. */
  148368. generateHarmonics?: boolean,
  148369. /**
  148370. * 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)
  148371. */
  148372. gammaSpace?: boolean,
  148373. /**
  148374. * Internal Use Only
  148375. */
  148376. reserved?: boolean);
  148377. /**
  148378. * Execute the current task
  148379. * @param scene defines the scene where you want your assets to be loaded
  148380. * @param onSuccess is a callback called when the task is successfully executed
  148381. * @param onError is a callback called if an error occurs
  148382. */
  148383. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148384. }
  148385. /**
  148386. * Define a task used by AssetsManager to load Equirectangular cube textures
  148387. */
  148388. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  148389. /**
  148390. * Defines the name of the task
  148391. */
  148392. name: string;
  148393. /**
  148394. * Defines the location of the file to load
  148395. */
  148396. url: string;
  148397. /**
  148398. * Defines the desired size (the more it increases the longer the generation will be)
  148399. */
  148400. size: number;
  148401. /**
  148402. * Defines if mipmaps should not be generated (default is false)
  148403. */
  148404. noMipmap: boolean;
  148405. /**
  148406. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  148407. * but the standard material would require them in Gamma space) (default is true)
  148408. */
  148409. gammaSpace: boolean;
  148410. /**
  148411. * Gets the loaded texture
  148412. */
  148413. texture: EquiRectangularCubeTexture;
  148414. /**
  148415. * Callback called when the task is successful
  148416. */
  148417. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  148418. /**
  148419. * Callback called when the task is successful
  148420. */
  148421. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  148422. /**
  148423. * Creates a new EquiRectangularCubeTextureAssetTask object
  148424. * @param name defines the name of the task
  148425. * @param url defines the location of the file to load
  148426. * @param size defines the desired size (the more it increases the longer the generation will be)
  148427. * If the size is omitted this implies you are using a preprocessed cubemap.
  148428. * @param noMipmap defines if mipmaps should not be generated (default is false)
  148429. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  148430. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  148431. * (default is true)
  148432. */
  148433. constructor(
  148434. /**
  148435. * Defines the name of the task
  148436. */
  148437. name: string,
  148438. /**
  148439. * Defines the location of the file to load
  148440. */
  148441. url: string,
  148442. /**
  148443. * Defines the desired size (the more it increases the longer the generation will be)
  148444. */
  148445. size: number,
  148446. /**
  148447. * Defines if mipmaps should not be generated (default is false)
  148448. */
  148449. noMipmap?: boolean,
  148450. /**
  148451. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  148452. * but the standard material would require them in Gamma space) (default is true)
  148453. */
  148454. gammaSpace?: boolean);
  148455. /**
  148456. * Execute the current task
  148457. * @param scene defines the scene where you want your assets to be loaded
  148458. * @param onSuccess is a callback called when the task is successfully executed
  148459. * @param onError is a callback called if an error occurs
  148460. */
  148461. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148462. }
  148463. /**
  148464. * This class can be used to easily import assets into a scene
  148465. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  148466. */
  148467. export class AssetsManager {
  148468. private _scene;
  148469. private _isLoading;
  148470. protected _tasks: AbstractAssetTask[];
  148471. protected _waitingTasksCount: number;
  148472. protected _totalTasksCount: number;
  148473. /**
  148474. * Callback called when all tasks are processed
  148475. */
  148476. onFinish: (tasks: AbstractAssetTask[]) => void;
  148477. /**
  148478. * Callback called when a task is successful
  148479. */
  148480. onTaskSuccess: (task: AbstractAssetTask) => void;
  148481. /**
  148482. * Callback called when a task had an error
  148483. */
  148484. onTaskError: (task: AbstractAssetTask) => void;
  148485. /**
  148486. * Callback called when a task is done (whatever the result is)
  148487. */
  148488. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  148489. /**
  148490. * Observable called when all tasks are processed
  148491. */
  148492. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  148493. /**
  148494. * Observable called when a task had an error
  148495. */
  148496. onTaskErrorObservable: Observable<AbstractAssetTask>;
  148497. /**
  148498. * Observable called when all tasks were executed
  148499. */
  148500. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  148501. /**
  148502. * Observable called when a task is done (whatever the result is)
  148503. */
  148504. onProgressObservable: Observable<IAssetsProgressEvent>;
  148505. /**
  148506. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  148507. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  148508. */
  148509. useDefaultLoadingScreen: boolean;
  148510. /**
  148511. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  148512. * when all assets have been downloaded.
  148513. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  148514. */
  148515. autoHideLoadingUI: boolean;
  148516. /**
  148517. * Creates a new AssetsManager
  148518. * @param scene defines the scene to work on
  148519. */
  148520. constructor(scene: Scene);
  148521. /**
  148522. * Add a MeshAssetTask to the list of active tasks
  148523. * @param taskName defines the name of the new task
  148524. * @param meshesNames defines the name of meshes to load
  148525. * @param rootUrl defines the root url to use to locate files
  148526. * @param sceneFilename defines the filename of the scene file
  148527. * @returns a new MeshAssetTask object
  148528. */
  148529. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  148530. /**
  148531. * Add a TextFileAssetTask to the list of active tasks
  148532. * @param taskName defines the name of the new task
  148533. * @param url defines the url of the file to load
  148534. * @returns a new TextFileAssetTask object
  148535. */
  148536. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  148537. /**
  148538. * Add a BinaryFileAssetTask to the list of active tasks
  148539. * @param taskName defines the name of the new task
  148540. * @param url defines the url of the file to load
  148541. * @returns a new BinaryFileAssetTask object
  148542. */
  148543. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  148544. /**
  148545. * Add a ImageAssetTask to the list of active tasks
  148546. * @param taskName defines the name of the new task
  148547. * @param url defines the url of the file to load
  148548. * @returns a new ImageAssetTask object
  148549. */
  148550. addImageTask(taskName: string, url: string): ImageAssetTask;
  148551. /**
  148552. * Add a TextureAssetTask to the list of active tasks
  148553. * @param taskName defines the name of the new task
  148554. * @param url defines the url of the file to load
  148555. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  148556. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  148557. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  148558. * @returns a new TextureAssetTask object
  148559. */
  148560. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  148561. /**
  148562. * Add a CubeTextureAssetTask to the list of active tasks
  148563. * @param taskName defines the name of the new task
  148564. * @param url defines the url of the file to load
  148565. * @param extensions defines the extension to use to load the cube map (can be null)
  148566. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  148567. * @param files defines the list of files to load (can be null)
  148568. * @returns a new CubeTextureAssetTask object
  148569. */
  148570. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  148571. /**
  148572. *
  148573. * Add a HDRCubeTextureAssetTask to the list of active tasks
  148574. * @param taskName defines the name of the new task
  148575. * @param url defines the url of the file to load
  148576. * @param size defines the size you want for the cubemap (can be null)
  148577. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  148578. * @param generateHarmonics defines if you want to automatically generate (true by default)
  148579. * @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)
  148580. * @param reserved Internal use only
  148581. * @returns a new HDRCubeTextureAssetTask object
  148582. */
  148583. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  148584. /**
  148585. *
  148586. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  148587. * @param taskName defines the name of the new task
  148588. * @param url defines the url of the file to load
  148589. * @param size defines the size you want for the cubemap (can be null)
  148590. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  148591. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  148592. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  148593. * @returns a new EquiRectangularCubeTextureAssetTask object
  148594. */
  148595. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  148596. /**
  148597. * Remove a task from the assets manager.
  148598. * @param task the task to remove
  148599. */
  148600. removeTask(task: AbstractAssetTask): void;
  148601. private _decreaseWaitingTasksCount;
  148602. private _runTask;
  148603. /**
  148604. * Reset the AssetsManager and remove all tasks
  148605. * @return the current instance of the AssetsManager
  148606. */
  148607. reset(): AssetsManager;
  148608. /**
  148609. * Start the loading process
  148610. * @return the current instance of the AssetsManager
  148611. */
  148612. load(): AssetsManager;
  148613. /**
  148614. * Start the loading process as an async operation
  148615. * @return a promise returning the list of failed tasks
  148616. */
  148617. loadAsync(): Promise<void>;
  148618. }
  148619. }
  148620. declare module BABYLON {
  148621. /**
  148622. * Wrapper class for promise with external resolve and reject.
  148623. */
  148624. export class Deferred<T> {
  148625. /**
  148626. * The promise associated with this deferred object.
  148627. */
  148628. readonly promise: Promise<T>;
  148629. private _resolve;
  148630. private _reject;
  148631. /**
  148632. * The resolve method of the promise associated with this deferred object.
  148633. */
  148634. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  148635. /**
  148636. * The reject method of the promise associated with this deferred object.
  148637. */
  148638. get reject(): (reason?: any) => void;
  148639. /**
  148640. * Constructor for this deferred object.
  148641. */
  148642. constructor();
  148643. }
  148644. }
  148645. declare module BABYLON {
  148646. /**
  148647. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  148648. */
  148649. export class MeshExploder {
  148650. private _centerMesh;
  148651. private _meshes;
  148652. private _meshesOrigins;
  148653. private _toCenterVectors;
  148654. private _scaledDirection;
  148655. private _newPosition;
  148656. private _centerPosition;
  148657. /**
  148658. * Explodes meshes from a center mesh.
  148659. * @param meshes The meshes to explode.
  148660. * @param centerMesh The mesh to be center of explosion.
  148661. */
  148662. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  148663. private _setCenterMesh;
  148664. /**
  148665. * Get class name
  148666. * @returns "MeshExploder"
  148667. */
  148668. getClassName(): string;
  148669. /**
  148670. * "Exploded meshes"
  148671. * @returns Array of meshes with the centerMesh at index 0.
  148672. */
  148673. getMeshes(): Array<Mesh>;
  148674. /**
  148675. * Explodes meshes giving a specific direction
  148676. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  148677. */
  148678. explode(direction?: number): void;
  148679. }
  148680. }
  148681. declare module BABYLON {
  148682. /**
  148683. * Class used to help managing file picking and drag'n'drop
  148684. */
  148685. export class FilesInput {
  148686. /**
  148687. * List of files ready to be loaded
  148688. */
  148689. static get FilesToLoad(): {
  148690. [key: string]: File;
  148691. };
  148692. /**
  148693. * Callback called when a file is processed
  148694. */
  148695. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  148696. private _engine;
  148697. private _currentScene;
  148698. private _sceneLoadedCallback;
  148699. private _progressCallback;
  148700. private _additionalRenderLoopLogicCallback;
  148701. private _textureLoadingCallback;
  148702. private _startingProcessingFilesCallback;
  148703. private _onReloadCallback;
  148704. private _errorCallback;
  148705. private _elementToMonitor;
  148706. private _sceneFileToLoad;
  148707. private _filesToLoad;
  148708. /**
  148709. * Creates a new FilesInput
  148710. * @param engine defines the rendering engine
  148711. * @param scene defines the hosting scene
  148712. * @param sceneLoadedCallback callback called when scene is loaded
  148713. * @param progressCallback callback called to track progress
  148714. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  148715. * @param textureLoadingCallback callback called when a texture is loading
  148716. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  148717. * @param onReloadCallback callback called when a reload is requested
  148718. * @param errorCallback callback call if an error occurs
  148719. */
  148720. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: (files?: File[]) => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  148721. private _dragEnterHandler;
  148722. private _dragOverHandler;
  148723. private _dropHandler;
  148724. /**
  148725. * Calls this function to listen to drag'n'drop events on a specific DOM element
  148726. * @param elementToMonitor defines the DOM element to track
  148727. */
  148728. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  148729. /**
  148730. * Release all associated resources
  148731. */
  148732. dispose(): void;
  148733. private renderFunction;
  148734. private drag;
  148735. private drop;
  148736. private _traverseFolder;
  148737. private _processFiles;
  148738. /**
  148739. * Load files from a drop event
  148740. * @param event defines the drop event to use as source
  148741. */
  148742. loadFiles(event: any): void;
  148743. private _processReload;
  148744. /**
  148745. * Reload the current scene from the loaded files
  148746. */
  148747. reload(): void;
  148748. }
  148749. }
  148750. declare module BABYLON {
  148751. /**
  148752. * Defines the root class used to create scene optimization to use with SceneOptimizer
  148753. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148754. */
  148755. export class SceneOptimization {
  148756. /**
  148757. * Defines the priority of this optimization (0 by default which means first in the list)
  148758. */
  148759. priority: number;
  148760. /**
  148761. * Gets a string describing the action executed by the current optimization
  148762. * @returns description string
  148763. */
  148764. getDescription(): string;
  148765. /**
  148766. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148767. * @param scene defines the current scene where to apply this optimization
  148768. * @param optimizer defines the current optimizer
  148769. * @returns true if everything that can be done was applied
  148770. */
  148771. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148772. /**
  148773. * Creates the SceneOptimization object
  148774. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  148775. * @param desc defines the description associated with the optimization
  148776. */
  148777. constructor(
  148778. /**
  148779. * Defines the priority of this optimization (0 by default which means first in the list)
  148780. */
  148781. priority?: number);
  148782. }
  148783. /**
  148784. * Defines an optimization used to reduce the size of render target textures
  148785. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148786. */
  148787. export class TextureOptimization extends SceneOptimization {
  148788. /**
  148789. * Defines the priority of this optimization (0 by default which means first in the list)
  148790. */
  148791. priority: number;
  148792. /**
  148793. * 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
  148794. */
  148795. maximumSize: number;
  148796. /**
  148797. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  148798. */
  148799. step: number;
  148800. /**
  148801. * Gets a string describing the action executed by the current optimization
  148802. * @returns description string
  148803. */
  148804. getDescription(): string;
  148805. /**
  148806. * Creates the TextureOptimization object
  148807. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  148808. * @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
  148809. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  148810. */
  148811. constructor(
  148812. /**
  148813. * Defines the priority of this optimization (0 by default which means first in the list)
  148814. */
  148815. priority?: number,
  148816. /**
  148817. * 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
  148818. */
  148819. maximumSize?: number,
  148820. /**
  148821. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  148822. */
  148823. step?: number);
  148824. /**
  148825. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148826. * @param scene defines the current scene where to apply this optimization
  148827. * @param optimizer defines the current optimizer
  148828. * @returns true if everything that can be done was applied
  148829. */
  148830. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148831. }
  148832. /**
  148833. * Defines an optimization used to increase or decrease the rendering resolution
  148834. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148835. */
  148836. export class HardwareScalingOptimization extends SceneOptimization {
  148837. /**
  148838. * Defines the priority of this optimization (0 by default which means first in the list)
  148839. */
  148840. priority: number;
  148841. /**
  148842. * Defines the maximum scale to use (2 by default)
  148843. */
  148844. maximumScale: number;
  148845. /**
  148846. * Defines the step to use between two passes (0.5 by default)
  148847. */
  148848. step: number;
  148849. private _currentScale;
  148850. private _directionOffset;
  148851. /**
  148852. * Gets a string describing the action executed by the current optimization
  148853. * @return description string
  148854. */
  148855. getDescription(): string;
  148856. /**
  148857. * Creates the HardwareScalingOptimization object
  148858. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  148859. * @param maximumScale defines the maximum scale to use (2 by default)
  148860. * @param step defines the step to use between two passes (0.5 by default)
  148861. */
  148862. constructor(
  148863. /**
  148864. * Defines the priority of this optimization (0 by default which means first in the list)
  148865. */
  148866. priority?: number,
  148867. /**
  148868. * Defines the maximum scale to use (2 by default)
  148869. */
  148870. maximumScale?: number,
  148871. /**
  148872. * Defines the step to use between two passes (0.5 by default)
  148873. */
  148874. step?: number);
  148875. /**
  148876. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148877. * @param scene defines the current scene where to apply this optimization
  148878. * @param optimizer defines the current optimizer
  148879. * @returns true if everything that can be done was applied
  148880. */
  148881. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148882. }
  148883. /**
  148884. * Defines an optimization used to remove shadows
  148885. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148886. */
  148887. export class ShadowsOptimization extends SceneOptimization {
  148888. /**
  148889. * Gets a string describing the action executed by the current optimization
  148890. * @return description string
  148891. */
  148892. getDescription(): string;
  148893. /**
  148894. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148895. * @param scene defines the current scene where to apply this optimization
  148896. * @param optimizer defines the current optimizer
  148897. * @returns true if everything that can be done was applied
  148898. */
  148899. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148900. }
  148901. /**
  148902. * Defines an optimization used to turn post-processes off
  148903. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148904. */
  148905. export class PostProcessesOptimization extends SceneOptimization {
  148906. /**
  148907. * Gets a string describing the action executed by the current optimization
  148908. * @return description string
  148909. */
  148910. getDescription(): string;
  148911. /**
  148912. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148913. * @param scene defines the current scene where to apply this optimization
  148914. * @param optimizer defines the current optimizer
  148915. * @returns true if everything that can be done was applied
  148916. */
  148917. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148918. }
  148919. /**
  148920. * Defines an optimization used to turn lens flares off
  148921. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148922. */
  148923. export class LensFlaresOptimization extends SceneOptimization {
  148924. /**
  148925. * Gets a string describing the action executed by the current optimization
  148926. * @return description string
  148927. */
  148928. getDescription(): string;
  148929. /**
  148930. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148931. * @param scene defines the current scene where to apply this optimization
  148932. * @param optimizer defines the current optimizer
  148933. * @returns true if everything that can be done was applied
  148934. */
  148935. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148936. }
  148937. /**
  148938. * Defines an optimization based on user defined callback.
  148939. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148940. */
  148941. export class CustomOptimization extends SceneOptimization {
  148942. /**
  148943. * Callback called to apply the custom optimization.
  148944. */
  148945. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  148946. /**
  148947. * Callback called to get custom description
  148948. */
  148949. onGetDescription: () => string;
  148950. /**
  148951. * Gets a string describing the action executed by the current optimization
  148952. * @returns description string
  148953. */
  148954. getDescription(): string;
  148955. /**
  148956. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148957. * @param scene defines the current scene where to apply this optimization
  148958. * @param optimizer defines the current optimizer
  148959. * @returns true if everything that can be done was applied
  148960. */
  148961. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148962. }
  148963. /**
  148964. * Defines an optimization used to turn particles off
  148965. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148966. */
  148967. export class ParticlesOptimization extends SceneOptimization {
  148968. /**
  148969. * Gets a string describing the action executed by the current optimization
  148970. * @return description string
  148971. */
  148972. getDescription(): string;
  148973. /**
  148974. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148975. * @param scene defines the current scene where to apply this optimization
  148976. * @param optimizer defines the current optimizer
  148977. * @returns true if everything that can be done was applied
  148978. */
  148979. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148980. }
  148981. /**
  148982. * Defines an optimization used to turn render targets off
  148983. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148984. */
  148985. export class RenderTargetsOptimization extends SceneOptimization {
  148986. /**
  148987. * Gets a string describing the action executed by the current optimization
  148988. * @return description string
  148989. */
  148990. getDescription(): string;
  148991. /**
  148992. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148993. * @param scene defines the current scene where to apply this optimization
  148994. * @param optimizer defines the current optimizer
  148995. * @returns true if everything that can be done was applied
  148996. */
  148997. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148998. }
  148999. /**
  149000. * Defines an optimization used to merge meshes with compatible materials
  149001. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149002. */
  149003. export class MergeMeshesOptimization extends SceneOptimization {
  149004. private static _UpdateSelectionTree;
  149005. /**
  149006. * Gets or sets a boolean which defines if optimization octree has to be updated
  149007. */
  149008. static get UpdateSelectionTree(): boolean;
  149009. /**
  149010. * Gets or sets a boolean which defines if optimization octree has to be updated
  149011. */
  149012. static set UpdateSelectionTree(value: boolean);
  149013. /**
  149014. * Gets a string describing the action executed by the current optimization
  149015. * @return description string
  149016. */
  149017. getDescription(): string;
  149018. private _canBeMerged;
  149019. /**
  149020. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149021. * @param scene defines the current scene where to apply this optimization
  149022. * @param optimizer defines the current optimizer
  149023. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  149024. * @returns true if everything that can be done was applied
  149025. */
  149026. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  149027. }
  149028. /**
  149029. * Defines a list of options used by SceneOptimizer
  149030. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149031. */
  149032. export class SceneOptimizerOptions {
  149033. /**
  149034. * Defines the target frame rate to reach (60 by default)
  149035. */
  149036. targetFrameRate: number;
  149037. /**
  149038. * Defines the interval between two checkes (2000ms by default)
  149039. */
  149040. trackerDuration: number;
  149041. /**
  149042. * Gets the list of optimizations to apply
  149043. */
  149044. optimizations: SceneOptimization[];
  149045. /**
  149046. * Creates a new list of options used by SceneOptimizer
  149047. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  149048. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  149049. */
  149050. constructor(
  149051. /**
  149052. * Defines the target frame rate to reach (60 by default)
  149053. */
  149054. targetFrameRate?: number,
  149055. /**
  149056. * Defines the interval between two checkes (2000ms by default)
  149057. */
  149058. trackerDuration?: number);
  149059. /**
  149060. * Add a new optimization
  149061. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  149062. * @returns the current SceneOptimizerOptions
  149063. */
  149064. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  149065. /**
  149066. * Add a new custom optimization
  149067. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  149068. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  149069. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  149070. * @returns the current SceneOptimizerOptions
  149071. */
  149072. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  149073. /**
  149074. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  149075. * @param targetFrameRate defines the target frame rate (60 by default)
  149076. * @returns a SceneOptimizerOptions object
  149077. */
  149078. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  149079. /**
  149080. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  149081. * @param targetFrameRate defines the target frame rate (60 by default)
  149082. * @returns a SceneOptimizerOptions object
  149083. */
  149084. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  149085. /**
  149086. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  149087. * @param targetFrameRate defines the target frame rate (60 by default)
  149088. * @returns a SceneOptimizerOptions object
  149089. */
  149090. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  149091. }
  149092. /**
  149093. * Class used to run optimizations in order to reach a target frame rate
  149094. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149095. */
  149096. export class SceneOptimizer implements IDisposable {
  149097. private _isRunning;
  149098. private _options;
  149099. private _scene;
  149100. private _currentPriorityLevel;
  149101. private _targetFrameRate;
  149102. private _trackerDuration;
  149103. private _currentFrameRate;
  149104. private _sceneDisposeObserver;
  149105. private _improvementMode;
  149106. /**
  149107. * Defines an observable called when the optimizer reaches the target frame rate
  149108. */
  149109. onSuccessObservable: Observable<SceneOptimizer>;
  149110. /**
  149111. * Defines an observable called when the optimizer enables an optimization
  149112. */
  149113. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  149114. /**
  149115. * Defines an observable called when the optimizer is not able to reach the target frame rate
  149116. */
  149117. onFailureObservable: Observable<SceneOptimizer>;
  149118. /**
  149119. * Gets a boolean indicating if the optimizer is in improvement mode
  149120. */
  149121. get isInImprovementMode(): boolean;
  149122. /**
  149123. * Gets the current priority level (0 at start)
  149124. */
  149125. get currentPriorityLevel(): number;
  149126. /**
  149127. * Gets the current frame rate checked by the SceneOptimizer
  149128. */
  149129. get currentFrameRate(): number;
  149130. /**
  149131. * Gets or sets the current target frame rate (60 by default)
  149132. */
  149133. get targetFrameRate(): number;
  149134. /**
  149135. * Gets or sets the current target frame rate (60 by default)
  149136. */
  149137. set targetFrameRate(value: number);
  149138. /**
  149139. * Gets or sets the current interval between two checks (every 2000ms by default)
  149140. */
  149141. get trackerDuration(): number;
  149142. /**
  149143. * Gets or sets the current interval between two checks (every 2000ms by default)
  149144. */
  149145. set trackerDuration(value: number);
  149146. /**
  149147. * Gets the list of active optimizations
  149148. */
  149149. get optimizations(): SceneOptimization[];
  149150. /**
  149151. * Creates a new SceneOptimizer
  149152. * @param scene defines the scene to work on
  149153. * @param options defines the options to use with the SceneOptimizer
  149154. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  149155. * @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)
  149156. */
  149157. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  149158. /**
  149159. * Stops the current optimizer
  149160. */
  149161. stop(): void;
  149162. /**
  149163. * Reset the optimizer to initial step (current priority level = 0)
  149164. */
  149165. reset(): void;
  149166. /**
  149167. * Start the optimizer. By default it will try to reach a specific framerate
  149168. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  149169. */
  149170. start(): void;
  149171. private _checkCurrentState;
  149172. /**
  149173. * Release all resources
  149174. */
  149175. dispose(): void;
  149176. /**
  149177. * Helper function to create a SceneOptimizer with one single line of code
  149178. * @param scene defines the scene to work on
  149179. * @param options defines the options to use with the SceneOptimizer
  149180. * @param onSuccess defines a callback to call on success
  149181. * @param onFailure defines a callback to call on failure
  149182. * @returns the new SceneOptimizer object
  149183. */
  149184. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  149185. }
  149186. }
  149187. declare module BABYLON {
  149188. /**
  149189. * Class used to serialize a scene into a string
  149190. */
  149191. export class SceneSerializer {
  149192. /**
  149193. * Clear cache used by a previous serialization
  149194. */
  149195. static ClearCache(): void;
  149196. /**
  149197. * Serialize a scene into a JSON compatible object
  149198. * @param scene defines the scene to serialize
  149199. * @returns a JSON compatible object
  149200. */
  149201. static Serialize(scene: Scene): any;
  149202. /**
  149203. * Serialize a mesh into a JSON compatible object
  149204. * @param toSerialize defines the mesh to serialize
  149205. * @param withParents defines if parents must be serialized as well
  149206. * @param withChildren defines if children must be serialized as well
  149207. * @returns a JSON compatible object
  149208. */
  149209. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  149210. }
  149211. }
  149212. declare module BABYLON {
  149213. /**
  149214. * Class used to host texture specific utilities
  149215. */
  149216. export class TextureTools {
  149217. /**
  149218. * Uses the GPU to create a copy texture rescaled at a given size
  149219. * @param texture Texture to copy from
  149220. * @param width defines the desired width
  149221. * @param height defines the desired height
  149222. * @param useBilinearMode defines if bilinear mode has to be used
  149223. * @return the generated texture
  149224. */
  149225. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  149226. }
  149227. }
  149228. declare module BABYLON {
  149229. /**
  149230. * This represents the different options available for the video capture.
  149231. */
  149232. export interface VideoRecorderOptions {
  149233. /** Defines the mime type of the video. */
  149234. mimeType: string;
  149235. /** Defines the FPS the video should be recorded at. */
  149236. fps: number;
  149237. /** Defines the chunk size for the recording data. */
  149238. recordChunckSize: number;
  149239. /** The audio tracks to attach to the recording. */
  149240. audioTracks?: MediaStreamTrack[];
  149241. }
  149242. /**
  149243. * This can help with recording videos from BabylonJS.
  149244. * This is based on the available WebRTC functionalities of the browser.
  149245. *
  149246. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  149247. */
  149248. export class VideoRecorder {
  149249. private static readonly _defaultOptions;
  149250. /**
  149251. * Returns whether or not the VideoRecorder is available in your browser.
  149252. * @param engine Defines the Babylon Engine.
  149253. * @returns true if supported otherwise false.
  149254. */
  149255. static IsSupported(engine: Engine): boolean;
  149256. private readonly _options;
  149257. private _canvas;
  149258. private _mediaRecorder;
  149259. private _recordedChunks;
  149260. private _fileName;
  149261. private _resolve;
  149262. private _reject;
  149263. /**
  149264. * True when a recording is already in progress.
  149265. */
  149266. get isRecording(): boolean;
  149267. /**
  149268. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  149269. * @param engine Defines the BabylonJS Engine you wish to record.
  149270. * @param options Defines options that can be used to customize the capture.
  149271. */
  149272. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  149273. /**
  149274. * Stops the current recording before the default capture timeout passed in the startRecording function.
  149275. */
  149276. stopRecording(): void;
  149277. /**
  149278. * Starts recording the canvas for a max duration specified in parameters.
  149279. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  149280. * If null no automatic download will start and you can rely on the promise to get the data back.
  149281. * @param maxDuration Defines the maximum recording time in seconds.
  149282. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  149283. * @return A promise callback at the end of the recording with the video data in Blob.
  149284. */
  149285. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  149286. /**
  149287. * Releases internal resources used during the recording.
  149288. */
  149289. dispose(): void;
  149290. private _handleDataAvailable;
  149291. private _handleError;
  149292. private _handleStop;
  149293. }
  149294. }
  149295. declare module BABYLON {
  149296. /**
  149297. * Class containing a set of static utilities functions for screenshots
  149298. */
  149299. export class ScreenshotTools {
  149300. /**
  149301. * Captures a screenshot of the current rendering
  149302. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  149303. * @param engine defines the rendering engine
  149304. * @param camera defines the source camera
  149305. * @param size This parameter can be set to a single number or to an object with the
  149306. * following (optional) properties: precision, width, height. If a single number is passed,
  149307. * it will be used for both width and height. If an object is passed, the screenshot size
  149308. * will be derived from the parameters. The precision property is a multiplier allowing
  149309. * rendering at a higher or lower resolution
  149310. * @param successCallback defines the callback receives a single parameter which contains the
  149311. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  149312. * src parameter of an <img> to display it
  149313. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  149314. * Check your browser for supported MIME types
  149315. */
  149316. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  149317. /**
  149318. * Captures a screenshot of the current rendering
  149319. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  149320. * @param engine defines the rendering engine
  149321. * @param camera defines the source camera
  149322. * @param size This parameter can be set to a single number or to an object with the
  149323. * following (optional) properties: precision, width, height. If a single number is passed,
  149324. * it will be used for both width and height. If an object is passed, the screenshot size
  149325. * will be derived from the parameters. The precision property is a multiplier allowing
  149326. * rendering at a higher or lower resolution
  149327. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  149328. * Check your browser for supported MIME types
  149329. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  149330. * to the src parameter of an <img> to display it
  149331. */
  149332. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  149333. /**
  149334. * Generates an image screenshot from the specified camera.
  149335. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  149336. * @param engine The engine to use for rendering
  149337. * @param camera The camera to use for rendering
  149338. * @param size This parameter can be set to a single number or to an object with the
  149339. * following (optional) properties: precision, width, height. If a single number is passed,
  149340. * it will be used for both width and height. If an object is passed, the screenshot size
  149341. * will be derived from the parameters. The precision property is a multiplier allowing
  149342. * rendering at a higher or lower resolution
  149343. * @param successCallback The callback receives a single parameter which contains the
  149344. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  149345. * src parameter of an <img> to display it
  149346. * @param mimeType The MIME type of the screenshot image (default: image/png).
  149347. * Check your browser for supported MIME types
  149348. * @param samples Texture samples (default: 1)
  149349. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  149350. * @param fileName A name for for the downloaded file.
  149351. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  149352. */
  149353. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  149354. /**
  149355. * Generates an image screenshot from the specified camera.
  149356. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  149357. * @param engine The engine to use for rendering
  149358. * @param camera The camera to use for rendering
  149359. * @param size This parameter can be set to a single number or to an object with the
  149360. * following (optional) properties: precision, width, height. If a single number is passed,
  149361. * it will be used for both width and height. If an object is passed, the screenshot size
  149362. * will be derived from the parameters. The precision property is a multiplier allowing
  149363. * rendering at a higher or lower resolution
  149364. * @param mimeType The MIME type of the screenshot image (default: image/png).
  149365. * Check your browser for supported MIME types
  149366. * @param samples Texture samples (default: 1)
  149367. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  149368. * @param fileName A name for for the downloaded file.
  149369. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  149370. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  149371. * to the src parameter of an <img> to display it
  149372. */
  149373. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  149374. /**
  149375. * Gets height and width for screenshot size
  149376. * @private
  149377. */
  149378. private static _getScreenshotSize;
  149379. }
  149380. }
  149381. declare module BABYLON {
  149382. /**
  149383. * Interface for a data buffer
  149384. */
  149385. export interface IDataBuffer {
  149386. /**
  149387. * Reads bytes from the data buffer.
  149388. * @param byteOffset The byte offset to read
  149389. * @param byteLength The byte length to read
  149390. * @returns A promise that resolves when the bytes are read
  149391. */
  149392. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  149393. /**
  149394. * The byte length of the buffer.
  149395. */
  149396. readonly byteLength: number;
  149397. }
  149398. /**
  149399. * Utility class for reading from a data buffer
  149400. */
  149401. export class DataReader {
  149402. /**
  149403. * The data buffer associated with this data reader.
  149404. */
  149405. readonly buffer: IDataBuffer;
  149406. /**
  149407. * The current byte offset from the beginning of the data buffer.
  149408. */
  149409. byteOffset: number;
  149410. private _dataView;
  149411. private _dataByteOffset;
  149412. /**
  149413. * Constructor
  149414. * @param buffer The buffer to read
  149415. */
  149416. constructor(buffer: IDataBuffer);
  149417. /**
  149418. * Loads the given byte length.
  149419. * @param byteLength The byte length to load
  149420. * @returns A promise that resolves when the load is complete
  149421. */
  149422. loadAsync(byteLength: number): Promise<void>;
  149423. /**
  149424. * Read a unsigned 32-bit integer from the currently loaded data range.
  149425. * @returns The 32-bit integer read
  149426. */
  149427. readUint32(): number;
  149428. /**
  149429. * Read a byte array from the currently loaded data range.
  149430. * @param byteLength The byte length to read
  149431. * @returns The byte array read
  149432. */
  149433. readUint8Array(byteLength: number): Uint8Array;
  149434. /**
  149435. * Read a string from the currently loaded data range.
  149436. * @param byteLength The byte length to read
  149437. * @returns The string read
  149438. */
  149439. readString(byteLength: number): string;
  149440. /**
  149441. * Skips the given byte length the currently loaded data range.
  149442. * @param byteLength The byte length to skip
  149443. */
  149444. skipBytes(byteLength: number): void;
  149445. }
  149446. }
  149447. declare module BABYLON {
  149448. /**
  149449. * Class for storing data to local storage if available or in-memory storage otherwise
  149450. */
  149451. export class DataStorage {
  149452. private static _Storage;
  149453. private static _GetStorage;
  149454. /**
  149455. * Reads a string from the data storage
  149456. * @param key The key to read
  149457. * @param defaultValue The value if the key doesn't exist
  149458. * @returns The string value
  149459. */
  149460. static ReadString(key: string, defaultValue: string): string;
  149461. /**
  149462. * Writes a string to the data storage
  149463. * @param key The key to write
  149464. * @param value The value to write
  149465. */
  149466. static WriteString(key: string, value: string): void;
  149467. /**
  149468. * Reads a boolean from the data storage
  149469. * @param key The key to read
  149470. * @param defaultValue The value if the key doesn't exist
  149471. * @returns The boolean value
  149472. */
  149473. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  149474. /**
  149475. * Writes a boolean to the data storage
  149476. * @param key The key to write
  149477. * @param value The value to write
  149478. */
  149479. static WriteBoolean(key: string, value: boolean): void;
  149480. /**
  149481. * Reads a number from the data storage
  149482. * @param key The key to read
  149483. * @param defaultValue The value if the key doesn't exist
  149484. * @returns The number value
  149485. */
  149486. static ReadNumber(key: string, defaultValue: number): number;
  149487. /**
  149488. * Writes a number to the data storage
  149489. * @param key The key to write
  149490. * @param value The value to write
  149491. */
  149492. static WriteNumber(key: string, value: number): void;
  149493. }
  149494. }
  149495. declare module BABYLON {
  149496. /**
  149497. * An interface for all Hit test features
  149498. */
  149499. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  149500. /**
  149501. * Triggered when new babylon (transformed) hit test results are available
  149502. */
  149503. onHitTestResultObservable: Observable<T[]>;
  149504. }
  149505. /**
  149506. * Options used for hit testing
  149507. */
  149508. export interface IWebXRLegacyHitTestOptions {
  149509. /**
  149510. * Only test when user interacted with the scene. Default - hit test every frame
  149511. */
  149512. testOnPointerDownOnly?: boolean;
  149513. /**
  149514. * The node to use to transform the local results to world coordinates
  149515. */
  149516. worldParentNode?: TransformNode;
  149517. }
  149518. /**
  149519. * Interface defining the babylon result of raycasting/hit-test
  149520. */
  149521. export interface IWebXRLegacyHitResult {
  149522. /**
  149523. * Transformation matrix that can be applied to a node that will put it in the hit point location
  149524. */
  149525. transformationMatrix: Matrix;
  149526. /**
  149527. * The native hit test result
  149528. */
  149529. xrHitResult: XRHitResult | XRHitTestResult;
  149530. }
  149531. /**
  149532. * The currently-working hit-test module.
  149533. * Hit test (or Ray-casting) is used to interact with the real world.
  149534. * For further information read here - https://github.com/immersive-web/hit-test
  149535. */
  149536. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  149537. /**
  149538. * options to use when constructing this feature
  149539. */
  149540. readonly options: IWebXRLegacyHitTestOptions;
  149541. private _direction;
  149542. private _mat;
  149543. private _onSelectEnabled;
  149544. private _origin;
  149545. /**
  149546. * The module's name
  149547. */
  149548. static readonly Name: string;
  149549. /**
  149550. * The (Babylon) version of this module.
  149551. * This is an integer representing the implementation version.
  149552. * This number does not correspond to the WebXR specs version
  149553. */
  149554. static readonly Version: number;
  149555. /**
  149556. * Populated with the last native XR Hit Results
  149557. */
  149558. lastNativeXRHitResults: XRHitResult[];
  149559. /**
  149560. * Triggered when new babylon (transformed) hit test results are available
  149561. */
  149562. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  149563. /**
  149564. * Creates a new instance of the (legacy version) hit test feature
  149565. * @param _xrSessionManager an instance of WebXRSessionManager
  149566. * @param options options to use when constructing this feature
  149567. */
  149568. constructor(_xrSessionManager: WebXRSessionManager,
  149569. /**
  149570. * options to use when constructing this feature
  149571. */
  149572. options?: IWebXRLegacyHitTestOptions);
  149573. /**
  149574. * execute a hit test with an XR Ray
  149575. *
  149576. * @param xrSession a native xrSession that will execute this hit test
  149577. * @param xrRay the ray (position and direction) to use for ray-casting
  149578. * @param referenceSpace native XR reference space to use for the hit-test
  149579. * @param filter filter function that will filter the results
  149580. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  149581. */
  149582. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  149583. /**
  149584. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  149585. * @param event the (select) event to use to select with
  149586. * @param referenceSpace the reference space to use for this hit test
  149587. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  149588. */
  149589. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  149590. /**
  149591. * attach this feature
  149592. * Will usually be called by the features manager
  149593. *
  149594. * @returns true if successful.
  149595. */
  149596. attach(): boolean;
  149597. /**
  149598. * detach this feature.
  149599. * Will usually be called by the features manager
  149600. *
  149601. * @returns true if successful.
  149602. */
  149603. detach(): boolean;
  149604. /**
  149605. * Dispose this feature and all of the resources attached
  149606. */
  149607. dispose(): void;
  149608. protected _onXRFrame(frame: XRFrame): void;
  149609. private _onHitTestResults;
  149610. private _onSelect;
  149611. }
  149612. }
  149613. declare module BABYLON {
  149614. /**
  149615. * Options used for hit testing (version 2)
  149616. */
  149617. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  149618. /**
  149619. * Do not create a permanent hit test. Will usually be used when only
  149620. * transient inputs are needed.
  149621. */
  149622. disablePermanentHitTest?: boolean;
  149623. /**
  149624. * Enable transient (for example touch-based) hit test inspections
  149625. */
  149626. enableTransientHitTest?: boolean;
  149627. /**
  149628. * Offset ray for the permanent hit test
  149629. */
  149630. offsetRay?: Vector3;
  149631. /**
  149632. * Offset ray for the transient hit test
  149633. */
  149634. transientOffsetRay?: Vector3;
  149635. /**
  149636. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  149637. */
  149638. useReferenceSpace?: boolean;
  149639. }
  149640. /**
  149641. * Interface defining the babylon result of hit-test
  149642. */
  149643. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  149644. /**
  149645. * The input source that generated this hit test (if transient)
  149646. */
  149647. inputSource?: XRInputSource;
  149648. /**
  149649. * Is this a transient hit test
  149650. */
  149651. isTransient?: boolean;
  149652. /**
  149653. * Position of the hit test result
  149654. */
  149655. position: Vector3;
  149656. /**
  149657. * Rotation of the hit test result
  149658. */
  149659. rotationQuaternion: Quaternion;
  149660. /**
  149661. * The native hit test result
  149662. */
  149663. xrHitResult: XRHitTestResult;
  149664. }
  149665. /**
  149666. * The currently-working hit-test module.
  149667. * Hit test (or Ray-casting) is used to interact with the real world.
  149668. * For further information read here - https://github.com/immersive-web/hit-test
  149669. *
  149670. * Tested on chrome (mobile) 80.
  149671. */
  149672. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  149673. /**
  149674. * options to use when constructing this feature
  149675. */
  149676. readonly options: IWebXRHitTestOptions;
  149677. private _tmpMat;
  149678. private _tmpPos;
  149679. private _tmpQuat;
  149680. private _transientXrHitTestSource;
  149681. private _xrHitTestSource;
  149682. private initHitTestSource;
  149683. /**
  149684. * The module's name
  149685. */
  149686. static readonly Name: string;
  149687. /**
  149688. * The (Babylon) version of this module.
  149689. * This is an integer representing the implementation version.
  149690. * This number does not correspond to the WebXR specs version
  149691. */
  149692. static readonly Version: number;
  149693. /**
  149694. * When set to true, each hit test will have its own position/rotation objects
  149695. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  149696. * the developers will clone them or copy them as they see fit.
  149697. */
  149698. autoCloneTransformation: boolean;
  149699. /**
  149700. * Triggered when new babylon (transformed) hit test results are available
  149701. */
  149702. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  149703. /**
  149704. * Use this to temporarily pause hit test checks.
  149705. */
  149706. paused: boolean;
  149707. /**
  149708. * Creates a new instance of the hit test feature
  149709. * @param _xrSessionManager an instance of WebXRSessionManager
  149710. * @param options options to use when constructing this feature
  149711. */
  149712. constructor(_xrSessionManager: WebXRSessionManager,
  149713. /**
  149714. * options to use when constructing this feature
  149715. */
  149716. options?: IWebXRHitTestOptions);
  149717. /**
  149718. * attach this feature
  149719. * Will usually be called by the features manager
  149720. *
  149721. * @returns true if successful.
  149722. */
  149723. attach(): boolean;
  149724. /**
  149725. * detach this feature.
  149726. * Will usually be called by the features manager
  149727. *
  149728. * @returns true if successful.
  149729. */
  149730. detach(): boolean;
  149731. /**
  149732. * Dispose this feature and all of the resources attached
  149733. */
  149734. dispose(): void;
  149735. protected _onXRFrame(frame: XRFrame): void;
  149736. private _processWebXRHitTestResult;
  149737. }
  149738. }
  149739. declare module BABYLON {
  149740. /**
  149741. * Configuration options of the anchor system
  149742. */
  149743. export interface IWebXRAnchorSystemOptions {
  149744. /**
  149745. * a node that will be used to convert local to world coordinates
  149746. */
  149747. worldParentNode?: TransformNode;
  149748. /**
  149749. * If set to true a reference of the created anchors will be kept until the next session starts
  149750. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  149751. */
  149752. doNotRemoveAnchorsOnSessionEnded?: boolean;
  149753. }
  149754. /**
  149755. * A babylon container for an XR Anchor
  149756. */
  149757. export interface IWebXRAnchor {
  149758. /**
  149759. * A babylon-assigned ID for this anchor
  149760. */
  149761. id: number;
  149762. /**
  149763. * Transformation matrix to apply to an object attached to this anchor
  149764. */
  149765. transformationMatrix: Matrix;
  149766. /**
  149767. * The native anchor object
  149768. */
  149769. xrAnchor: XRAnchor;
  149770. /**
  149771. * if defined, this object will be constantly updated by the anchor's position and rotation
  149772. */
  149773. attachedNode?: TransformNode;
  149774. }
  149775. /**
  149776. * An implementation of the anchor system for WebXR.
  149777. * For further information see https://github.com/immersive-web/anchors/
  149778. */
  149779. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  149780. private _options;
  149781. private _lastFrameDetected;
  149782. private _trackedAnchors;
  149783. private _referenceSpaceForFrameAnchors;
  149784. private _futureAnchors;
  149785. /**
  149786. * The module's name
  149787. */
  149788. static readonly Name: string;
  149789. /**
  149790. * The (Babylon) version of this module.
  149791. * This is an integer representing the implementation version.
  149792. * This number does not correspond to the WebXR specs version
  149793. */
  149794. static readonly Version: number;
  149795. /**
  149796. * Observers registered here will be executed when a new anchor was added to the session
  149797. */
  149798. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  149799. /**
  149800. * Observers registered here will be executed when an anchor was removed from the session
  149801. */
  149802. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  149803. /**
  149804. * Observers registered here will be executed when an existing anchor updates
  149805. * This can execute N times every frame
  149806. */
  149807. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  149808. /**
  149809. * Set the reference space to use for anchor creation, when not using a hit test.
  149810. * Will default to the session's reference space if not defined
  149811. */
  149812. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  149813. /**
  149814. * constructs a new anchor system
  149815. * @param _xrSessionManager an instance of WebXRSessionManager
  149816. * @param _options configuration object for this feature
  149817. */
  149818. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  149819. private _tmpVector;
  149820. private _tmpQuaternion;
  149821. private _populateTmpTransformation;
  149822. /**
  149823. * Create a new anchor point using a hit test result at a specific point in the scene
  149824. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  149825. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  149826. *
  149827. * @param hitTestResult The hit test result to use for this anchor creation
  149828. * @param position an optional position offset for this anchor
  149829. * @param rotationQuaternion an optional rotation offset for this anchor
  149830. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  149831. */
  149832. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  149833. /**
  149834. * Add a new anchor at a specific position and rotation
  149835. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  149836. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  149837. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  149838. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  149839. *
  149840. * @param position the position in which to add an anchor
  149841. * @param rotationQuaternion an optional rotation for the anchor transformation
  149842. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  149843. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  149844. */
  149845. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  149846. /**
  149847. * detach this feature.
  149848. * Will usually be called by the features manager
  149849. *
  149850. * @returns true if successful.
  149851. */
  149852. detach(): boolean;
  149853. /**
  149854. * Dispose this feature and all of the resources attached
  149855. */
  149856. dispose(): void;
  149857. protected _onXRFrame(frame: XRFrame): void;
  149858. /**
  149859. * avoiding using Array.find for global support.
  149860. * @param xrAnchor the plane to find in the array
  149861. */
  149862. private _findIndexInAnchorArray;
  149863. private _updateAnchorWithXRFrame;
  149864. private _createAnchorAtTransformation;
  149865. }
  149866. }
  149867. declare module BABYLON {
  149868. /**
  149869. * Options used in the plane detector module
  149870. */
  149871. export interface IWebXRPlaneDetectorOptions {
  149872. /**
  149873. * The node to use to transform the local results to world coordinates
  149874. */
  149875. worldParentNode?: TransformNode;
  149876. /**
  149877. * If set to true a reference of the created planes will be kept until the next session starts
  149878. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  149879. */
  149880. doNotRemovePlanesOnSessionEnded?: boolean;
  149881. }
  149882. /**
  149883. * A babylon interface for a WebXR plane.
  149884. * A Plane is actually a polygon, built from N points in space
  149885. *
  149886. * Supported in chrome 79, not supported in canary 81 ATM
  149887. */
  149888. export interface IWebXRPlane {
  149889. /**
  149890. * a babylon-assigned ID for this polygon
  149891. */
  149892. id: number;
  149893. /**
  149894. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  149895. */
  149896. polygonDefinition: Array<Vector3>;
  149897. /**
  149898. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  149899. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  149900. */
  149901. transformationMatrix: Matrix;
  149902. /**
  149903. * the native xr-plane object
  149904. */
  149905. xrPlane: XRPlane;
  149906. }
  149907. /**
  149908. * The plane detector is used to detect planes in the real world when in AR
  149909. * For more information see https://github.com/immersive-web/real-world-geometry/
  149910. */
  149911. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  149912. private _options;
  149913. private _detectedPlanes;
  149914. private _enabled;
  149915. private _lastFrameDetected;
  149916. /**
  149917. * The module's name
  149918. */
  149919. static readonly Name: string;
  149920. /**
  149921. * The (Babylon) version of this module.
  149922. * This is an integer representing the implementation version.
  149923. * This number does not correspond to the WebXR specs version
  149924. */
  149925. static readonly Version: number;
  149926. /**
  149927. * Observers registered here will be executed when a new plane was added to the session
  149928. */
  149929. onPlaneAddedObservable: Observable<IWebXRPlane>;
  149930. /**
  149931. * Observers registered here will be executed when a plane is no longer detected in the session
  149932. */
  149933. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  149934. /**
  149935. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  149936. * This can execute N times every frame
  149937. */
  149938. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  149939. /**
  149940. * construct a new Plane Detector
  149941. * @param _xrSessionManager an instance of xr Session manager
  149942. * @param _options configuration to use when constructing this feature
  149943. */
  149944. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  149945. /**
  149946. * detach this feature.
  149947. * Will usually be called by the features manager
  149948. *
  149949. * @returns true if successful.
  149950. */
  149951. detach(): boolean;
  149952. /**
  149953. * Dispose this feature and all of the resources attached
  149954. */
  149955. dispose(): void;
  149956. protected _onXRFrame(frame: XRFrame): void;
  149957. private _init;
  149958. private _updatePlaneWithXRPlane;
  149959. /**
  149960. * avoiding using Array.find for global support.
  149961. * @param xrPlane the plane to find in the array
  149962. */
  149963. private findIndexInPlaneArray;
  149964. }
  149965. }
  149966. declare module BABYLON {
  149967. /**
  149968. * Options interface for the background remover plugin
  149969. */
  149970. export interface IWebXRBackgroundRemoverOptions {
  149971. /**
  149972. * Further background meshes to disable when entering AR
  149973. */
  149974. backgroundMeshes?: AbstractMesh[];
  149975. /**
  149976. * flags to configure the removal of the environment helper.
  149977. * If not set, the entire background will be removed. If set, flags should be set as well.
  149978. */
  149979. environmentHelperRemovalFlags?: {
  149980. /**
  149981. * Should the skybox be removed (default false)
  149982. */
  149983. skyBox?: boolean;
  149984. /**
  149985. * Should the ground be removed (default false)
  149986. */
  149987. ground?: boolean;
  149988. };
  149989. /**
  149990. * don't disable the environment helper
  149991. */
  149992. ignoreEnvironmentHelper?: boolean;
  149993. }
  149994. /**
  149995. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  149996. */
  149997. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  149998. /**
  149999. * read-only options to be used in this module
  150000. */
  150001. readonly options: IWebXRBackgroundRemoverOptions;
  150002. /**
  150003. * The module's name
  150004. */
  150005. static readonly Name: string;
  150006. /**
  150007. * The (Babylon) version of this module.
  150008. * This is an integer representing the implementation version.
  150009. * This number does not correspond to the WebXR specs version
  150010. */
  150011. static readonly Version: number;
  150012. /**
  150013. * registered observers will be triggered when the background state changes
  150014. */
  150015. onBackgroundStateChangedObservable: Observable<boolean>;
  150016. /**
  150017. * constructs a new background remover module
  150018. * @param _xrSessionManager the session manager for this module
  150019. * @param options read-only options to be used in this module
  150020. */
  150021. constructor(_xrSessionManager: WebXRSessionManager,
  150022. /**
  150023. * read-only options to be used in this module
  150024. */
  150025. options?: IWebXRBackgroundRemoverOptions);
  150026. /**
  150027. * attach this feature
  150028. * Will usually be called by the features manager
  150029. *
  150030. * @returns true if successful.
  150031. */
  150032. attach(): boolean;
  150033. /**
  150034. * detach this feature.
  150035. * Will usually be called by the features manager
  150036. *
  150037. * @returns true if successful.
  150038. */
  150039. detach(): boolean;
  150040. /**
  150041. * Dispose this feature and all of the resources attached
  150042. */
  150043. dispose(): void;
  150044. protected _onXRFrame(_xrFrame: XRFrame): void;
  150045. private _setBackgroundState;
  150046. }
  150047. }
  150048. declare module BABYLON {
  150049. /**
  150050. * Options for the controller physics feature
  150051. */
  150052. export class IWebXRControllerPhysicsOptions {
  150053. /**
  150054. * Should the headset get its own impostor
  150055. */
  150056. enableHeadsetImpostor?: boolean;
  150057. /**
  150058. * Optional parameters for the headset impostor
  150059. */
  150060. headsetImpostorParams?: {
  150061. /**
  150062. * The type of impostor to create. Default is sphere
  150063. */
  150064. impostorType: number;
  150065. /**
  150066. * the size of the impostor. Defaults to 10cm
  150067. */
  150068. impostorSize?: number | {
  150069. width: number;
  150070. height: number;
  150071. depth: number;
  150072. };
  150073. /**
  150074. * Friction definitions
  150075. */
  150076. friction?: number;
  150077. /**
  150078. * Restitution
  150079. */
  150080. restitution?: number;
  150081. };
  150082. /**
  150083. * The physics properties of the future impostors
  150084. */
  150085. physicsProperties?: {
  150086. /**
  150087. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  150088. * Note that this requires a physics engine that supports mesh impostors!
  150089. */
  150090. useControllerMesh?: boolean;
  150091. /**
  150092. * The type of impostor to create. Default is sphere
  150093. */
  150094. impostorType?: number;
  150095. /**
  150096. * the size of the impostor. Defaults to 10cm
  150097. */
  150098. impostorSize?: number | {
  150099. width: number;
  150100. height: number;
  150101. depth: number;
  150102. };
  150103. /**
  150104. * Friction definitions
  150105. */
  150106. friction?: number;
  150107. /**
  150108. * Restitution
  150109. */
  150110. restitution?: number;
  150111. };
  150112. /**
  150113. * the xr input to use with this pointer selection
  150114. */
  150115. xrInput: WebXRInput;
  150116. }
  150117. /**
  150118. * Add physics impostor to your webxr controllers,
  150119. * including naive calculation of their linear and angular velocity
  150120. */
  150121. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  150122. private readonly _options;
  150123. private _attachController;
  150124. private _controllers;
  150125. private _debugMode;
  150126. private _delta;
  150127. private _headsetImpostor?;
  150128. private _headsetMesh?;
  150129. private _lastTimestamp;
  150130. private _tmpQuaternion;
  150131. private _tmpVector;
  150132. /**
  150133. * The module's name
  150134. */
  150135. static readonly Name: string;
  150136. /**
  150137. * The (Babylon) version of this module.
  150138. * This is an integer representing the implementation version.
  150139. * This number does not correspond to the webxr specs version
  150140. */
  150141. static readonly Version: number;
  150142. /**
  150143. * Construct a new Controller Physics Feature
  150144. * @param _xrSessionManager the corresponding xr session manager
  150145. * @param _options options to create this feature with
  150146. */
  150147. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  150148. /**
  150149. * @hidden
  150150. * enable debugging - will show console outputs and the impostor mesh
  150151. */
  150152. _enablePhysicsDebug(): void;
  150153. /**
  150154. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  150155. * @param xrController the controller to add
  150156. */
  150157. addController(xrController: WebXRInputSource): void;
  150158. /**
  150159. * attach this feature
  150160. * Will usually be called by the features manager
  150161. *
  150162. * @returns true if successful.
  150163. */
  150164. attach(): boolean;
  150165. /**
  150166. * detach this feature.
  150167. * Will usually be called by the features manager
  150168. *
  150169. * @returns true if successful.
  150170. */
  150171. detach(): boolean;
  150172. /**
  150173. * Get the headset impostor, if enabled
  150174. * @returns the impostor
  150175. */
  150176. getHeadsetImpostor(): PhysicsImpostor | undefined;
  150177. /**
  150178. * Get the physics impostor of a specific controller.
  150179. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  150180. * @param controller the controller or the controller id of which to get the impostor
  150181. * @returns the impostor or null
  150182. */
  150183. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  150184. /**
  150185. * Update the physics properties provided in the constructor
  150186. * @param newProperties the new properties object
  150187. */
  150188. setPhysicsProperties(newProperties: {
  150189. impostorType?: number;
  150190. impostorSize?: number | {
  150191. width: number;
  150192. height: number;
  150193. depth: number;
  150194. };
  150195. friction?: number;
  150196. restitution?: number;
  150197. }): void;
  150198. protected _onXRFrame(_xrFrame: any): void;
  150199. private _detachController;
  150200. }
  150201. }
  150202. declare module BABYLON {
  150203. /**
  150204. * The motion controller class for all microsoft mixed reality controllers
  150205. */
  150206. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  150207. protected readonly _mapping: {
  150208. defaultButton: {
  150209. valueNodeName: string;
  150210. unpressedNodeName: string;
  150211. pressedNodeName: string;
  150212. };
  150213. defaultAxis: {
  150214. valueNodeName: string;
  150215. minNodeName: string;
  150216. maxNodeName: string;
  150217. };
  150218. buttons: {
  150219. "xr-standard-trigger": {
  150220. rootNodeName: string;
  150221. componentProperty: string;
  150222. states: string[];
  150223. };
  150224. "xr-standard-squeeze": {
  150225. rootNodeName: string;
  150226. componentProperty: string;
  150227. states: string[];
  150228. };
  150229. "xr-standard-touchpad": {
  150230. rootNodeName: string;
  150231. labelAnchorNodeName: string;
  150232. touchPointNodeName: string;
  150233. };
  150234. "xr-standard-thumbstick": {
  150235. rootNodeName: string;
  150236. componentProperty: string;
  150237. states: string[];
  150238. };
  150239. };
  150240. axes: {
  150241. "xr-standard-touchpad": {
  150242. "x-axis": {
  150243. rootNodeName: string;
  150244. };
  150245. "y-axis": {
  150246. rootNodeName: string;
  150247. };
  150248. };
  150249. "xr-standard-thumbstick": {
  150250. "x-axis": {
  150251. rootNodeName: string;
  150252. };
  150253. "y-axis": {
  150254. rootNodeName: string;
  150255. };
  150256. };
  150257. };
  150258. };
  150259. /**
  150260. * The base url used to load the left and right controller models
  150261. */
  150262. static MODEL_BASE_URL: string;
  150263. /**
  150264. * The name of the left controller model file
  150265. */
  150266. static MODEL_LEFT_FILENAME: string;
  150267. /**
  150268. * The name of the right controller model file
  150269. */
  150270. static MODEL_RIGHT_FILENAME: string;
  150271. profileId: string;
  150272. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  150273. protected _getFilenameAndPath(): {
  150274. filename: string;
  150275. path: string;
  150276. };
  150277. protected _getModelLoadingConstraints(): boolean;
  150278. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  150279. protected _setRootMesh(meshes: AbstractMesh[]): void;
  150280. protected _updateModel(): void;
  150281. }
  150282. }
  150283. declare module BABYLON {
  150284. /**
  150285. * The motion controller class for oculus touch (quest, rift).
  150286. * This class supports legacy mapping as well the standard xr mapping
  150287. */
  150288. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  150289. private _forceLegacyControllers;
  150290. private _modelRootNode;
  150291. /**
  150292. * The base url used to load the left and right controller models
  150293. */
  150294. static MODEL_BASE_URL: string;
  150295. /**
  150296. * The name of the left controller model file
  150297. */
  150298. static MODEL_LEFT_FILENAME: string;
  150299. /**
  150300. * The name of the right controller model file
  150301. */
  150302. static MODEL_RIGHT_FILENAME: string;
  150303. /**
  150304. * Base Url for the Quest controller model.
  150305. */
  150306. static QUEST_MODEL_BASE_URL: string;
  150307. profileId: string;
  150308. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  150309. protected _getFilenameAndPath(): {
  150310. filename: string;
  150311. path: string;
  150312. };
  150313. protected _getModelLoadingConstraints(): boolean;
  150314. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  150315. protected _setRootMesh(meshes: AbstractMesh[]): void;
  150316. protected _updateModel(): void;
  150317. /**
  150318. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  150319. * between the touch and touch 2.
  150320. */
  150321. private _isQuest;
  150322. }
  150323. }
  150324. declare module BABYLON {
  150325. /**
  150326. * The motion controller class for the standard HTC-Vive controllers
  150327. */
  150328. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  150329. private _modelRootNode;
  150330. /**
  150331. * The base url used to load the left and right controller models
  150332. */
  150333. static MODEL_BASE_URL: string;
  150334. /**
  150335. * File name for the controller model.
  150336. */
  150337. static MODEL_FILENAME: string;
  150338. profileId: string;
  150339. /**
  150340. * Create a new Vive motion controller object
  150341. * @param scene the scene to use to create this controller
  150342. * @param gamepadObject the corresponding gamepad object
  150343. * @param handedness the handedness of the controller
  150344. */
  150345. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  150346. protected _getFilenameAndPath(): {
  150347. filename: string;
  150348. path: string;
  150349. };
  150350. protected _getModelLoadingConstraints(): boolean;
  150351. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  150352. protected _setRootMesh(meshes: AbstractMesh[]): void;
  150353. protected _updateModel(): void;
  150354. }
  150355. }
  150356. declare module BABYLON {
  150357. /**
  150358. * A cursor which tracks a point on a path
  150359. */
  150360. export class PathCursor {
  150361. private path;
  150362. /**
  150363. * Stores path cursor callbacks for when an onchange event is triggered
  150364. */
  150365. private _onchange;
  150366. /**
  150367. * The value of the path cursor
  150368. */
  150369. value: number;
  150370. /**
  150371. * The animation array of the path cursor
  150372. */
  150373. animations: Animation[];
  150374. /**
  150375. * Initializes the path cursor
  150376. * @param path The path to track
  150377. */
  150378. constructor(path: Path2);
  150379. /**
  150380. * Gets the cursor point on the path
  150381. * @returns A point on the path cursor at the cursor location
  150382. */
  150383. getPoint(): Vector3;
  150384. /**
  150385. * Moves the cursor ahead by the step amount
  150386. * @param step The amount to move the cursor forward
  150387. * @returns This path cursor
  150388. */
  150389. moveAhead(step?: number): PathCursor;
  150390. /**
  150391. * Moves the cursor behind by the step amount
  150392. * @param step The amount to move the cursor back
  150393. * @returns This path cursor
  150394. */
  150395. moveBack(step?: number): PathCursor;
  150396. /**
  150397. * Moves the cursor by the step amount
  150398. * If the step amount is greater than one, an exception is thrown
  150399. * @param step The amount to move the cursor
  150400. * @returns This path cursor
  150401. */
  150402. move(step: number): PathCursor;
  150403. /**
  150404. * Ensures that the value is limited between zero and one
  150405. * @returns This path cursor
  150406. */
  150407. private ensureLimits;
  150408. /**
  150409. * Runs onchange callbacks on change (used by the animation engine)
  150410. * @returns This path cursor
  150411. */
  150412. private raiseOnChange;
  150413. /**
  150414. * Executes a function on change
  150415. * @param f A path cursor onchange callback
  150416. * @returns This path cursor
  150417. */
  150418. onchange(f: (cursor: PathCursor) => void): PathCursor;
  150419. }
  150420. }
  150421. declare module BABYLON {
  150422. /** @hidden */
  150423. export var blurPixelShader: {
  150424. name: string;
  150425. shader: string;
  150426. };
  150427. }
  150428. declare module BABYLON {
  150429. /** @hidden */
  150430. export var pointCloudVertexDeclaration: {
  150431. name: string;
  150432. shader: string;
  150433. };
  150434. }
  150435. // Mixins
  150436. interface Window {
  150437. mozIndexedDB: IDBFactory;
  150438. webkitIndexedDB: IDBFactory;
  150439. msIndexedDB: IDBFactory;
  150440. webkitURL: typeof URL;
  150441. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  150442. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  150443. WebGLRenderingContext: WebGLRenderingContext;
  150444. MSGesture: MSGesture;
  150445. CANNON: any;
  150446. AudioContext: AudioContext;
  150447. webkitAudioContext: AudioContext;
  150448. PointerEvent: any;
  150449. Math: Math;
  150450. Uint8Array: Uint8ArrayConstructor;
  150451. Float32Array: Float32ArrayConstructor;
  150452. mozURL: typeof URL;
  150453. msURL: typeof URL;
  150454. VRFrameData: any; // WebVR, from specs 1.1
  150455. DracoDecoderModule: any;
  150456. setImmediate(handler: (...args: any[]) => void): number;
  150457. }
  150458. interface HTMLCanvasElement {
  150459. requestPointerLock(): void;
  150460. msRequestPointerLock?(): void;
  150461. mozRequestPointerLock?(): void;
  150462. webkitRequestPointerLock?(): void;
  150463. /** Track wether a record is in progress */
  150464. isRecording: boolean;
  150465. /** Capture Stream method defined by some browsers */
  150466. captureStream(fps?: number): MediaStream;
  150467. }
  150468. interface CanvasRenderingContext2D {
  150469. msImageSmoothingEnabled: boolean;
  150470. }
  150471. interface MouseEvent {
  150472. mozMovementX: number;
  150473. mozMovementY: number;
  150474. webkitMovementX: number;
  150475. webkitMovementY: number;
  150476. msMovementX: number;
  150477. msMovementY: number;
  150478. }
  150479. interface Navigator {
  150480. mozGetVRDevices: (any: any) => any;
  150481. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  150482. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  150483. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  150484. webkitGetGamepads(): Gamepad[];
  150485. msGetGamepads(): Gamepad[];
  150486. webkitGamepads(): Gamepad[];
  150487. }
  150488. interface HTMLVideoElement {
  150489. mozSrcObject: any;
  150490. }
  150491. interface Math {
  150492. fround(x: number): number;
  150493. imul(a: number, b: number): number;
  150494. }
  150495. interface WebGLRenderingContext {
  150496. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  150497. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  150498. vertexAttribDivisor(index: number, divisor: number): void;
  150499. createVertexArray(): any;
  150500. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  150501. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  150502. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  150503. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  150504. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  150505. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  150506. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  150507. // Queries
  150508. createQuery(): WebGLQuery;
  150509. deleteQuery(query: WebGLQuery): void;
  150510. beginQuery(target: number, query: WebGLQuery): void;
  150511. endQuery(target: number): void;
  150512. getQueryParameter(query: WebGLQuery, pname: number): any;
  150513. getQuery(target: number, pname: number): any;
  150514. MAX_SAMPLES: number;
  150515. RGBA8: number;
  150516. READ_FRAMEBUFFER: number;
  150517. DRAW_FRAMEBUFFER: number;
  150518. UNIFORM_BUFFER: number;
  150519. HALF_FLOAT_OES: number;
  150520. RGBA16F: number;
  150521. RGBA32F: number;
  150522. R32F: number;
  150523. RG32F: number;
  150524. RGB32F: number;
  150525. R16F: number;
  150526. RG16F: number;
  150527. RGB16F: number;
  150528. RED: number;
  150529. RG: number;
  150530. R8: number;
  150531. RG8: number;
  150532. UNSIGNED_INT_24_8: number;
  150533. DEPTH24_STENCIL8: number;
  150534. MIN: number;
  150535. MAX: number;
  150536. /* Multiple Render Targets */
  150537. drawBuffers(buffers: number[]): void;
  150538. readBuffer(src: number): void;
  150539. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  150540. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  150541. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  150542. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  150543. // Occlusion Query
  150544. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  150545. ANY_SAMPLES_PASSED: number;
  150546. QUERY_RESULT_AVAILABLE: number;
  150547. QUERY_RESULT: number;
  150548. }
  150549. interface WebGLProgram {
  150550. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  150551. }
  150552. interface EXT_disjoint_timer_query {
  150553. QUERY_COUNTER_BITS_EXT: number;
  150554. TIME_ELAPSED_EXT: number;
  150555. TIMESTAMP_EXT: number;
  150556. GPU_DISJOINT_EXT: number;
  150557. QUERY_RESULT_EXT: number;
  150558. QUERY_RESULT_AVAILABLE_EXT: number;
  150559. queryCounterEXT(query: WebGLQuery, target: number): void;
  150560. createQueryEXT(): WebGLQuery;
  150561. beginQueryEXT(target: number, query: WebGLQuery): void;
  150562. endQueryEXT(target: number): void;
  150563. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  150564. deleteQueryEXT(query: WebGLQuery): void;
  150565. }
  150566. interface WebGLUniformLocation {
  150567. _currentState: any;
  150568. }
  150569. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  150570. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  150571. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  150572. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  150573. interface WebGLRenderingContext {
  150574. readonly RASTERIZER_DISCARD: number;
  150575. readonly DEPTH_COMPONENT24: number;
  150576. readonly TEXTURE_3D: number;
  150577. readonly TEXTURE_2D_ARRAY: number;
  150578. readonly TEXTURE_COMPARE_FUNC: number;
  150579. readonly TEXTURE_COMPARE_MODE: number;
  150580. readonly COMPARE_REF_TO_TEXTURE: number;
  150581. readonly TEXTURE_WRAP_R: number;
  150582. readonly HALF_FLOAT: number;
  150583. readonly RGB8: number;
  150584. readonly RED_INTEGER: number;
  150585. readonly RG_INTEGER: number;
  150586. readonly RGB_INTEGER: number;
  150587. readonly RGBA_INTEGER: number;
  150588. readonly R8_SNORM: number;
  150589. readonly RG8_SNORM: number;
  150590. readonly RGB8_SNORM: number;
  150591. readonly RGBA8_SNORM: number;
  150592. readonly R8I: number;
  150593. readonly RG8I: number;
  150594. readonly RGB8I: number;
  150595. readonly RGBA8I: number;
  150596. readonly R8UI: number;
  150597. readonly RG8UI: number;
  150598. readonly RGB8UI: number;
  150599. readonly RGBA8UI: number;
  150600. readonly R16I: number;
  150601. readonly RG16I: number;
  150602. readonly RGB16I: number;
  150603. readonly RGBA16I: number;
  150604. readonly R16UI: number;
  150605. readonly RG16UI: number;
  150606. readonly RGB16UI: number;
  150607. readonly RGBA16UI: number;
  150608. readonly R32I: number;
  150609. readonly RG32I: number;
  150610. readonly RGB32I: number;
  150611. readonly RGBA32I: number;
  150612. readonly R32UI: number;
  150613. readonly RG32UI: number;
  150614. readonly RGB32UI: number;
  150615. readonly RGBA32UI: number;
  150616. readonly RGB10_A2UI: number;
  150617. readonly R11F_G11F_B10F: number;
  150618. readonly RGB9_E5: number;
  150619. readonly RGB10_A2: number;
  150620. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  150621. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  150622. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  150623. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  150624. readonly DEPTH_COMPONENT32F: number;
  150625. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  150626. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  150627. 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;
  150628. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  150629. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  150630. readonly TRANSFORM_FEEDBACK: number;
  150631. readonly INTERLEAVED_ATTRIBS: number;
  150632. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  150633. createTransformFeedback(): WebGLTransformFeedback;
  150634. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  150635. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  150636. beginTransformFeedback(primitiveMode: number): void;
  150637. endTransformFeedback(): void;
  150638. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  150639. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  150640. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  150641. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  150642. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  150643. }
  150644. interface ImageBitmap {
  150645. readonly width: number;
  150646. readonly height: number;
  150647. close(): void;
  150648. }
  150649. interface WebGLQuery extends WebGLObject {
  150650. }
  150651. declare var WebGLQuery: {
  150652. prototype: WebGLQuery;
  150653. new(): WebGLQuery;
  150654. };
  150655. interface WebGLSampler extends WebGLObject {
  150656. }
  150657. declare var WebGLSampler: {
  150658. prototype: WebGLSampler;
  150659. new(): WebGLSampler;
  150660. };
  150661. interface WebGLSync extends WebGLObject {
  150662. }
  150663. declare var WebGLSync: {
  150664. prototype: WebGLSync;
  150665. new(): WebGLSync;
  150666. };
  150667. interface WebGLTransformFeedback extends WebGLObject {
  150668. }
  150669. declare var WebGLTransformFeedback: {
  150670. prototype: WebGLTransformFeedback;
  150671. new(): WebGLTransformFeedback;
  150672. };
  150673. interface WebGLVertexArrayObject extends WebGLObject {
  150674. }
  150675. declare var WebGLVertexArrayObject: {
  150676. prototype: WebGLVertexArrayObject;
  150677. new(): WebGLVertexArrayObject;
  150678. };
  150679. // Type definitions for WebVR API
  150680. // Project: https://w3c.github.io/webvr/
  150681. // Definitions by: six a <https://github.com/lostfictions>
  150682. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  150683. interface VRDisplay extends EventTarget {
  150684. /**
  150685. * Dictionary of capabilities describing the VRDisplay.
  150686. */
  150687. readonly capabilities: VRDisplayCapabilities;
  150688. /**
  150689. * z-depth defining the far plane of the eye view frustum
  150690. * enables mapping of values in the render target depth
  150691. * attachment to scene coordinates. Initially set to 10000.0.
  150692. */
  150693. depthFar: number;
  150694. /**
  150695. * z-depth defining the near plane of the eye view frustum
  150696. * enables mapping of values in the render target depth
  150697. * attachment to scene coordinates. Initially set to 0.01.
  150698. */
  150699. depthNear: number;
  150700. /**
  150701. * An identifier for this distinct VRDisplay. Used as an
  150702. * association point in the Gamepad API.
  150703. */
  150704. readonly displayId: number;
  150705. /**
  150706. * A display name, a user-readable name identifying it.
  150707. */
  150708. readonly displayName: string;
  150709. readonly isConnected: boolean;
  150710. readonly isPresenting: boolean;
  150711. /**
  150712. * If this VRDisplay supports room-scale experiences, the optional
  150713. * stage attribute contains details on the room-scale parameters.
  150714. */
  150715. readonly stageParameters: VRStageParameters | null;
  150716. /**
  150717. * Passing the value returned by `requestAnimationFrame` to
  150718. * `cancelAnimationFrame` will unregister the callback.
  150719. * @param handle Define the hanle of the request to cancel
  150720. */
  150721. cancelAnimationFrame(handle: number): void;
  150722. /**
  150723. * Stops presenting to the VRDisplay.
  150724. * @returns a promise to know when it stopped
  150725. */
  150726. exitPresent(): Promise<void>;
  150727. /**
  150728. * Return the current VREyeParameters for the given eye.
  150729. * @param whichEye Define the eye we want the parameter for
  150730. * @returns the eye parameters
  150731. */
  150732. getEyeParameters(whichEye: string): VREyeParameters;
  150733. /**
  150734. * Populates the passed VRFrameData with the information required to render
  150735. * the current frame.
  150736. * @param frameData Define the data structure to populate
  150737. * @returns true if ok otherwise false
  150738. */
  150739. getFrameData(frameData: VRFrameData): boolean;
  150740. /**
  150741. * Get the layers currently being presented.
  150742. * @returns the list of VR layers
  150743. */
  150744. getLayers(): VRLayer[];
  150745. /**
  150746. * Return a VRPose containing the future predicted pose of the VRDisplay
  150747. * when the current frame will be presented. The value returned will not
  150748. * change until JavaScript has returned control to the browser.
  150749. *
  150750. * The VRPose will contain the position, orientation, velocity,
  150751. * and acceleration of each of these properties.
  150752. * @returns the pose object
  150753. */
  150754. getPose(): VRPose;
  150755. /**
  150756. * Return the current instantaneous pose of the VRDisplay, with no
  150757. * prediction applied.
  150758. * @returns the current instantaneous pose
  150759. */
  150760. getImmediatePose(): VRPose;
  150761. /**
  150762. * The callback passed to `requestAnimationFrame` will be called
  150763. * any time a new frame should be rendered. When the VRDisplay is
  150764. * presenting the callback will be called at the native refresh
  150765. * rate of the HMD. When not presenting this function acts
  150766. * identically to how window.requestAnimationFrame acts. Content should
  150767. * make no assumptions of frame rate or vsync behavior as the HMD runs
  150768. * asynchronously from other displays and at differing refresh rates.
  150769. * @param callback Define the eaction to run next frame
  150770. * @returns the request handle it
  150771. */
  150772. requestAnimationFrame(callback: FrameRequestCallback): number;
  150773. /**
  150774. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  150775. * Repeat calls while already presenting will update the VRLayers being displayed.
  150776. * @param layers Define the list of layer to present
  150777. * @returns a promise to know when the request has been fulfilled
  150778. */
  150779. requestPresent(layers: VRLayer[]): Promise<void>;
  150780. /**
  150781. * Reset the pose for this display, treating its current position and
  150782. * orientation as the "origin/zero" values. VRPose.position,
  150783. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  150784. * updated when calling resetPose(). This should be called in only
  150785. * sitting-space experiences.
  150786. */
  150787. resetPose(): void;
  150788. /**
  150789. * The VRLayer provided to the VRDisplay will be captured and presented
  150790. * in the HMD. Calling this function has the same effect on the source
  150791. * canvas as any other operation that uses its source image, and canvases
  150792. * created without preserveDrawingBuffer set to true will be cleared.
  150793. * @param pose Define the pose to submit
  150794. */
  150795. submitFrame(pose?: VRPose): void;
  150796. }
  150797. declare var VRDisplay: {
  150798. prototype: VRDisplay;
  150799. new(): VRDisplay;
  150800. };
  150801. interface VRLayer {
  150802. leftBounds?: number[] | Float32Array | null;
  150803. rightBounds?: number[] | Float32Array | null;
  150804. source?: HTMLCanvasElement | null;
  150805. }
  150806. interface VRDisplayCapabilities {
  150807. readonly canPresent: boolean;
  150808. readonly hasExternalDisplay: boolean;
  150809. readonly hasOrientation: boolean;
  150810. readonly hasPosition: boolean;
  150811. readonly maxLayers: number;
  150812. }
  150813. interface VREyeParameters {
  150814. /** @deprecated */
  150815. readonly fieldOfView: VRFieldOfView;
  150816. readonly offset: Float32Array;
  150817. readonly renderHeight: number;
  150818. readonly renderWidth: number;
  150819. }
  150820. interface VRFieldOfView {
  150821. readonly downDegrees: number;
  150822. readonly leftDegrees: number;
  150823. readonly rightDegrees: number;
  150824. readonly upDegrees: number;
  150825. }
  150826. interface VRFrameData {
  150827. readonly leftProjectionMatrix: Float32Array;
  150828. readonly leftViewMatrix: Float32Array;
  150829. readonly pose: VRPose;
  150830. readonly rightProjectionMatrix: Float32Array;
  150831. readonly rightViewMatrix: Float32Array;
  150832. readonly timestamp: number;
  150833. }
  150834. interface VRPose {
  150835. readonly angularAcceleration: Float32Array | null;
  150836. readonly angularVelocity: Float32Array | null;
  150837. readonly linearAcceleration: Float32Array | null;
  150838. readonly linearVelocity: Float32Array | null;
  150839. readonly orientation: Float32Array | null;
  150840. readonly position: Float32Array | null;
  150841. readonly timestamp: number;
  150842. }
  150843. interface VRStageParameters {
  150844. sittingToStandingTransform?: Float32Array;
  150845. sizeX?: number;
  150846. sizeY?: number;
  150847. }
  150848. interface Navigator {
  150849. getVRDisplays(): Promise<VRDisplay[]>;
  150850. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  150851. }
  150852. interface Window {
  150853. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  150854. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  150855. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  150856. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  150857. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  150858. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  150859. }
  150860. interface Gamepad {
  150861. readonly displayId: number;
  150862. }
  150863. type XRSessionMode =
  150864. | "inline"
  150865. | "immersive-vr"
  150866. | "immersive-ar";
  150867. type XRReferenceSpaceType =
  150868. | "viewer"
  150869. | "local"
  150870. | "local-floor"
  150871. | "bounded-floor"
  150872. | "unbounded";
  150873. type XREnvironmentBlendMode =
  150874. | "opaque"
  150875. | "additive"
  150876. | "alpha-blend";
  150877. type XRVisibilityState =
  150878. | "visible"
  150879. | "visible-blurred"
  150880. | "hidden";
  150881. type XRHandedness =
  150882. | "none"
  150883. | "left"
  150884. | "right";
  150885. type XRTargetRayMode =
  150886. | "gaze"
  150887. | "tracked-pointer"
  150888. | "screen";
  150889. type XREye =
  150890. | "none"
  150891. | "left"
  150892. | "right";
  150893. type XREventType =
  150894. | "devicechange"
  150895. | "visibilitychange"
  150896. | "end"
  150897. | "inputsourceschange"
  150898. | "select"
  150899. | "selectstart"
  150900. | "selectend"
  150901. | "squeeze"
  150902. | "squeezestart"
  150903. | "squeezeend"
  150904. | "reset";
  150905. interface XRSpace extends EventTarget {
  150906. }
  150907. interface XRRenderState {
  150908. depthNear?: number;
  150909. depthFar?: number;
  150910. inlineVerticalFieldOfView?: number;
  150911. baseLayer?: XRWebGLLayer;
  150912. }
  150913. interface XRInputSource {
  150914. handedness: XRHandedness;
  150915. targetRayMode: XRTargetRayMode;
  150916. targetRaySpace: XRSpace;
  150917. gripSpace: XRSpace | undefined;
  150918. gamepad: Gamepad | undefined;
  150919. profiles: Array<string>;
  150920. }
  150921. interface XRSessionInit {
  150922. optionalFeatures?: string[];
  150923. requiredFeatures?: string[];
  150924. }
  150925. interface XRSession {
  150926. addEventListener: Function;
  150927. removeEventListener: Function;
  150928. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  150929. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  150930. requestAnimationFrame: Function;
  150931. end(): Promise<void>;
  150932. renderState: XRRenderState;
  150933. inputSources: Array<XRInputSource>;
  150934. // hit test
  150935. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  150936. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  150937. // legacy AR hit test
  150938. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  150939. // legacy plane detection
  150940. updateWorldTrackingState(options: {
  150941. planeDetectionState?: { enabled: boolean; }
  150942. }): void;
  150943. }
  150944. interface XRReferenceSpace extends XRSpace {
  150945. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  150946. onreset: any;
  150947. }
  150948. type XRPlaneSet = Set<XRPlane>;
  150949. type XRAnchorSet = Set<XRAnchor>;
  150950. interface XRFrame {
  150951. session: XRSession;
  150952. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  150953. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  150954. // AR
  150955. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  150956. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  150957. // Anchors
  150958. trackedAnchors?: XRAnchorSet;
  150959. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  150960. // Planes
  150961. worldInformation: {
  150962. detectedPlanes?: XRPlaneSet;
  150963. };
  150964. }
  150965. interface XRViewerPose extends XRPose {
  150966. views: Array<XRView>;
  150967. }
  150968. interface XRPose {
  150969. transform: XRRigidTransform;
  150970. emulatedPosition: boolean;
  150971. }
  150972. interface XRWebGLLayerOptions {
  150973. antialias?: boolean;
  150974. depth?: boolean;
  150975. stencil?: boolean;
  150976. alpha?: boolean;
  150977. multiview?: boolean;
  150978. framebufferScaleFactor?: number;
  150979. }
  150980. declare var XRWebGLLayer: {
  150981. prototype: XRWebGLLayer;
  150982. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  150983. };
  150984. interface XRWebGLLayer {
  150985. framebuffer: WebGLFramebuffer;
  150986. framebufferWidth: number;
  150987. framebufferHeight: number;
  150988. getViewport: Function;
  150989. }
  150990. declare class XRRigidTransform {
  150991. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  150992. position: DOMPointReadOnly;
  150993. orientation: DOMPointReadOnly;
  150994. matrix: Float32Array;
  150995. inverse: XRRigidTransform;
  150996. }
  150997. interface XRView {
  150998. eye: XREye;
  150999. projectionMatrix: Float32Array;
  151000. transform: XRRigidTransform;
  151001. }
  151002. interface XRInputSourceChangeEvent {
  151003. session: XRSession;
  151004. removed: Array<XRInputSource>;
  151005. added: Array<XRInputSource>;
  151006. }
  151007. interface XRInputSourceEvent extends Event {
  151008. readonly frame: XRFrame;
  151009. readonly inputSource: XRInputSource;
  151010. }
  151011. // Experimental(er) features
  151012. declare class XRRay {
  151013. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  151014. origin: DOMPointReadOnly;
  151015. direction: DOMPointReadOnly;
  151016. matrix: Float32Array;
  151017. }
  151018. declare enum XRHitTestTrackableType {
  151019. "point",
  151020. "plane"
  151021. }
  151022. interface XRHitResult {
  151023. hitMatrix: Float32Array;
  151024. }
  151025. interface XRTransientInputHitTestResult {
  151026. readonly inputSource: XRInputSource;
  151027. readonly results: Array<XRHitTestResult>;
  151028. }
  151029. interface XRHitTestResult {
  151030. getPose(baseSpace: XRSpace): XRPose | undefined;
  151031. // When anchor system is enabled
  151032. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  151033. }
  151034. interface XRHitTestSource {
  151035. cancel(): void;
  151036. }
  151037. interface XRTransientInputHitTestSource {
  151038. cancel(): void;
  151039. }
  151040. interface XRHitTestOptionsInit {
  151041. space: XRSpace;
  151042. entityTypes?: Array<XRHitTestTrackableType>;
  151043. offsetRay?: XRRay;
  151044. }
  151045. interface XRTransientInputHitTestOptionsInit {
  151046. profile: string;
  151047. entityTypes?: Array<XRHitTestTrackableType>;
  151048. offsetRay?: XRRay;
  151049. }
  151050. interface XRAnchor {
  151051. anchorSpace: XRSpace;
  151052. delete(): void;
  151053. }
  151054. interface XRPlane {
  151055. orientation: "Horizontal" | "Vertical";
  151056. planeSpace: XRSpace;
  151057. polygon: Array<DOMPointReadOnly>;
  151058. lastChangedTime: number;
  151059. }